blob: f558b801c82d7fe20a1e217959c64b737777e667 [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
26#include <sound/driver.h>
27#include <linux/init.h>
28#include <linux/delay.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <sound/core.h>
32#include "hda_codec.h"
33#include "hda_local.h"
34
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 Iwaie9edcee2005-06-13 14:16:38 +020063#ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010066 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020067 ALC880_MODEL_LAST /* last tag */
68};
69
70/* ALC260 models */
71enum {
72 ALC260_BASIC,
73 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010074 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010076 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020077 ALC260_WILL,
78 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010079#ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010082 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020083 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070084};
85
Kailang Yangdf694da2005-12-05 19:42:22 +010086/* ALC262 models */
87enum {
88 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020089 ALC262_HIPPO,
90 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010091 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020092 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010093 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020095 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +020096 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +020097 ALC262_BENQ_T31,
Kailang Yangdf694da2005-12-05 19:42:22 +010098 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100};
101
Kailang Yanga361d842007-06-05 12:30:55 +0200102/* ALC268 models */
103enum {
104 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200105 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200106 ALC268_ACER,
Kailang Yanga361d842007-06-05 12:30:55 +0200107 ALC268_AUTO,
108 ALC268_MODEL_LAST /* last tag */
109};
110
Kailang Yangdf694da2005-12-05 19:42:22 +0100111/* ALC861 models */
112enum {
113 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200114 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100115 ALC861_3ST_DIG,
116 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200117 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200118 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200119 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100120 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100121 ALC861_AUTO,
122 ALC861_MODEL_LAST,
123};
124
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100125/* ALC861-VD models */
126enum {
127 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200128 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100129 ALC861VD_3ST,
130 ALC861VD_3ST_DIG,
131 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200132 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200133 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200134 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100135 ALC861VD_AUTO,
136 ALC861VD_MODEL_LAST,
137};
138
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200139/* ALC662 models */
140enum {
141 ALC662_3ST_2ch_DIG,
142 ALC662_3ST_6ch_DIG,
143 ALC662_3ST_6ch,
144 ALC662_5ST_DIG,
145 ALC662_LENOVO_101E,
146 ALC662_AUTO,
147 ALC662_MODEL_LAST,
148};
149
Kailang Yangdf694da2005-12-05 19:42:22 +0100150/* ALC882 models */
151enum {
152 ALC882_3ST_DIG,
153 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200154 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200155 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200156 ALC882_TARGA,
157 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100158 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200159 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200160 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200161 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100162 ALC882_MODEL_LAST,
163};
164
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200165/* ALC883 models */
166enum {
167 ALC883_3ST_2ch_DIG,
168 ALC883_3ST_6ch_DIG,
169 ALC883_3ST_6ch,
170 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200171 ALC883_TARGA_DIG,
172 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200173 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200174 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200175 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200176 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100177 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200178 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200179 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200180 ALC888_LENOVO_MS7195_DIG,
181 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200182 ALC888_6ST_HP,
183 ALC888_3ST_HP,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200184 ALC883_AUTO,
185 ALC883_MODEL_LAST,
186};
187
Kailang Yangdf694da2005-12-05 19:42:22 +0100188/* for GPIO Poll */
189#define GPIO_MASK 0x03
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191struct alc_spec {
192 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100193 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 unsigned int num_mixers;
195
Kailang Yangdf694da2005-12-05 19:42:22 +0100196 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200197 * don't forget NULL
198 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200199 */
200 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Takashi Iwai16ded522005-06-10 19:58:24 +0200202 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 struct hda_pcm_stream *stream_analog_playback;
204 struct hda_pcm_stream *stream_analog_capture;
205
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200206 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 struct hda_pcm_stream *stream_digital_playback;
208 struct hda_pcm_stream *stream_digital_capture;
209
210 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200211 struct hda_multi_out multiout; /* playback set-up
212 * max_channels, dacs must be set
213 * dig_out_nid and hp_nid are optional
214 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216 /* capture */
217 unsigned int num_adc_nids;
218 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200219 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200222 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 const struct hda_input_mux *input_mux;
224 unsigned int cur_mux[3];
225
226 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100227 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200229 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
231 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100232 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200233
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200234 /* dynamic controls, init_verbs and input_mux */
235 struct auto_pin_cfg autocfg;
236 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100237 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200238 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100239 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100240
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100241 /* hooks */
242 void (*init_hook)(struct hda_codec *codec);
243 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
244
Takashi Iwai834be882006-03-01 14:16:17 +0100245 /* for pin sensing */
246 unsigned int sense_updated: 1;
247 unsigned int jack_present: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200248
249#ifdef CONFIG_SND_HDA_POWER_SAVE
250 struct hda_loopback_check loopback;
251#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100252};
253
254/*
255 * configuration template - to be copied to the spec instance
256 */
257struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258 struct snd_kcontrol_new *mixers[5]; /* should be identical size
259 * with spec
260 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100261 const struct hda_verb *init_verbs[5];
262 unsigned int num_dacs;
263 hda_nid_t *dac_nids;
264 hda_nid_t dig_out_nid; /* optional */
265 hda_nid_t hp_nid; /* optional */
266 unsigned int num_adc_nids;
267 hda_nid_t *adc_nids;
268 hda_nid_t dig_in_nid;
269 unsigned int num_channel_mode;
270 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200271 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200272 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100273 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100274 void (*unsol_event)(struct hda_codec *, unsigned int);
275 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200276#ifdef CONFIG_SND_HDA_POWER_SAVE
277 struct hda_amp_list *loopbacks;
278#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279};
280
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282/*
283 * input MUX handling
284 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200285static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
286 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287{
288 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
289 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200290 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
291 if (mux_idx >= spec->num_mux_defs)
292 mux_idx = 0;
293 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294}
295
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200296static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
297 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298{
299 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
300 struct alc_spec *spec = codec->spec;
301 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
302
303 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
304 return 0;
305}
306
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200307static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
308 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309{
310 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
311 struct alc_spec *spec = codec->spec;
312 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200313 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
314 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200315 spec->adc_nids[adc_idx],
316 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317}
318
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200319
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320/*
321 * channel mode setting
322 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200323static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
324 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325{
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
327 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100328 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
329 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330}
331
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200332static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334{
335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
336 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100337 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200338 spec->num_channel_mode,
339 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200342static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
343 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344{
345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
346 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200347 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
348 spec->num_channel_mode,
349 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200350 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200351 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
352 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353}
354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356 * Control the mode of pin widget settings via the mixer. "pc" is used
357 * instead of "%" to avoid consequences of accidently treating the % as
358 * being part of a format specifier. Maximum allowed length of a value is
359 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100360 *
361 * Note: some retasking pin complexes seem to ignore requests for input
362 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
363 * are requested. Therefore order this list so that this behaviour will not
364 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200365 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
366 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200367 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100368static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100369 "Mic 50pc bias", "Mic 80pc bias",
370 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100371};
372static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100373 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100374};
375/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200376 * in the pin being assumed to be exclusively an input or an output pin. In
377 * addition, "input" pins may or may not process the mic bias option
378 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
379 * accept requests for bias as of chip versions up to March 2006) and/or
380 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100381 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200382#define ALC_PIN_DIR_IN 0x00
383#define ALC_PIN_DIR_OUT 0x01
384#define ALC_PIN_DIR_INOUT 0x02
385#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
386#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100387
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200388/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100389 * For each direction the minimum and maximum values are given.
390 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200391static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100392 { 0, 2 }, /* ALC_PIN_DIR_IN */
393 { 3, 4 }, /* ALC_PIN_DIR_OUT */
394 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200395 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
396 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100397};
398#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
399#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
400#define alc_pin_mode_n_items(_dir) \
401 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
402
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200403static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200405{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100406 unsigned int item_num = uinfo->value.enumerated.item;
407 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
408
409 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200410 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100411 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
412
413 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
414 item_num = alc_pin_mode_min(dir);
415 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200416 return 0;
417}
418
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200419static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200421{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100422 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200423 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
424 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100425 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200426 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200427 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
428 AC_VERB_GET_PIN_WIDGET_CONTROL,
429 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200430
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100431 /* Find enumerated value for current pinctl setting */
432 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100434 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100436 return 0;
437}
438
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200439static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100441{
442 signed int change;
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 hda_nid_t nid = kcontrol->private_value & 0xffff;
445 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
446 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200447 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
448 AC_VERB_GET_PIN_WIDGET_CONTROL,
449 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200451 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100452 val = alc_pin_mode_min(dir);
453
454 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100455 if (change) {
456 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200457 snd_hda_codec_write_cache(codec, nid, 0,
458 AC_VERB_SET_PIN_WIDGET_CONTROL,
459 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100460
461 /* Also enable the retasking pin's input/output as required
462 * for the requested pin mode. Enum values of 2 or less are
463 * input modes.
464 *
465 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200466 * reduces noise slightly (particularly on input) so we'll
467 * do it. However, having both input and output buffers
468 * enabled simultaneously doesn't seem to be problematic if
469 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100470 */
471 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200472 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
473 HDA_AMP_MUTE, HDA_AMP_MUTE);
474 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
475 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100476 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200477 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
478 HDA_AMP_MUTE, HDA_AMP_MUTE);
479 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
480 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100481 }
482 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200483 return change;
484}
485
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100486#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200487 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100488 .info = alc_pin_mode_info, \
489 .get = alc_pin_mode_get, \
490 .put = alc_pin_mode_put, \
491 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100492
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100493/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
494 * together using a mask with more than one bit set. This control is
495 * currently used only by the ALC260 test model. At this stage they are not
496 * needed for any "production" models.
497 */
498#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200499#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200500
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200501static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
502 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100503{
504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
505 hda_nid_t nid = kcontrol->private_value & 0xffff;
506 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
507 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200508 unsigned int val = snd_hda_codec_read(codec, nid, 0,
509 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100510
511 *valp = (val & mask) != 0;
512 return 0;
513}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100516{
517 signed int change;
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 hda_nid_t nid = kcontrol->private_value & 0xffff;
520 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
521 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200522 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
523 AC_VERB_GET_GPIO_DATA,
524 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100525
526 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200527 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
528 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100529 gpio_data &= ~mask;
530 else
531 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200532 snd_hda_codec_write_cache(codec, nid, 0,
533 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100534
535 return change;
536}
537#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
538 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
539 .info = alc_gpio_data_info, \
540 .get = alc_gpio_data_get, \
541 .put = alc_gpio_data_put, \
542 .private_value = nid | (mask<<16) }
543#endif /* CONFIG_SND_DEBUG */
544
Jonathan Woithe92621f12006-02-28 11:47:47 +0100545/* A switch control to allow the enabling of the digital IO pins on the
546 * ALC260. This is incredibly simplistic; the intention of this control is
547 * to provide something in the test model allowing digital outputs to be
548 * identified if present. If models are found which can utilise these
549 * outputs a more complete mixer control can be devised for those models if
550 * necessary.
551 */
552#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200553#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200554
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100557{
558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
559 hda_nid_t nid = kcontrol->private_value & 0xffff;
560 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
561 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562 unsigned int val = snd_hda_codec_read(codec, nid, 0,
563 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100564
565 *valp = (val & mask) != 0;
566 return 0;
567}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100570{
571 signed int change;
572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
573 hda_nid_t nid = kcontrol->private_value & 0xffff;
574 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
575 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
577 AC_VERB_GET_DIGI_CONVERT,
578 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100579
580 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200581 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100582 if (val==0)
583 ctrl_data &= ~mask;
584 else
585 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200586 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
587 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100588
589 return change;
590}
591#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
592 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
593 .info = alc_spdif_ctrl_info, \
594 .get = alc_spdif_ctrl_get, \
595 .put = alc_spdif_ctrl_put, \
596 .private_value = nid | (mask<<16) }
597#endif /* CONFIG_SND_DEBUG */
598
Kailang Yangdf694da2005-12-05 19:42:22 +0100599/*
600 * set up from the preset table
601 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602static void setup_preset(struct alc_spec *spec,
603 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100604{
605 int i;
606
607 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
608 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200609 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
610 i++)
611 spec->init_verbs[spec->num_init_verbs++] =
612 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100613
614 spec->channel_mode = preset->channel_mode;
615 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200616 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100617
618 spec->multiout.max_channels = spec->channel_mode[0].channels;
619
620 spec->multiout.num_dacs = preset->num_dacs;
621 spec->multiout.dac_nids = preset->dac_nids;
622 spec->multiout.dig_out_nid = preset->dig_out_nid;
623 spec->multiout.hp_nid = preset->hp_nid;
624
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200625 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200626 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200627 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100628 spec->input_mux = preset->input_mux;
629
630 spec->num_adc_nids = preset->num_adc_nids;
631 spec->adc_nids = preset->adc_nids;
632 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100633
634 spec->unsol_event = preset->unsol_event;
635 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200636#ifdef CONFIG_SND_HDA_POWER_SAVE
637 spec->loopback.amplist = preset->loopbacks;
638#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100639}
640
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200641/* Enable GPIO mask and set output */
642static struct hda_verb alc_gpio1_init_verbs[] = {
643 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
644 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
645 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
646 { }
647};
648
649static struct hda_verb alc_gpio2_init_verbs[] = {
650 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
651 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
652 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
653 { }
654};
655
Kailang Yangbdd148a2007-05-08 15:19:08 +0200656static struct hda_verb alc_gpio3_init_verbs[] = {
657 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
658 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
659 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
660 { }
661};
662
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200663/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
664 * 31 ~ 16 : Manufacture ID
665 * 15 ~ 8 : SKU ID
666 * 7 ~ 0 : Assembly ID
667 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
668 */
669static void alc_subsystem_id(struct hda_codec *codec,
670 unsigned int porta, unsigned int porte,
671 unsigned int portd)
672{
673 unsigned int ass, tmp;
674
675 ass = codec->subsystem_id;
676 if (!(ass & 1))
677 return;
678
679 /* Override */
680 tmp = (ass & 0x38) >> 3; /* external Amp control */
681 switch (tmp) {
682 case 1:
683 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
684 break;
685 case 3:
686 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
687 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200688 case 7:
689 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
690 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200691 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200692 switch (codec->vendor_id) {
693 case 0x10ec0862:
694 case 0x10ec0660:
695 case 0x10ec0662:
696 case 0x10ec0267:
697 case 0x10ec0268:
698 snd_hda_codec_write(codec, 0x14, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
700 snd_hda_codec_write(codec, 0x15, 0,
701 AC_VERB_SET_EAPD_BTLENABLE, 2);
702 return;
703 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200704 case 6:
705 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
706 hda_nid_t port = 0;
707 tmp = (ass & 0x1800) >> 11;
708 switch (tmp) {
709 case 0: port = porta; break;
710 case 1: port = porte; break;
711 case 2: port = portd; break;
712 }
713 if (port)
714 snd_hda_codec_write(codec, port, 0,
715 AC_VERB_SET_EAPD_BTLENABLE,
716 2);
717 }
718 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
719 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
720 (tmp == 5 ? 0x3040 : 0x3050));
721 break;
722 }
723}
724
Takashi Iwai41e41f12005-06-08 14:48:49 +0200725/*
Takashi Iwaif95474e2007-07-10 00:47:43 +0200726 * Fix-up pin default configurations
727 */
728
729struct alc_pincfg {
730 hda_nid_t nid;
731 u32 val;
732};
733
734static void alc_fix_pincfg(struct hda_codec *codec,
735 const struct snd_pci_quirk *quirk,
736 const struct alc_pincfg **pinfix)
737{
738 const struct alc_pincfg *cfg;
739
740 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
741 if (!quirk)
742 return;
743
744 cfg = pinfix[quirk->value];
745 for (; cfg->nid; cfg++) {
746 int i;
747 u32 val = cfg->val;
748 for (i = 0; i < 4; i++) {
749 snd_hda_codec_write(codec, cfg->nid, 0,
750 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
751 val & 0xff);
752 val >>= 8;
753 }
754 }
755}
756
757/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200758 * ALC880 3-stack model
759 *
760 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200761 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
762 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 */
764
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200765static hda_nid_t alc880_dac_nids[4] = {
766 /* front, rear, clfe, rear_surr */
767 0x02, 0x05, 0x04, 0x03
768};
769
770static hda_nid_t alc880_adc_nids[3] = {
771 /* ADC0-2 */
772 0x07, 0x08, 0x09,
773};
774
775/* The datasheet says the node 0x07 is connected from inputs,
776 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100777 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200779static hda_nid_t alc880_adc_nids_alt[2] = {
780 /* ADC1-2 */
781 0x08, 0x09,
782};
783
784#define ALC880_DIGOUT_NID 0x06
785#define ALC880_DIGIN_NID 0x0a
786
787static struct hda_input_mux alc880_capture_source = {
788 .num_items = 4,
789 .items = {
790 { "Mic", 0x0 },
791 { "Front Mic", 0x3 },
792 { "Line", 0x2 },
793 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200795};
796
797/* channel source setting (2/6 channel selection for 3-stack) */
798/* 2ch mode */
799static struct hda_verb alc880_threestack_ch2_init[] = {
800 /* set line-in to input, mute it */
801 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
802 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
803 /* set mic-in to input vref 80%, mute it */
804 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
805 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 { } /* end */
807};
808
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200809/* 6ch mode */
810static struct hda_verb alc880_threestack_ch6_init[] = {
811 /* set line-in to output, unmute it */
812 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
813 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
814 /* set mic-in to output, unmute it */
815 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
816 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
817 { } /* end */
818};
819
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100820static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200821 { 2, alc880_threestack_ch2_init },
822 { 6, alc880_threestack_ch6_init },
823};
824
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100825static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200826 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100827 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200828 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100829 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200830 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
831 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100832 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
833 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
842 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
843 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200845 {
846 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
847 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100848 .info = alc_ch_mode_info,
849 .get = alc_ch_mode_get,
850 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200851 },
852 { } /* end */
853};
854
855/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100856static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200857 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
858 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
859 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
861 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
862 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
863 {
864 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
865 /* The multiple "Capture Source" controls confuse alsamixer
866 * So call somewhat different..
867 * FIXME: the controls appear in the "playback" view!
868 */
869 /* .name = "Capture Source", */
870 .name = "Input Source",
871 .count = 3,
872 .info = alc_mux_enum_info,
873 .get = alc_mux_enum_get,
874 .put = alc_mux_enum_put,
875 },
876 { } /* end */
877};
878
879/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100880static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
883 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
884 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 {
886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
887 /* The multiple "Capture Source" controls confuse alsamixer
888 * So call somewhat different..
889 * FIXME: the controls appear in the "playback" view!
890 */
891 /* .name = "Capture Source", */
892 .name = "Input Source",
893 .count = 2,
894 .info = alc_mux_enum_info,
895 .get = alc_mux_enum_get,
896 .put = alc_mux_enum_put,
897 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 { } /* end */
899};
900
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200901
902
903/*
904 * ALC880 5-stack model
905 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200906 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
907 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200908 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
909 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
910 */
911
912/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100913static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200914 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100915 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 { } /* end */
917};
918
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200919/* channel source setting (6/8 channel selection for 5-stack) */
920/* 6ch mode */
921static struct hda_verb alc880_fivestack_ch6_init[] = {
922 /* set line-in to input, mute it */
923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200925 { } /* end */
926};
927
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200928/* 8ch mode */
929static struct hda_verb alc880_fivestack_ch8_init[] = {
930 /* set line-in to output, unmute it */
931 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
932 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
933 { } /* end */
934};
935
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100936static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200937 { 6, alc880_fivestack_ch6_init },
938 { 8, alc880_fivestack_ch8_init },
939};
940
941
942/*
943 * ALC880 6-stack model
944 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200945 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
946 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200947 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
948 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
949 */
950
951static hda_nid_t alc880_6st_dac_nids[4] = {
952 /* front, rear, clfe, rear_surr */
953 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200954};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200955
956static struct hda_input_mux alc880_6stack_capture_source = {
957 .num_items = 4,
958 .items = {
959 { "Mic", 0x0 },
960 { "Front Mic", 0x1 },
961 { "Line", 0x2 },
962 { "CD", 0x4 },
963 },
964};
965
966/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100967static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200968 { 8, NULL },
969};
970
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100971static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200980 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100981 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
984 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
985 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
988 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
989 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
990 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
991 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200992 {
993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
994 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100995 .info = alc_ch_mode_info,
996 .get = alc_ch_mode_get,
997 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200998 },
999 { } /* end */
1000};
1001
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001002
1003/*
1004 * ALC880 W810 model
1005 *
1006 * W810 has rear IO for:
1007 * Front (DAC 02)
1008 * Surround (DAC 03)
1009 * Center/LFE (DAC 04)
1010 * Digital out (06)
1011 *
1012 * The system also has a pair of internal speakers, and a headphone jack.
1013 * These are both connected to Line2 on the codec, hence to DAC 02.
1014 *
1015 * There is a variable resistor to control the speaker or headphone
1016 * volume. This is a hardware-only device without a software API.
1017 *
1018 * Plugging headphones in will disable the internal speakers. This is
1019 * implemented in hardware, not via the driver using jack sense. In
1020 * a similar fashion, plugging into the rear socket marked "front" will
1021 * disable both the speakers and headphones.
1022 *
1023 * For input, there's a microphone jack, and an "audio in" jack.
1024 * These may not do anything useful with this driver yet, because I
1025 * haven't setup any initialization verbs for these yet...
1026 */
1027
1028static hda_nid_t alc880_w810_dac_nids[3] = {
1029 /* front, rear/surround, clfe */
1030 0x02, 0x03, 0x04
1031};
1032
1033/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001034static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001035 { 6, NULL }
1036};
1037
1038/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001039static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001041 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001042 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001043 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001044 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001046 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1047 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1049 { } /* end */
1050};
1051
1052
1053/*
1054 * Z710V model
1055 *
1056 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001057 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1058 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001059 */
1060
1061static hda_nid_t alc880_z71v_dac_nids[1] = {
1062 0x02
1063};
1064#define ALC880_Z71V_HP_DAC 0x03
1065
1066/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001067static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001068 { 2, NULL }
1069};
1070
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001071static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001072 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001073 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001075 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001076 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1077 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1080 { } /* end */
1081};
1082
1083
1084/* FIXME! */
1085/*
1086 * ALC880 F1734 model
1087 *
1088 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1089 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1090 */
1091
1092static hda_nid_t alc880_f1734_dac_nids[1] = {
1093 0x03
1094};
1095#define ALC880_F1734_HP_DAC 0x02
1096
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001097static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001099 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001100 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001101 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001106 { } /* end */
1107};
1108
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001109
1110/* FIXME! */
1111/*
1112 * ALC880 ASUS model
1113 *
1114 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1115 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1116 * Mic = 0x18, Line = 0x1a
1117 */
1118
1119#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1120#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1121
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001122static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001125 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001126 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001127 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1128 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001129 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1130 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001131 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1132 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1134 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001137 {
1138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1139 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001140 .info = alc_ch_mode_info,
1141 .get = alc_ch_mode_get,
1142 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001143 },
1144 { } /* end */
1145};
1146
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001147/* FIXME! */
1148/*
1149 * ALC880 ASUS W1V model
1150 *
1151 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1152 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1153 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1154 */
1155
1156/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001157static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001158 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1159 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001160 { } /* end */
1161};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001162
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001163/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001164static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001165 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1166 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1167 { } /* end */
1168};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001169
Kailang Yangdf694da2005-12-05 19:42:22 +01001170/* TCL S700 */
1171static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1175 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1176 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1179 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1181 {
1182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1183 /* The multiple "Capture Source" controls confuse alsamixer
1184 * So call somewhat different..
1185 * FIXME: the controls appear in the "playback" view!
1186 */
1187 /* .name = "Capture Source", */
1188 .name = "Input Source",
1189 .count = 1,
1190 .info = alc_mux_enum_info,
1191 .get = alc_mux_enum_get,
1192 .put = alc_mux_enum_put,
1193 },
1194 { } /* end */
1195};
1196
Kailang Yangccc656c2006-10-17 12:32:26 +02001197/* Uniwill */
1198static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1199 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1202 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1203 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1207 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1208 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1209 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1210 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1213 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1215 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1216 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1217 {
1218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1219 .name = "Channel Mode",
1220 .info = alc_ch_mode_info,
1221 .get = alc_ch_mode_get,
1222 .put = alc_ch_mode_put,
1223 },
1224 { } /* end */
1225};
1226
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001227static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1228 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1229 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1230 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1231 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1235 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1236 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1237 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1238 { } /* end */
1239};
1240
Kailang Yangccc656c2006-10-17 12:32:26 +02001241static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1242 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1243 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1244 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1245 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1248 { } /* end */
1249};
1250
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001252 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 */
1254static int alc_build_controls(struct hda_codec *codec)
1255{
1256 struct alc_spec *spec = codec->spec;
1257 int err;
1258 int i;
1259
1260 for (i = 0; i < spec->num_mixers; i++) {
1261 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1262 if (err < 0)
1263 return err;
1264 }
1265
1266 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001267 err = snd_hda_create_spdif_out_ctls(codec,
1268 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 if (err < 0)
1270 return err;
1271 }
1272 if (spec->dig_in_nid) {
1273 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1274 if (err < 0)
1275 return err;
1276 }
1277 return 0;
1278}
1279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281/*
1282 * initialize the codec volumes, etc
1283 */
1284
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001285/*
1286 * generic initialization of ADC, input mixers and output mixers
1287 */
1288static struct hda_verb alc880_volume_init_verbs[] = {
1289 /*
1290 * Unmute ADC0-2 and set the default input to mic-in
1291 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001292 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001294 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001296 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001299 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1300 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001301 * Note: PASD motherboards uses the Line In 2 as the input for front
1302 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001304 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001313 /*
1314 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001316 /* set vol=0 to output mixers */
1317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1321 /* set up input amps for analog loopback */
1322 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331
1332 { }
1333};
1334
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001335/*
1336 * 3-stack pin configuration:
1337 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1338 */
1339static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1340 /*
1341 * preset connection lists of input pins
1342 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1343 */
1344 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1345 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1346 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1347
1348 /*
1349 * Set pin mode and muting
1350 */
1351 /* set front pin widgets 0x14 for output */
1352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1357 /* Mic2 (as headphone out) for HP output */
1358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1360 /* Line In pin widget for input */
1361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1363 /* Line2 (as front mic) pin widget for input and vref at 80% */
1364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 /* CD pin widget for input */
1367 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1368
1369 { }
1370};
1371
1372/*
1373 * 5-stack pin configuration:
1374 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1375 * line-in/side = 0x1a, f-mic = 0x1b
1376 */
1377static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1378 /*
1379 * preset connection lists of input pins
1380 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1381 */
1382 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1383 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1384
1385 /*
1386 * Set pin mode and muting
1387 */
1388 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001393 /* unmute pins for output (no gain on this amp) */
1394 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1397 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1398
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001400 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001401 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1402 /* Mic2 (as headphone out) for HP output */
1403 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001404 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001405 /* Line In pin widget for input */
1406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1408 /* Line2 (as front mic) pin widget for input and vref at 80% */
1409 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1410 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1411 /* CD pin widget for input */
1412 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413
1414 { }
1415};
1416
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001417/*
1418 * W810 pin configuration:
1419 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1420 */
1421static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 /* hphone/speaker input selector: front DAC */
1423 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1424
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1429 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1430 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1431
1432 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001433 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 { }
1436};
1437
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001438/*
1439 * Z71V pin configuration:
1440 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1441 */
1442static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001447
Takashi Iwai16ded522005-06-10 19:58:24 +02001448 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001449 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001450 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001451 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001452
1453 { }
1454};
1455
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001456/*
1457 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001458 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1459 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001460 */
1461static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1463
Takashi Iwai16ded522005-06-10 19:58:24 +02001464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001470 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1472
Takashi Iwai16ded522005-06-10 19:58:24 +02001473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001475 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001477 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001480 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1482
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001483 { }
1484};
Takashi Iwai16ded522005-06-10 19:58:24 +02001485
Kailang Yangccc656c2006-10-17 12:32:26 +02001486/*
1487 * Uniwill pin configuration:
1488 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1489 * line = 0x1a
1490 */
1491static struct hda_verb alc880_uniwill_init_verbs[] = {
1492 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1493
1494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1499 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1508
1509 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1512 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1515 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1516 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1518
1519 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1520 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1521
1522 { }
1523};
1524
1525/*
1526* Uniwill P53
1527* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1528 */
1529static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1530 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1531
1532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1537 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1540 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1542 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1543 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1544
1545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1548 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1551
1552 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1553 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1554
1555 { }
1556};
1557
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001558static struct hda_verb alc880_beep_init_verbs[] = {
1559 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1560 { }
1561};
1562
Kailang Yangccc656c2006-10-17 12:32:26 +02001563/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001564static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001565{
1566 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001567 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001568
1569 present = snd_hda_codec_read(codec, 0x14, 0,
1570 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001571 bits = present ? HDA_AMP_MUTE : 0;
1572 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1573 HDA_AMP_MUTE, bits);
1574 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1575 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001576}
1577
1578/* auto-toggle front mic */
1579static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1580{
1581 unsigned int present;
1582 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001583
1584 present = snd_hda_codec_read(codec, 0x18, 0,
1585 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001586 bits = present ? HDA_AMP_MUTE : 0;
1587 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001588}
1589
1590static void alc880_uniwill_automute(struct hda_codec *codec)
1591{
1592 alc880_uniwill_hp_automute(codec);
1593 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001594}
1595
1596static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1597 unsigned int res)
1598{
1599 /* Looks like the unsol event is incompatible with the standard
1600 * definition. 4bit tag is placed at 28 bit!
1601 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001602 switch (res >> 28) {
1603 case ALC880_HP_EVENT:
1604 alc880_uniwill_hp_automute(codec);
1605 break;
1606 case ALC880_MIC_EVENT:
1607 alc880_uniwill_mic_automute(codec);
1608 break;
1609 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001610}
1611
1612static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1613{
1614 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001615 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001616
1617 present = snd_hda_codec_read(codec, 0x14, 0,
1618 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001619 bits = present ? HDA_AMP_MUTE : 0;
1620 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001621}
1622
1623static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1624{
1625 unsigned int present;
1626
1627 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001628 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1629 present &= HDA_AMP_VOLMASK;
1630 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1631 HDA_AMP_VOLMASK, present);
1632 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1633 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001634}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001635
Kailang Yangccc656c2006-10-17 12:32:26 +02001636static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1637 unsigned int res)
1638{
1639 /* Looks like the unsol event is incompatible with the standard
1640 * definition. 4bit tag is placed at 28 bit!
1641 */
1642 if ((res >> 28) == ALC880_HP_EVENT)
1643 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001644 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001645 alc880_uniwill_p53_dcvol_automute(codec);
1646}
1647
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001648/* FIXME! */
1649/*
1650 * F1734 pin configuration:
1651 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1652 */
1653static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1654 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1655 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1656 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1657 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1658
1659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663
1664 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1665 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1666 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1667 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1671 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001673
1674 { }
1675};
1676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001677/* FIXME! */
1678/*
1679 * ASUS pin configuration:
1680 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1681 */
1682static struct hda_verb alc880_pin_asus_init_verbs[] = {
1683 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1684 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1685 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1687
1688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696
1697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1703 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1706
1707 { }
1708};
1709
1710/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001711#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1712#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001713
Kailang Yangdf694da2005-12-05 19:42:22 +01001714/* Clevo m520g init */
1715static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1716 /* headphone output */
1717 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1718 /* line-out */
1719 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1721 /* Line-in */
1722 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1724 /* CD */
1725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1726 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1727 /* Mic1 (rear panel) */
1728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1730 /* Mic2 (front panel) */
1731 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 /* headphone */
1734 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1735 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1736 /* change to EAPD mode */
1737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1738 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1739
1740 { }
1741};
1742
1743static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001744 /* change to EAPD mode */
1745 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1746 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1747
Kailang Yangdf694da2005-12-05 19:42:22 +01001748 /* Headphone output */
1749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1750 /* Front output*/
1751 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1752 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1753
1754 /* Line In pin widget for input */
1755 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756 /* CD pin widget for input */
1757 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1758 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1759 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1760
1761 /* change to EAPD mode */
1762 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1763 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1764
1765 { }
1766};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001767
1768/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001769 * LG m1 express dual
1770 *
1771 * Pin assignment:
1772 * Rear Line-In/Out (blue): 0x14
1773 * Build-in Mic-In: 0x15
1774 * Speaker-out: 0x17
1775 * HP-Out (green): 0x1b
1776 * Mic-In/Out (red): 0x19
1777 * SPDIF-Out: 0x1e
1778 */
1779
1780/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1781static hda_nid_t alc880_lg_dac_nids[3] = {
1782 0x05, 0x02, 0x03
1783};
1784
1785/* seems analog CD is not working */
1786static struct hda_input_mux alc880_lg_capture_source = {
1787 .num_items = 3,
1788 .items = {
1789 { "Mic", 0x1 },
1790 { "Line", 0x5 },
1791 { "Internal Mic", 0x6 },
1792 },
1793};
1794
1795/* 2,4,6 channel modes */
1796static struct hda_verb alc880_lg_ch2_init[] = {
1797 /* set line-in and mic-in to input */
1798 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1799 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1800 { }
1801};
1802
1803static struct hda_verb alc880_lg_ch4_init[] = {
1804 /* set line-in to out and mic-in to input */
1805 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1806 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1807 { }
1808};
1809
1810static struct hda_verb alc880_lg_ch6_init[] = {
1811 /* set line-in and mic-in to output */
1812 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1813 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1814 { }
1815};
1816
1817static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1818 { 2, alc880_lg_ch2_init },
1819 { 4, alc880_lg_ch4_init },
1820 { 6, alc880_lg_ch6_init },
1821};
1822
1823static struct snd_kcontrol_new alc880_lg_mixer[] = {
1824 /* FIXME: it's not really "master" but front channels */
1825 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1826 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1828 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1831 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1832 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1835 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1836 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1837 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1838 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1839 {
1840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1841 .name = "Channel Mode",
1842 .info = alc_ch_mode_info,
1843 .get = alc_ch_mode_get,
1844 .put = alc_ch_mode_put,
1845 },
1846 { } /* end */
1847};
1848
1849static struct hda_verb alc880_lg_init_verbs[] = {
1850 /* set capture source to mic-in */
1851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1852 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1854 /* mute all amp mixer inputs */
1855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02001856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1857 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001858 /* line-in to input */
1859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1861 /* built-in mic */
1862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1864 /* speaker-out */
1865 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1866 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 /* mic-in to input */
1868 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1869 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1870 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1871 /* HP-out */
1872 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1873 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1874 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1875 /* jack sense */
1876 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1877 { }
1878};
1879
1880/* toggle speaker-output according to the hp-jack state */
1881static void alc880_lg_automute(struct hda_codec *codec)
1882{
1883 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001884 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001885
1886 present = snd_hda_codec_read(codec, 0x1b, 0,
1887 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001888 bits = present ? HDA_AMP_MUTE : 0;
1889 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
1890 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001891}
1892
1893static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1894{
1895 /* Looks like the unsol event is incompatible with the standard
1896 * definition. 4bit tag is placed at 28 bit!
1897 */
1898 if ((res >> 28) == 0x01)
1899 alc880_lg_automute(codec);
1900}
1901
1902/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001903 * LG LW20
1904 *
1905 * Pin assignment:
1906 * Speaker-out: 0x14
1907 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001908 * Built-in Mic-In: 0x19
1909 * Line-In: 0x1b
1910 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01001911 * SPDIF-Out: 0x1e
1912 */
1913
Takashi Iwaid6815182006-03-23 16:06:23 +01001914static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001915 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01001916 .items = {
1917 { "Mic", 0x0 },
1918 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02001919 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001920 },
1921};
1922
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001923#define alc880_lg_lw_modes alc880_threestack_modes
1924
Takashi Iwaid6815182006-03-23 16:06:23 +01001925static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001926 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1927 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1929 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1930 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1931 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1932 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1933 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01001936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1938 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1939 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001940 {
1941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1942 .name = "Channel Mode",
1943 .info = alc_ch_mode_info,
1944 .get = alc_ch_mode_get,
1945 .put = alc_ch_mode_put,
1946 },
Takashi Iwaid6815182006-03-23 16:06:23 +01001947 { } /* end */
1948};
1949
1950static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02001951 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1952 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1953 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1954
Takashi Iwaid6815182006-03-23 16:06:23 +01001955 /* set capture source to mic-in */
1956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1957 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1958 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02001959 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01001960 /* speaker-out */
1961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1963 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01001964 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1965 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1966 /* mic-in to input */
1967 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1969 /* built-in mic */
1970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1972 /* jack sense */
1973 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1974 { }
1975};
1976
1977/* toggle speaker-output according to the hp-jack state */
1978static void alc880_lg_lw_automute(struct hda_codec *codec)
1979{
1980 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001981 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001982
1983 present = snd_hda_codec_read(codec, 0x1b, 0,
1984 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001985 bits = present ? HDA_AMP_MUTE : 0;
1986 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1987 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001988}
1989
1990static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1991{
1992 /* Looks like the unsol event is incompatible with the standard
1993 * definition. 4bit tag is placed at 28 bit!
1994 */
1995 if ((res >> 28) == 0x01)
1996 alc880_lg_lw_automute(codec);
1997}
1998
Takashi Iwaicb53c622007-08-10 17:21:45 +02001999#ifdef CONFIG_SND_HDA_POWER_SAVE
2000static struct hda_amp_list alc880_loopbacks[] = {
2001 { 0x0b, HDA_INPUT, 0 },
2002 { 0x0b, HDA_INPUT, 1 },
2003 { 0x0b, HDA_INPUT, 2 },
2004 { 0x0b, HDA_INPUT, 3 },
2005 { 0x0b, HDA_INPUT, 4 },
2006 { } /* end */
2007};
2008
2009static struct hda_amp_list alc880_lg_loopbacks[] = {
2010 { 0x0b, HDA_INPUT, 1 },
2011 { 0x0b, HDA_INPUT, 6 },
2012 { 0x0b, HDA_INPUT, 7 },
2013 { } /* end */
2014};
2015#endif
2016
Takashi Iwaid6815182006-03-23 16:06:23 +01002017/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002018 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002019 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002020
Linus Torvalds1da177e2005-04-16 15:20:36 -07002021static int alc_init(struct hda_codec *codec)
2022{
2023 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002024 unsigned int i;
2025
2026 for (i = 0; i < spec->num_init_verbs; i++)
2027 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002028
2029 if (spec->init_hook)
2030 spec->init_hook(codec);
2031
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032 return 0;
2033}
2034
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002035static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2036{
2037 struct alc_spec *spec = codec->spec;
2038
2039 if (spec->unsol_event)
2040 spec->unsol_event(codec, res);
2041}
2042
Takashi Iwaicb53c622007-08-10 17:21:45 +02002043#ifdef CONFIG_SND_HDA_POWER_SAVE
2044static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2045{
2046 struct alc_spec *spec = codec->spec;
2047 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2048}
2049#endif
2050
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051/*
2052 * Analog playback callbacks
2053 */
2054static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2055 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002056 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057{
2058 struct alc_spec *spec = codec->spec;
2059 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2060}
2061
2062static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2063 struct hda_codec *codec,
2064 unsigned int stream_tag,
2065 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002066 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067{
2068 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002069 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2070 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071}
2072
2073static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2074 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002075 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076{
2077 struct alc_spec *spec = codec->spec;
2078 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2079}
2080
2081/*
2082 * Digital out
2083 */
2084static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2085 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002086 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087{
2088 struct alc_spec *spec = codec->spec;
2089 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2090}
2091
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002092static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2093 struct hda_codec *codec,
2094 unsigned int stream_tag,
2095 unsigned int format,
2096 struct snd_pcm_substream *substream)
2097{
2098 struct alc_spec *spec = codec->spec;
2099 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2100 stream_tag, format, substream);
2101}
2102
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2104 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002105 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002106{
2107 struct alc_spec *spec = codec->spec;
2108 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2109}
2110
2111/*
2112 * Analog capture
2113 */
2114static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2115 struct hda_codec *codec,
2116 unsigned int stream_tag,
2117 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002118 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119{
2120 struct alc_spec *spec = codec->spec;
2121
2122 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2123 stream_tag, 0, format);
2124 return 0;
2125}
2126
2127static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2128 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002129 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130{
2131 struct alc_spec *spec = codec->spec;
2132
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002133 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2134 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002135 return 0;
2136}
2137
2138
2139/*
2140 */
2141static struct hda_pcm_stream alc880_pcm_analog_playback = {
2142 .substreams = 1,
2143 .channels_min = 2,
2144 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002145 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002146 .ops = {
2147 .open = alc880_playback_pcm_open,
2148 .prepare = alc880_playback_pcm_prepare,
2149 .cleanup = alc880_playback_pcm_cleanup
2150 },
2151};
2152
2153static struct hda_pcm_stream alc880_pcm_analog_capture = {
2154 .substreams = 2,
2155 .channels_min = 2,
2156 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002157 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 .ops = {
2159 .prepare = alc880_capture_pcm_prepare,
2160 .cleanup = alc880_capture_pcm_cleanup
2161 },
2162};
2163
2164static struct hda_pcm_stream alc880_pcm_digital_playback = {
2165 .substreams = 1,
2166 .channels_min = 2,
2167 .channels_max = 2,
2168 /* NID is set in alc_build_pcms */
2169 .ops = {
2170 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002171 .close = alc880_dig_playback_pcm_close,
2172 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 },
2174};
2175
2176static struct hda_pcm_stream alc880_pcm_digital_capture = {
2177 .substreams = 1,
2178 .channels_min = 2,
2179 .channels_max = 2,
2180 /* NID is set in alc_build_pcms */
2181};
2182
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002183/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2184static struct hda_pcm_stream alc_pcm_null_playback = {
2185 .substreams = 0,
2186 .channels_min = 0,
2187 .channels_max = 0,
2188};
2189
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190static int alc_build_pcms(struct hda_codec *codec)
2191{
2192 struct alc_spec *spec = codec->spec;
2193 struct hda_pcm *info = spec->pcm_rec;
2194 int i;
2195
2196 codec->num_pcms = 1;
2197 codec->pcm_info = info;
2198
2199 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002200 if (spec->stream_analog_playback) {
2201 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2202 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2203 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2204 }
2205 if (spec->stream_analog_capture) {
2206 snd_assert(spec->adc_nids, return -EINVAL);
2207 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2208 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2209 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210
Takashi Iwai4a471b72005-12-07 13:56:29 +01002211 if (spec->channel_mode) {
2212 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2213 for (i = 0; i < spec->num_channel_mode; i++) {
2214 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2215 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2216 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217 }
2218 }
2219
Takashi Iwaie08a0072006-09-07 17:52:14 +02002220 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002222 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002223 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002225 if (spec->multiout.dig_out_nid &&
2226 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2228 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2229 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002230 if (spec->dig_in_nid &&
2231 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2233 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2234 }
2235 }
2236
Takashi Iwaie08a0072006-09-07 17:52:14 +02002237 /* If the use of more than one ADC is requested for the current
2238 * model, configure a second analog capture-only PCM.
2239 */
2240 /* Additional Analaog capture for index #2 */
2241 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2242 spec->adc_nids) {
2243 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002244 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002245 info->name = spec->stream_name_analog;
2246 /* No playback stream for second PCM */
2247 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2248 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2249 if (spec->stream_analog_capture) {
2250 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2251 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2252 }
2253 }
2254
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 return 0;
2256}
2257
2258static void alc_free(struct hda_codec *codec)
2259{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002260 struct alc_spec *spec = codec->spec;
2261 unsigned int i;
2262
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002263 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002264 return;
2265
2266 if (spec->kctl_alloc) {
2267 for (i = 0; i < spec->num_kctl_used; i++)
2268 kfree(spec->kctl_alloc[i].name);
2269 kfree(spec->kctl_alloc);
2270 }
2271 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272}
2273
2274/*
2275 */
2276static struct hda_codec_ops alc_patch_ops = {
2277 .build_controls = alc_build_controls,
2278 .build_pcms = alc_build_pcms,
2279 .init = alc_init,
2280 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002281 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002282#ifdef CONFIG_SND_HDA_POWER_SAVE
2283 .check_power_status = alc_check_power_status,
2284#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285};
2286
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002287
2288/*
2289 * Test configuration for debugging
2290 *
2291 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2292 * enum controls.
2293 */
2294#ifdef CONFIG_SND_DEBUG
2295static hda_nid_t alc880_test_dac_nids[4] = {
2296 0x02, 0x03, 0x04, 0x05
2297};
2298
2299static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002300 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002301 .items = {
2302 { "In-1", 0x0 },
2303 { "In-2", 0x1 },
2304 { "In-3", 0x2 },
2305 { "In-4", 0x3 },
2306 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002307 { "Front", 0x5 },
2308 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002309 },
2310};
2311
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002312static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002313 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002314 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002315 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002316 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002317};
2318
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002319static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2320 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002321{
2322 static char *texts[] = {
2323 "N/A", "Line Out", "HP Out",
2324 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2325 };
2326 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2327 uinfo->count = 1;
2328 uinfo->value.enumerated.items = 8;
2329 if (uinfo->value.enumerated.item >= 8)
2330 uinfo->value.enumerated.item = 7;
2331 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2332 return 0;
2333}
2334
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002335static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2336 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002337{
2338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2339 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2340 unsigned int pin_ctl, item = 0;
2341
2342 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2343 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2344 if (pin_ctl & AC_PINCTL_OUT_EN) {
2345 if (pin_ctl & AC_PINCTL_HP_EN)
2346 item = 2;
2347 else
2348 item = 1;
2349 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2350 switch (pin_ctl & AC_PINCTL_VREFEN) {
2351 case AC_PINCTL_VREF_HIZ: item = 3; break;
2352 case AC_PINCTL_VREF_50: item = 4; break;
2353 case AC_PINCTL_VREF_GRD: item = 5; break;
2354 case AC_PINCTL_VREF_80: item = 6; break;
2355 case AC_PINCTL_VREF_100: item = 7; break;
2356 }
2357 }
2358 ucontrol->value.enumerated.item[0] = item;
2359 return 0;
2360}
2361
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002362static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2363 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002364{
2365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2366 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2367 static unsigned int ctls[] = {
2368 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2369 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2372 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2373 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2374 };
2375 unsigned int old_ctl, new_ctl;
2376
2377 old_ctl = snd_hda_codec_read(codec, nid, 0,
2378 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2379 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2380 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002381 int val;
2382 snd_hda_codec_write_cache(codec, nid, 0,
2383 AC_VERB_SET_PIN_WIDGET_CONTROL,
2384 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002385 val = ucontrol->value.enumerated.item[0] >= 3 ?
2386 HDA_AMP_MUTE : 0;
2387 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2388 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002389 return 1;
2390 }
2391 return 0;
2392}
2393
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002394static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2395 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002396{
2397 static char *texts[] = {
2398 "Front", "Surround", "CLFE", "Side"
2399 };
2400 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2401 uinfo->count = 1;
2402 uinfo->value.enumerated.items = 4;
2403 if (uinfo->value.enumerated.item >= 4)
2404 uinfo->value.enumerated.item = 3;
2405 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2406 return 0;
2407}
2408
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002409static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2410 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002411{
2412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2413 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2414 unsigned int sel;
2415
2416 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2417 ucontrol->value.enumerated.item[0] = sel & 3;
2418 return 0;
2419}
2420
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002421static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2422 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002423{
2424 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2425 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2426 unsigned int sel;
2427
2428 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2429 if (ucontrol->value.enumerated.item[0] != sel) {
2430 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002431 snd_hda_codec_write_cache(codec, nid, 0,
2432 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002433 return 1;
2434 }
2435 return 0;
2436}
2437
2438#define PIN_CTL_TEST(xname,nid) { \
2439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2440 .name = xname, \
2441 .info = alc_test_pin_ctl_info, \
2442 .get = alc_test_pin_ctl_get, \
2443 .put = alc_test_pin_ctl_put, \
2444 .private_value = nid \
2445 }
2446
2447#define PIN_SRC_TEST(xname,nid) { \
2448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2449 .name = xname, \
2450 .info = alc_test_pin_src_info, \
2451 .get = alc_test_pin_src_get, \
2452 .put = alc_test_pin_src_put, \
2453 .private_value = nid \
2454 }
2455
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002456static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2458 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2459 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2460 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002461 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2462 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2463 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2464 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002465 PIN_CTL_TEST("Front Pin Mode", 0x14),
2466 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2467 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2468 PIN_CTL_TEST("Side Pin Mode", 0x17),
2469 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2470 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2471 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2472 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2473 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2474 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2475 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2476 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2477 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2478 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2479 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2480 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2481 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2482 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2483 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2484 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2485 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2486 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002487 {
2488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2489 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002490 .info = alc_ch_mode_info,
2491 .get = alc_ch_mode_get,
2492 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002493 },
2494 { } /* end */
2495};
2496
2497static struct hda_verb alc880_test_init_verbs[] = {
2498 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2501 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2503 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2506 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002507 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2510 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2511 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002512 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2516 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002517 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002518 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2521 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002522 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2524 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002525 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2526 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2527 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002528 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2531 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2532 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002533 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002536 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002537 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002540 /* Analog input/passthru */
2541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002546 { }
2547};
2548#endif
2549
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550/*
2551 */
2552
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002553static const char *alc880_models[ALC880_MODEL_LAST] = {
2554 [ALC880_3ST] = "3stack",
2555 [ALC880_TCL_S700] = "tcl",
2556 [ALC880_3ST_DIG] = "3stack-digout",
2557 [ALC880_CLEVO] = "clevo",
2558 [ALC880_5ST] = "5stack",
2559 [ALC880_5ST_DIG] = "5stack-digout",
2560 [ALC880_W810] = "w810",
2561 [ALC880_Z71V] = "z71v",
2562 [ALC880_6ST] = "6stack",
2563 [ALC880_6ST_DIG] = "6stack-digout",
2564 [ALC880_ASUS] = "asus",
2565 [ALC880_ASUS_W1V] = "asus-w1v",
2566 [ALC880_ASUS_DIG] = "asus-dig",
2567 [ALC880_ASUS_DIG2] = "asus-dig2",
2568 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002569 [ALC880_UNIWILL_P53] = "uniwill-p53",
2570 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002571 [ALC880_F1734] = "F1734",
2572 [ALC880_LG] = "lg",
2573 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002574#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002575 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002576#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002577 [ALC880_AUTO] = "auto",
2578};
2579
2580static struct snd_pci_quirk alc880_cfg_tbl[] = {
2581 /* Broken BIOS configuration */
2582 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2583 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2584
2585 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2586 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002587 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002588 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2589 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2590 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2591 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2592 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2593 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2594
2595 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2596 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2597
2598 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2599 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2600 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2603 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2604 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2605 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2606 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2607 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002608 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002609 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2610 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2611 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2612 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2613
2614 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2615 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2616 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2617 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2618 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2619 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2620 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2621 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2622 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2623 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2624 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2625 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2626 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2627 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2628 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2629 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2630 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2631 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2632
2633 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2634 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2635 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2636 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2637
2638 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2639 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2640 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002641 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002642
2643 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2644 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2645 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2646 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2647
2648 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2649 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2654 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2655 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2656 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2657 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2658 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002659
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 {}
2661};
2662
Takashi Iwai16ded522005-06-10 19:58:24 +02002663/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002664 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002665 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002666static struct alc_config_preset alc880_presets[] = {
2667 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002669 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2674 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002675 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 .input_mux = &alc880_capture_source,
2677 },
2678 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002679 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002680 .init_verbs = { alc880_volume_init_verbs,
2681 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 .dac_nids = alc880_dac_nids,
2684 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002685 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2686 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002687 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 .input_mux = &alc880_capture_source,
2689 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002690 [ALC880_TCL_S700] = {
2691 .mixers = { alc880_tcl_s700_mixer },
2692 .init_verbs = { alc880_volume_init_verbs,
2693 alc880_pin_tcl_S700_init_verbs,
2694 alc880_gpio2_init_verbs },
2695 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2696 .dac_nids = alc880_dac_nids,
2697 .hp_nid = 0x03,
2698 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2699 .channel_mode = alc880_2_jack_modes,
2700 .input_mux = &alc880_capture_source,
2701 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002702 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002703 .mixers = { alc880_three_stack_mixer,
2704 alc880_five_stack_mixer},
2705 .init_verbs = { alc880_volume_init_verbs,
2706 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002707 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2708 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002709 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2710 .channel_mode = alc880_fivestack_modes,
2711 .input_mux = &alc880_capture_source,
2712 },
2713 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002714 .mixers = { alc880_three_stack_mixer,
2715 alc880_five_stack_mixer },
2716 .init_verbs = { alc880_volume_init_verbs,
2717 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002718 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2719 .dac_nids = alc880_dac_nids,
2720 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002721 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2722 .channel_mode = alc880_fivestack_modes,
2723 .input_mux = &alc880_capture_source,
2724 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002725 [ALC880_6ST] = {
2726 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002727 .init_verbs = { alc880_volume_init_verbs,
2728 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002729 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2730 .dac_nids = alc880_6st_dac_nids,
2731 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2732 .channel_mode = alc880_sixstack_modes,
2733 .input_mux = &alc880_6stack_capture_source,
2734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002735 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002736 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002737 .init_verbs = { alc880_volume_init_verbs,
2738 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2740 .dac_nids = alc880_6st_dac_nids,
2741 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002742 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2743 .channel_mode = alc880_sixstack_modes,
2744 .input_mux = &alc880_6stack_capture_source,
2745 },
2746 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002748 .init_verbs = { alc880_volume_init_verbs,
2749 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002750 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002751 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2752 .dac_nids = alc880_w810_dac_nids,
2753 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002754 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2755 .channel_mode = alc880_w810_modes,
2756 .input_mux = &alc880_capture_source,
2757 },
2758 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002759 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002760 .init_verbs = { alc880_volume_init_verbs,
2761 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002762 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2763 .dac_nids = alc880_z71v_dac_nids,
2764 .dig_out_nid = ALC880_DIGOUT_NID,
2765 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2767 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002768 .input_mux = &alc880_capture_source,
2769 },
2770 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002771 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002772 .init_verbs = { alc880_volume_init_verbs,
2773 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2775 .dac_nids = alc880_f1734_dac_nids,
2776 .hp_nid = 0x02,
2777 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2778 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 .input_mux = &alc880_capture_source,
2780 },
2781 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002782 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002783 .init_verbs = { alc880_volume_init_verbs,
2784 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002785 alc880_gpio1_init_verbs },
2786 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2787 .dac_nids = alc880_asus_dac_nids,
2788 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2789 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002790 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002791 .input_mux = &alc880_capture_source,
2792 },
2793 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002795 .init_verbs = { alc880_volume_init_verbs,
2796 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797 alc880_gpio1_init_verbs },
2798 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2799 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002800 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002801 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2802 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002803 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002804 .input_mux = &alc880_capture_source,
2805 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002806 [ALC880_ASUS_DIG2] = {
2807 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002808 .init_verbs = { alc880_volume_init_verbs,
2809 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002810 alc880_gpio2_init_verbs }, /* use GPIO2 */
2811 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2812 .dac_nids = alc880_asus_dac_nids,
2813 .dig_out_nid = ALC880_DIGOUT_NID,
2814 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2815 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002816 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002817 .input_mux = &alc880_capture_source,
2818 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002819 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002821 .init_verbs = { alc880_volume_init_verbs,
2822 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002823 alc880_gpio1_init_verbs },
2824 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2825 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002826 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002827 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2828 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002829 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002830 .input_mux = &alc880_capture_source,
2831 },
2832 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002833 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002834 .init_verbs = { alc880_volume_init_verbs,
2835 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002836 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2837 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002838 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002839 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2840 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002841 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002842 .input_mux = &alc880_capture_source,
2843 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002844 [ALC880_UNIWILL] = {
2845 .mixers = { alc880_uniwill_mixer },
2846 .init_verbs = { alc880_volume_init_verbs,
2847 alc880_uniwill_init_verbs },
2848 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2849 .dac_nids = alc880_asus_dac_nids,
2850 .dig_out_nid = ALC880_DIGOUT_NID,
2851 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2852 .channel_mode = alc880_threestack_modes,
2853 .need_dac_fix = 1,
2854 .input_mux = &alc880_capture_source,
2855 .unsol_event = alc880_uniwill_unsol_event,
2856 .init_hook = alc880_uniwill_automute,
2857 },
2858 [ALC880_UNIWILL_P53] = {
2859 .mixers = { alc880_uniwill_p53_mixer },
2860 .init_verbs = { alc880_volume_init_verbs,
2861 alc880_uniwill_p53_init_verbs },
2862 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2863 .dac_nids = alc880_asus_dac_nids,
2864 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002865 .channel_mode = alc880_threestack_modes,
2866 .input_mux = &alc880_capture_source,
2867 .unsol_event = alc880_uniwill_p53_unsol_event,
2868 .init_hook = alc880_uniwill_p53_hp_automute,
2869 },
2870 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002871 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002872 alc880_pcbeep_mixer, },
2873 .init_verbs = { alc880_volume_init_verbs,
2874 alc880_uniwill_p53_init_verbs,
2875 alc880_beep_init_verbs },
2876 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2877 .dac_nids = alc880_dac_nids,
2878 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2879 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002880 .input_mux = &alc880_capture_source,
2881 .unsol_event = alc880_uniwill_p53_unsol_event,
2882 .init_hook = alc880_uniwill_p53_hp_automute,
2883 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002884 [ALC880_CLEVO] = {
2885 .mixers = { alc880_three_stack_mixer },
2886 .init_verbs = { alc880_volume_init_verbs,
2887 alc880_pin_clevo_init_verbs },
2888 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2889 .dac_nids = alc880_dac_nids,
2890 .hp_nid = 0x03,
2891 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2892 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002893 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002894 .input_mux = &alc880_capture_source,
2895 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002896 [ALC880_LG] = {
2897 .mixers = { alc880_lg_mixer },
2898 .init_verbs = { alc880_volume_init_verbs,
2899 alc880_lg_init_verbs },
2900 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2901 .dac_nids = alc880_lg_dac_nids,
2902 .dig_out_nid = ALC880_DIGOUT_NID,
2903 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2904 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002905 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002906 .input_mux = &alc880_lg_capture_source,
2907 .unsol_event = alc880_lg_unsol_event,
2908 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002909#ifdef CONFIG_SND_HDA_POWER_SAVE
2910 .loopbacks = alc880_lg_loopbacks,
2911#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002912 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002913 [ALC880_LG_LW] = {
2914 .mixers = { alc880_lg_lw_mixer },
2915 .init_verbs = { alc880_volume_init_verbs,
2916 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002917 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01002918 .dac_nids = alc880_dac_nids,
2919 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002920 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2921 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01002922 .input_mux = &alc880_lg_lw_capture_source,
2923 .unsol_event = alc880_lg_lw_unsol_event,
2924 .init_hook = alc880_lg_lw_automute,
2925 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002926#ifdef CONFIG_SND_DEBUG
2927 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002928 .mixers = { alc880_test_mixer },
2929 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002930 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2931 .dac_nids = alc880_test_dac_nids,
2932 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002933 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2934 .channel_mode = alc880_test_modes,
2935 .input_mux = &alc880_test_capture_source,
2936 },
2937#endif
2938};
2939
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002940/*
2941 * Automatic parse of I/O pins from the BIOS configuration
2942 */
2943
2944#define NUM_CONTROL_ALLOC 32
2945#define NUM_VERB_ALLOC 32
2946
2947enum {
2948 ALC_CTL_WIDGET_VOL,
2949 ALC_CTL_WIDGET_MUTE,
2950 ALC_CTL_BIND_MUTE,
2951};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002952static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002953 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2954 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002955 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002956};
2957
2958/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002959static int add_control(struct alc_spec *spec, int type, const char *name,
2960 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002962 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963
2964 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2965 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2966
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002967 /* array + terminator */
2968 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2969 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002970 return -ENOMEM;
2971 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002972 memcpy(knew, spec->kctl_alloc,
2973 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974 kfree(spec->kctl_alloc);
2975 }
2976 spec->kctl_alloc = knew;
2977 spec->num_kctl_alloc = num;
2978 }
2979
2980 knew = &spec->kctl_alloc[spec->num_kctl_used];
2981 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002982 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002983 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002984 return -ENOMEM;
2985 knew->private_value = val;
2986 spec->num_kctl_used++;
2987 return 0;
2988}
2989
2990#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2991#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2992#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2993#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2994#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2995#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2996#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2997#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2998#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2999#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3000#define ALC880_PIN_CD_NID 0x1c
3001
3002/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003003static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3004 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003005{
3006 hda_nid_t nid;
3007 int assigned[4];
3008 int i, j;
3009
3010 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003011 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003012
3013 /* check the pins hardwired to audio widget */
3014 for (i = 0; i < cfg->line_outs; i++) {
3015 nid = cfg->line_out_pins[i];
3016 if (alc880_is_fixed_pin(nid)) {
3017 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003018 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003019 assigned[idx] = 1;
3020 }
3021 }
3022 /* left pins can be connect to any audio widget */
3023 for (i = 0; i < cfg->line_outs; i++) {
3024 nid = cfg->line_out_pins[i];
3025 if (alc880_is_fixed_pin(nid))
3026 continue;
3027 /* search for an empty channel */
3028 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003029 if (!assigned[j]) {
3030 spec->multiout.dac_nids[i] =
3031 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003032 assigned[j] = 1;
3033 break;
3034 }
3035 }
3036 }
3037 spec->multiout.num_dacs = cfg->line_outs;
3038 return 0;
3039}
3040
3041/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003042static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3043 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003044{
3045 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003046 static const char *chname[4] = {
3047 "Front", "Surround", NULL /*CLFE*/, "Side"
3048 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003049 hda_nid_t nid;
3050 int i, err;
3051
3052 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003053 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003054 continue;
3055 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3056 if (i == 2) {
3057 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003058 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3059 "Center Playback Volume",
3060 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3061 HDA_OUTPUT));
3062 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003063 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003064 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3065 "LFE Playback Volume",
3066 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3067 HDA_OUTPUT));
3068 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003069 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003070 err = add_control(spec, ALC_CTL_BIND_MUTE,
3071 "Center Playback Switch",
3072 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3073 HDA_INPUT));
3074 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003075 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003076 err = add_control(spec, ALC_CTL_BIND_MUTE,
3077 "LFE Playback Switch",
3078 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3079 HDA_INPUT));
3080 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003081 return err;
3082 } else {
3083 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003084 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3085 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3086 HDA_OUTPUT));
3087 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 return err;
3089 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003090 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3091 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3092 HDA_INPUT));
3093 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003094 return err;
3095 }
3096 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097 return 0;
3098}
3099
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003100/* add playback controls for speaker and HP outputs */
3101static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3102 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003103{
3104 hda_nid_t nid;
3105 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003106 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003108 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 return 0;
3110
3111 if (alc880_is_fixed_pin(pin)) {
3112 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003113 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003114 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003115 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003116 else
3117 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 /* control HP volume/switch on the output mixer amp */
3119 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003120 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003121 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3122 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3123 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003125 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003126 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3127 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3128 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003129 return err;
3130 } else if (alc880_is_multi_pin(pin)) {
3131 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003133 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003134 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3135 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3136 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 return err;
3138 }
3139 return 0;
3140}
3141
3142/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003143static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3144 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003145 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146{
3147 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003148 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003149
3150 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003151 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3152 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3153 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003154 return err;
3155 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003156 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3157 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3158 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003159 return err;
3160 return 0;
3161}
3162
3163/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003164static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3165 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003166{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003167 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003168 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003169
3170 for (i = 0; i < AUTO_PIN_LAST; i++) {
3171 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003172 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003173 err = new_analog_input(spec, cfg->input_pins[i],
3174 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003175 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003176 if (err < 0)
3177 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003178 imux->items[imux->num_items].label =
3179 auto_pin_cfg_labels[i];
3180 imux->items[imux->num_items].index =
3181 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003182 imux->num_items++;
3183 }
3184 }
3185 return 0;
3186}
3187
Kailang Yangdf694da2005-12-05 19:42:22 +01003188static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3189 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003190 int dac_idx)
3191{
3192 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003193 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3194 pin_type);
3195 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3196 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 /* need the manual connection? */
3198 if (alc880_is_multi_pin(nid)) {
3199 struct alc_spec *spec = codec->spec;
3200 int idx = alc880_multi_pin_idx(nid);
3201 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3202 AC_VERB_SET_CONNECT_SEL,
3203 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3204 }
3205}
3206
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003207static int get_pin_type(int line_out_type)
3208{
3209 if (line_out_type == AUTO_PIN_HP_OUT)
3210 return PIN_HP;
3211 else
3212 return PIN_OUT;
3213}
3214
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003215static void alc880_auto_init_multi_out(struct hda_codec *codec)
3216{
3217 struct alc_spec *spec = codec->spec;
3218 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003219
3220 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003221 for (i = 0; i < spec->autocfg.line_outs; i++) {
3222 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003223 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3224 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003225 }
3226}
3227
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003228static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229{
3230 struct alc_spec *spec = codec->spec;
3231 hda_nid_t pin;
3232
Takashi Iwai82bc9552006-03-21 11:24:42 +01003233 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003234 if (pin) /* connect to front */
3235 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003236 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237 if (pin) /* connect to front */
3238 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3239}
3240
3241static void alc880_auto_init_analog_input(struct hda_codec *codec)
3242{
3243 struct alc_spec *spec = codec->spec;
3244 int i;
3245
3246 for (i = 0; i < AUTO_PIN_LAST; i++) {
3247 hda_nid_t nid = spec->autocfg.input_pins[i];
3248 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003249 snd_hda_codec_write(codec, nid, 0,
3250 AC_VERB_SET_PIN_WIDGET_CONTROL,
3251 i <= AUTO_PIN_FRONT_MIC ?
3252 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003253 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003254 snd_hda_codec_write(codec, nid, 0,
3255 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 AMP_OUT_MUTE);
3257 }
3258 }
3259}
3260
3261/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003262/* return 1 if successful, 0 if the proper config is not found,
3263 * or a negative error code
3264 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265static int alc880_parse_auto_config(struct hda_codec *codec)
3266{
3267 struct alc_spec *spec = codec->spec;
3268 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003269 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003271 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3272 alc880_ignore);
3273 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003275 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003277
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003278 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3279 if (err < 0)
3280 return err;
3281 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3282 if (err < 0)
3283 return err;
3284 err = alc880_auto_create_extra_out(spec,
3285 spec->autocfg.speaker_pins[0],
3286 "Speaker");
3287 if (err < 0)
3288 return err;
3289 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3290 "Headphone");
3291 if (err < 0)
3292 return err;
3293 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3294 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003295 return err;
3296
3297 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3298
3299 if (spec->autocfg.dig_out_pin)
3300 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3301 if (spec->autocfg.dig_in_pin)
3302 spec->dig_in_nid = ALC880_DIGIN_NID;
3303
3304 if (spec->kctl_alloc)
3305 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3306
3307 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3308
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003309 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003310 spec->input_mux = &spec->private_imux;
3311
3312 return 1;
3313}
3314
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003315/* additional initialization for auto-configuration model */
3316static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003317{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003318 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003319 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003321}
3322
3323/*
3324 * OK, here we have finally the patch for ALC880
3325 */
3326
Linus Torvalds1da177e2005-04-16 15:20:36 -07003327static int patch_alc880(struct hda_codec *codec)
3328{
3329 struct alc_spec *spec;
3330 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003331 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003332
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003333 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334 if (spec == NULL)
3335 return -ENOMEM;
3336
3337 codec->spec = spec;
3338
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003339 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3340 alc880_models,
3341 alc880_cfg_tbl);
3342 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003343 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3344 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003345 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003346 }
3347
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003348 if (board_config == ALC880_AUTO) {
3349 /* automatic parse from the BIOS config */
3350 err = alc880_parse_auto_config(codec);
3351 if (err < 0) {
3352 alc_free(codec);
3353 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003354 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003355 printk(KERN_INFO
3356 "hda_codec: Cannot set up configuration "
3357 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358 board_config = ALC880_3ST;
3359 }
3360 }
3361
Kailang Yangdf694da2005-12-05 19:42:22 +01003362 if (board_config != ALC880_AUTO)
3363 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364
3365 spec->stream_name_analog = "ALC880 Analog";
3366 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3367 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3368
3369 spec->stream_name_digital = "ALC880 Digital";
3370 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3371 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3372
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003373 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003374 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003375 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003376 /* get type */
3377 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003378 if (wcap != AC_WID_AUD_IN) {
3379 spec->adc_nids = alc880_adc_nids_alt;
3380 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003381 spec->mixers[spec->num_mixers] =
3382 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003383 spec->num_mixers++;
3384 } else {
3385 spec->adc_nids = alc880_adc_nids;
3386 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3387 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3388 spec->num_mixers++;
3389 }
3390 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391
3392 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003393 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003394 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003395#ifdef CONFIG_SND_HDA_POWER_SAVE
3396 if (!spec->loopback.amplist)
3397 spec->loopback.amplist = alc880_loopbacks;
3398#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003399
3400 return 0;
3401}
3402
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003403
Linus Torvalds1da177e2005-04-16 15:20:36 -07003404/*
3405 * ALC260 support
3406 */
3407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003408static hda_nid_t alc260_dac_nids[1] = {
3409 /* front */
3410 0x02,
3411};
3412
3413static hda_nid_t alc260_adc_nids[1] = {
3414 /* ADC0 */
3415 0x04,
3416};
3417
Kailang Yangdf694da2005-12-05 19:42:22 +01003418static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419 /* ADC1 */
3420 0x05,
3421};
3422
Kailang Yangdf694da2005-12-05 19:42:22 +01003423static hda_nid_t alc260_hp_adc_nids[2] = {
3424 /* ADC1, 0 */
3425 0x05, 0x04
3426};
3427
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003428/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3429 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3430 */
3431static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003432 /* ADC0, ADC1 */
3433 0x04, 0x05
3434};
3435
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436#define ALC260_DIGOUT_NID 0x03
3437#define ALC260_DIGIN_NID 0x06
3438
3439static struct hda_input_mux alc260_capture_source = {
3440 .num_items = 4,
3441 .items = {
3442 { "Mic", 0x0 },
3443 { "Front Mic", 0x1 },
3444 { "Line", 0x2 },
3445 { "CD", 0x4 },
3446 },
3447};
3448
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003449/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003450 * headphone jack and the internal CD lines since these are the only pins at
3451 * which audio can appear. For flexibility, also allow the option of
3452 * recording the mixer output on the second ADC (ADC0 doesn't have a
3453 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003454 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003455static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3456 {
3457 .num_items = 3,
3458 .items = {
3459 { "Mic/Line", 0x0 },
3460 { "CD", 0x4 },
3461 { "Headphone", 0x2 },
3462 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003463 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003464 {
3465 .num_items = 4,
3466 .items = {
3467 { "Mic/Line", 0x0 },
3468 { "CD", 0x4 },
3469 { "Headphone", 0x2 },
3470 { "Mixer", 0x5 },
3471 },
3472 },
3473
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003474};
3475
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003476/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3477 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003478 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003479static struct hda_input_mux alc260_acer_capture_sources[2] = {
3480 {
3481 .num_items = 4,
3482 .items = {
3483 { "Mic", 0x0 },
3484 { "Line", 0x2 },
3485 { "CD", 0x4 },
3486 { "Headphone", 0x5 },
3487 },
3488 },
3489 {
3490 .num_items = 5,
3491 .items = {
3492 { "Mic", 0x0 },
3493 { "Line", 0x2 },
3494 { "CD", 0x4 },
3495 { "Headphone", 0x6 },
3496 { "Mixer", 0x5 },
3497 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003498 },
3499};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003500/*
3501 * This is just place-holder, so there's something for alc_build_pcms to look
3502 * at when it calculates the maximum number of channels. ALC260 has no mixer
3503 * element which allows changing the channel mode, so the verb list is
3504 * never used.
3505 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003506static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003507 { 2, NULL },
3508};
3509
Kailang Yangdf694da2005-12-05 19:42:22 +01003510
3511/* Mixer combinations
3512 *
3513 * basic: base_output + input + pc_beep + capture
3514 * HP: base_output + input + capture_alt
3515 * HP_3013: hp_3013 + input + capture
3516 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003517 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003518 */
3519
3520static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003521 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003522 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003523 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3524 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3525 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3526 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3527 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003528};
Kailang Yangdf694da2005-12-05 19:42:22 +01003529
3530static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003531 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3532 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3533 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3534 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3536 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3537 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3538 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003539 { } /* end */
3540};
3541
Kailang Yangdf694da2005-12-05 19:42:22 +01003542static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3543 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3544 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3545 { } /* end */
3546};
3547
3548static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3549 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3550 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3551 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3552 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3553 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3555 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3556 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003557 { } /* end */
3558};
3559
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003560/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3561 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3562 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003563static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003564 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003565 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003566 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003567 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3568 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3569 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3570 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003571 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003572 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3573 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3574 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003575 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003576 { } /* end */
3577};
3578
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003579/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3580 * versions of the ALC260 don't act on requests to enable mic bias from NID
3581 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3582 * datasheet doesn't mention this restriction. At this stage it's not clear
3583 * whether this behaviour is intentional or is a hardware bug in chip
3584 * revisions available in early 2006. Therefore for now allow the
3585 * "Headphone Jack Mode" control to span all choices, but if it turns out
3586 * that the lack of mic bias for this NID is intentional we could change the
3587 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3588 *
3589 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3590 * don't appear to make the mic bias available from the "line" jack, even
3591 * though the NID used for this jack (0x14) can supply it. The theory is
3592 * that perhaps Acer have included blocking capacitors between the ALC260
3593 * and the output jack. If this turns out to be the case for all such
3594 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3595 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003596 *
3597 * The C20x Tablet series have a mono internal speaker which is controlled
3598 * via the chip's Mono sum widget and pin complex, so include the necessary
3599 * controls for such models. On models without a "mono speaker" the control
3600 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003601 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003602static struct snd_kcontrol_new alc260_acer_mixer[] = {
3603 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3604 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003605 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003606 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3607 HDA_OUTPUT),
3608 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3609 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003610 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3611 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3613 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3614 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3615 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3616 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3617 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3618 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3619 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3620 { } /* end */
3621};
3622
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003623/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3624 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3625 */
3626static struct snd_kcontrol_new alc260_will_mixer[] = {
3627 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3628 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3630 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3631 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3632 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3633 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3634 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3635 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3636 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3637 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3638 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3639 { } /* end */
3640};
3641
3642/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3643 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3644 */
3645static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3646 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3647 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3649 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3650 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3651 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3652 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3653 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3654 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3655 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3656 { } /* end */
3657};
3658
Kailang Yangdf694da2005-12-05 19:42:22 +01003659/* capture mixer elements */
3660static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003661 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3662 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003663 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3664 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003665 {
3666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003667 /* The multiple "Capture Source" controls confuse alsamixer
3668 * So call somewhat different..
3669 * FIXME: the controls appear in the "playback" view!
3670 */
3671 /* .name = "Capture Source", */
3672 .name = "Input Source",
3673 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003674 .info = alc_mux_enum_info,
3675 .get = alc_mux_enum_get,
3676 .put = alc_mux_enum_put,
3677 },
3678 { } /* end */
3679};
3680
Kailang Yangdf694da2005-12-05 19:42:22 +01003681static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3682 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3683 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3684 {
3685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3686 /* The multiple "Capture Source" controls confuse alsamixer
3687 * So call somewhat different..
3688 * FIXME: the controls appear in the "playback" view!
3689 */
3690 /* .name = "Capture Source", */
3691 .name = "Input Source",
3692 .count = 1,
3693 .info = alc_mux_enum_info,
3694 .get = alc_mux_enum_get,
3695 .put = alc_mux_enum_put,
3696 },
3697 { } /* end */
3698};
3699
3700/*
3701 * initialization verbs
3702 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003703static struct hda_verb alc260_init_verbs[] = {
3704 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003707 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003708 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003709 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003711 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003714 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003715 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003716 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003718 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003719 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003720 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003721 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3722 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003723 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003724 /* set connection select to line in (default select for this ADC) */
3725 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003726 /* mute capture amp left and right */
3727 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3728 /* set connection select to line in (default select for this ADC) */
3729 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003730 /* set vol=0 Line-Out mixer amp left and right */
3731 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3732 /* unmute pin widget amp left and right (no gain on this amp) */
3733 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3734 /* set vol=0 HP mixer amp left and right */
3735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3736 /* unmute pin widget amp left and right (no gain on this amp) */
3737 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3738 /* set vol=0 Mono mixer amp left and right */
3739 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3740 /* unmute pin widget amp left and right (no gain on this amp) */
3741 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3742 /* unmute LINE-2 out pin */
3743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003744 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3745 * Line In 2 = 0x03
3746 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003747 /* mute analog inputs */
3748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003753 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003754 /* mute Front out path */
3755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3757 /* mute Headphone out path */
3758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3759 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3760 /* mute Mono out path */
3761 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3762 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003763 { }
3764};
3765
Takashi Iwai474167d2006-05-17 17:17:43 +02003766#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003767static struct hda_verb alc260_hp_init_verbs[] = {
3768 /* Headphone and output */
3769 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3770 /* mono output */
3771 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3772 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3773 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3774 /* Mic2 (front panel) pin widget for input and vref at 80% */
3775 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3776 /* Line In pin widget for input */
3777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3778 /* Line-2 pin widget for output */
3779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3780 /* CD pin widget for input */
3781 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3782 /* unmute amp left and right */
3783 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3784 /* set connection select to line in (default select for this ADC) */
3785 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3786 /* unmute Line-Out mixer amp left and right (volume = 0) */
3787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3788 /* mute pin widget amp left and right (no gain on this amp) */
3789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3790 /* unmute HP mixer amp left and right (volume = 0) */
3791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3792 /* mute pin widget amp left and right (no gain on this amp) */
3793 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003794 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3795 * Line In 2 = 0x03
3796 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003797 /* mute analog inputs */
3798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01003803 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3804 /* Unmute Front out path */
3805 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3806 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3807 /* Unmute Headphone out path */
3808 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3809 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3810 /* Unmute Mono out path */
3811 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3812 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3813 { }
3814};
Takashi Iwai474167d2006-05-17 17:17:43 +02003815#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003816
3817static struct hda_verb alc260_hp_3013_init_verbs[] = {
3818 /* Line out and output */
3819 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3820 /* mono output */
3821 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3822 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3823 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3824 /* Mic2 (front panel) pin widget for input and vref at 80% */
3825 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3826 /* Line In pin widget for input */
3827 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3828 /* Headphone pin widget for output */
3829 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3830 /* CD pin widget for input */
3831 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3832 /* unmute amp left and right */
3833 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3834 /* set connection select to line in (default select for this ADC) */
3835 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3836 /* unmute Line-Out mixer amp left and right (volume = 0) */
3837 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3838 /* mute pin widget amp left and right (no gain on this amp) */
3839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3840 /* unmute HP mixer amp left and right (volume = 0) */
3841 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3842 /* mute pin widget amp left and right (no gain on this amp) */
3843 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003844 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3845 * Line In 2 = 0x03
3846 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003847 /* mute analog inputs */
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01003853 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3854 /* Unmute Front out path */
3855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3857 /* Unmute Headphone out path */
3858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3860 /* Unmute Mono out path */
3861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3863 { }
3864};
3865
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003866/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003867 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3868 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003869 */
3870static struct hda_verb alc260_fujitsu_init_verbs[] = {
3871 /* Disable all GPIOs */
3872 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3873 /* Internal speaker is connected to headphone pin */
3874 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3875 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3876 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003877 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3878 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3879 /* Ensure all other unused pins are disabled and muted. */
3880 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3881 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003882 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003883 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003884 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003885 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3886 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003888
Jonathan Woithef7ace402006-02-28 11:46:14 +01003889 /* Disable digital (SPDIF) pins */
3890 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3891 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003892
Jonathan Woithef7ace402006-02-28 11:46:14 +01003893 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3894 * when acting as an output.
3895 */
3896 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3897
3898 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3906 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3907 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003908
Jonathan Woithef7ace402006-02-28 11:46:14 +01003909 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3910 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3911 /* Unmute Line1 pin widget output buffer since it starts as an output.
3912 * If the pin mode is changed by the user the pin mode control will
3913 * take care of enabling the pin's input/output buffers as needed.
3914 * Therefore there's no need to enable the input buffer at this
3915 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003916 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003918 /* Unmute input buffer of pin widget used for Line-in (no equiv
3919 * mixer ctrl)
3920 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003921 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003922
Jonathan Woithef7ace402006-02-28 11:46:14 +01003923 /* Mute capture amp left and right */
3924 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3925 /* Set ADC connection select to match default mixer setting - line
3926 * in (on mic1 pin)
3927 */
3928 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003929
Jonathan Woithef7ace402006-02-28 11:46:14 +01003930 /* Do the same for the second ADC: mute capture input amp and
3931 * set ADC connection to line in (on mic1 pin)
3932 */
3933 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3934 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003935
Jonathan Woithef7ace402006-02-28 11:46:14 +01003936 /* Mute all inputs to mixer widget (even unconnected ones) */
3937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003945
3946 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003947};
3948
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003949/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3950 * similar laptops (adapted from Fujitsu init verbs).
3951 */
3952static struct hda_verb alc260_acer_init_verbs[] = {
3953 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3954 * the headphone jack. Turn this on and rely on the standard mute
3955 * methods whenever the user wants to turn these outputs off.
3956 */
3957 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3958 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3959 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3960 /* Internal speaker/Headphone jack is connected to Line-out pin */
3961 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3962 /* Internal microphone/Mic jack is connected to Mic1 pin */
3963 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3964 /* Line In jack is connected to Line1 pin */
3965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003966 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3967 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003968 /* Ensure all other unused pins are disabled and muted. */
3969 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3970 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003971 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3972 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3975 /* Disable digital (SPDIF) pins */
3976 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3977 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3978
3979 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3980 * bus when acting as outputs.
3981 */
3982 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3983 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3984
3985 /* Start with output sum widgets muted and their output gains at min */
3986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3987 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3990 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3993 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3994 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3995
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996 /* Unmute Line-out pin widget amp left and right
3997 * (no equiv mixer ctrl)
3998 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004000 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4001 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004002 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4003 * inputs. If the pin mode is changed by the user the pin mode control
4004 * will take care of enabling the pin's input/output buffers as needed.
4005 * Therefore there's no need to enable the input buffer at this
4006 * stage.
4007 */
4008 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4010
4011 /* Mute capture amp left and right */
4012 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4013 /* Set ADC connection select to match default mixer setting - mic
4014 * (on mic1 pin)
4015 */
4016 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4017
4018 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004019 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004020 */
4021 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004022 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004023
4024 /* Mute all inputs to mixer widget (even unconnected ones) */
4025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4033
4034 { }
4035};
4036
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004037static struct hda_verb alc260_will_verbs[] = {
4038 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4039 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4040 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4041 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4042 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4043 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4044 {}
4045};
4046
4047static struct hda_verb alc260_replacer_672v_verbs[] = {
4048 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4049 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4050 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4051
4052 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4053 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4054 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4055
4056 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4057 {}
4058};
4059
4060/* toggle speaker-output according to the hp-jack state */
4061static void alc260_replacer_672v_automute(struct hda_codec *codec)
4062{
4063 unsigned int present;
4064
4065 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4066 present = snd_hda_codec_read(codec, 0x0f, 0,
4067 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4068 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004069 snd_hda_codec_write_cache(codec, 0x01, 0,
4070 AC_VERB_SET_GPIO_DATA, 1);
4071 snd_hda_codec_write_cache(codec, 0x0f, 0,
4072 AC_VERB_SET_PIN_WIDGET_CONTROL,
4073 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004074 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004075 snd_hda_codec_write_cache(codec, 0x01, 0,
4076 AC_VERB_SET_GPIO_DATA, 0);
4077 snd_hda_codec_write_cache(codec, 0x0f, 0,
4078 AC_VERB_SET_PIN_WIDGET_CONTROL,
4079 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004080 }
4081}
4082
4083static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4084 unsigned int res)
4085{
4086 if ((res >> 26) == ALC880_HP_EVENT)
4087 alc260_replacer_672v_automute(codec);
4088}
4089
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004090/* Test configuration for debugging, modelled after the ALC880 test
4091 * configuration.
4092 */
4093#ifdef CONFIG_SND_DEBUG
4094static hda_nid_t alc260_test_dac_nids[1] = {
4095 0x02,
4096};
4097static hda_nid_t alc260_test_adc_nids[2] = {
4098 0x04, 0x05,
4099};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004100/* For testing the ALC260, each input MUX needs its own definition since
4101 * the signal assignments are different. This assumes that the first ADC
4102 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004103 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004104static struct hda_input_mux alc260_test_capture_sources[2] = {
4105 {
4106 .num_items = 7,
4107 .items = {
4108 { "MIC1 pin", 0x0 },
4109 { "MIC2 pin", 0x1 },
4110 { "LINE1 pin", 0x2 },
4111 { "LINE2 pin", 0x3 },
4112 { "CD pin", 0x4 },
4113 { "LINE-OUT pin", 0x5 },
4114 { "HP-OUT pin", 0x6 },
4115 },
4116 },
4117 {
4118 .num_items = 8,
4119 .items = {
4120 { "MIC1 pin", 0x0 },
4121 { "MIC2 pin", 0x1 },
4122 { "LINE1 pin", 0x2 },
4123 { "LINE2 pin", 0x3 },
4124 { "CD pin", 0x4 },
4125 { "Mixer", 0x5 },
4126 { "LINE-OUT pin", 0x6 },
4127 { "HP-OUT pin", 0x7 },
4128 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004129 },
4130};
4131static struct snd_kcontrol_new alc260_test_mixer[] = {
4132 /* Output driver widgets */
4133 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4134 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4135 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4136 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4137 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4138 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4139
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004140 /* Modes for retasking pin widgets
4141 * Note: the ALC260 doesn't seem to act on requests to enable mic
4142 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4143 * mention this restriction. At this stage it's not clear whether
4144 * this behaviour is intentional or is a hardware bug in chip
4145 * revisions available at least up until early 2006. Therefore for
4146 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4147 * choices, but if it turns out that the lack of mic bias for these
4148 * NIDs is intentional we could change their modes from
4149 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4150 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004151 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4152 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4155 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4156 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4157
4158 /* Loopback mixer controls */
4159 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4160 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4161 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4162 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4163 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4164 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4165 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4166 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4167 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4168 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4169 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4170 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4171 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4172 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4173 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4174 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004175
4176 /* Controls for GPIO pins, assuming they are configured as outputs */
4177 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4178 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4179 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4180 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4181
Jonathan Woithe92621f12006-02-28 11:47:47 +01004182 /* Switches to allow the digital IO pins to be enabled. The datasheet
4183 * is ambigious as to which NID is which; testing on laptops which
4184 * make this output available should provide clarification.
4185 */
4186 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4187 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4188
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004189 { } /* end */
4190};
4191static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004192 /* Enable all GPIOs as outputs with an initial value of 0 */
4193 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4194 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4195 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4196
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004197 /* Enable retasking pins as output, initially without power amp */
4198 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4199 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4203 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4204
Jonathan Woithe92621f12006-02-28 11:47:47 +01004205 /* Disable digital (SPDIF) pins initially, but users can enable
4206 * them via a mixer switch. In the case of SPDIF-out, this initverb
4207 * payload also sets the generation to 0, output to be in "consumer"
4208 * PCM format, copyright asserted, no pre-emphasis and no validity
4209 * control.
4210 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004211 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4212 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4213
Jonathan Woithef7ace402006-02-28 11:46:14 +01004214 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004215 * OUT1 sum bus when acting as an output.
4216 */
4217 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4218 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4219 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4220 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4221
4222 /* Start with output sum widgets muted and their output gains at min */
4223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4224 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4225 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4227 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4228 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4229 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4230 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4231 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4232
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004233 /* Unmute retasking pin widget output buffers since the default
4234 * state appears to be output. As the pin mode is changed by the
4235 * user the pin mode control will take care of enabling the pin's
4236 * input/output buffers as needed.
4237 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004238 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4239 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244 /* Also unmute the mono-out pin widget */
4245 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004247 /* Mute capture amp left and right */
4248 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004249 /* Set ADC connection select to match default mixer setting (mic1
4250 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004251 */
4252 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4253
4254 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004255 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004256 */
4257 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4258 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4259
4260 /* Mute all inputs to mixer widget (even unconnected ones) */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4268 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4269
4270 { }
4271};
4272#endif
4273
Linus Torvalds1da177e2005-04-16 15:20:36 -07004274static struct hda_pcm_stream alc260_pcm_analog_playback = {
4275 .substreams = 1,
4276 .channels_min = 2,
4277 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004278};
4279
4280static struct hda_pcm_stream alc260_pcm_analog_capture = {
4281 .substreams = 1,
4282 .channels_min = 2,
4283 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004284};
4285
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004286#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4287#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4288
Kailang Yangdf694da2005-12-05 19:42:22 +01004289/*
4290 * for BIOS auto-configuration
4291 */
4292
4293static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4294 const char *pfx)
4295{
4296 hda_nid_t nid_vol;
4297 unsigned long vol_val, sw_val;
4298 char name[32];
4299 int err;
4300
4301 if (nid >= 0x0f && nid < 0x11) {
4302 nid_vol = nid - 0x7;
4303 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4304 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4305 } else if (nid == 0x11) {
4306 nid_vol = nid - 0x7;
4307 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4308 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4309 } else if (nid >= 0x12 && nid <= 0x15) {
4310 nid_vol = 0x08;
4311 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4312 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4313 } else
4314 return 0; /* N/A */
4315
4316 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4318 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004319 return err;
4320 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004321 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4322 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004323 return err;
4324 return 1;
4325}
4326
4327/* add playback controls from the parsed DAC table */
4328static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4329 const struct auto_pin_cfg *cfg)
4330{
4331 hda_nid_t nid;
4332 int err;
4333
4334 spec->multiout.num_dacs = 1;
4335 spec->multiout.dac_nids = spec->private_dac_nids;
4336 spec->multiout.dac_nids[0] = 0x02;
4337
4338 nid = cfg->line_out_pins[0];
4339 if (nid) {
4340 err = alc260_add_playback_controls(spec, nid, "Front");
4341 if (err < 0)
4342 return err;
4343 }
4344
Takashi Iwai82bc9552006-03-21 11:24:42 +01004345 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004346 if (nid) {
4347 err = alc260_add_playback_controls(spec, nid, "Speaker");
4348 if (err < 0)
4349 return err;
4350 }
4351
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004352 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004353 if (nid) {
4354 err = alc260_add_playback_controls(spec, nid, "Headphone");
4355 if (err < 0)
4356 return err;
4357 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004358 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004359}
4360
4361/* create playback/capture controls for input pins */
4362static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4363 const struct auto_pin_cfg *cfg)
4364{
Kailang Yangdf694da2005-12-05 19:42:22 +01004365 struct hda_input_mux *imux = &spec->private_imux;
4366 int i, err, idx;
4367
4368 for (i = 0; i < AUTO_PIN_LAST; i++) {
4369 if (cfg->input_pins[i] >= 0x12) {
4370 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004371 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004372 auto_pin_cfg_labels[i], idx,
4373 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004374 if (err < 0)
4375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004376 imux->items[imux->num_items].label =
4377 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004378 imux->items[imux->num_items].index = idx;
4379 imux->num_items++;
4380 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004381 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004382 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004383 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004384 auto_pin_cfg_labels[i], idx,
4385 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004386 if (err < 0)
4387 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004388 imux->items[imux->num_items].label =
4389 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004390 imux->items[imux->num_items].index = idx;
4391 imux->num_items++;
4392 }
4393 }
4394 return 0;
4395}
4396
4397static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4398 hda_nid_t nid, int pin_type,
4399 int sel_idx)
4400{
4401 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004402 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4403 pin_type);
4404 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4405 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004406 /* need the manual connection? */
4407 if (nid >= 0x12) {
4408 int idx = nid - 0x12;
4409 snd_hda_codec_write(codec, idx + 0x0b, 0,
4410 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004411 }
4412}
4413
4414static void alc260_auto_init_multi_out(struct hda_codec *codec)
4415{
4416 struct alc_spec *spec = codec->spec;
4417 hda_nid_t nid;
4418
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004419 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004420 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004421 if (nid) {
4422 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4423 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4424 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004425
Takashi Iwai82bc9552006-03-21 11:24:42 +01004426 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004427 if (nid)
4428 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4429
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004430 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004431 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004432 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004433}
Kailang Yangdf694da2005-12-05 19:42:22 +01004434
4435#define ALC260_PIN_CD_NID 0x16
4436static void alc260_auto_init_analog_input(struct hda_codec *codec)
4437{
4438 struct alc_spec *spec = codec->spec;
4439 int i;
4440
4441 for (i = 0; i < AUTO_PIN_LAST; i++) {
4442 hda_nid_t nid = spec->autocfg.input_pins[i];
4443 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004444 snd_hda_codec_write(codec, nid, 0,
4445 AC_VERB_SET_PIN_WIDGET_CONTROL,
4446 i <= AUTO_PIN_FRONT_MIC ?
4447 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004448 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004449 snd_hda_codec_write(codec, nid, 0,
4450 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004451 AMP_OUT_MUTE);
4452 }
4453 }
4454}
4455
4456/*
4457 * generic initialization of ADC, input mixers and output mixers
4458 */
4459static struct hda_verb alc260_volume_init_verbs[] = {
4460 /*
4461 * Unmute ADC0-1 and set the default input to mic-in
4462 */
4463 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4464 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4465 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4466 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4467
4468 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4469 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004470 * Note: PASD motherboards uses the Line In 2 as the input for
4471 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004472 */
4473 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004474 /* mute analog inputs */
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004480
4481 /*
4482 * Set up output mixers (0x08 - 0x0a)
4483 */
4484 /* set vol=0 to output mixers */
4485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4487 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4488 /* set up input amps for analog loopback */
4489 /* Amp Indices: DAC = 0, mixer = 1 */
4490 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4494 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4495 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4496
4497 { }
4498};
4499
4500static int alc260_parse_auto_config(struct hda_codec *codec)
4501{
4502 struct alc_spec *spec = codec->spec;
4503 unsigned int wcap;
4504 int err;
4505 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4506
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004507 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4508 alc260_ignore);
4509 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004510 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004511 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4512 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004513 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004514 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004515 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004516 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4517 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004518 return err;
4519
4520 spec->multiout.max_channels = 2;
4521
4522 if (spec->autocfg.dig_out_pin)
4523 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4524 if (spec->kctl_alloc)
4525 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4526
4527 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4528
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004529 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004530 spec->input_mux = &spec->private_imux;
4531
4532 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004533 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004534 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4535 if (wcap != AC_WID_AUD_IN) {
4536 spec->adc_nids = alc260_adc_nids_alt;
4537 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4538 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004539 } else {
4540 spec->adc_nids = alc260_adc_nids;
4541 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4542 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004543 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004544 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004545
4546 return 1;
4547}
4548
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004549/* additional initialization for auto-configuration model */
4550static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004551{
Kailang Yangdf694da2005-12-05 19:42:22 +01004552 alc260_auto_init_multi_out(codec);
4553 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004554}
4555
Takashi Iwaicb53c622007-08-10 17:21:45 +02004556#ifdef CONFIG_SND_HDA_POWER_SAVE
4557static struct hda_amp_list alc260_loopbacks[] = {
4558 { 0x07, HDA_INPUT, 0 },
4559 { 0x07, HDA_INPUT, 1 },
4560 { 0x07, HDA_INPUT, 2 },
4561 { 0x07, HDA_INPUT, 3 },
4562 { 0x07, HDA_INPUT, 4 },
4563 { } /* end */
4564};
4565#endif
4566
Kailang Yangdf694da2005-12-05 19:42:22 +01004567/*
4568 * ALC260 configurations
4569 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004570static const char *alc260_models[ALC260_MODEL_LAST] = {
4571 [ALC260_BASIC] = "basic",
4572 [ALC260_HP] = "hp",
4573 [ALC260_HP_3013] = "hp-3013",
4574 [ALC260_FUJITSU_S702X] = "fujitsu",
4575 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004576 [ALC260_WILL] = "will",
4577 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004578#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004579 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004580#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004581 [ALC260_AUTO] = "auto",
4582};
4583
4584static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004585 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004586 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004587 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004588 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004589 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4590 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4591 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4592 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4593 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4594 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4595 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4596 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4597 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4598 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4599 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4600 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004601 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4602 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004603 {}
4604};
4605
Kailang Yangdf694da2005-12-05 19:42:22 +01004606static struct alc_config_preset alc260_presets[] = {
4607 [ALC260_BASIC] = {
4608 .mixers = { alc260_base_output_mixer,
4609 alc260_input_mixer,
4610 alc260_pc_beep_mixer,
4611 alc260_capture_mixer },
4612 .init_verbs = { alc260_init_verbs },
4613 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4614 .dac_nids = alc260_dac_nids,
4615 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4616 .adc_nids = alc260_adc_nids,
4617 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4618 .channel_mode = alc260_modes,
4619 .input_mux = &alc260_capture_source,
4620 },
4621 [ALC260_HP] = {
4622 .mixers = { alc260_base_output_mixer,
4623 alc260_input_mixer,
4624 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004625 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004626 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4627 .dac_nids = alc260_dac_nids,
4628 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4629 .adc_nids = alc260_hp_adc_nids,
4630 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4631 .channel_mode = alc260_modes,
4632 .input_mux = &alc260_capture_source,
4633 },
4634 [ALC260_HP_3013] = {
4635 .mixers = { alc260_hp_3013_mixer,
4636 alc260_input_mixer,
4637 alc260_capture_alt_mixer },
4638 .init_verbs = { alc260_hp_3013_init_verbs },
4639 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4640 .dac_nids = alc260_dac_nids,
4641 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4642 .adc_nids = alc260_hp_adc_nids,
4643 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4644 .channel_mode = alc260_modes,
4645 .input_mux = &alc260_capture_source,
4646 },
4647 [ALC260_FUJITSU_S702X] = {
4648 .mixers = { alc260_fujitsu_mixer,
4649 alc260_capture_mixer },
4650 .init_verbs = { alc260_fujitsu_init_verbs },
4651 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4652 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004653 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4654 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004655 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4656 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004657 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4658 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004659 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004660 [ALC260_ACER] = {
4661 .mixers = { alc260_acer_mixer,
4662 alc260_capture_mixer },
4663 .init_verbs = { alc260_acer_init_verbs },
4664 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4665 .dac_nids = alc260_dac_nids,
4666 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4667 .adc_nids = alc260_dual_adc_nids,
4668 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4669 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004670 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4671 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004672 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004673 [ALC260_WILL] = {
4674 .mixers = { alc260_will_mixer,
4675 alc260_capture_mixer },
4676 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4677 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4678 .dac_nids = alc260_dac_nids,
4679 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4680 .adc_nids = alc260_adc_nids,
4681 .dig_out_nid = ALC260_DIGOUT_NID,
4682 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4683 .channel_mode = alc260_modes,
4684 .input_mux = &alc260_capture_source,
4685 },
4686 [ALC260_REPLACER_672V] = {
4687 .mixers = { alc260_replacer_672v_mixer,
4688 alc260_capture_mixer },
4689 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4690 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4691 .dac_nids = alc260_dac_nids,
4692 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4693 .adc_nids = alc260_adc_nids,
4694 .dig_out_nid = ALC260_DIGOUT_NID,
4695 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4696 .channel_mode = alc260_modes,
4697 .input_mux = &alc260_capture_source,
4698 .unsol_event = alc260_replacer_672v_unsol_event,
4699 .init_hook = alc260_replacer_672v_automute,
4700 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004701#ifdef CONFIG_SND_DEBUG
4702 [ALC260_TEST] = {
4703 .mixers = { alc260_test_mixer,
4704 alc260_capture_mixer },
4705 .init_verbs = { alc260_test_init_verbs },
4706 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4707 .dac_nids = alc260_test_dac_nids,
4708 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4709 .adc_nids = alc260_test_adc_nids,
4710 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4711 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004712 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4713 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004714 },
4715#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004716};
4717
Linus Torvalds1da177e2005-04-16 15:20:36 -07004718static int patch_alc260(struct hda_codec *codec)
4719{
4720 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004721 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004722
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004723 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004724 if (spec == NULL)
4725 return -ENOMEM;
4726
4727 codec->spec = spec;
4728
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004729 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4730 alc260_models,
4731 alc260_cfg_tbl);
4732 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004733 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4734 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004735 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004736 }
4737
Kailang Yangdf694da2005-12-05 19:42:22 +01004738 if (board_config == ALC260_AUTO) {
4739 /* automatic parse from the BIOS config */
4740 err = alc260_parse_auto_config(codec);
4741 if (err < 0) {
4742 alc_free(codec);
4743 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004744 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004745 printk(KERN_INFO
4746 "hda_codec: Cannot set up configuration "
4747 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004748 board_config = ALC260_BASIC;
4749 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004750 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004751
Kailang Yangdf694da2005-12-05 19:42:22 +01004752 if (board_config != ALC260_AUTO)
4753 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004754
4755 spec->stream_name_analog = "ALC260 Analog";
4756 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4757 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4758
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004759 spec->stream_name_digital = "ALC260 Digital";
4760 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4761 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4762
Linus Torvalds1da177e2005-04-16 15:20:36 -07004763 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004764 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004765 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004766#ifdef CONFIG_SND_HDA_POWER_SAVE
4767 if (!spec->loopback.amplist)
4768 spec->loopback.amplist = alc260_loopbacks;
4769#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004770
4771 return 0;
4772}
4773
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774
Linus Torvalds1da177e2005-04-16 15:20:36 -07004775/*
4776 * ALC882 support
4777 *
4778 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4779 * configuration. Each pin widget can choose any input DACs and a mixer.
4780 * Each ADC is connected from a mixer of all inputs. This makes possible
4781 * 6-channel independent captures.
4782 *
4783 * In addition, an independent DAC for the multi-playback (not used in this
4784 * driver yet).
4785 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004786#define ALC882_DIGOUT_NID 0x06
4787#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004788
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004789static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004790 { 8, NULL }
4791};
4792
4793static hda_nid_t alc882_dac_nids[4] = {
4794 /* front, rear, clfe, rear_surr */
4795 0x02, 0x03, 0x04, 0x05
4796};
4797
Kailang Yangdf694da2005-12-05 19:42:22 +01004798/* identical with ALC880 */
4799#define alc882_adc_nids alc880_adc_nids
4800#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004801
4802/* input MUX */
4803/* FIXME: should be a matrix-type input source selection */
4804
4805static struct hda_input_mux alc882_capture_source = {
4806 .num_items = 4,
4807 .items = {
4808 { "Mic", 0x0 },
4809 { "Front Mic", 0x1 },
4810 { "Line", 0x2 },
4811 { "CD", 0x4 },
4812 },
4813};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004814#define alc882_mux_enum_info alc_mux_enum_info
4815#define alc882_mux_enum_get alc_mux_enum_get
4816
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4818 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004819{
4820 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4821 struct alc_spec *spec = codec->spec;
4822 const struct hda_input_mux *imux = spec->input_mux;
4823 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4824 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4825 hda_nid_t nid = capture_mixers[adc_idx];
4826 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4827 unsigned int i, idx;
4828
4829 idx = ucontrol->value.enumerated.item[0];
4830 if (idx >= imux->num_items)
4831 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004832 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004833 return 0;
4834 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02004835 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4836 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004837 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02004838 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004839 }
4840 *cur_val = idx;
4841 return 1;
4842}
4843
Kailang Yangdf694da2005-12-05 19:42:22 +01004844/*
Kailang Yang272a5272007-05-14 11:00:38 +02004845 * 2ch mode
4846 */
4847static struct hda_verb alc882_3ST_ch2_init[] = {
4848 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4849 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4850 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4851 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4852 { } /* end */
4853};
4854
4855/*
4856 * 6ch mode
4857 */
4858static struct hda_verb alc882_3ST_ch6_init[] = {
4859 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4860 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4861 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4864 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4865 { } /* end */
4866};
4867
4868static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4869 { 2, alc882_3ST_ch2_init },
4870 { 6, alc882_3ST_ch6_init },
4871};
4872
4873/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004874 * 6ch mode
4875 */
4876static struct hda_verb alc882_sixstack_ch6_init[] = {
4877 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4878 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4879 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4880 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4881 { } /* end */
4882};
4883
4884/*
4885 * 8ch mode
4886 */
4887static struct hda_verb alc882_sixstack_ch8_init[] = {
4888 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4889 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4890 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4891 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4892 { } /* end */
4893};
4894
4895static struct hda_channel_mode alc882_sixstack_modes[2] = {
4896 { 6, alc882_sixstack_ch6_init },
4897 { 8, alc882_sixstack_ch8_init },
4898};
4899
Takashi Iwai87350ad2007-08-16 18:19:38 +02004900/*
4901 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
4902 */
4903
4904/*
4905 * 2ch mode
4906 */
4907static struct hda_verb alc885_mbp_ch2_init[] = {
4908 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4909 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4910 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4911 { } /* end */
4912};
4913
4914/*
4915 * 6ch mode
4916 */
4917static struct hda_verb alc885_mbp_ch6_init[] = {
4918 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4919 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4920 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4921 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4922 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4923 { } /* end */
4924};
4925
4926static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
4927 { 2, alc885_mbp_ch2_init },
4928 { 6, alc885_mbp_ch6_init },
4929};
4930
4931
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4933 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4934 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004935static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004937 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004938 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004939 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004940 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4941 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004942 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4943 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004944 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004945 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004952 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004955 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004956 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4957 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4958 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004959 { } /* end */
4960};
4961
Takashi Iwai87350ad2007-08-16 18:19:38 +02004962static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
4963 HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
4964 HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
4965 HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
4966 HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
4967 HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
4968 HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
4969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
4970 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
4971 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
4972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
4973 { } /* end */
4974};
Kailang Yangbdd148a2007-05-08 15:19:08 +02004975static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4976 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4977 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4978 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4979 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4983 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4985 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4986 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4987 { } /* end */
4988};
4989
Kailang Yang272a5272007-05-14 11:00:38 +02004990static struct snd_kcontrol_new alc882_targa_mixer[] = {
4991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4995 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5000 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5002 { } /* end */
5003};
5004
5005/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5006 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5007 */
5008static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5009 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5010 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5012 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5013 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5014 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5015 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5016 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5017 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5018 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5021 { } /* end */
5022};
5023
Kailang Yangdf694da2005-12-05 19:42:22 +01005024static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5025 {
5026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5027 .name = "Channel Mode",
5028 .info = alc_ch_mode_info,
5029 .get = alc_ch_mode_get,
5030 .put = alc_ch_mode_put,
5031 },
5032 { } /* end */
5033};
5034
Linus Torvalds1da177e2005-04-16 15:20:36 -07005035static struct hda_verb alc882_init_verbs[] = {
5036 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005040 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5042 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5043 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005044 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005045 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5046 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5047 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005048 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005049 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5050 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5051 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005052
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005056 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005057 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005058 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005060 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005061 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005062 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005063 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005064 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005065 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005066 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005067 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005068 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005069 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005070 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005071 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5072 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005073 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5075 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005076 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5078 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5081 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005082 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005083 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005084
5085 /* FIXME: use matrix-type input source selection */
5086 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5087 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5091 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005092 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005097 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5102 /* ADC1: mute amp left and right */
5103 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005104 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005105 /* ADC2: mute amp left and right */
5106 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005107 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005108 /* ADC3: mute amp left and right */
5109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005110 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005111
5112 { }
5113};
5114
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005115static struct hda_verb alc882_eapd_verbs[] = {
5116 /* change to EAPD mode */
5117 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005118 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005120};
5121
Tobin Davis9102cd12006-12-15 10:02:12 +01005122/* Mac Pro test */
5123static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5125 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5129 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5130 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5131 { } /* end */
5132};
5133
5134static struct hda_verb alc882_macpro_init_verbs[] = {
5135 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5136 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5139 /* Front Pin: output 0 (0x0c) */
5140 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5142 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5143 /* Front Mic pin: input vref at 80% */
5144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5145 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5146 /* Speaker: output */
5147 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5148 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5149 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5150 /* Headphone output (output 0 - 0x0c) */
5151 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5152 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5153 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5154
5155 /* FIXME: use matrix-type input source selection */
5156 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5157 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5160 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5161 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5162 /* Input mixer2 */
5163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5167 /* Input mixer3 */
5168 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5170 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5172 /* ADC1: mute amp left and right */
5173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5174 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5175 /* ADC2: mute amp left and right */
5176 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5177 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5178 /* ADC3: mute amp left and right */
5179 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5180 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5181
5182 { }
5183};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005184
Takashi Iwai87350ad2007-08-16 18:19:38 +02005185/* Macbook Pro rev3 */
5186static struct hda_verb alc885_mbp3_init_verbs[] = {
5187 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5188 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5191 /* Rear mixer */
5192 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5195 /* Front Pin: output 0 (0x0c) */
5196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5198 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5199 /* HP Pin: output 0 (0x0d) */
5200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5203 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5204 /* Mic (rear) pin: input vref at 80% */
5205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5206 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5207 /* Front Mic pin: input vref at 80% */
5208 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5209 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5210 /* Line In pin: use output 1 when in LineOut mode */
5211 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5212 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5213 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5214
5215 /* FIXME: use matrix-type input source selection */
5216 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5217 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5222 /* Input mixer2 */
5223 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5224 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5225 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5226 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5227 /* Input mixer3 */
5228 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5231 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5232 /* ADC1: mute amp left and right */
5233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5234 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5235 /* ADC2: mute amp left and right */
5236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5237 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5238 /* ADC3: mute amp left and right */
5239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5240 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5241
5242 { }
5243};
5244
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005245/* iMac 24 mixer. */
5246static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5247 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5248 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5249 { } /* end */
5250};
5251
5252/* iMac 24 init verbs. */
5253static struct hda_verb alc885_imac24_init_verbs[] = {
5254 /* Internal speakers: output 0 (0x0c) */
5255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5257 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5258 /* Internal speakers: output 0 (0x0c) */
5259 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5261 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5262 /* Headphone: output 0 (0x0c) */
5263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5265 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5266 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5267 /* Front Mic: input vref at 80% */
5268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5270 { }
5271};
5272
5273/* Toggle speaker-output according to the hp-jack state */
5274static void alc885_imac24_automute(struct hda_codec *codec)
5275{
5276 unsigned int present;
5277
5278 present = snd_hda_codec_read(codec, 0x14, 0,
5279 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005280 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5281 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5282 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5283 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005284}
5285
5286/* Processes unsolicited events. */
5287static void alc885_imac24_unsol_event(struct hda_codec *codec,
5288 unsigned int res)
5289{
5290 /* Headphone insertion or removal. */
5291 if ((res >> 26) == ALC880_HP_EVENT)
5292 alc885_imac24_automute(codec);
5293}
5294
Takashi Iwai87350ad2007-08-16 18:19:38 +02005295static void alc885_mbp3_automute(struct hda_codec *codec)
5296{
5297 unsigned int present;
5298
5299 present = snd_hda_codec_read(codec, 0x15, 0,
5300 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5301 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5302 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5303 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5304 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5305
5306}
5307static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5308 unsigned int res)
5309{
5310 /* Headphone insertion or removal. */
5311 if ((res >> 26) == ALC880_HP_EVENT)
5312 alc885_mbp3_automute(codec);
5313}
5314
5315
Kailang Yang272a5272007-05-14 11:00:38 +02005316static struct hda_verb alc882_targa_verbs[] = {
5317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5319
5320 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5321 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5322
5323 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5324 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5325 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5326
5327 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5328 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5329 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5330 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5331 { } /* end */
5332};
5333
5334/* toggle speaker-output according to the hp-jack state */
5335static void alc882_targa_automute(struct hda_codec *codec)
5336{
5337 unsigned int present;
5338
5339 present = snd_hda_codec_read(codec, 0x14, 0,
5340 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005341 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5342 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005343 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5344 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02005345}
5346
5347static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5348{
5349 /* Looks like the unsol event is incompatible with the standard
5350 * definition. 4bit tag is placed at 26 bit!
5351 */
5352 if (((res >> 26) == ALC880_HP_EVENT)) {
5353 alc882_targa_automute(codec);
5354 }
5355}
5356
5357static struct hda_verb alc882_asus_a7j_verbs[] = {
5358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5360
5361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5363 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5364
5365 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5367 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5368
5369 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5370 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5371 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5372 { } /* end */
5373};
5374
Tobin Davis9102cd12006-12-15 10:02:12 +01005375static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5376{
5377 unsigned int gpiostate, gpiomask, gpiodir;
5378
5379 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5380 AC_VERB_GET_GPIO_DATA, 0);
5381
5382 if (!muted)
5383 gpiostate |= (1 << pin);
5384 else
5385 gpiostate &= ~(1 << pin);
5386
5387 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5388 AC_VERB_GET_GPIO_MASK, 0);
5389 gpiomask |= (1 << pin);
5390
5391 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5392 AC_VERB_GET_GPIO_DIRECTION, 0);
5393 gpiodir |= (1 << pin);
5394
5395
5396 snd_hda_codec_write(codec, codec->afg, 0,
5397 AC_VERB_SET_GPIO_MASK, gpiomask);
5398 snd_hda_codec_write(codec, codec->afg, 0,
5399 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5400
5401 msleep(1);
5402
5403 snd_hda_codec_write(codec, codec->afg, 0,
5404 AC_VERB_SET_GPIO_DATA, gpiostate);
5405}
5406
Takashi Iwai7debbe52007-08-16 15:01:03 +02005407/* set up GPIO at initialization */
5408static void alc885_macpro_init_hook(struct hda_codec *codec)
5409{
5410 alc882_gpio_mute(codec, 0, 0);
5411 alc882_gpio_mute(codec, 1, 0);
5412}
5413
5414/* set up GPIO and update auto-muting at initialization */
5415static void alc885_imac24_init_hook(struct hda_codec *codec)
5416{
5417 alc885_macpro_init_hook(codec);
5418 alc885_imac24_automute(codec);
5419}
5420
Kailang Yangdf694da2005-12-05 19:42:22 +01005421/*
5422 * generic initialization of ADC, input mixers and output mixers
5423 */
5424static struct hda_verb alc882_auto_init_verbs[] = {
5425 /*
5426 * Unmute ADC0-2 and set the default input to mic-in
5427 */
5428 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5430 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5432 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5434
Takashi Iwaicb53c622007-08-10 17:21:45 +02005435 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01005436 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005437 * Note: PASD motherboards uses the Line In 2 as the input for
5438 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005439 */
5440 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005446
5447 /*
5448 * Set up output mixers (0x0c - 0x0f)
5449 */
5450 /* set vol=0 to output mixers */
5451 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5453 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5454 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5455 /* set up input amps for analog loopback */
5456 /* Amp Indices: DAC = 0, mixer = 1 */
5457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5463 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5465 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5466 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5467
5468 /* FIXME: use matrix-type input source selection */
5469 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5470 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5475 /* Input mixer2 */
5476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5480 /* Input mixer3 */
5481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5485
5486 { }
5487};
5488
5489/* capture mixer elements */
5490static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5491 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5492 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5493 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5494 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5495 {
5496 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5497 /* The multiple "Capture Source" controls confuse alsamixer
5498 * So call somewhat different..
5499 * FIXME: the controls appear in the "playback" view!
5500 */
5501 /* .name = "Capture Source", */
5502 .name = "Input Source",
5503 .count = 2,
5504 .info = alc882_mux_enum_info,
5505 .get = alc882_mux_enum_get,
5506 .put = alc882_mux_enum_put,
5507 },
5508 { } /* end */
5509};
5510
5511static struct snd_kcontrol_new alc882_capture_mixer[] = {
5512 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5513 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5514 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5515 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5516 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5517 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5518 {
5519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5520 /* The multiple "Capture Source" controls confuse alsamixer
5521 * So call somewhat different..
5522 * FIXME: the controls appear in the "playback" view!
5523 */
5524 /* .name = "Capture Source", */
5525 .name = "Input Source",
5526 .count = 3,
5527 .info = alc882_mux_enum_info,
5528 .get = alc882_mux_enum_get,
5529 .put = alc882_mux_enum_put,
5530 },
5531 { } /* end */
5532};
5533
Takashi Iwaicb53c622007-08-10 17:21:45 +02005534#ifdef CONFIG_SND_HDA_POWER_SAVE
5535#define alc882_loopbacks alc880_loopbacks
5536#endif
5537
Kailang Yangdf694da2005-12-05 19:42:22 +01005538/* pcm configuration: identiacal with ALC880 */
5539#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5540#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5541#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5542#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5543
5544/*
5545 * configuration and preset
5546 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005547static const char *alc882_models[ALC882_MODEL_LAST] = {
5548 [ALC882_3ST_DIG] = "3stack-dig",
5549 [ALC882_6ST_DIG] = "6stack-dig",
5550 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005551 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005552 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02005553 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005554 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005555 [ALC882_AUTO] = "auto",
5556};
5557
5558static struct snd_pci_quirk alc882_cfg_tbl[] = {
5559 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5560 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5561 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005562 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005563 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005564 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02005565 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005566 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005567 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005568 {}
5569};
5570
5571static struct alc_config_preset alc882_presets[] = {
5572 [ALC882_3ST_DIG] = {
5573 .mixers = { alc882_base_mixer },
5574 .init_verbs = { alc882_init_verbs },
5575 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5576 .dac_nids = alc882_dac_nids,
5577 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005578 .dig_in_nid = ALC882_DIGIN_NID,
5579 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5580 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005581 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005582 .input_mux = &alc882_capture_source,
5583 },
5584 [ALC882_6ST_DIG] = {
5585 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5586 .init_verbs = { alc882_init_verbs },
5587 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5588 .dac_nids = alc882_dac_nids,
5589 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005590 .dig_in_nid = ALC882_DIGIN_NID,
5591 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5592 .channel_mode = alc882_sixstack_modes,
5593 .input_mux = &alc882_capture_source,
5594 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005595 [ALC882_ARIMA] = {
5596 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5597 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5598 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5599 .dac_nids = alc882_dac_nids,
5600 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5601 .channel_mode = alc882_sixstack_modes,
5602 .input_mux = &alc882_capture_source,
5603 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005604 [ALC882_W2JC] = {
5605 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5606 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5607 alc880_gpio1_init_verbs },
5608 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5609 .dac_nids = alc882_dac_nids,
5610 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5611 .channel_mode = alc880_threestack_modes,
5612 .need_dac_fix = 1,
5613 .input_mux = &alc882_capture_source,
5614 .dig_out_nid = ALC882_DIGOUT_NID,
5615 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02005616 [ALC885_MBP3] = {
5617 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5618 .init_verbs = { alc885_mbp3_init_verbs,
5619 alc880_gpio1_init_verbs },
5620 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5621 .dac_nids = alc882_dac_nids,
5622 .channel_mode = alc885_mbp_6ch_modes,
5623 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5624 .input_mux = &alc882_capture_source,
5625 .dig_out_nid = ALC882_DIGOUT_NID,
5626 .dig_in_nid = ALC882_DIGIN_NID,
5627 .unsol_event = alc885_mbp3_unsol_event,
5628 .init_hook = alc885_mbp3_automute,
5629 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005630 [ALC885_MACPRO] = {
5631 .mixers = { alc882_macpro_mixer },
5632 .init_verbs = { alc882_macpro_init_verbs },
5633 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5634 .dac_nids = alc882_dac_nids,
5635 .dig_out_nid = ALC882_DIGOUT_NID,
5636 .dig_in_nid = ALC882_DIGIN_NID,
5637 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5638 .channel_mode = alc882_ch_modes,
5639 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005640 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01005641 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005642 [ALC885_IMAC24] = {
5643 .mixers = { alc885_imac24_mixer },
5644 .init_verbs = { alc885_imac24_init_verbs },
5645 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5646 .dac_nids = alc882_dac_nids,
5647 .dig_out_nid = ALC882_DIGOUT_NID,
5648 .dig_in_nid = ALC882_DIGIN_NID,
5649 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5650 .channel_mode = alc882_ch_modes,
5651 .input_mux = &alc882_capture_source,
5652 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02005653 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005654 },
Kailang Yang272a5272007-05-14 11:00:38 +02005655 [ALC882_TARGA] = {
5656 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5657 alc882_capture_mixer },
5658 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5659 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5660 .dac_nids = alc882_dac_nids,
5661 .dig_out_nid = ALC882_DIGOUT_NID,
5662 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5663 .adc_nids = alc882_adc_nids,
5664 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5665 .channel_mode = alc882_3ST_6ch_modes,
5666 .need_dac_fix = 1,
5667 .input_mux = &alc882_capture_source,
5668 .unsol_event = alc882_targa_unsol_event,
5669 .init_hook = alc882_targa_automute,
5670 },
5671 [ALC882_ASUS_A7J] = {
5672 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5673 alc882_capture_mixer },
5674 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5675 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5676 .dac_nids = alc882_dac_nids,
5677 .dig_out_nid = ALC882_DIGOUT_NID,
5678 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5679 .adc_nids = alc882_adc_nids,
5680 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5681 .channel_mode = alc882_3ST_6ch_modes,
5682 .need_dac_fix = 1,
5683 .input_mux = &alc882_capture_source,
5684 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005685};
5686
5687
5688/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02005689 * Pin config fixes
5690 */
5691enum {
5692 PINFIX_ABIT_AW9D_MAX
5693};
5694
5695static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5696 { 0x15, 0x01080104 }, /* side */
5697 { 0x16, 0x01011012 }, /* rear */
5698 { 0x17, 0x01016011 }, /* clfe */
5699 { }
5700};
5701
5702static const struct alc_pincfg *alc882_pin_fixes[] = {
5703 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5704};
5705
5706static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5707 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5708 {}
5709};
5710
5711/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005712 * BIOS auto configuration
5713 */
5714static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5715 hda_nid_t nid, int pin_type,
5716 int dac_idx)
5717{
5718 /* set as output */
5719 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005720 int idx;
5721
Kailang Yangdf694da2005-12-05 19:42:22 +01005722 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5723 idx = 4;
5724 else
5725 idx = spec->multiout.dac_nids[dac_idx] - 2;
5726
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005727 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5728 pin_type);
5729 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5730 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005731 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5732
5733}
5734
5735static void alc882_auto_init_multi_out(struct hda_codec *codec)
5736{
5737 struct alc_spec *spec = codec->spec;
5738 int i;
5739
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005740 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005741 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005742 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005743 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005744 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005745 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005746 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005747 }
5748}
5749
5750static void alc882_auto_init_hp_out(struct hda_codec *codec)
5751{
5752 struct alc_spec *spec = codec->spec;
5753 hda_nid_t pin;
5754
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005755 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005756 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005757 /* use dac 0 */
5758 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005759}
5760
5761#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5762#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5763
5764static void alc882_auto_init_analog_input(struct hda_codec *codec)
5765{
5766 struct alc_spec *spec = codec->spec;
5767 int i;
5768
5769 for (i = 0; i < AUTO_PIN_LAST; i++) {
5770 hda_nid_t nid = spec->autocfg.input_pins[i];
5771 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005772 snd_hda_codec_write(codec, nid, 0,
5773 AC_VERB_SET_PIN_WIDGET_CONTROL,
5774 i <= AUTO_PIN_FRONT_MIC ?
5775 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005776 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005777 snd_hda_codec_write(codec, nid, 0,
5778 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005779 AMP_OUT_MUTE);
5780 }
5781 }
5782}
5783
5784/* almost identical with ALC880 parser... */
5785static int alc882_parse_auto_config(struct hda_codec *codec)
5786{
5787 struct alc_spec *spec = codec->spec;
5788 int err = alc880_parse_auto_config(codec);
5789
5790 if (err < 0)
5791 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005792 else if (err > 0)
5793 /* hack - override the init verbs */
5794 spec->init_verbs[0] = alc882_auto_init_verbs;
5795 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005796}
5797
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005798/* additional initialization for auto-configuration model */
5799static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005800{
Kailang Yangdf694da2005-12-05 19:42:22 +01005801 alc882_auto_init_multi_out(codec);
5802 alc882_auto_init_hp_out(codec);
5803 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005804}
5805
Linus Torvalds1da177e2005-04-16 15:20:36 -07005806static int patch_alc882(struct hda_codec *codec)
5807{
5808 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005809 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005810
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005811 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005812 if (spec == NULL)
5813 return -ENOMEM;
5814
Linus Torvalds1da177e2005-04-16 15:20:36 -07005815 codec->spec = spec;
5816
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005817 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5818 alc882_models,
5819 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005820
Kailang Yangdf694da2005-12-05 19:42:22 +01005821 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005822 /* Pick up systems that don't supply PCI SSID */
5823 switch (codec->subsystem_id) {
5824 case 0x106b0c00: /* Mac Pro */
5825 board_config = ALC885_MACPRO;
5826 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005827 case 0x106b1000: /* iMac 24 */
5828 board_config = ALC885_IMAC24;
5829 break;
Takashi Iwai87350ad2007-08-16 18:19:38 +02005830 case 0x106b2c00: /* Macbook Pro rev3 */
5831 board_config = ALC885_MBP3;
5832 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01005833 default:
5834 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5835 "trying auto-probe from BIOS...\n");
5836 board_config = ALC882_AUTO;
5837 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005838 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005839
Takashi Iwaif95474e2007-07-10 00:47:43 +02005840 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5841
Kailang Yangdf694da2005-12-05 19:42:22 +01005842 if (board_config == ALC882_AUTO) {
5843 /* automatic parse from the BIOS config */
5844 err = alc882_parse_auto_config(codec);
5845 if (err < 0) {
5846 alc_free(codec);
5847 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005848 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005849 printk(KERN_INFO
5850 "hda_codec: Cannot set up configuration "
5851 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005852 board_config = ALC882_3ST_DIG;
5853 }
5854 }
5855
5856 if (board_config != ALC882_AUTO)
5857 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005858
5859 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005860 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5861 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005862
5863 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005864 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5865 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005866
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005867 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005868 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005869 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005870 /* get type */
5871 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005872 if (wcap != AC_WID_AUD_IN) {
5873 spec->adc_nids = alc882_adc_nids_alt;
5874 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005875 spec->mixers[spec->num_mixers] =
5876 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005877 spec->num_mixers++;
5878 } else {
5879 spec->adc_nids = alc882_adc_nids;
5880 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5881 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5882 spec->num_mixers++;
5883 }
5884 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005885
5886 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005887 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005888 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005889#ifdef CONFIG_SND_HDA_POWER_SAVE
5890 if (!spec->loopback.amplist)
5891 spec->loopback.amplist = alc882_loopbacks;
5892#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005893
5894 return 0;
5895}
5896
5897/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005898 * ALC883 support
5899 *
5900 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5901 * configuration. Each pin widget can choose any input DACs and a mixer.
5902 * Each ADC is connected from a mixer of all inputs. This makes possible
5903 * 6-channel independent captures.
5904 *
5905 * In addition, an independent DAC for the multi-playback (not used in this
5906 * driver yet).
5907 */
5908#define ALC883_DIGOUT_NID 0x06
5909#define ALC883_DIGIN_NID 0x0a
5910
5911static hda_nid_t alc883_dac_nids[4] = {
5912 /* front, rear, clfe, rear_surr */
5913 0x02, 0x04, 0x03, 0x05
5914};
5915
5916static hda_nid_t alc883_adc_nids[2] = {
5917 /* ADC1-2 */
5918 0x08, 0x09,
5919};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005920
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005921/* input MUX */
5922/* FIXME: should be a matrix-type input source selection */
5923
5924static struct hda_input_mux alc883_capture_source = {
5925 .num_items = 4,
5926 .items = {
5927 { "Mic", 0x0 },
5928 { "Front Mic", 0x1 },
5929 { "Line", 0x2 },
5930 { "CD", 0x4 },
5931 },
5932};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005933
5934static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5935 .num_items = 2,
5936 .items = {
5937 { "Mic", 0x1 },
5938 { "Line", 0x2 },
5939 },
5940};
5941
Kailang Yang272a5272007-05-14 11:00:38 +02005942static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5943 .num_items = 4,
5944 .items = {
5945 { "Mic", 0x0 },
5946 { "iMic", 0x1 },
5947 { "Line", 0x2 },
5948 { "CD", 0x4 },
5949 },
5950};
5951
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005952#define alc883_mux_enum_info alc_mux_enum_info
5953#define alc883_mux_enum_get alc_mux_enum_get
5954
5955static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5956 struct snd_ctl_elem_value *ucontrol)
5957{
5958 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5959 struct alc_spec *spec = codec->spec;
5960 const struct hda_input_mux *imux = spec->input_mux;
5961 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5962 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5963 hda_nid_t nid = capture_mixers[adc_idx];
5964 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5965 unsigned int i, idx;
5966
5967 idx = ucontrol->value.enumerated.item[0];
5968 if (idx >= imux->num_items)
5969 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005970 if (*cur_val == idx)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005971 return 0;
5972 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005973 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5974 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005975 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005976 HDA_AMP_MUTE, v);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005977 }
5978 *cur_val = idx;
5979 return 1;
5980}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005981
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005982/*
5983 * 2ch mode
5984 */
5985static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5986 { 2, NULL }
5987};
5988
5989/*
5990 * 2ch mode
5991 */
5992static struct hda_verb alc883_3ST_ch2_init[] = {
5993 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5994 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5995 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5996 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5997 { } /* end */
5998};
5999
6000/*
6001 * 6ch mode
6002 */
6003static struct hda_verb alc883_3ST_ch6_init[] = {
6004 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6005 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6006 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6007 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6008 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6009 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6010 { } /* end */
6011};
6012
6013static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
6014 { 2, alc883_3ST_ch2_init },
6015 { 6, alc883_3ST_ch6_init },
6016};
6017
6018/*
6019 * 6ch mode
6020 */
6021static struct hda_verb alc883_sixstack_ch6_init[] = {
6022 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6023 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6024 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6025 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6026 { } /* end */
6027};
6028
6029/*
6030 * 8ch mode
6031 */
6032static struct hda_verb alc883_sixstack_ch8_init[] = {
6033 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6034 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6035 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6036 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6037 { } /* end */
6038};
6039
6040static struct hda_channel_mode alc883_sixstack_modes[2] = {
6041 { 6, alc883_sixstack_ch6_init },
6042 { 8, alc883_sixstack_ch8_init },
6043};
6044
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006045static struct hda_verb alc883_medion_eapd_verbs[] = {
6046 /* eanable EAPD on medion laptop */
6047 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6048 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6049 { }
6050};
6051
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006052/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6053 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6054 */
6055
6056static struct snd_kcontrol_new alc883_base_mixer[] = {
6057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6060 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6061 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6063 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6064 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6065 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6066 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006076 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6078 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6079 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6080 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6081 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6082 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6083 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6084 {
6085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6086 /* .name = "Capture Source", */
6087 .name = "Input Source",
6088 .count = 2,
6089 .info = alc883_mux_enum_info,
6090 .get = alc883_mux_enum_get,
6091 .put = alc883_mux_enum_put,
6092 },
6093 { } /* end */
6094};
6095
6096static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6097 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6098 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006105 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6107 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006108 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006109 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6110 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6111 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6112 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6113 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6114 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6115 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6116 {
6117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6118 /* .name = "Capture Source", */
6119 .name = "Input Source",
6120 .count = 2,
6121 .info = alc883_mux_enum_info,
6122 .get = alc883_mux_enum_get,
6123 .put = alc883_mux_enum_put,
6124 },
6125 { } /* end */
6126};
6127
6128static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6129 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6130 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6131 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6132 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6133 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6134 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6135 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6136 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6138 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6139 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6140 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6141 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006144 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6145 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006146 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6148 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6149 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6150 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6151 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6152 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6153 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6154 {
6155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6156 /* .name = "Capture Source", */
6157 .name = "Input Source",
6158 .count = 2,
6159 .info = alc883_mux_enum_info,
6160 .get = alc883_mux_enum_get,
6161 .put = alc883_mux_enum_put,
6162 },
6163 { } /* end */
6164};
6165
Takashi Iwaid1d985f2006-11-23 19:27:12 +01006166static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02006167 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6168 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6169 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6170 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6171 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6172 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6173 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6174 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006181 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6183 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006184 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02006185 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6186 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6187 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6188 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6189 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6190
6191 {
6192 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6193 /* .name = "Capture Source", */
6194 .name = "Input Source",
6195 .count = 1,
6196 .info = alc883_mux_enum_info,
6197 .get = alc883_mux_enum_get,
6198 .put = alc883_mux_enum_put,
6199 },
6200 { } /* end */
6201};
6202
Kailang Yangccc656c2006-10-17 12:32:26 +02006203static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6206 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6207 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6208 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6209 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6210 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6211 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6212 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6213 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6214 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6215 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6216 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006218 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006219 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6220 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6221 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6222 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6223 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6224 {
6225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6226 /* .name = "Capture Source", */
6227 .name = "Input Source",
6228 .count = 2,
6229 .info = alc883_mux_enum_info,
6230 .get = alc883_mux_enum_get,
6231 .put = alc883_mux_enum_put,
6232 },
6233 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006234};
Kailang Yangccc656c2006-10-17 12:32:26 +02006235
6236static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6237 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6239 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6245 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6246 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6247 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6248 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6249 {
6250 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6251 /* .name = "Capture Source", */
6252 .name = "Input Source",
6253 .count = 2,
6254 .info = alc883_mux_enum_info,
6255 .get = alc883_mux_enum_get,
6256 .put = alc883_mux_enum_put,
6257 },
6258 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259};
Kailang Yangccc656c2006-10-17 12:32:26 +02006260
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006261static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6262 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6263 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6264 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6265 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6268 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6269 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6270 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6271 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6272 {
6273 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6274 /* .name = "Capture Source", */
6275 .name = "Input Source",
6276 .count = 1,
6277 .info = alc883_mux_enum_info,
6278 .get = alc883_mux_enum_get,
6279 .put = alc883_mux_enum_put,
6280 },
6281 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006282};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006283
Kailang Yang272a5272007-05-14 11:00:38 +02006284static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6285 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6286 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6287 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6288 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6289 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6291 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6292 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6293 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6294 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6295 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6296 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6297 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6298 {
6299 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6300 /* .name = "Capture Source", */
6301 .name = "Input Source",
6302 .count = 2,
6303 .info = alc883_mux_enum_info,
6304 .get = alc883_mux_enum_get,
6305 .put = alc883_mux_enum_put,
6306 },
6307 { } /* end */
6308};
6309
6310static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6311 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6313 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6318 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6319 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6320 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6321 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6322 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6323 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6324 {
6325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6326 /* .name = "Capture Source", */
6327 .name = "Input Source",
6328 .count = 2,
6329 .info = alc883_mux_enum_info,
6330 .get = alc883_mux_enum_get,
6331 .put = alc883_mux_enum_put,
6332 },
6333 { } /* end */
6334};
6335
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006336static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6338 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6339 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6340 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6341 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6342 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6343 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6344 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6345 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6346 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6353 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6355 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6356 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6357 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6358 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6359 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6360 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6361 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6362 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6363 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6364 {
6365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6366 /* .name = "Capture Source", */
6367 .name = "Input Source",
6368 .count = 2,
6369 .info = alc883_mux_enum_info,
6370 .get = alc883_mux_enum_get,
6371 .put = alc883_mux_enum_put,
6372 },
6373 { } /* end */
6374};
6375
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006376static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006377 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6378 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6379 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6380 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6381 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6382 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6383 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6384 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6386 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6387 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6388 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6389 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6390 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6393 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6394 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6395 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6396 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6397 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6398 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6399 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6400 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6401 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6402 {
6403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6404 /* .name = "Capture Source", */
6405 .name = "Input Source",
6406 .count = 2,
6407 .info = alc883_mux_enum_info,
6408 .get = alc883_mux_enum_get,
6409 .put = alc883_mux_enum_put,
6410 },
6411 { } /* end */
6412};
6413
Tobin Davis2880a862007-08-07 11:50:26 +02006414static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02006415 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6416 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006418 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6419 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006420 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6422 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02006423 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6424 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6425 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6426 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6427 {
6428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6429 /* .name = "Capture Source", */
6430 .name = "Input Source",
6431 .count = 2,
6432 .info = alc883_mux_enum_info,
6433 .get = alc883_mux_enum_get,
6434 .put = alc883_mux_enum_put,
6435 },
6436 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02006437};
Tobin Davis2880a862007-08-07 11:50:26 +02006438
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006439static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6440 {
6441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6442 .name = "Channel Mode",
6443 .info = alc_ch_mode_info,
6444 .get = alc_ch_mode_get,
6445 .put = alc_ch_mode_put,
6446 },
6447 { } /* end */
6448};
6449
6450static struct hda_verb alc883_init_verbs[] = {
6451 /* ADC1: mute amp left and right */
6452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6453 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6454 /* ADC2: mute amp left and right */
6455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6456 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6457 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6461 /* Rear mixer */
6462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6463 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6464 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6465 /* CLFE mixer */
6466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6469 /* Side mixer */
6470 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6472 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6473
Takashi Iwaicb53c622007-08-10 17:21:45 +02006474 /* mute analog input loopbacks */
6475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006480
6481 /* Front Pin: output 0 (0x0c) */
6482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6485 /* Rear Pin: output 1 (0x0d) */
6486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6489 /* CLFE Pin: output 2 (0x0e) */
6490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6492 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6493 /* Side Pin: output 3 (0x0f) */
6494 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6495 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6496 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6497 /* Mic (rear) pin: input vref at 80% */
6498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6500 /* Front Mic pin: input vref at 80% */
6501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6503 /* Line In pin: input */
6504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6506 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6510 /* CD pin widget for input */
6511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6512
6513 /* FIXME: use matrix-type input source selection */
6514 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6515 /* Input mixer2 */
6516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6517 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6520 /* Input mixer3 */
6521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6525 { }
6526};
6527
Kailang Yangccc656c2006-10-17 12:32:26 +02006528static struct hda_verb alc883_tagra_verbs[] = {
6529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6531
6532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6533 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6534
6535 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6536 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6538
6539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006540 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6541 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6542 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006543
6544 { } /* end */
6545};
6546
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006547static struct hda_verb alc883_lenovo_101e_verbs[] = {
6548 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6549 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6550 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6551 { } /* end */
6552};
6553
Kailang Yang272a5272007-05-14 11:00:38 +02006554static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6555 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6557 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6559 { } /* end */
6560};
6561
6562static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6563 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6565 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6566 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6567 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6568 { } /* end */
6569};
6570
Kailang Yang189609a2007-08-20 11:31:23 +02006571static struct hda_verb alc883_haier_w66_verbs[] = {
6572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6574
6575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6576
6577 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6578 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6579 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6580 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6581 { } /* end */
6582};
6583
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006584static struct hda_verb alc888_6st_hp_verbs[] = {
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02006585 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6586 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6587 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6588 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6589 { }
6590};
6591
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006592static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006593 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6594 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6595 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6596 { }
6597};
6598
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006599static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006600 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6601 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6602 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6603 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6604 { }
6605};
6606
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006607static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006608 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6609 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6610 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6611 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6612 { }
6613};
6614
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006615static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6616 { 2, alc888_3st_hp_2ch_init },
6617 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02006618};
6619
Kailang Yang272a5272007-05-14 11:00:38 +02006620/* toggle front-jack and RCA according to the hp-jack state */
6621static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6622{
6623 unsigned int present;
6624
6625 present = snd_hda_codec_read(codec, 0x1b, 0,
6626 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006627 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6628 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6629 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6630 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006631}
6632
6633/* toggle RCA according to the front-jack state */
6634static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6635{
6636 unsigned int present;
6637
6638 present = snd_hda_codec_read(codec, 0x14, 0,
6639 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006640 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6641 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006642}
Takashi Iwai47fd8302007-08-10 17:11:07 +02006643
Kailang Yang272a5272007-05-14 11:00:38 +02006644static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6645 unsigned int res)
6646{
6647 if ((res >> 26) == ALC880_HP_EVENT)
6648 alc888_lenovo_ms7195_front_automute(codec);
6649 if ((res >> 26) == ALC880_FRONT_EVENT)
6650 alc888_lenovo_ms7195_rca_automute(codec);
6651}
6652
6653static struct hda_verb alc883_medion_md2_verbs[] = {
6654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6656
6657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6658
6659 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6660 { } /* end */
6661};
6662
6663/* toggle speaker-output according to the hp-jack state */
6664static void alc883_medion_md2_automute(struct hda_codec *codec)
6665{
6666 unsigned int present;
6667
6668 present = snd_hda_codec_read(codec, 0x14, 0,
6669 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006670 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6671 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02006672}
6673
6674static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6675 unsigned int res)
6676{
6677 if ((res >> 26) == ALC880_HP_EVENT)
6678 alc883_medion_md2_automute(codec);
6679}
6680
Kailang Yangccc656c2006-10-17 12:32:26 +02006681/* toggle speaker-output according to the hp-jack state */
6682static void alc883_tagra_automute(struct hda_codec *codec)
6683{
6684 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006685 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006686
6687 present = snd_hda_codec_read(codec, 0x14, 0,
6688 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006689 bits = present ? HDA_AMP_MUTE : 0;
6690 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6691 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006692 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6693 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006694}
6695
6696static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6697{
6698 if ((res >> 26) == ALC880_HP_EVENT)
6699 alc883_tagra_automute(codec);
6700}
6701
Kailang Yang189609a2007-08-20 11:31:23 +02006702static void alc883_haier_w66_automute(struct hda_codec *codec)
6703{
6704 unsigned int present;
6705 unsigned char bits;
6706
6707 present = snd_hda_codec_read(codec, 0x1b, 0,
6708 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6709 bits = present ? 0x80 : 0;
6710 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6711 0x80, bits);
6712}
6713
6714static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
6715 unsigned int res)
6716{
6717 if ((res >> 26) == ALC880_HP_EVENT)
6718 alc883_haier_w66_automute(codec);
6719}
6720
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006721static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6722{
6723 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006724 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006725
6726 present = snd_hda_codec_read(codec, 0x14, 0,
6727 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006728 bits = present ? HDA_AMP_MUTE : 0;
6729 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6730 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006731}
6732
6733static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6734{
6735 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006736 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006737
6738 present = snd_hda_codec_read(codec, 0x1b, 0,
6739 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006740 bits = present ? HDA_AMP_MUTE : 0;
6741 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6742 HDA_AMP_MUTE, bits);
6743 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6744 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006745}
6746
6747static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6748 unsigned int res)
6749{
6750 if ((res >> 26) == ALC880_HP_EVENT)
6751 alc883_lenovo_101e_all_automute(codec);
6752 if ((res >> 26) == ALC880_FRONT_EVENT)
6753 alc883_lenovo_101e_ispeaker_automute(codec);
6754}
6755
Takashi Iwai676a9b52007-08-16 15:23:35 +02006756/* toggle speaker-output according to the hp-jack state */
6757static void alc883_acer_aspire_automute(struct hda_codec *codec)
6758{
6759 unsigned int present;
6760
6761 present = snd_hda_codec_read(codec, 0x14, 0,
6762 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6763 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6764 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6765 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
6766 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6767}
6768
6769static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
6770 unsigned int res)
6771{
6772 if ((res >> 26) == ALC880_HP_EVENT)
6773 alc883_acer_aspire_automute(codec);
6774}
6775
Kailang Yangd1a991a2007-08-15 16:21:59 +02006776static struct hda_verb alc883_acer_eapd_verbs[] = {
6777 /* HP Pin: output 0 (0x0c) */
6778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6779 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6780 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6781 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02006782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6783 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02006784 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02006785 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
6786 /* eanable EAPD on medion laptop */
6787 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6788 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02006789 /* enable unsolicited event */
6790 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02006791 { }
6792};
6793
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006794/*
6795 * generic initialization of ADC, input mixers and output mixers
6796 */
6797static struct hda_verb alc883_auto_init_verbs[] = {
6798 /*
6799 * Unmute ADC0-2 and set the default input to mic-in
6800 */
6801 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6802 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6803 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6804 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6805
Takashi Iwaicb53c622007-08-10 17:21:45 +02006806 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006807 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006808 * Note: PASD motherboards uses the Line In 2 as the input for
6809 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006810 */
6811 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006812 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6813 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6814 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6815 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006817
6818 /*
6819 * Set up output mixers (0x0c - 0x0f)
6820 */
6821 /* set vol=0 to output mixers */
6822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6826 /* set up input amps for analog loopback */
6827 /* Amp Indices: DAC = 0, mixer = 1 */
6828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6829 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6830 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6831 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6832 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6834 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6835 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6836 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6837 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6838
6839 /* FIXME: use matrix-type input source selection */
6840 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6841 /* Input mixer1 */
6842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6844 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006845 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006846 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6847 /* Input mixer2 */
6848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006851 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6853
6854 { }
6855};
6856
6857/* capture mixer elements */
6858static struct snd_kcontrol_new alc883_capture_mixer[] = {
6859 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6860 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6861 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6862 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6863 {
6864 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6865 /* The multiple "Capture Source" controls confuse alsamixer
6866 * So call somewhat different..
6867 * FIXME: the controls appear in the "playback" view!
6868 */
6869 /* .name = "Capture Source", */
6870 .name = "Input Source",
6871 .count = 2,
6872 .info = alc882_mux_enum_info,
6873 .get = alc882_mux_enum_get,
6874 .put = alc882_mux_enum_put,
6875 },
6876 { } /* end */
6877};
6878
Takashi Iwaicb53c622007-08-10 17:21:45 +02006879#ifdef CONFIG_SND_HDA_POWER_SAVE
6880#define alc883_loopbacks alc880_loopbacks
6881#endif
6882
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006883/* pcm configuration: identiacal with ALC880 */
6884#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6885#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6886#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6887#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6888
6889/*
6890 * configuration and preset
6891 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006892static const char *alc883_models[ALC883_MODEL_LAST] = {
6893 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6894 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6895 [ALC883_3ST_6ch] = "3stack-6ch",
6896 [ALC883_6ST_DIG] = "6stack-dig",
6897 [ALC883_TARGA_DIG] = "targa-dig",
6898 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006899 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02006900 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006901 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006902 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006903 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006904 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006905 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6906 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02006907 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006908 [ALC888_6ST_HP] = "6stack-hp",
6909 [ALC888_3ST_HP] = "3stack-hp",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006910 [ALC883_AUTO] = "auto",
6911};
6912
6913static struct snd_pci_quirk alc883_cfg_tbl[] = {
6914 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Tobin Davisfebe3372007-06-12 11:27:46 +02006915 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006916 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6917 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6918 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006919 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006920 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6921 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006922 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006923 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02006924 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Daniel T Chen6f3bf652007-06-08 11:39:35 +02006925 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006926 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006927 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006928 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6929 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6930 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6931 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6932 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
Takashi Iwai64ca1c22007-08-16 17:23:32 +02006933 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006934 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6935 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6936 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6937 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Kailang Yangd1a991a2007-08-15 16:21:59 +02006938 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Tobin Davis2880a862007-08-07 11:50:26 +02006939 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006940 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006941 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006942 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6943 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6944 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006945 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6946 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6947 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Claudio Matsuoka4723c022007-07-13 14:36:19 +02006948 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6949 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6950 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
Kailang Yang272a5272007-05-14 11:00:38 +02006951 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Kailang Yang189609a2007-08-20 11:31:23 +02006952 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
6953 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006954 {}
6955};
6956
6957static struct alc_config_preset alc883_presets[] = {
6958 [ALC883_3ST_2ch_DIG] = {
6959 .mixers = { alc883_3ST_2ch_mixer },
6960 .init_verbs = { alc883_init_verbs },
6961 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6962 .dac_nids = alc883_dac_nids,
6963 .dig_out_nid = ALC883_DIGOUT_NID,
6964 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6965 .adc_nids = alc883_adc_nids,
6966 .dig_in_nid = ALC883_DIGIN_NID,
6967 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6968 .channel_mode = alc883_3ST_2ch_modes,
6969 .input_mux = &alc883_capture_source,
6970 },
6971 [ALC883_3ST_6ch_DIG] = {
6972 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6973 .init_verbs = { alc883_init_verbs },
6974 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6975 .dac_nids = alc883_dac_nids,
6976 .dig_out_nid = ALC883_DIGOUT_NID,
6977 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6978 .adc_nids = alc883_adc_nids,
6979 .dig_in_nid = ALC883_DIGIN_NID,
6980 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6981 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006982 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006983 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006984 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006985 [ALC883_3ST_6ch] = {
6986 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6987 .init_verbs = { alc883_init_verbs },
6988 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6989 .dac_nids = alc883_dac_nids,
6990 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6991 .adc_nids = alc883_adc_nids,
6992 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6993 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006994 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006995 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006996 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006997 [ALC883_6ST_DIG] = {
6998 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6999 .init_verbs = { alc883_init_verbs },
7000 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7001 .dac_nids = alc883_dac_nids,
7002 .dig_out_nid = ALC883_DIGOUT_NID,
7003 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7004 .adc_nids = alc883_adc_nids,
7005 .dig_in_nid = ALC883_DIGIN_NID,
7006 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7007 .channel_mode = alc883_sixstack_modes,
7008 .input_mux = &alc883_capture_source,
7009 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007010 [ALC883_TARGA_DIG] = {
7011 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7012 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7013 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7014 .dac_nids = alc883_dac_nids,
7015 .dig_out_nid = ALC883_DIGOUT_NID,
7016 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7017 .adc_nids = alc883_adc_nids,
7018 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7019 .channel_mode = alc883_3ST_6ch_modes,
7020 .need_dac_fix = 1,
7021 .input_mux = &alc883_capture_source,
7022 .unsol_event = alc883_tagra_unsol_event,
7023 .init_hook = alc883_tagra_automute,
7024 },
7025 [ALC883_TARGA_2ch_DIG] = {
7026 .mixers = { alc883_tagra_2ch_mixer},
7027 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7028 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7029 .dac_nids = alc883_dac_nids,
7030 .dig_out_nid = ALC883_DIGOUT_NID,
7031 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7032 .adc_nids = alc883_adc_nids,
7033 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7034 .channel_mode = alc883_3ST_2ch_modes,
7035 .input_mux = &alc883_capture_source,
7036 .unsol_event = alc883_tagra_unsol_event,
7037 .init_hook = alc883_tagra_automute,
7038 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007039 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007040 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02007041 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7042 * and the headphone jack. Turn this on and rely on the
7043 * standard mute methods whenever the user wants to turn
7044 * these outputs off.
7045 */
7046 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7047 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7048 .dac_nids = alc883_dac_nids,
7049 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7050 .adc_nids = alc883_adc_nids,
7051 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7052 .channel_mode = alc883_3ST_2ch_modes,
7053 .input_mux = &alc883_capture_source,
7054 },
Tobin Davis2880a862007-08-07 11:50:26 +02007055 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007056 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02007057 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02007058 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7059 .dac_nids = alc883_dac_nids,
7060 .dig_out_nid = ALC883_DIGOUT_NID,
7061 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7062 .adc_nids = alc883_adc_nids,
7063 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7064 .channel_mode = alc883_3ST_2ch_modes,
7065 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02007066 .unsol_event = alc883_acer_aspire_unsol_event,
7067 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02007068 },
Tobin Davisc07584c2006-10-13 12:32:16 +02007069 [ALC883_MEDION] = {
7070 .mixers = { alc883_fivestack_mixer,
7071 alc883_chmode_mixer },
7072 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007073 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02007074 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7075 .dac_nids = alc883_dac_nids,
7076 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7077 .adc_nids = alc883_adc_nids,
7078 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7079 .channel_mode = alc883_sixstack_modes,
7080 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007081 },
Kailang Yang272a5272007-05-14 11:00:38 +02007082 [ALC883_MEDION_MD2] = {
7083 .mixers = { alc883_medion_md2_mixer},
7084 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7086 .dac_nids = alc883_dac_nids,
7087 .dig_out_nid = ALC883_DIGOUT_NID,
7088 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7089 .adc_nids = alc883_adc_nids,
7090 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7091 .channel_mode = alc883_3ST_2ch_modes,
7092 .input_mux = &alc883_capture_source,
7093 .unsol_event = alc883_medion_md2_unsol_event,
7094 .init_hook = alc883_medion_md2_automute,
7095 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007096 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02007097 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007098 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7099 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7100 .dac_nids = alc883_dac_nids,
7101 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7102 .adc_nids = alc883_adc_nids,
7103 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7104 .channel_mode = alc883_3ST_2ch_modes,
7105 .input_mux = &alc883_capture_source,
7106 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007107 [ALC883_LENOVO_101E_2ch] = {
7108 .mixers = { alc883_lenovo_101e_2ch_mixer},
7109 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7110 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7111 .dac_nids = alc883_dac_nids,
7112 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7113 .adc_nids = alc883_adc_nids,
7114 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7115 .channel_mode = alc883_3ST_2ch_modes,
7116 .input_mux = &alc883_lenovo_101e_capture_source,
7117 .unsol_event = alc883_lenovo_101e_unsol_event,
7118 .init_hook = alc883_lenovo_101e_all_automute,
7119 },
Kailang Yang272a5272007-05-14 11:00:38 +02007120 [ALC883_LENOVO_NB0763] = {
7121 .mixers = { alc883_lenovo_nb0763_mixer },
7122 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7123 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7124 .dac_nids = alc883_dac_nids,
7125 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7126 .adc_nids = alc883_adc_nids,
7127 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7128 .channel_mode = alc883_3ST_2ch_modes,
7129 .need_dac_fix = 1,
7130 .input_mux = &alc883_lenovo_nb0763_capture_source,
7131 .unsol_event = alc883_medion_md2_unsol_event,
7132 .init_hook = alc883_medion_md2_automute,
7133 },
7134 [ALC888_LENOVO_MS7195_DIG] = {
7135 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7136 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7138 .dac_nids = alc883_dac_nids,
7139 .dig_out_nid = ALC883_DIGOUT_NID,
7140 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7141 .adc_nids = alc883_adc_nids,
7142 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7143 .channel_mode = alc883_3ST_6ch_modes,
7144 .need_dac_fix = 1,
7145 .input_mux = &alc883_capture_source,
7146 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7147 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02007148 },
7149 [ALC883_HAIER_W66] = {
7150 .mixers = { alc883_tagra_2ch_mixer},
7151 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7152 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7153 .dac_nids = alc883_dac_nids,
7154 .dig_out_nid = ALC883_DIGOUT_NID,
7155 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7156 .adc_nids = alc883_adc_nids,
7157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7158 .channel_mode = alc883_3ST_2ch_modes,
7159 .input_mux = &alc883_capture_source,
7160 .unsol_event = alc883_haier_w66_unsol_event,
7161 .init_hook = alc883_haier_w66_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02007162 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007163 [ALC888_6ST_HP] = {
7164 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7165 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
Claudio Matsuokacd1e3b42007-07-06 12:10:01 +02007166 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7167 .dac_nids = alc883_dac_nids,
7168 .dig_out_nid = ALC883_DIGOUT_NID,
7169 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7170 .adc_nids = alc883_adc_nids,
7171 .dig_in_nid = ALC883_DIGIN_NID,
7172 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7173 .channel_mode = alc883_sixstack_modes,
7174 .input_mux = &alc883_capture_source,
7175 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007176 [ALC888_3ST_HP] = {
7177 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7178 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007179 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7180 .dac_nids = alc883_dac_nids,
7181 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7182 .adc_nids = alc883_adc_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007183 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7184 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007185 .need_dac_fix = 1,
7186 .input_mux = &alc883_capture_source,
7187 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007188};
7189
7190
7191/*
7192 * BIOS auto configuration
7193 */
7194static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7195 hda_nid_t nid, int pin_type,
7196 int dac_idx)
7197{
7198 /* set as output */
7199 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007200 int idx;
7201
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007202 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7203 idx = 4;
7204 else
7205 idx = spec->multiout.dac_nids[dac_idx] - 2;
7206
7207 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7208 pin_type);
7209 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7210 AMP_OUT_UNMUTE);
7211 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7212
7213}
7214
7215static void alc883_auto_init_multi_out(struct hda_codec *codec)
7216{
7217 struct alc_spec *spec = codec->spec;
7218 int i;
7219
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007220 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007221 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007222 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007223 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007224 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007225 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007226 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007227 }
7228}
7229
7230static void alc883_auto_init_hp_out(struct hda_codec *codec)
7231{
7232 struct alc_spec *spec = codec->spec;
7233 hda_nid_t pin;
7234
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007235 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007236 if (pin) /* connect to front */
7237 /* use dac 0 */
7238 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7239}
7240
7241#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7242#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7243
7244static void alc883_auto_init_analog_input(struct hda_codec *codec)
7245{
7246 struct alc_spec *spec = codec->spec;
7247 int i;
7248
7249 for (i = 0; i < AUTO_PIN_LAST; i++) {
7250 hda_nid_t nid = spec->autocfg.input_pins[i];
7251 if (alc883_is_input_pin(nid)) {
7252 snd_hda_codec_write(codec, nid, 0,
7253 AC_VERB_SET_PIN_WIDGET_CONTROL,
7254 (i <= AUTO_PIN_FRONT_MIC ?
7255 PIN_VREF80 : PIN_IN));
7256 if (nid != ALC883_PIN_CD_NID)
7257 snd_hda_codec_write(codec, nid, 0,
7258 AC_VERB_SET_AMP_GAIN_MUTE,
7259 AMP_OUT_MUTE);
7260 }
7261 }
7262}
7263
7264/* almost identical with ALC880 parser... */
7265static int alc883_parse_auto_config(struct hda_codec *codec)
7266{
7267 struct alc_spec *spec = codec->spec;
7268 int err = alc880_parse_auto_config(codec);
7269
7270 if (err < 0)
7271 return err;
7272 else if (err > 0)
7273 /* hack - override the init verbs */
7274 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007275 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7276 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007277 return err;
7278}
7279
7280/* additional initialization for auto-configuration model */
7281static void alc883_auto_init(struct hda_codec *codec)
7282{
7283 alc883_auto_init_multi_out(codec);
7284 alc883_auto_init_hp_out(codec);
7285 alc883_auto_init_analog_input(codec);
7286}
7287
7288static int patch_alc883(struct hda_codec *codec)
7289{
7290 struct alc_spec *spec;
7291 int err, board_config;
7292
7293 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7294 if (spec == NULL)
7295 return -ENOMEM;
7296
7297 codec->spec = spec;
7298
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007299 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7300 alc883_models,
7301 alc883_cfg_tbl);
7302 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007303 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7304 "trying auto-probe from BIOS...\n");
7305 board_config = ALC883_AUTO;
7306 }
7307
7308 if (board_config == ALC883_AUTO) {
7309 /* automatic parse from the BIOS config */
7310 err = alc883_parse_auto_config(codec);
7311 if (err < 0) {
7312 alc_free(codec);
7313 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007314 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007315 printk(KERN_INFO
7316 "hda_codec: Cannot set up configuration "
7317 "from BIOS. Using base mode...\n");
7318 board_config = ALC883_3ST_2ch_DIG;
7319 }
7320 }
7321
7322 if (board_config != ALC883_AUTO)
7323 setup_preset(spec, &alc883_presets[board_config]);
7324
7325 spec->stream_name_analog = "ALC883 Analog";
7326 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7327 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7328
7329 spec->stream_name_digital = "ALC883 Digital";
7330 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7331 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7332
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007333 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007334 spec->adc_nids = alc883_adc_nids;
7335 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7336 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007337
7338 codec->patch_ops = alc_patch_ops;
7339 if (board_config == ALC883_AUTO)
7340 spec->init_hook = alc883_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007341#ifdef CONFIG_SND_HDA_POWER_SAVE
7342 if (!spec->loopback.amplist)
7343 spec->loopback.amplist = alc883_loopbacks;
7344#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007345
7346 return 0;
7347}
7348
7349/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007350 * ALC262 support
7351 */
7352
7353#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7354#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7355
7356#define alc262_dac_nids alc260_dac_nids
7357#define alc262_adc_nids alc882_adc_nids
7358#define alc262_adc_nids_alt alc882_adc_nids_alt
7359
7360#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01007361#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01007362
7363static struct snd_kcontrol_new alc262_base_mixer[] = {
7364 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7365 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7366 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7367 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7368 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7369 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7370 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7371 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007372 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007373 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007375 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007376 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7377 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7378 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7379 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7380 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7381 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01007382 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01007383};
7384
Kailang Yangccc656c2006-10-17 12:32:26 +02007385static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7386 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7387 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7388 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7389 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7390 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7391 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007394 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007395 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7396 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007397 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007398 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7399 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7400 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7402 { } /* end */
7403};
7404
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007405static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7407 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7408 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7409 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7410 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7411
7412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007415 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7416 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007417 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007418 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7419 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7420 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7421 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7422 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7423 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7424 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7425 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7426 { } /* end */
7427};
7428
Kailang Yangcd7509a2007-01-26 18:33:17 +01007429static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7430 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7431 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7432 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7433 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7434 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7435 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7436 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7437 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007438 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007439 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7440 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7441 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7442 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7443 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7444 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7445 { } /* end */
7446};
7447
7448static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7449 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7450 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01007451 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007452 { } /* end */
7453};
7454
Takashi Iwai532d5382007-07-27 19:02:40 +02007455static struct hda_bind_ctls alc262_sony_bind_sw = {
7456 .ops = &snd_hda_bind_sw,
7457 .values = {
7458 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7459 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7460 0,
7461 },
7462};
Takashi Iwai5b319542007-07-26 11:49:22 +02007463
Kailang Yang272a5272007-05-14 11:00:38 +02007464static struct snd_kcontrol_new alc262_sony_mixer[] = {
7465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai532d5382007-07-27 19:02:40 +02007466 HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
Kailang Yang272a5272007-05-14 11:00:38 +02007467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7469 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7470 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7471 { } /* end */
7472};
7473
Kailang Yang83c34212007-07-05 11:43:05 +02007474static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7475 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7476 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7477 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7479 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7480 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7481 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7482 { } /* end */
7483};
Kailang Yang272a5272007-05-14 11:00:38 +02007484
Kailang Yangdf694da2005-12-05 19:42:22 +01007485#define alc262_capture_mixer alc882_capture_mixer
7486#define alc262_capture_alt_mixer alc882_capture_alt_mixer
7487
7488/*
7489 * generic initialization of ADC, input mixers and output mixers
7490 */
7491static struct hda_verb alc262_init_verbs[] = {
7492 /*
7493 * Unmute ADC0-2 and set the default input to mic-in
7494 */
7495 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7497 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7498 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7499 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7500 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7501
Takashi Iwaicb53c622007-08-10 17:21:45 +02007502 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007503 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007504 * Note: PASD motherboards uses the Line In 2 as the input for
7505 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007506 */
7507 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007513
7514 /*
7515 * Set up output mixers (0x0c - 0x0e)
7516 */
7517 /* set vol=0 to output mixers */
7518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7521 /* set up input amps for analog loopback */
7522 /* Amp Indices: DAC = 0, mixer = 1 */
7523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7526 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7529
7530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7532 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7533 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7534 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7536
7537 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7540 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7542
7543 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7544 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7545
7546 /* FIXME: use matrix-type input source selection */
7547 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7548 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7549 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7550 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7551 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7552 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7553 /* Input mixer2 */
7554 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7555 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7557 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7558 /* Input mixer3 */
7559 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7560 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01007563
7564 { }
7565};
7566
Kailang Yangccc656c2006-10-17 12:32:26 +02007567static struct hda_verb alc262_hippo_unsol_verbs[] = {
7568 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7570 {}
7571};
7572
7573static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7574 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7575 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7576 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7577
7578 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7580 {}
7581};
7582
Kailang Yang272a5272007-05-14 11:00:38 +02007583static struct hda_verb alc262_sony_unsol_verbs[] = {
7584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7586 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7587
7588 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7590};
7591
Kailang Yangccc656c2006-10-17 12:32:26 +02007592/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02007593static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007594{
7595 struct alc_spec *spec = codec->spec;
7596 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007597 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007598
Takashi Iwai5b319542007-07-26 11:49:22 +02007599 /* need to execute and sync at first */
7600 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7601 present = snd_hda_codec_read(codec, 0x15, 0,
7602 AC_VERB_GET_PIN_SENSE, 0);
7603 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02007604 if (spec->jack_present) {
7605 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007606 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7607 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02007608 } else {
7609 /* unmute internal speaker if necessary */
7610 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007611 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7612 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02007613 }
7614}
7615
7616/* unsolicited event for HP jack sensing */
7617static void alc262_hippo_unsol_event(struct hda_codec *codec,
7618 unsigned int res)
7619{
7620 if ((res >> 26) != ALC880_HP_EVENT)
7621 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007622 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007623}
7624
Takashi Iwai5b319542007-07-26 11:49:22 +02007625static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02007626{
Kailang Yangccc656c2006-10-17 12:32:26 +02007627 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02007628 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02007629
Takashi Iwai5b319542007-07-26 11:49:22 +02007630 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7631 present = snd_hda_codec_read(codec, 0x1b, 0,
7632 AC_VERB_GET_PIN_SENSE, 0);
7633 present = (present & 0x80000000) != 0;
7634 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007635 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007636 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7637 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02007638 } else {
7639 /* unmute internal speaker if necessary */
7640 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007641 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7642 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02007643 }
7644}
7645
7646/* unsolicited event for HP jack sensing */
7647static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7648 unsigned int res)
7649{
7650 if ((res >> 26) != ALC880_HP_EVENT)
7651 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02007652 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02007653}
7654
Takashi Iwai834be882006-03-01 14:16:17 +01007655/*
7656 * fujitsu model
7657 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7658 */
7659
7660#define ALC_HP_EVENT 0x37
7661
7662static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7663 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7665 {}
7666};
7667
7668static struct hda_input_mux alc262_fujitsu_capture_source = {
7669 .num_items = 2,
7670 .items = {
7671 { "Mic", 0x0 },
7672 { "CD", 0x4 },
7673 },
7674};
7675
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007676static struct hda_input_mux alc262_HP_capture_source = {
7677 .num_items = 5,
7678 .items = {
7679 { "Mic", 0x0 },
7680 { "Front Mic", 0x3 },
7681 { "Line", 0x2 },
7682 { "CD", 0x4 },
7683 { "AUX IN", 0x6 },
7684 },
7685};
7686
Takashi Iwai834be882006-03-01 14:16:17 +01007687/* mute/unmute internal speaker according to the hp jack and mute state */
7688static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7689{
7690 struct alc_spec *spec = codec->spec;
7691 unsigned int mute;
7692
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007693 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007694 unsigned int present;
7695 /* need to execute and sync at first */
7696 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7697 present = snd_hda_codec_read(codec, 0x14, 0,
7698 AC_VERB_GET_PIN_SENSE, 0);
7699 spec->jack_present = (present & 0x80000000) != 0;
7700 spec->sense_updated = 1;
7701 }
7702 if (spec->jack_present) {
7703 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02007704 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7705 HDA_AMP_MUTE, HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01007706 } else {
7707 /* unmute internal speaker if necessary */
7708 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02007709 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7710 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01007711 }
7712}
7713
7714/* unsolicited event for HP jack sensing */
7715static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7716 unsigned int res)
7717{
7718 if ((res >> 26) != ALC_HP_EVENT)
7719 return;
7720 alc262_fujitsu_automute(codec, 1);
7721}
7722
7723/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02007724static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7725 .ops = &snd_hda_bind_vol,
7726 .values = {
7727 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7728 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7729 0
7730 },
7731};
Takashi Iwai834be882006-03-01 14:16:17 +01007732
7733/* bind hp and internal speaker mute (with plug check) */
7734static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7735 struct snd_ctl_elem_value *ucontrol)
7736{
7737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7738 long *valp = ucontrol->value.integer.value;
7739 int change;
7740
7741 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02007742 HDA_AMP_MUTE,
7743 valp[0] ? 0 : HDA_AMP_MUTE);
Takashi Iwai834be882006-03-01 14:16:17 +01007744 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02007745 HDA_AMP_MUTE,
7746 valp[1] ? 0 : HDA_AMP_MUTE);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007747 if (change)
7748 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01007749 return change;
7750}
7751
7752static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02007753 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01007754 {
7755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7756 .name = "Master Playback Switch",
7757 .info = snd_hda_mixer_amp_switch_info,
7758 .get = snd_hda_mixer_amp_switch_get,
7759 .put = alc262_fujitsu_master_sw_put,
7760 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7761 },
7762 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7763 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7764 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7767 { } /* end */
7768};
7769
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007770/* additional init verbs for Benq laptops */
7771static struct hda_verb alc262_EAPD_verbs[] = {
7772 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7773 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7774 {}
7775};
7776
Kailang Yang83c34212007-07-05 11:43:05 +02007777static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7778 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7780
7781 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7782 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7783 {}
7784};
7785
Kailang Yangdf694da2005-12-05 19:42:22 +01007786/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007787static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7788 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007789{
7790 hda_nid_t nid;
7791 int err;
7792
7793 spec->multiout.num_dacs = 1; /* only use one dac */
7794 spec->multiout.dac_nids = spec->private_dac_nids;
7795 spec->multiout.dac_nids[0] = 2;
7796
7797 nid = cfg->line_out_pins[0];
7798 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007799 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7800 "Front Playback Volume",
7801 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7802 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007803 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007804 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7805 "Front Playback Switch",
7806 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7807 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007808 return err;
7809 }
7810
Takashi Iwai82bc9552006-03-21 11:24:42 +01007811 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007812 if (nid) {
7813 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007814 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7815 "Speaker Playback Volume",
7816 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7817 HDA_OUTPUT));
7818 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007819 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007820 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7821 "Speaker Playback Switch",
7822 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7823 HDA_OUTPUT));
7824 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007825 return err;
7826 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007827 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7828 "Speaker Playback Switch",
7829 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7830 HDA_OUTPUT));
7831 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007832 return err;
7833 }
7834 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007835 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007836 if (nid) {
7837 /* spec->multiout.hp_nid = 2; */
7838 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007839 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7840 "Headphone Playback Volume",
7841 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7842 HDA_OUTPUT));
7843 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007844 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007845 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7846 "Headphone Playback Switch",
7847 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7848 HDA_OUTPUT));
7849 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007850 return err;
7851 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007852 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7853 "Headphone Playback Switch",
7854 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7855 HDA_OUTPUT));
7856 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007857 return err;
7858 }
7859 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007860 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007861}
7862
7863/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007864#define alc262_auto_create_analog_input_ctls \
7865 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007866
7867/*
7868 * generic initialization of ADC, input mixers and output mixers
7869 */
7870static struct hda_verb alc262_volume_init_verbs[] = {
7871 /*
7872 * Unmute ADC0-2 and set the default input to mic-in
7873 */
7874 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7876 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7878 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7880
Takashi Iwaicb53c622007-08-10 17:21:45 +02007881 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007882 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007883 * Note: PASD motherboards uses the Line In 2 as the input for
7884 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007885 */
7886 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7891 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007892
7893 /*
7894 * Set up output mixers (0x0c - 0x0f)
7895 */
7896 /* set vol=0 to output mixers */
7897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7900
7901 /* set up input amps for analog loopback */
7902 /* Amp Indices: DAC = 0, mixer = 1 */
7903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7907 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7909
7910 /* FIXME: use matrix-type input source selection */
7911 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7912 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7913 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7914 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7915 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7916 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7917 /* Input mixer2 */
7918 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7919 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7920 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7921 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7922 /* Input mixer3 */
7923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7924 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7927
7928 { }
7929};
7930
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007931static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7932 /*
7933 * Unmute ADC0-2 and set the default input to mic-in
7934 */
7935 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7937 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7938 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7939 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7940 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7941
Takashi Iwaicb53c622007-08-10 17:21:45 +02007942 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007943 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007944 * Note: PASD motherboards uses the Line In 2 as the input for
7945 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007946 */
7947 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007955
7956 /*
7957 * Set up output mixers (0x0c - 0x0e)
7958 */
7959 /* set vol=0 to output mixers */
7960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7963
7964 /* set up input amps for analog loopback */
7965 /* Amp Indices: DAC = 0, mixer = 1 */
7966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7968 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7969 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7970 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7971 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7972
7973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7975 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7976
7977 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7979
7980 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7982
7983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7987 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7988
7989 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7992 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7993 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7994 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7995
7996
7997 /* FIXME: use matrix-type input source selection */
7998 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7999 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8000 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8001 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8002 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8003 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8004 /* Input mixer2 */
8005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8009 /* Input mixer3 */
8010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8014
8015 { }
8016};
8017
Kailang Yangcd7509a2007-01-26 18:33:17 +01008018static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8019 /*
8020 * Unmute ADC0-2 and set the default input to mic-in
8021 */
8022 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8024 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8025 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8026 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8027 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8028
Takashi Iwaicb53c622007-08-10 17:21:45 +02008029 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01008030 * mixer widget
8031 * Note: PASD motherboards uses the Line In 2 as the input for front
8032 * panel mic (mic 2)
8033 */
8034 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01008043 /*
8044 * Set up output mixers (0x0c - 0x0e)
8045 */
8046 /* set vol=0 to output mixers */
8047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8050
8051 /* set up input amps for analog loopback */
8052 /* Amp Indices: DAC = 0, mixer = 1 */
8053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8059
8060
8061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8062 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8063 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8064 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8066 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8067 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8068
8069 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8071
8072 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8074
8075 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8076 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8077 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8079 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8080 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8081
8082 /* FIXME: use matrix-type input source selection */
8083 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8084 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8085 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8090 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8091 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8092 /* Input mixer2 */
8093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8098 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8100 /* Input mixer3 */
8101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8106 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8108
8109 { }
8110};
8111
Takashi Iwaicb53c622007-08-10 17:21:45 +02008112#ifdef CONFIG_SND_HDA_POWER_SAVE
8113#define alc262_loopbacks alc880_loopbacks
8114#endif
8115
Kailang Yangdf694da2005-12-05 19:42:22 +01008116/* pcm configuration: identiacal with ALC880 */
8117#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8118#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8119#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8120#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8121
8122/*
8123 * BIOS auto configuration
8124 */
8125static int alc262_parse_auto_config(struct hda_codec *codec)
8126{
8127 struct alc_spec *spec = codec->spec;
8128 int err;
8129 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8130
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008131 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8132 alc262_ignore);
8133 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008134 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008135 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008136 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008137 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8138 if (err < 0)
8139 return err;
8140 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8141 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008142 return err;
8143
8144 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8145
8146 if (spec->autocfg.dig_out_pin)
8147 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8148 if (spec->autocfg.dig_in_pin)
8149 spec->dig_in_nid = ALC262_DIGIN_NID;
8150
8151 if (spec->kctl_alloc)
8152 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8153
8154 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008155 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008156 spec->input_mux = &spec->private_imux;
8157
8158 return 1;
8159}
8160
8161#define alc262_auto_init_multi_out alc882_auto_init_multi_out
8162#define alc262_auto_init_hp_out alc882_auto_init_hp_out
8163#define alc262_auto_init_analog_input alc882_auto_init_analog_input
8164
8165
8166/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008167static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01008168{
Kailang Yangdf694da2005-12-05 19:42:22 +01008169 alc262_auto_init_multi_out(codec);
8170 alc262_auto_init_hp_out(codec);
8171 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01008172}
8173
8174/*
8175 * configuration and preset
8176 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008177static const char *alc262_models[ALC262_MODEL_LAST] = {
8178 [ALC262_BASIC] = "basic",
8179 [ALC262_HIPPO] = "hippo",
8180 [ALC262_HIPPO_1] = "hippo_1",
8181 [ALC262_FUJITSU] = "fujitsu",
8182 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01008183 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008184 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02008185 [ALC262_BENQ_T31] = "benq-t31",
8186 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008187 [ALC262_AUTO] = "auto",
8188};
8189
8190static struct snd_pci_quirk alc262_cfg_tbl[] = {
8191 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
8192 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
8193 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008194 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
8195 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008196 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008197 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008198 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02008199 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008200 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
8201 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
8202 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
8203 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
8204 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
8205 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
8206 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
8207 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008208 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
8209 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
8210 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
8211 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +02008212 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwai5b319542007-07-26 11:49:22 +02008213 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yang272a5272007-05-14 11:00:38 +02008214 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8215 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8216 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01008217 {}
8218};
8219
8220static struct alc_config_preset alc262_presets[] = {
8221 [ALC262_BASIC] = {
8222 .mixers = { alc262_base_mixer },
8223 .init_verbs = { alc262_init_verbs },
8224 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8225 .dac_nids = alc262_dac_nids,
8226 .hp_nid = 0x03,
8227 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8228 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01008229 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01008230 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008231 [ALC262_HIPPO] = {
8232 .mixers = { alc262_base_mixer },
8233 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8234 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8235 .dac_nids = alc262_dac_nids,
8236 .hp_nid = 0x03,
8237 .dig_out_nid = ALC262_DIGOUT_NID,
8238 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8239 .channel_mode = alc262_modes,
8240 .input_mux = &alc262_capture_source,
8241 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008242 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008243 },
8244 [ALC262_HIPPO_1] = {
8245 .mixers = { alc262_hippo1_mixer },
8246 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8247 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8248 .dac_nids = alc262_dac_nids,
8249 .hp_nid = 0x02,
8250 .dig_out_nid = ALC262_DIGOUT_NID,
8251 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8252 .channel_mode = alc262_modes,
8253 .input_mux = &alc262_capture_source,
8254 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008255 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02008256 },
Takashi Iwai834be882006-03-01 14:16:17 +01008257 [ALC262_FUJITSU] = {
8258 .mixers = { alc262_fujitsu_mixer },
8259 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8260 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8261 .dac_nids = alc262_dac_nids,
8262 .hp_nid = 0x03,
8263 .dig_out_nid = ALC262_DIGOUT_NID,
8264 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8265 .channel_mode = alc262_modes,
8266 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008267 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01008268 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008269 [ALC262_HP_BPC] = {
8270 .mixers = { alc262_HP_BPC_mixer },
8271 .init_verbs = { alc262_HP_BPC_init_verbs },
8272 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8273 .dac_nids = alc262_dac_nids,
8274 .hp_nid = 0x03,
8275 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8276 .channel_mode = alc262_modes,
8277 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008278 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008279 [ALC262_HP_BPC_D7000_WF] = {
8280 .mixers = { alc262_HP_BPC_WildWest_mixer },
8281 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8282 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8283 .dac_nids = alc262_dac_nids,
8284 .hp_nid = 0x03,
8285 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8286 .channel_mode = alc262_modes,
8287 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008288 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008289 [ALC262_HP_BPC_D7000_WL] = {
8290 .mixers = { alc262_HP_BPC_WildWest_mixer,
8291 alc262_HP_BPC_WildWest_option_mixer },
8292 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8293 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8294 .dac_nids = alc262_dac_nids,
8295 .hp_nid = 0x03,
8296 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8297 .channel_mode = alc262_modes,
8298 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008299 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02008300 [ALC262_BENQ_ED8] = {
8301 .mixers = { alc262_base_mixer },
8302 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8303 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8304 .dac_nids = alc262_dac_nids,
8305 .hp_nid = 0x03,
8306 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8307 .channel_mode = alc262_modes,
8308 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008309 },
Kailang Yang272a5272007-05-14 11:00:38 +02008310 [ALC262_SONY_ASSAMD] = {
8311 .mixers = { alc262_sony_mixer },
8312 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8313 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8314 .dac_nids = alc262_dac_nids,
8315 .hp_nid = 0x02,
8316 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8317 .channel_mode = alc262_modes,
8318 .input_mux = &alc262_capture_source,
8319 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008320 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +02008321 },
8322 [ALC262_BENQ_T31] = {
8323 .mixers = { alc262_benq_t31_mixer },
8324 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8325 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8326 .dac_nids = alc262_dac_nids,
8327 .hp_nid = 0x03,
8328 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8329 .channel_mode = alc262_modes,
8330 .input_mux = &alc262_capture_source,
8331 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +02008332 .init_hook = alc262_hippo_automute,
Kailang Yang272a5272007-05-14 11:00:38 +02008333 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008334};
8335
8336static int patch_alc262(struct hda_codec *codec)
8337{
8338 struct alc_spec *spec;
8339 int board_config;
8340 int err;
8341
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008342 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008343 if (spec == NULL)
8344 return -ENOMEM;
8345
8346 codec->spec = spec;
8347#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008348 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8349 * under-run
8350 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008351 {
8352 int tmp;
8353 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8354 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8355 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8356 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8357 }
8358#endif
8359
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008360 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8361 alc262_models,
8362 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01008363
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008364 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008365 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8366 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008367 board_config = ALC262_AUTO;
8368 }
8369
8370 if (board_config == ALC262_AUTO) {
8371 /* automatic parse from the BIOS config */
8372 err = alc262_parse_auto_config(codec);
8373 if (err < 0) {
8374 alc_free(codec);
8375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008376 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008377 printk(KERN_INFO
8378 "hda_codec: Cannot set up configuration "
8379 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008380 board_config = ALC262_BASIC;
8381 }
8382 }
8383
8384 if (board_config != ALC262_AUTO)
8385 setup_preset(spec, &alc262_presets[board_config]);
8386
8387 spec->stream_name_analog = "ALC262 Analog";
8388 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8389 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8390
8391 spec->stream_name_digital = "ALC262 Digital";
8392 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8393 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8394
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008395 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008396 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01008397 unsigned int wcap = get_wcaps(codec, 0x07);
8398
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008399 /* get type */
8400 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01008401 if (wcap != AC_WID_AUD_IN) {
8402 spec->adc_nids = alc262_adc_nids_alt;
8403 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008404 spec->mixers[spec->num_mixers] =
8405 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01008406 spec->num_mixers++;
8407 } else {
8408 spec->adc_nids = alc262_adc_nids;
8409 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8410 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8411 spec->num_mixers++;
8412 }
8413 }
8414
8415 codec->patch_ops = alc_patch_ops;
8416 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008417 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02008418#ifdef CONFIG_SND_HDA_POWER_SAVE
8419 if (!spec->loopback.amplist)
8420 spec->loopback.amplist = alc262_loopbacks;
8421#endif
Takashi Iwai834be882006-03-01 14:16:17 +01008422
Kailang Yangdf694da2005-12-05 19:42:22 +01008423 return 0;
8424}
8425
Kailang Yangdf694da2005-12-05 19:42:22 +01008426/*
Kailang Yanga361d842007-06-05 12:30:55 +02008427 * ALC268 channel source setting (2 channel)
8428 */
8429#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8430#define alc268_modes alc260_modes
8431
8432static hda_nid_t alc268_dac_nids[2] = {
8433 /* front, hp */
8434 0x02, 0x03
8435};
8436
8437static hda_nid_t alc268_adc_nids[2] = {
8438 /* ADC0-1 */
8439 0x08, 0x07
8440};
8441
8442static hda_nid_t alc268_adc_nids_alt[1] = {
8443 /* ADC0 */
8444 0x08
8445};
8446
8447static struct snd_kcontrol_new alc268_base_mixer[] = {
8448 /* output mixer control */
8449 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8450 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8451 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8452 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8453 { }
8454};
8455
Kailang Yangd1a991a2007-08-15 16:21:59 +02008456static struct hda_verb alc268_eapd_verbs[] = {
8457 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8458 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8459 { }
8460};
8461
Takashi Iwaid2738092007-08-16 14:59:45 +02008462/* Toshiba specific */
8463#define alc268_toshiba_automute alc262_hippo_automute
8464
8465static struct hda_verb alc268_toshiba_verbs[] = {
8466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8467 { } /* end */
8468};
8469
8470/* Acer specific */
Takashi Iwai6bc96852007-08-17 09:02:12 +02008471/* bind volumes of both NID 0x0c and 0x0d */
8472static struct hda_bind_ctls alc268_acer_bind_master_vol = {
8473 .ops = &snd_hda_bind_vol,
8474 .values = {
8475 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
8476 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
8477 0
8478 },
8479};
8480
Takashi Iwaid2738092007-08-16 14:59:45 +02008481#define alc268_acer_master_sw_put alc262_fujitsu_master_sw_put
8482#define alc268_acer_automute alc262_fujitsu_automute
8483
8484static struct snd_kcontrol_new alc268_acer_mixer[] = {
8485 /* output mixer control */
8486 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
8487 {
8488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8489 .name = "Master Playback Switch",
8490 .info = snd_hda_mixer_amp_switch_info,
8491 .get = snd_hda_mixer_amp_switch_get,
8492 .put = alc268_acer_master_sw_put,
8493 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8494 },
8495 { }
8496};
8497
8498static struct hda_verb alc268_acer_verbs[] = {
8499 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8501
8502 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8503 { }
8504};
8505
8506/* unsolicited event for HP jack sensing */
8507static void alc268_toshiba_unsol_event(struct hda_codec *codec,
8508 unsigned int res)
8509{
8510 if ((res >> 28) != ALC880_HP_EVENT)
8511 return;
8512 alc268_toshiba_automute(codec);
8513}
8514
8515static void alc268_acer_unsol_event(struct hda_codec *codec,
8516 unsigned int res)
8517{
8518 if ((res >> 28) != ALC880_HP_EVENT)
8519 return;
8520 alc268_acer_automute(codec, 1);
8521}
8522
Kailang Yanga361d842007-06-05 12:30:55 +02008523/*
8524 * generic initialization of ADC, input mixers and output mixers
8525 */
8526static struct hda_verb alc268_base_init_verbs[] = {
8527 /* Unmute DAC0-1 and set vol = 0 */
8528 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8529 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8530 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8531 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8532 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8533 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8534
8535 /*
8536 * Set up output mixers (0x0c - 0x0e)
8537 */
8538 /* set vol=0 to output mixers */
8539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8542 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8543
8544 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8545 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8546
8547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8548 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8549 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8550 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8551 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8552 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8553 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8554 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8555
8556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8558 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8559 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8560 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8562 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8563 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8564
8565 /* FIXME: use matrix-type input source selection */
8566 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8567 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8568 /* Input mixer2 */
8569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8573
8574 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8575 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8578 { }
8579};
8580
8581/*
8582 * generic initialization of ADC, input mixers and output mixers
8583 */
8584static struct hda_verb alc268_volume_init_verbs[] = {
8585 /* set output DAC */
8586 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8587 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8588 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8589 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8590
8591 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8592 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8593 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8594 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8595 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8596
8597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8600 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8601 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8602
8603 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8604 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8606 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8607
8608 /* set PCBEEP vol = 0 */
8609 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8610
8611 { }
8612};
8613
8614#define alc268_mux_enum_info alc_mux_enum_info
8615#define alc268_mux_enum_get alc_mux_enum_get
8616
8617static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8618 struct snd_ctl_elem_value *ucontrol)
8619{
8620 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8621 struct alc_spec *spec = codec->spec;
8622 const struct hda_input_mux *imux = spec->input_mux;
8623 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8624 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8625 hda_nid_t nid = capture_mixers[adc_idx];
8626 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8627 unsigned int i, idx;
8628
8629 idx = ucontrol->value.enumerated.item[0];
8630 if (idx >= imux->num_items)
8631 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008632 if (*cur_val == idx)
Kailang Yanga361d842007-06-05 12:30:55 +02008633 return 0;
8634 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02008635 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8636 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8637 imux->items[i].index,
8638 HDA_AMP_MUTE, v);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008639 snd_hda_codec_write_cache(codec, nid, 0,
8640 AC_VERB_SET_CONNECT_SEL,
8641 idx );
Kailang Yanga361d842007-06-05 12:30:55 +02008642 }
8643 *cur_val = idx;
8644 return 1;
8645}
8646
8647static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8648 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8649 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8650 {
8651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8652 /* The multiple "Capture Source" controls confuse alsamixer
8653 * So call somewhat different..
8654 * FIXME: the controls appear in the "playback" view!
8655 */
8656 /* .name = "Capture Source", */
8657 .name = "Input Source",
8658 .count = 1,
8659 .info = alc268_mux_enum_info,
8660 .get = alc268_mux_enum_get,
8661 .put = alc268_mux_enum_put,
8662 },
8663 { } /* end */
8664};
8665
8666static struct snd_kcontrol_new alc268_capture_mixer[] = {
8667 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8668 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8669 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8670 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8671 {
8672 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8673 /* The multiple "Capture Source" controls confuse alsamixer
8674 * So call somewhat different..
8675 * FIXME: the controls appear in the "playback" view!
8676 */
8677 /* .name = "Capture Source", */
8678 .name = "Input Source",
8679 .count = 2,
8680 .info = alc268_mux_enum_info,
8681 .get = alc268_mux_enum_get,
8682 .put = alc268_mux_enum_put,
8683 },
8684 { } /* end */
8685};
8686
8687static struct hda_input_mux alc268_capture_source = {
8688 .num_items = 4,
8689 .items = {
8690 { "Mic", 0x0 },
8691 { "Front Mic", 0x1 },
8692 { "Line", 0x2 },
8693 { "CD", 0x3 },
8694 },
8695};
8696
8697/* create input playback/capture controls for the given pin */
8698static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8699 const char *ctlname, int idx)
8700{
8701 char name[32];
8702 int err;
8703
8704 sprintf(name, "%s Playback Volume", ctlname);
8705 if (nid == 0x14) {
8706 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8707 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8708 HDA_OUTPUT));
8709 if (err < 0)
8710 return err;
8711 } else if (nid == 0x15) {
8712 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8713 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8714 HDA_OUTPUT));
8715 if (err < 0)
8716 return err;
8717 } else
8718 return -1;
8719 sprintf(name, "%s Playback Switch", ctlname);
8720 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8721 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8722 if (err < 0)
8723 return err;
8724 return 0;
8725}
8726
8727/* add playback controls from the parsed DAC table */
8728static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8729 const struct auto_pin_cfg *cfg)
8730{
8731 hda_nid_t nid;
8732 int err;
8733
8734 spec->multiout.num_dacs = 2; /* only use one dac */
8735 spec->multiout.dac_nids = spec->private_dac_nids;
8736 spec->multiout.dac_nids[0] = 2;
8737 spec->multiout.dac_nids[1] = 3;
8738
8739 nid = cfg->line_out_pins[0];
8740 if (nid)
8741 alc268_new_analog_output(spec, nid, "Front", 0);
8742
8743 nid = cfg->speaker_pins[0];
8744 if (nid == 0x1d) {
8745 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8746 "Speaker Playback Volume",
8747 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8748 if (err < 0)
8749 return err;
8750 }
8751 nid = cfg->hp_pins[0];
8752 if (nid)
8753 alc268_new_analog_output(spec, nid, "Headphone", 0);
8754
8755 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8756 if (nid == 0x16) {
8757 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8758 "Mono Playback Switch",
8759 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8760 if (err < 0)
8761 return err;
8762 }
8763 return 0;
8764}
8765
8766/* create playback/capture controls for input pins */
8767static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8768 const struct auto_pin_cfg *cfg)
8769{
8770 struct hda_input_mux *imux = &spec->private_imux;
8771 int i, idx1;
8772
8773 for (i = 0; i < AUTO_PIN_LAST; i++) {
8774 switch(cfg->input_pins[i]) {
8775 case 0x18:
8776 idx1 = 0; /* Mic 1 */
8777 break;
8778 case 0x19:
8779 idx1 = 1; /* Mic 2 */
8780 break;
8781 case 0x1a:
8782 idx1 = 2; /* Line In */
8783 break;
8784 case 0x1c:
8785 idx1 = 3; /* CD */
8786 break;
8787 default:
8788 continue;
8789 }
8790 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8791 imux->items[imux->num_items].index = idx1;
8792 imux->num_items++;
8793 }
8794 return 0;
8795}
8796
8797static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8798{
8799 struct alc_spec *spec = codec->spec;
8800 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8801 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8802 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8803 unsigned int dac_vol1, dac_vol2;
8804
8805 if (speaker_nid) {
8806 snd_hda_codec_write(codec, speaker_nid, 0,
8807 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8808 snd_hda_codec_write(codec, 0x0f, 0,
8809 AC_VERB_SET_AMP_GAIN_MUTE,
8810 AMP_IN_UNMUTE(1));
8811 snd_hda_codec_write(codec, 0x10, 0,
8812 AC_VERB_SET_AMP_GAIN_MUTE,
8813 AMP_IN_UNMUTE(1));
8814 } else {
8815 snd_hda_codec_write(codec, 0x0f, 0,
8816 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8817 snd_hda_codec_write(codec, 0x10, 0,
8818 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8819 }
8820
8821 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8822 if (line_nid == 0x14)
8823 dac_vol2 = AMP_OUT_ZERO;
8824 else if (line_nid == 0x15)
8825 dac_vol1 = AMP_OUT_ZERO;
8826 if (hp_nid == 0x14)
8827 dac_vol2 = AMP_OUT_ZERO;
8828 else if (hp_nid == 0x15)
8829 dac_vol1 = AMP_OUT_ZERO;
8830 if (line_nid != 0x16 || hp_nid != 0x16 ||
8831 spec->autocfg.line_out_pins[1] != 0x16 ||
8832 spec->autocfg.line_out_pins[2] != 0x16)
8833 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8834
8835 snd_hda_codec_write(codec, 0x02, 0,
8836 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8837 snd_hda_codec_write(codec, 0x03, 0,
8838 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8839}
8840
8841/* pcm configuration: identiacal with ALC880 */
8842#define alc268_pcm_analog_playback alc880_pcm_analog_playback
8843#define alc268_pcm_analog_capture alc880_pcm_analog_capture
8844#define alc268_pcm_digital_playback alc880_pcm_digital_playback
8845
8846/*
8847 * BIOS auto configuration
8848 */
8849static int alc268_parse_auto_config(struct hda_codec *codec)
8850{
8851 struct alc_spec *spec = codec->spec;
8852 int err;
8853 static hda_nid_t alc268_ignore[] = { 0 };
8854
8855 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8856 alc268_ignore);
8857 if (err < 0)
8858 return err;
8859 if (!spec->autocfg.line_outs)
8860 return 0; /* can't find valid BIOS pin config */
8861
8862 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8863 if (err < 0)
8864 return err;
8865 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8866 if (err < 0)
8867 return err;
8868
8869 spec->multiout.max_channels = 2;
8870
8871 /* digital only support output */
8872 if (spec->autocfg.dig_out_pin)
8873 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8874
8875 if (spec->kctl_alloc)
8876 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8877
8878 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8879 spec->num_mux_defs = 1;
8880 spec->input_mux = &spec->private_imux;
8881
8882 return 1;
8883}
8884
8885#define alc268_auto_init_multi_out alc882_auto_init_multi_out
8886#define alc268_auto_init_hp_out alc882_auto_init_hp_out
8887#define alc268_auto_init_analog_input alc882_auto_init_analog_input
8888
8889/* init callback for auto-configuration model -- overriding the default init */
8890static void alc268_auto_init(struct hda_codec *codec)
8891{
8892 alc268_auto_init_multi_out(codec);
8893 alc268_auto_init_hp_out(codec);
8894 alc268_auto_init_mono_speaker_out(codec);
8895 alc268_auto_init_analog_input(codec);
8896}
8897
8898/*
8899 * configuration and preset
8900 */
8901static const char *alc268_models[ALC268_MODEL_LAST] = {
8902 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +02008903 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +02008904 [ALC268_ACER] = "acer",
Kailang Yanga361d842007-06-05 12:30:55 +02008905 [ALC268_AUTO] = "auto",
8906};
8907
8908static struct snd_pci_quirk alc268_cfg_tbl[] = {
8909 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008910 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwaid2738092007-08-16 14:59:45 +02008911 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
8912 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Kailang Yanga361d842007-06-05 12:30:55 +02008913 {}
8914};
8915
8916static struct alc_config_preset alc268_presets[] = {
8917 [ALC268_3ST] = {
8918 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8919 .init_verbs = { alc268_base_init_verbs },
8920 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8921 .dac_nids = alc268_dac_nids,
8922 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8923 .adc_nids = alc268_adc_nids_alt,
8924 .hp_nid = 0x03,
8925 .dig_out_nid = ALC268_DIGOUT_NID,
8926 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8927 .channel_mode = alc268_modes,
8928 .input_mux = &alc268_capture_source,
8929 },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008930 [ALC268_TOSHIBA] = {
8931 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +02008932 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8933 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008934 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8935 .dac_nids = alc268_dac_nids,
8936 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8937 .adc_nids = alc268_adc_nids_alt,
8938 .hp_nid = 0x03,
8939 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8940 .channel_mode = alc268_modes,
8941 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +02008942 .input_mux = &alc268_capture_source,
8943 .unsol_event = alc268_toshiba_unsol_event,
8944 .init_hook = alc268_toshiba_automute,
8945 },
8946 [ALC268_ACER] = {
8947 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
8948 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8949 alc268_acer_verbs },
8950 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8951 .dac_nids = alc268_dac_nids,
8952 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8953 .adc_nids = alc268_adc_nids_alt,
8954 .hp_nid = 0x02,
8955 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8956 .channel_mode = alc268_modes,
8957 .input_mux = &alc268_capture_source,
8958 .unsol_event = alc268_acer_unsol_event,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008959 },
Kailang Yanga361d842007-06-05 12:30:55 +02008960};
8961
8962static int patch_alc268(struct hda_codec *codec)
8963{
8964 struct alc_spec *spec;
8965 int board_config;
8966 int err;
8967
8968 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8969 if (spec == NULL)
8970 return -ENOMEM;
8971
8972 codec->spec = spec;
8973
8974 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8975 alc268_models,
8976 alc268_cfg_tbl);
8977
8978 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8979 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8980 "trying auto-probe from BIOS...\n");
8981 board_config = ALC268_AUTO;
8982 }
8983
8984 if (board_config == ALC268_AUTO) {
8985 /* automatic parse from the BIOS config */
8986 err = alc268_parse_auto_config(codec);
8987 if (err < 0) {
8988 alc_free(codec);
8989 return err;
8990 } else if (!err) {
8991 printk(KERN_INFO
8992 "hda_codec: Cannot set up configuration "
8993 "from BIOS. Using base mode...\n");
8994 board_config = ALC268_3ST;
8995 }
8996 }
8997
8998 if (board_config != ALC268_AUTO)
8999 setup_preset(spec, &alc268_presets[board_config]);
9000
9001 spec->stream_name_analog = "ALC268 Analog";
9002 spec->stream_analog_playback = &alc268_pcm_analog_playback;
9003 spec->stream_analog_capture = &alc268_pcm_analog_capture;
9004
9005 spec->stream_name_digital = "ALC268 Digital";
9006 spec->stream_digital_playback = &alc268_pcm_digital_playback;
9007
9008 if (board_config == ALC268_AUTO) {
9009 if (!spec->adc_nids && spec->input_mux) {
9010 /* check whether NID 0x07 is valid */
9011 unsigned int wcap = get_wcaps(codec, 0x07);
9012
9013 /* get type */
9014 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9015 if (wcap != AC_WID_AUD_IN) {
9016 spec->adc_nids = alc268_adc_nids_alt;
9017 spec->num_adc_nids =
9018 ARRAY_SIZE(alc268_adc_nids_alt);
9019 spec->mixers[spec->num_mixers] =
9020 alc268_capture_alt_mixer;
9021 spec->num_mixers++;
9022 } else {
9023 spec->adc_nids = alc268_adc_nids;
9024 spec->num_adc_nids =
9025 ARRAY_SIZE(alc268_adc_nids);
9026 spec->mixers[spec->num_mixers] =
9027 alc268_capture_mixer;
9028 spec->num_mixers++;
9029 }
9030 }
9031 }
9032 codec->patch_ops = alc_patch_ops;
9033 if (board_config == ALC268_AUTO)
9034 spec->init_hook = alc268_auto_init;
9035
9036 return 0;
9037}
9038
9039/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009040 * ALC861 channel source setting (2/6 channel selection for 3-stack)
9041 */
9042
9043/*
9044 * set the path ways for 2 channel output
9045 * need to set the codec line out and mic 1 pin widgets to inputs
9046 */
9047static struct hda_verb alc861_threestack_ch2_init[] = {
9048 /* set pin widget 1Ah (line in) for input */
9049 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009050 /* set pin widget 18h (mic1/2) for input, for mic also enable
9051 * the vref
9052 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009053 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9054
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009055 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9056#if 0
9057 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9058 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9059#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01009060 { } /* end */
9061};
9062/*
9063 * 6ch mode
9064 * need to set the codec line out and mic 1 pin widgets to outputs
9065 */
9066static struct hda_verb alc861_threestack_ch6_init[] = {
9067 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9068 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9069 /* set pin widget 18h (mic1) for output (CLFE)*/
9070 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9071
9072 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009073 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009074
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009075 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9076#if 0
9077 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9078 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9079#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01009080 { } /* end */
9081};
9082
9083static struct hda_channel_mode alc861_threestack_modes[2] = {
9084 { 2, alc861_threestack_ch2_init },
9085 { 6, alc861_threestack_ch6_init },
9086};
Takashi Iwai22309c32006-08-09 16:57:28 +02009087/* Set mic1 as input and unmute the mixer */
9088static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
9089 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9090 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9091 { } /* end */
9092};
9093/* Set mic1 as output and mute mixer */
9094static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
9095 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9096 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9097 { } /* end */
9098};
9099
9100static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
9101 { 2, alc861_uniwill_m31_ch2_init },
9102 { 4, alc861_uniwill_m31_ch4_init },
9103};
Kailang Yangdf694da2005-12-05 19:42:22 +01009104
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009105/* Set mic1 and line-in as input and unmute the mixer */
9106static struct hda_verb alc861_asus_ch2_init[] = {
9107 /* set pin widget 1Ah (line in) for input */
9108 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009109 /* set pin widget 18h (mic1/2) for input, for mic also enable
9110 * the vref
9111 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009112 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9113
9114 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
9115#if 0
9116 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
9117 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
9118#endif
9119 { } /* end */
9120};
9121/* Set mic1 nad line-in as output and mute mixer */
9122static struct hda_verb alc861_asus_ch6_init[] = {
9123 /* set pin widget 1Ah (line in) for output (Back Surround)*/
9124 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9125 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9126 /* set pin widget 18h (mic1) for output (CLFE)*/
9127 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9128 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
9129 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
9130 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
9131
9132 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
9133#if 0
9134 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
9135 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
9136#endif
9137 { } /* end */
9138};
9139
9140static struct hda_channel_mode alc861_asus_modes[2] = {
9141 { 2, alc861_asus_ch2_init },
9142 { 6, alc861_asus_ch6_init },
9143};
9144
Kailang Yangdf694da2005-12-05 19:42:22 +01009145/* patch-ALC861 */
9146
9147static struct snd_kcontrol_new alc861_base_mixer[] = {
9148 /* output mixer control */
9149 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9150 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9151 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9152 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9153 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9154
9155 /*Input mixer control */
9156 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9157 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9158 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9159 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9160 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9161 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9163 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009166
Kailang Yangdf694da2005-12-05 19:42:22 +01009167 /* Capture mixer control */
9168 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9169 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9170 {
9171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9172 .name = "Capture Source",
9173 .count = 1,
9174 .info = alc_mux_enum_info,
9175 .get = alc_mux_enum_get,
9176 .put = alc_mux_enum_put,
9177 },
9178 { } /* end */
9179};
9180
9181static struct snd_kcontrol_new alc861_3ST_mixer[] = {
9182 /* output mixer control */
9183 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9184 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9185 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9186 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9187 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9188
9189 /* Input mixer control */
9190 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9191 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9192 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9193 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9194 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9195 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9197 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9198 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9199 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009200
Kailang Yangdf694da2005-12-05 19:42:22 +01009201 /* Capture mixer control */
9202 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9203 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9204 {
9205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9206 .name = "Capture Source",
9207 .count = 1,
9208 .info = alc_mux_enum_info,
9209 .get = alc_mux_enum_get,
9210 .put = alc_mux_enum_put,
9211 },
9212 {
9213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9214 .name = "Channel Mode",
9215 .info = alc_ch_mode_info,
9216 .get = alc_ch_mode_get,
9217 .put = alc_ch_mode_put,
9218 .private_value = ARRAY_SIZE(alc861_threestack_modes),
9219 },
9220 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009221};
9222
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009223static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009224 /* output mixer control */
9225 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9227 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9228
9229 /*Capture mixer control */
9230 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9231 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9232 {
9233 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9234 .name = "Capture Source",
9235 .count = 1,
9236 .info = alc_mux_enum_info,
9237 .get = alc_mux_enum_get,
9238 .put = alc_mux_enum_put,
9239 },
9240
9241 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009242};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009243
Takashi Iwai22309c32006-08-09 16:57:28 +02009244static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9245 /* output mixer control */
9246 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9247 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9248 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9249 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9250 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9251
9252 /* Input mixer control */
9253 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9254 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9255 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9256 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9257 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9258 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9260 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9262 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009263
Takashi Iwai22309c32006-08-09 16:57:28 +02009264 /* Capture mixer control */
9265 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9266 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9267 {
9268 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9269 .name = "Capture Source",
9270 .count = 1,
9271 .info = alc_mux_enum_info,
9272 .get = alc_mux_enum_get,
9273 .put = alc_mux_enum_put,
9274 },
9275 {
9276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9277 .name = "Channel Mode",
9278 .info = alc_ch_mode_info,
9279 .get = alc_ch_mode_get,
9280 .put = alc_ch_mode_put,
9281 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9282 },
9283 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009284};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009285
9286static struct snd_kcontrol_new alc861_asus_mixer[] = {
9287 /* output mixer control */
9288 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9289 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9290 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9291 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9292 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9293
9294 /* Input mixer control */
9295 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9296 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9297 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9298 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9299 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9300 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9302 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9303 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9305
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009306 /* Capture mixer control */
9307 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9308 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9309 {
9310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9311 .name = "Capture Source",
9312 .count = 1,
9313 .info = alc_mux_enum_info,
9314 .get = alc_mux_enum_get,
9315 .put = alc_mux_enum_put,
9316 },
9317 {
9318 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9319 .name = "Channel Mode",
9320 .info = alc_ch_mode_info,
9321 .get = alc_ch_mode_get,
9322 .put = alc_ch_mode_put,
9323 .private_value = ARRAY_SIZE(alc861_asus_modes),
9324 },
9325 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009326};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009327
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009328/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01009329static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009330 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9331 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9332 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9333 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9334 { }
9335};
9336
Kailang Yangdf694da2005-12-05 19:42:22 +01009337/*
9338 * generic initialization of ADC, input mixers and output mixers
9339 */
9340static struct hda_verb alc861_base_init_verbs[] = {
9341 /*
9342 * Unmute ADC0 and set the default input to mic-in
9343 */
9344 /* port-A for surround (rear panel) */
9345 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9346 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9347 /* port-B for mic-in (rear panel) with vref */
9348 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9349 /* port-C for line-in (rear panel) */
9350 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9351 /* port-D for Front */
9352 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9353 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9354 /* port-E for HP out (front panel) */
9355 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9356 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009357 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009358 /* port-F for mic-in (front panel) with vref */
9359 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9360 /* port-G for CLFE (rear panel) */
9361 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9362 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9363 /* port-H for side (rear panel) */
9364 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9365 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9366 /* CD-in */
9367 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9368 /* route front mic to ADC1*/
9369 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9371
9372 /* Unmute DAC0~3 & spdif out*/
9373 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9374 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9375 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9376 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9378
9379 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9380 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9381 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9382 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9383 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9384
9385 /* Unmute Stereo Mixer 15 */
9386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009390
9391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9392 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9394 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9395 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9396 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9397 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9398 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009399 /* hp used DAC 3 (Front) */
9400 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009401 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9402
9403 { }
9404};
9405
9406static struct hda_verb alc861_threestack_init_verbs[] = {
9407 /*
9408 * Unmute ADC0 and set the default input to mic-in
9409 */
9410 /* port-A for surround (rear panel) */
9411 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9412 /* port-B for mic-in (rear panel) with vref */
9413 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9414 /* port-C for line-in (rear panel) */
9415 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9416 /* port-D for Front */
9417 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9418 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9419 /* port-E for HP out (front panel) */
9420 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9421 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009422 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01009423 /* port-F for mic-in (front panel) with vref */
9424 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9425 /* port-G for CLFE (rear panel) */
9426 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9427 /* port-H for side (rear panel) */
9428 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9429 /* CD-in */
9430 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9431 /* route front mic to ADC1*/
9432 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9433 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9434 /* Unmute DAC0~3 & spdif out*/
9435 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9436 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9437 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9438 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9440
9441 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9442 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9443 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9444 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9445 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9446
9447 /* Unmute Stereo Mixer 15 */
9448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01009452
9453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9457 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009461 /* hp used DAC 3 (Front) */
9462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009463 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9464 { }
9465};
Takashi Iwai22309c32006-08-09 16:57:28 +02009466
9467static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9468 /*
9469 * Unmute ADC0 and set the default input to mic-in
9470 */
9471 /* port-A for surround (rear panel) */
9472 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9473 /* port-B for mic-in (rear panel) with vref */
9474 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9475 /* port-C for line-in (rear panel) */
9476 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9477 /* port-D for Front */
9478 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9479 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9480 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009481 /* this has to be set to VREF80 */
9482 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009483 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009484 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02009485 /* port-F for mic-in (front panel) with vref */
9486 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9487 /* port-G for CLFE (rear panel) */
9488 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9489 /* port-H for side (rear panel) */
9490 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9491 /* CD-in */
9492 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9493 /* route front mic to ADC1*/
9494 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9495 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9496 /* Unmute DAC0~3 & spdif out*/
9497 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9498 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9499 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9500 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9502
9503 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9504 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9505 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9506 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9507 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9508
9509 /* Unmute Stereo Mixer 15 */
9510 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02009514
9515 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9516 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9518 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9521 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9522 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009523 /* hp used DAC 3 (Front) */
9524 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02009525 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9526 { }
9527};
9528
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009529static struct hda_verb alc861_asus_init_verbs[] = {
9530 /*
9531 * Unmute ADC0 and set the default input to mic-in
9532 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009533 /* port-A for surround (rear panel)
9534 * according to codec#0 this is the HP jack
9535 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009536 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9537 /* route front PCM to HP */
9538 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9539 /* port-B for mic-in (rear panel) with vref */
9540 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9541 /* port-C for line-in (rear panel) */
9542 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9543 /* port-D for Front */
9544 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9545 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9546 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009547 /* this has to be set to VREF80 */
9548 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009549 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01009550 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009551 /* port-F for mic-in (front panel) with vref */
9552 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9553 /* port-G for CLFE (rear panel) */
9554 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9555 /* port-H for side (rear panel) */
9556 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9557 /* CD-in */
9558 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9559 /* route front mic to ADC1*/
9560 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9561 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9562 /* Unmute DAC0~3 & spdif out*/
9563 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9564 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9565 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9566 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9568 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9569 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9570 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9571 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9572 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9573
9574 /* Unmute Stereo Mixer 15 */
9575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009579
9580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9581 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9583 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9585 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9586 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9587 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009588 /* hp used DAC 3 (Front) */
9589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009590 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9591 { }
9592};
9593
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01009594/* additional init verbs for ASUS laptops */
9595static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9596 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9597 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9598 { }
9599};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02009600
Kailang Yangdf694da2005-12-05 19:42:22 +01009601/*
9602 * generic initialization of ADC, input mixers and output mixers
9603 */
9604static struct hda_verb alc861_auto_init_verbs[] = {
9605 /*
9606 * Unmute ADC0 and set the default input to mic-in
9607 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009608 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01009609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9610
9611 /* Unmute DAC0~3 & spdif out*/
9612 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9613 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9614 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9615 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9617
9618 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9619 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9620 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9621 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9622 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9623
9624 /* Unmute Stereo Mixer 15 */
9625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9629
9630 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9632 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9633 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9634 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9635 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9636 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9638
9639 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009641 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9642 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009643 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9644 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009645 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009647
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009648 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009649
9650 { }
9651};
9652
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009653static struct hda_verb alc861_toshiba_init_verbs[] = {
9654 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009655
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009656 { }
9657};
9658
9659/* toggle speaker-output according to the hp-jack state */
9660static void alc861_toshiba_automute(struct hda_codec *codec)
9661{
9662 unsigned int present;
9663
9664 present = snd_hda_codec_read(codec, 0x0f, 0,
9665 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02009666 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
9667 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9668 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
9669 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009670}
9671
9672static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9673 unsigned int res)
9674{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02009675 if ((res >> 26) == ALC880_HP_EVENT)
9676 alc861_toshiba_automute(codec);
9677}
9678
Kailang Yangdf694da2005-12-05 19:42:22 +01009679/* pcm configuration: identiacal with ALC880 */
9680#define alc861_pcm_analog_playback alc880_pcm_analog_playback
9681#define alc861_pcm_analog_capture alc880_pcm_analog_capture
9682#define alc861_pcm_digital_playback alc880_pcm_digital_playback
9683#define alc861_pcm_digital_capture alc880_pcm_digital_capture
9684
9685
9686#define ALC861_DIGOUT_NID 0x07
9687
9688static struct hda_channel_mode alc861_8ch_modes[1] = {
9689 { 8, NULL }
9690};
9691
9692static hda_nid_t alc861_dac_nids[4] = {
9693 /* front, surround, clfe, side */
9694 0x03, 0x06, 0x05, 0x04
9695};
9696
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009697static hda_nid_t alc660_dac_nids[3] = {
9698 /* front, clfe, surround */
9699 0x03, 0x05, 0x06
9700};
9701
Kailang Yangdf694da2005-12-05 19:42:22 +01009702static hda_nid_t alc861_adc_nids[1] = {
9703 /* ADC0-2 */
9704 0x08,
9705};
9706
9707static struct hda_input_mux alc861_capture_source = {
9708 .num_items = 5,
9709 .items = {
9710 { "Mic", 0x0 },
9711 { "Front Mic", 0x3 },
9712 { "Line", 0x1 },
9713 { "CD", 0x4 },
9714 { "Mixer", 0x5 },
9715 },
9716};
9717
9718/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009719static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9720 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009721{
9722 int i;
9723 hda_nid_t nid;
9724
9725 spec->multiout.dac_nids = spec->private_dac_nids;
9726 for (i = 0; i < cfg->line_outs; i++) {
9727 nid = cfg->line_out_pins[i];
9728 if (nid) {
9729 if (i >= ARRAY_SIZE(alc861_dac_nids))
9730 continue;
9731 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9732 }
9733 }
9734 spec->multiout.num_dacs = cfg->line_outs;
9735 return 0;
9736}
9737
9738/* add playback controls from the parsed DAC table */
9739static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9740 const struct auto_pin_cfg *cfg)
9741{
9742 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009743 static const char *chname[4] = {
9744 "Front", "Surround", NULL /*CLFE*/, "Side"
9745 };
Kailang Yangdf694da2005-12-05 19:42:22 +01009746 hda_nid_t nid;
9747 int i, idx, err;
9748
9749 for (i = 0; i < cfg->line_outs; i++) {
9750 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009751 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01009752 continue;
9753 if (nid == 0x05) {
9754 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009755 err = add_control(spec, ALC_CTL_BIND_MUTE,
9756 "Center Playback Switch",
9757 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9758 HDA_OUTPUT));
9759 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009760 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009761 err = add_control(spec, ALC_CTL_BIND_MUTE,
9762 "LFE Playback Switch",
9763 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9764 HDA_OUTPUT));
9765 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009766 return err;
9767 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009768 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9769 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01009770 if (nid == alc861_dac_nids[idx])
9771 break;
9772 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009773 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9774 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9775 HDA_OUTPUT));
9776 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009777 return err;
9778 }
9779 }
9780 return 0;
9781}
9782
9783static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9784{
9785 int err;
9786 hda_nid_t nid;
9787
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009788 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01009789 return 0;
9790
9791 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9792 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009793 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9794 "Headphone Playback Switch",
9795 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9796 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009797 return err;
9798 spec->multiout.hp_nid = nid;
9799 }
9800 return 0;
9801}
9802
9803/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009804static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9805 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009806{
Kailang Yangdf694da2005-12-05 19:42:22 +01009807 struct hda_input_mux *imux = &spec->private_imux;
9808 int i, err, idx, idx1;
9809
9810 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009811 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01009812 case 0x0c:
9813 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009814 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009815 break;
9816 case 0x0f:
9817 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009818 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009819 break;
9820 case 0x0d:
9821 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009822 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009823 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009824 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01009825 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009826 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01009827 break;
9828 case 0x11:
9829 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009830 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01009831 break;
9832 default:
9833 continue;
9834 }
9835
Takashi Iwai4a471b72005-12-07 13:56:29 +01009836 err = new_analog_input(spec, cfg->input_pins[i],
9837 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01009838 if (err < 0)
9839 return err;
9840
Takashi Iwai4a471b72005-12-07 13:56:29 +01009841 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01009842 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009843 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01009844 }
9845 return 0;
9846}
9847
9848static struct snd_kcontrol_new alc861_capture_mixer[] = {
9849 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9850 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9851
9852 {
9853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9854 /* The multiple "Capture Source" controls confuse alsamixer
9855 * So call somewhat different..
9856 *FIXME: the controls appear in the "playback" view!
9857 */
9858 /* .name = "Capture Source", */
9859 .name = "Input Source",
9860 .count = 1,
9861 .info = alc_mux_enum_info,
9862 .get = alc_mux_enum_get,
9863 .put = alc_mux_enum_put,
9864 },
9865 { } /* end */
9866};
9867
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009868static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9869 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01009870 int pin_type, int dac_idx)
9871{
9872 /* set as output */
9873
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009874 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9875 pin_type);
9876 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9877 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01009878
9879}
9880
9881static void alc861_auto_init_multi_out(struct hda_codec *codec)
9882{
9883 struct alc_spec *spec = codec->spec;
9884 int i;
9885
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009886 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01009887 for (i = 0; i < spec->autocfg.line_outs; i++) {
9888 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009889 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01009890 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009891 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009892 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009893 }
9894}
9895
9896static void alc861_auto_init_hp_out(struct hda_codec *codec)
9897{
9898 struct alc_spec *spec = codec->spec;
9899 hda_nid_t pin;
9900
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009901 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009902 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009903 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9904 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01009905}
9906
9907static void alc861_auto_init_analog_input(struct hda_codec *codec)
9908{
9909 struct alc_spec *spec = codec->spec;
9910 int i;
9911
9912 for (i = 0; i < AUTO_PIN_LAST; i++) {
9913 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009914 if (nid >= 0x0c && nid <= 0x11) {
9915 snd_hda_codec_write(codec, nid, 0,
9916 AC_VERB_SET_PIN_WIDGET_CONTROL,
9917 i <= AUTO_PIN_FRONT_MIC ?
9918 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01009919 }
9920 }
9921}
9922
9923/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009924/* return 1 if successful, 0 if the proper config is not found,
9925 * or a negative error code
9926 */
Kailang Yangdf694da2005-12-05 19:42:22 +01009927static int alc861_parse_auto_config(struct hda_codec *codec)
9928{
9929 struct alc_spec *spec = codec->spec;
9930 int err;
9931 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9932
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009933 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9934 alc861_ignore);
9935 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009936 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009937 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009938 return 0; /* can't find valid BIOS pin config */
9939
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009940 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9941 if (err < 0)
9942 return err;
9943 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9944 if (err < 0)
9945 return err;
9946 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9947 if (err < 0)
9948 return err;
9949 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9950 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009951 return err;
9952
9953 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9954
9955 if (spec->autocfg.dig_out_pin)
9956 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9957
9958 if (spec->kctl_alloc)
9959 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9960
9961 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9962
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009963 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009964 spec->input_mux = &spec->private_imux;
9965
9966 spec->adc_nids = alc861_adc_nids;
9967 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9968 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9969 spec->num_mixers++;
9970
9971 return 1;
9972}
9973
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009974/* additional initialization for auto-configuration model */
9975static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009976{
Kailang Yangdf694da2005-12-05 19:42:22 +01009977 alc861_auto_init_multi_out(codec);
9978 alc861_auto_init_hp_out(codec);
9979 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009980}
9981
Takashi Iwaicb53c622007-08-10 17:21:45 +02009982#ifdef CONFIG_SND_HDA_POWER_SAVE
9983static struct hda_amp_list alc861_loopbacks[] = {
9984 { 0x15, HDA_INPUT, 0 },
9985 { 0x15, HDA_INPUT, 1 },
9986 { 0x15, HDA_INPUT, 2 },
9987 { 0x15, HDA_INPUT, 3 },
9988 { } /* end */
9989};
9990#endif
9991
Kailang Yangdf694da2005-12-05 19:42:22 +01009992
9993/*
9994 * configuration and preset
9995 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009996static const char *alc861_models[ALC861_MODEL_LAST] = {
9997 [ALC861_3ST] = "3stack",
9998 [ALC660_3ST] = "3stack-660",
9999 [ALC861_3ST_DIG] = "3stack-dig",
10000 [ALC861_6ST_DIG] = "6stack-dig",
10001 [ALC861_UNIWILL_M31] = "uniwill-m31",
10002 [ALC861_TOSHIBA] = "toshiba",
10003 [ALC861_ASUS] = "asus",
10004 [ALC861_ASUS_LAPTOP] = "asus-laptop",
10005 [ALC861_AUTO] = "auto",
10006};
10007
10008static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010010009 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010010 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
10011 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +020010012 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020010013 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010014 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Kailang Yang83c34212007-07-05 11:43:05 +020010015 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010010016 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020010017 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
10018 * Any other models that need this preset?
10019 */
10020 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010021 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Dave Jones35739bb2007-06-06 14:48:52 +020010022 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +010010023 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +010010024 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010025 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020010026 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
10027 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010010028 {}
10029};
10030
10031static struct alc_config_preset alc861_presets[] = {
10032 [ALC861_3ST] = {
10033 .mixers = { alc861_3ST_mixer },
10034 .init_verbs = { alc861_threestack_init_verbs },
10035 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10036 .dac_nids = alc861_dac_nids,
10037 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10038 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010039 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010010040 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10041 .adc_nids = alc861_adc_nids,
10042 .input_mux = &alc861_capture_source,
10043 },
10044 [ALC861_3ST_DIG] = {
10045 .mixers = { alc861_base_mixer },
10046 .init_verbs = { alc861_threestack_init_verbs },
10047 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10048 .dac_nids = alc861_dac_nids,
10049 .dig_out_nid = ALC861_DIGOUT_NID,
10050 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10051 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010052 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010010053 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10054 .adc_nids = alc861_adc_nids,
10055 .input_mux = &alc861_capture_source,
10056 },
10057 [ALC861_6ST_DIG] = {
10058 .mixers = { alc861_base_mixer },
10059 .init_verbs = { alc861_base_init_verbs },
10060 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10061 .dac_nids = alc861_dac_nids,
10062 .dig_out_nid = ALC861_DIGOUT_NID,
10063 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
10064 .channel_mode = alc861_8ch_modes,
10065 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10066 .adc_nids = alc861_adc_nids,
10067 .input_mux = &alc861_capture_source,
10068 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010069 [ALC660_3ST] = {
10070 .mixers = { alc861_3ST_mixer },
10071 .init_verbs = { alc861_threestack_init_verbs },
10072 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
10073 .dac_nids = alc660_dac_nids,
10074 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
10075 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010076 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010077 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10078 .adc_nids = alc861_adc_nids,
10079 .input_mux = &alc861_capture_source,
10080 },
Takashi Iwai22309c32006-08-09 16:57:28 +020010081 [ALC861_UNIWILL_M31] = {
10082 .mixers = { alc861_uniwill_m31_mixer },
10083 .init_verbs = { alc861_uniwill_m31_init_verbs },
10084 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10085 .dac_nids = alc861_dac_nids,
10086 .dig_out_nid = ALC861_DIGOUT_NID,
10087 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
10088 .channel_mode = alc861_uniwill_m31_modes,
10089 .need_dac_fix = 1,
10090 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10091 .adc_nids = alc861_adc_nids,
10092 .input_mux = &alc861_capture_source,
10093 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010094 [ALC861_TOSHIBA] = {
10095 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010096 .init_verbs = { alc861_base_init_verbs,
10097 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020010098 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10099 .dac_nids = alc861_dac_nids,
10100 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10101 .channel_mode = alc883_3ST_2ch_modes,
10102 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10103 .adc_nids = alc861_adc_nids,
10104 .input_mux = &alc861_capture_source,
10105 .unsol_event = alc861_toshiba_unsol_event,
10106 .init_hook = alc861_toshiba_automute,
10107 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020010108 [ALC861_ASUS] = {
10109 .mixers = { alc861_asus_mixer },
10110 .init_verbs = { alc861_asus_init_verbs },
10111 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10112 .dac_nids = alc861_dac_nids,
10113 .dig_out_nid = ALC861_DIGOUT_NID,
10114 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
10115 .channel_mode = alc861_asus_modes,
10116 .need_dac_fix = 1,
10117 .hp_nid = 0x06,
10118 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10119 .adc_nids = alc861_adc_nids,
10120 .input_mux = &alc861_capture_source,
10121 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010010122 [ALC861_ASUS_LAPTOP] = {
10123 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
10124 .init_verbs = { alc861_asus_init_verbs,
10125 alc861_asus_laptop_init_verbs },
10126 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
10127 .dac_nids = alc861_dac_nids,
10128 .dig_out_nid = ALC861_DIGOUT_NID,
10129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10130 .channel_mode = alc883_3ST_2ch_modes,
10131 .need_dac_fix = 1,
10132 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
10133 .adc_nids = alc861_adc_nids,
10134 .input_mux = &alc861_capture_source,
10135 },
10136};
Kailang Yangdf694da2005-12-05 19:42:22 +010010137
10138
10139static int patch_alc861(struct hda_codec *codec)
10140{
10141 struct alc_spec *spec;
10142 int board_config;
10143 int err;
10144
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010145 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010146 if (spec == NULL)
10147 return -ENOMEM;
10148
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010149 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010150
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010151 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
10152 alc861_models,
10153 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010154
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010155 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010156 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
10157 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010158 board_config = ALC861_AUTO;
10159 }
10160
10161 if (board_config == ALC861_AUTO) {
10162 /* automatic parse from the BIOS config */
10163 err = alc861_parse_auto_config(codec);
10164 if (err < 0) {
10165 alc_free(codec);
10166 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010167 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010168 printk(KERN_INFO
10169 "hda_codec: Cannot set up configuration "
10170 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010171 board_config = ALC861_3ST_DIG;
10172 }
10173 }
10174
10175 if (board_config != ALC861_AUTO)
10176 setup_preset(spec, &alc861_presets[board_config]);
10177
10178 spec->stream_name_analog = "ALC861 Analog";
10179 spec->stream_analog_playback = &alc861_pcm_analog_playback;
10180 spec->stream_analog_capture = &alc861_pcm_analog_capture;
10181
10182 spec->stream_name_digital = "ALC861 Digital";
10183 spec->stream_digital_playback = &alc861_pcm_digital_playback;
10184 spec->stream_digital_capture = &alc861_pcm_digital_capture;
10185
10186 codec->patch_ops = alc_patch_ops;
10187 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010188 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010189#ifdef CONFIG_SND_HDA_POWER_SAVE
10190 if (!spec->loopback.amplist)
10191 spec->loopback.amplist = alc861_loopbacks;
10192#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010010193
10194 return 0;
10195}
10196
10197/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010198 * ALC861-VD support
10199 *
10200 * Based on ALC882
10201 *
10202 * In addition, an independent DAC
10203 */
10204#define ALC861VD_DIGOUT_NID 0x06
10205
10206static hda_nid_t alc861vd_dac_nids[4] = {
10207 /* front, surr, clfe, side surr */
10208 0x02, 0x03, 0x04, 0x05
10209};
10210
10211/* dac_nids for ALC660vd are in a different order - according to
10212 * Realtek's driver.
10213 * This should probably tesult in a different mixer for 6stack models
10214 * of ALC660vd codecs, but for now there is only 3stack mixer
10215 * - and it is the same as in 861vd.
10216 * adc_nids in ALC660vd are (is) the same as in 861vd
10217 */
10218static hda_nid_t alc660vd_dac_nids[3] = {
10219 /* front, rear, clfe, rear_surr */
10220 0x02, 0x04, 0x03
10221};
10222
10223static hda_nid_t alc861vd_adc_nids[1] = {
10224 /* ADC0 */
10225 0x09,
10226};
10227
10228/* input MUX */
10229/* FIXME: should be a matrix-type input source selection */
10230static struct hda_input_mux alc861vd_capture_source = {
10231 .num_items = 4,
10232 .items = {
10233 { "Mic", 0x0 },
10234 { "Front Mic", 0x1 },
10235 { "Line", 0x2 },
10236 { "CD", 0x4 },
10237 },
10238};
10239
Kailang Yang272a5272007-05-14 11:00:38 +020010240static struct hda_input_mux alc861vd_dallas_capture_source = {
10241 .num_items = 3,
10242 .items = {
10243 { "Front Mic", 0x0 },
10244 { "ATAPI Mic", 0x1 },
10245 { "Line In", 0x5 },
10246 },
10247};
10248
Kailang Yangd1a991a2007-08-15 16:21:59 +020010249static struct hda_input_mux alc861vd_hp_capture_source = {
10250 .num_items = 2,
10251 .items = {
10252 { "Front Mic", 0x0 },
10253 { "ATAPI Mic", 0x1 },
10254 },
10255};
10256
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010257#define alc861vd_mux_enum_info alc_mux_enum_info
10258#define alc861vd_mux_enum_get alc_mux_enum_get
10259
10260static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10261 struct snd_ctl_elem_value *ucontrol)
10262{
10263 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10264 struct alc_spec *spec = codec->spec;
10265 const struct hda_input_mux *imux = spec->input_mux;
10266 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10267 static hda_nid_t capture_mixers[1] = { 0x22 };
10268 hda_nid_t nid = capture_mixers[adc_idx];
10269 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10270 unsigned int i, idx;
10271
10272 idx = ucontrol->value.enumerated.item[0];
10273 if (idx >= imux->num_items)
10274 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010275 if (*cur_val == idx)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010276 return 0;
10277 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020010278 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10279 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10280 imux->items[i].index,
10281 HDA_AMP_MUTE, v);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010282 }
10283 *cur_val = idx;
10284 return 1;
10285}
10286
10287/*
10288 * 2ch mode
10289 */
10290static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10291 { 2, NULL }
10292};
10293
10294/*
10295 * 6ch mode
10296 */
10297static struct hda_verb alc861vd_6stack_ch6_init[] = {
10298 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10299 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10300 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10301 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10302 { } /* end */
10303};
10304
10305/*
10306 * 8ch mode
10307 */
10308static struct hda_verb alc861vd_6stack_ch8_init[] = {
10309 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10310 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10311 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10312 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10313 { } /* end */
10314};
10315
10316static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10317 { 6, alc861vd_6stack_ch6_init },
10318 { 8, alc861vd_6stack_ch8_init },
10319};
10320
10321static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10322 {
10323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10324 .name = "Channel Mode",
10325 .info = alc_ch_mode_info,
10326 .get = alc_ch_mode_get,
10327 .put = alc_ch_mode_put,
10328 },
10329 { } /* end */
10330};
10331
10332static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10333 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10334 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10335
10336 {
10337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10338 /* The multiple "Capture Source" controls confuse alsamixer
10339 * So call somewhat different..
10340 *FIXME: the controls appear in the "playback" view!
10341 */
10342 /* .name = "Capture Source", */
10343 .name = "Input Source",
10344 .count = 1,
10345 .info = alc861vd_mux_enum_info,
10346 .get = alc861vd_mux_enum_get,
10347 .put = alc861vd_mux_enum_put,
10348 },
10349 { } /* end */
10350};
10351
10352/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10353 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10354 */
10355static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10356 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10357 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10358
10359 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10360 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10361
10362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10363 HDA_OUTPUT),
10364 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10365 HDA_OUTPUT),
10366 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10367 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10368
10369 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10370 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10371
10372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10373
10374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10376 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10377
10378 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10379 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10380 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10381
10382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10384
10385 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10386 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10387
10388 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10389 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10390
10391 { } /* end */
10392};
10393
10394static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10395 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10396 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10397
10398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10399
10400 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10401 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10402 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10403
10404 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10405 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10406 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10407
10408 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10409 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10410
10411 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10412 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10413
10414 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10415 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10416
10417 { } /* end */
10418};
10419
Kailang Yangbdd148a2007-05-08 15:19:08 +020010420static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10421 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10422 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10423 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10424
10425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10426
10427 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10430
10431 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10432 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10433 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10434
10435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10437
10438 { } /* end */
10439};
10440
Kailang Yang272a5272007-05-14 11:00:38 +020010441/* Pin assignment: Front=0x14, HP = 0x15,
10442 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10443 */
10444static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10445 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10447 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10448 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10449 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10450 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10451 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10452 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10453 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10454 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020010455 { } /* end */
10456};
10457
Kailang Yangd1a991a2007-08-15 16:21:59 +020010458/* Pin assignment: Speaker=0x14, Line-out = 0x15,
10459 * Front Mic=0x18, ATAPI Mic = 0x19,
10460 */
10461static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10462 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10463 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10464 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10465 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10466 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10467 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10468 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10469 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10470
10471 { } /* end */
10472};
10473
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010474/*
10475 * generic initialization of ADC, input mixers and output mixers
10476 */
10477static struct hda_verb alc861vd_volume_init_verbs[] = {
10478 /*
10479 * Unmute ADC0 and set the default input to mic-in
10480 */
10481 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10483
10484 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10485 * the analog-loopback mixer widget
10486 */
10487 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10491 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10492 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010493
10494 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020010495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10496 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10497 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010498 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010499
10500 /*
10501 * Set up output mixers (0x02 - 0x05)
10502 */
10503 /* set vol=0 to output mixers */
10504 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10505 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10506 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10507 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10508
10509 /* set up input amps for analog loopback */
10510 /* Amp Indices: DAC = 0, mixer = 1 */
10511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10518 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10519
10520 { }
10521};
10522
10523/*
10524 * 3-stack pin configuration:
10525 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10526 */
10527static struct hda_verb alc861vd_3stack_init_verbs[] = {
10528 /*
10529 * Set pin mode and muting
10530 */
10531 /* set front pin widgets 0x14 for output */
10532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10534 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10535
10536 /* Mic (rear) pin: input vref at 80% */
10537 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10538 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10539 /* Front Mic pin: input vref at 80% */
10540 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10541 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10542 /* Line In pin: input */
10543 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10544 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10545 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10547 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10548 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10549 /* CD pin widget for input */
10550 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10551
10552 { }
10553};
10554
10555/*
10556 * 6-stack pin configuration:
10557 */
10558static struct hda_verb alc861vd_6stack_init_verbs[] = {
10559 /*
10560 * Set pin mode and muting
10561 */
10562 /* set front pin widgets 0x14 for output */
10563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10565 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10566
10567 /* Rear Pin: output 1 (0x0d) */
10568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10570 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10571 /* CLFE Pin: output 2 (0x0e) */
10572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10573 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10574 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10575 /* Side Pin: output 3 (0x0f) */
10576 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10577 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10578 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10579
10580 /* Mic (rear) pin: input vref at 80% */
10581 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10583 /* Front Mic pin: input vref at 80% */
10584 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10586 /* Line In pin: input */
10587 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10589 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10591 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10592 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10593 /* CD pin widget for input */
10594 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10595
10596 { }
10597};
10598
Kailang Yangbdd148a2007-05-08 15:19:08 +020010599static struct hda_verb alc861vd_eapd_verbs[] = {
10600 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10601 { }
10602};
10603
10604static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10605 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10606 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10608 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10609 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10610 {}
10611};
10612
10613/* toggle speaker-output according to the hp-jack state */
10614static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10615{
10616 unsigned int present;
10617 unsigned char bits;
10618
10619 present = snd_hda_codec_read(codec, 0x1b, 0,
10620 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010621 bits = present ? HDA_AMP_MUTE : 0;
10622 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10623 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020010624}
10625
10626static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10627{
10628 unsigned int present;
10629 unsigned char bits;
10630
10631 present = snd_hda_codec_read(codec, 0x18, 0,
10632 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010633 bits = present ? HDA_AMP_MUTE : 0;
10634 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
10635 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020010636}
10637
10638static void alc861vd_lenovo_automute(struct hda_codec *codec)
10639{
10640 alc861vd_lenovo_hp_automute(codec);
10641 alc861vd_lenovo_mic_automute(codec);
10642}
10643
10644static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10645 unsigned int res)
10646{
10647 switch (res >> 26) {
10648 case ALC880_HP_EVENT:
10649 alc861vd_lenovo_hp_automute(codec);
10650 break;
10651 case ALC880_MIC_EVENT:
10652 alc861vd_lenovo_mic_automute(codec);
10653 break;
10654 }
10655}
10656
Kailang Yang272a5272007-05-14 11:00:38 +020010657static struct hda_verb alc861vd_dallas_verbs[] = {
10658 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10659 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10661 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10662
10663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10665 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10666 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10669 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10671
10672 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10673 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10676 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10678 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10680
10681 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10683 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10685 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10686 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10687 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10688 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10689
10690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10693 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10694
10695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10696 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10697 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10698
10699 { } /* end */
10700};
10701
10702/* toggle speaker-output according to the hp-jack state */
10703static void alc861vd_dallas_automute(struct hda_codec *codec)
10704{
10705 unsigned int present;
10706
10707 present = snd_hda_codec_read(codec, 0x15, 0,
10708 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020010709 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10710 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020010711}
10712
10713static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10714{
10715 if ((res >> 26) == ALC880_HP_EVENT)
10716 alc861vd_dallas_automute(codec);
10717}
10718
Takashi Iwaicb53c622007-08-10 17:21:45 +020010719#ifdef CONFIG_SND_HDA_POWER_SAVE
10720#define alc861vd_loopbacks alc880_loopbacks
10721#endif
10722
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010723/* pcm configuration: identiacal with ALC880 */
10724#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10725#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10726#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10727#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10728
10729/*
10730 * configuration and preset
10731 */
10732static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10733 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010734 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010735 [ALC861VD_3ST] = "3stack",
10736 [ALC861VD_3ST_DIG] = "3stack-digout",
10737 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020010738 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020010739 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020010740 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010741 [ALC861VD_AUTO] = "auto",
10742};
10743
10744static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +010010745 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010746 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Mike Crash6963f842007-06-25 12:12:51 +020010747 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010748 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10749 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10750
Takashi Iwai38baf5a2007-08-16 17:52:43 +020010751 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020010752 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +020010753 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10754 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Takashi Iwaia18519e2007-06-14 12:58:23 +020010755 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020010756 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Takashi Iwai39c5d412007-08-15 16:24:17 +020010757 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Tobin Davis625dc0b2007-07-30 21:42:10 +020010758 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Kailang Yangd1a991a2007-08-15 16:21:59 +020010759 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010760 {}
10761};
10762
10763static struct alc_config_preset alc861vd_presets[] = {
10764 [ALC660VD_3ST] = {
10765 .mixers = { alc861vd_3st_mixer },
10766 .init_verbs = { alc861vd_volume_init_verbs,
10767 alc861vd_3stack_init_verbs },
10768 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10769 .dac_nids = alc660vd_dac_nids,
10770 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10771 .adc_nids = alc861vd_adc_nids,
10772 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10773 .channel_mode = alc861vd_3stack_2ch_modes,
10774 .input_mux = &alc861vd_capture_source,
10775 },
Mike Crash6963f842007-06-25 12:12:51 +020010776 [ALC660VD_3ST_DIG] = {
10777 .mixers = { alc861vd_3st_mixer },
10778 .init_verbs = { alc861vd_volume_init_verbs,
10779 alc861vd_3stack_init_verbs },
10780 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10781 .dac_nids = alc660vd_dac_nids,
10782 .dig_out_nid = ALC861VD_DIGOUT_NID,
10783 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10784 .adc_nids = alc861vd_adc_nids,
10785 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10786 .channel_mode = alc861vd_3stack_2ch_modes,
10787 .input_mux = &alc861vd_capture_source,
10788 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010789 [ALC861VD_3ST] = {
10790 .mixers = { alc861vd_3st_mixer },
10791 .init_verbs = { alc861vd_volume_init_verbs,
10792 alc861vd_3stack_init_verbs },
10793 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10794 .dac_nids = alc861vd_dac_nids,
10795 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10796 .channel_mode = alc861vd_3stack_2ch_modes,
10797 .input_mux = &alc861vd_capture_source,
10798 },
10799 [ALC861VD_3ST_DIG] = {
10800 .mixers = { alc861vd_3st_mixer },
10801 .init_verbs = { alc861vd_volume_init_verbs,
10802 alc861vd_3stack_init_verbs },
10803 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10804 .dac_nids = alc861vd_dac_nids,
10805 .dig_out_nid = ALC861VD_DIGOUT_NID,
10806 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10807 .channel_mode = alc861vd_3stack_2ch_modes,
10808 .input_mux = &alc861vd_capture_source,
10809 },
10810 [ALC861VD_6ST_DIG] = {
10811 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10812 .init_verbs = { alc861vd_volume_init_verbs,
10813 alc861vd_6stack_init_verbs },
10814 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10815 .dac_nids = alc861vd_dac_nids,
10816 .dig_out_nid = ALC861VD_DIGOUT_NID,
10817 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10818 .channel_mode = alc861vd_6stack_modes,
10819 .input_mux = &alc861vd_capture_source,
10820 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020010821 [ALC861VD_LENOVO] = {
10822 .mixers = { alc861vd_lenovo_mixer },
10823 .init_verbs = { alc861vd_volume_init_verbs,
10824 alc861vd_3stack_init_verbs,
10825 alc861vd_eapd_verbs,
10826 alc861vd_lenovo_unsol_verbs },
10827 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10828 .dac_nids = alc660vd_dac_nids,
10829 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10830 .adc_nids = alc861vd_adc_nids,
10831 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10832 .channel_mode = alc861vd_3stack_2ch_modes,
10833 .input_mux = &alc861vd_capture_source,
10834 .unsol_event = alc861vd_lenovo_unsol_event,
10835 .init_hook = alc861vd_lenovo_automute,
10836 },
Kailang Yang272a5272007-05-14 11:00:38 +020010837 [ALC861VD_DALLAS] = {
10838 .mixers = { alc861vd_dallas_mixer },
10839 .init_verbs = { alc861vd_dallas_verbs },
10840 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10841 .dac_nids = alc861vd_dac_nids,
10842 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10843 .adc_nids = alc861vd_adc_nids,
10844 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10845 .channel_mode = alc861vd_3stack_2ch_modes,
10846 .input_mux = &alc861vd_dallas_capture_source,
10847 .unsol_event = alc861vd_dallas_unsol_event,
10848 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010849 },
10850 [ALC861VD_HP] = {
10851 .mixers = { alc861vd_hp_mixer },
10852 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
10853 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10854 .dac_nids = alc861vd_dac_nids,
10855 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10856 .dig_out_nid = ALC861VD_DIGOUT_NID,
10857 .adc_nids = alc861vd_adc_nids,
10858 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10859 .channel_mode = alc861vd_3stack_2ch_modes,
10860 .input_mux = &alc861vd_hp_capture_source,
10861 .unsol_event = alc861vd_dallas_unsol_event,
10862 .init_hook = alc861vd_dallas_automute,
10863 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010864};
10865
10866/*
10867 * BIOS auto configuration
10868 */
10869static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10870 hda_nid_t nid, int pin_type, int dac_idx)
10871{
10872 /* set as output */
10873 snd_hda_codec_write(codec, nid, 0,
10874 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10875 snd_hda_codec_write(codec, nid, 0,
10876 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10877}
10878
10879static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10880{
10881 struct alc_spec *spec = codec->spec;
10882 int i;
10883
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010884 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010885 for (i = 0; i <= HDA_SIDE; i++) {
10886 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010887 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010888 if (nid)
10889 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010890 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010891 }
10892}
10893
10894
10895static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10896{
10897 struct alc_spec *spec = codec->spec;
10898 hda_nid_t pin;
10899
10900 pin = spec->autocfg.hp_pins[0];
10901 if (pin) /* connect to front and use dac 0 */
10902 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10903}
10904
10905#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10906#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10907
10908static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10909{
10910 struct alc_spec *spec = codec->spec;
10911 int i;
10912
10913 for (i = 0; i < AUTO_PIN_LAST; i++) {
10914 hda_nid_t nid = spec->autocfg.input_pins[i];
10915 if (alc861vd_is_input_pin(nid)) {
10916 snd_hda_codec_write(codec, nid, 0,
10917 AC_VERB_SET_PIN_WIDGET_CONTROL,
10918 i <= AUTO_PIN_FRONT_MIC ?
10919 PIN_VREF80 : PIN_IN);
10920 if (nid != ALC861VD_PIN_CD_NID)
10921 snd_hda_codec_write(codec, nid, 0,
10922 AC_VERB_SET_AMP_GAIN_MUTE,
10923 AMP_OUT_MUTE);
10924 }
10925 }
10926}
10927
10928#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10929#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10930
10931/* add playback controls from the parsed DAC table */
10932/* Based on ALC880 version. But ALC861VD has separate,
10933 * different NIDs for mute/unmute switch and volume control */
10934static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10935 const struct auto_pin_cfg *cfg)
10936{
10937 char name[32];
10938 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10939 hda_nid_t nid_v, nid_s;
10940 int i, err;
10941
10942 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010943 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010944 continue;
10945 nid_v = alc861vd_idx_to_mixer_vol(
10946 alc880_dac_to_idx(
10947 spec->multiout.dac_nids[i]));
10948 nid_s = alc861vd_idx_to_mixer_switch(
10949 alc880_dac_to_idx(
10950 spec->multiout.dac_nids[i]));
10951
10952 if (i == 2) {
10953 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010954 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10955 "Center Playback Volume",
10956 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10957 HDA_OUTPUT));
10958 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010959 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010960 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10961 "LFE Playback Volume",
10962 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10963 HDA_OUTPUT));
10964 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010965 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010966 err = add_control(spec, ALC_CTL_BIND_MUTE,
10967 "Center Playback Switch",
10968 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10969 HDA_INPUT));
10970 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010971 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010972 err = add_control(spec, ALC_CTL_BIND_MUTE,
10973 "LFE Playback Switch",
10974 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10975 HDA_INPUT));
10976 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010977 return err;
10978 } else {
10979 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010980 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10981 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10982 HDA_OUTPUT));
10983 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010984 return err;
10985 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010986 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020010987 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010988 HDA_INPUT));
10989 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010990 return err;
10991 }
10992 }
10993 return 0;
10994}
10995
10996/* add playback controls for speaker and HP outputs */
10997/* Based on ALC880 version. But ALC861VD has separate,
10998 * different NIDs for mute/unmute switch and volume control */
10999static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
11000 hda_nid_t pin, const char *pfx)
11001{
11002 hda_nid_t nid_v, nid_s;
11003 int err;
11004 char name[32];
11005
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011006 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011007 return 0;
11008
11009 if (alc880_is_fixed_pin(pin)) {
11010 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11011 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011012 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011013 spec->multiout.hp_nid = nid_v;
11014 else
11015 spec->multiout.extra_out_nid[0] = nid_v;
11016 /* control HP volume/switch on the output mixer amp */
11017 nid_v = alc861vd_idx_to_mixer_vol(
11018 alc880_fixed_pin_idx(pin));
11019 nid_s = alc861vd_idx_to_mixer_switch(
11020 alc880_fixed_pin_idx(pin));
11021
11022 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011023 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11024 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
11025 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011026 return err;
11027 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011028 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11029 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
11030 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011031 return err;
11032 } else if (alc880_is_multi_pin(pin)) {
11033 /* set manual connection */
11034 /* we have only a switch on HP-out PIN */
11035 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011036 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11037 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11038 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011039 return err;
11040 }
11041 return 0;
11042}
11043
11044/* parse the BIOS configuration and set up the alc_spec
11045 * return 1 if successful, 0 if the proper config is not found,
11046 * or a negative error code
11047 * Based on ALC880 version - had to change it to override
11048 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
11049static int alc861vd_parse_auto_config(struct hda_codec *codec)
11050{
11051 struct alc_spec *spec = codec->spec;
11052 int err;
11053 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
11054
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011055 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11056 alc861vd_ignore);
11057 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011058 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011059 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011060 return 0; /* can't find valid BIOS pin config */
11061
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011062 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11063 if (err < 0)
11064 return err;
11065 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
11066 if (err < 0)
11067 return err;
11068 err = alc861vd_auto_create_extra_out(spec,
11069 spec->autocfg.speaker_pins[0],
11070 "Speaker");
11071 if (err < 0)
11072 return err;
11073 err = alc861vd_auto_create_extra_out(spec,
11074 spec->autocfg.hp_pins[0],
11075 "Headphone");
11076 if (err < 0)
11077 return err;
11078 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
11079 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011080 return err;
11081
11082 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11083
11084 if (spec->autocfg.dig_out_pin)
11085 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
11086
11087 if (spec->kctl_alloc)
11088 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11089
11090 spec->init_verbs[spec->num_init_verbs++]
11091 = alc861vd_volume_init_verbs;
11092
11093 spec->num_mux_defs = 1;
11094 spec->input_mux = &spec->private_imux;
11095
11096 return 1;
11097}
11098
11099/* additional initialization for auto-configuration model */
11100static void alc861vd_auto_init(struct hda_codec *codec)
11101{
11102 alc861vd_auto_init_multi_out(codec);
11103 alc861vd_auto_init_hp_out(codec);
11104 alc861vd_auto_init_analog_input(codec);
11105}
11106
11107static int patch_alc861vd(struct hda_codec *codec)
11108{
11109 struct alc_spec *spec;
11110 int err, board_config;
11111
11112 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11113 if (spec == NULL)
11114 return -ENOMEM;
11115
11116 codec->spec = spec;
11117
11118 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
11119 alc861vd_models,
11120 alc861vd_cfg_tbl);
11121
11122 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
11123 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
11124 "ALC861VD, trying auto-probe from BIOS...\n");
11125 board_config = ALC861VD_AUTO;
11126 }
11127
11128 if (board_config == ALC861VD_AUTO) {
11129 /* automatic parse from the BIOS config */
11130 err = alc861vd_parse_auto_config(codec);
11131 if (err < 0) {
11132 alc_free(codec);
11133 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011134 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011135 printk(KERN_INFO
11136 "hda_codec: Cannot set up configuration "
11137 "from BIOS. Using base mode...\n");
11138 board_config = ALC861VD_3ST;
11139 }
11140 }
11141
11142 if (board_config != ALC861VD_AUTO)
11143 setup_preset(spec, &alc861vd_presets[board_config]);
11144
11145 spec->stream_name_analog = "ALC861VD Analog";
11146 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
11147 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
11148
11149 spec->stream_name_digital = "ALC861VD Digital";
11150 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
11151 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
11152
11153 spec->adc_nids = alc861vd_adc_nids;
11154 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
11155
11156 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
11157 spec->num_mixers++;
11158
11159 codec->patch_ops = alc_patch_ops;
11160
11161 if (board_config == ALC861VD_AUTO)
11162 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011163#ifdef CONFIG_SND_HDA_POWER_SAVE
11164 if (!spec->loopback.amplist)
11165 spec->loopback.amplist = alc861vd_loopbacks;
11166#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010011167
11168 return 0;
11169}
11170
11171/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011172 * ALC662 support
11173 *
11174 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
11175 * configuration. Each pin widget can choose any input DACs and a mixer.
11176 * Each ADC is connected from a mixer of all inputs. This makes possible
11177 * 6-channel independent captures.
11178 *
11179 * In addition, an independent DAC for the multi-playback (not used in this
11180 * driver yet).
11181 */
11182#define ALC662_DIGOUT_NID 0x06
11183#define ALC662_DIGIN_NID 0x0a
11184
11185static hda_nid_t alc662_dac_nids[4] = {
11186 /* front, rear, clfe, rear_surr */
11187 0x02, 0x03, 0x04
11188};
11189
11190static hda_nid_t alc662_adc_nids[1] = {
11191 /* ADC1-2 */
11192 0x09,
11193};
11194/* input MUX */
11195/* FIXME: should be a matrix-type input source selection */
11196
11197static struct hda_input_mux alc662_capture_source = {
11198 .num_items = 4,
11199 .items = {
11200 { "Mic", 0x0 },
11201 { "Front Mic", 0x1 },
11202 { "Line", 0x2 },
11203 { "CD", 0x4 },
11204 },
11205};
11206
11207static struct hda_input_mux alc662_lenovo_101e_capture_source = {
11208 .num_items = 2,
11209 .items = {
11210 { "Mic", 0x1 },
11211 { "Line", 0x2 },
11212 },
11213};
11214#define alc662_mux_enum_info alc_mux_enum_info
11215#define alc662_mux_enum_get alc_mux_enum_get
11216
11217static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
11218 struct snd_ctl_elem_value *ucontrol)
11219{
11220 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11221 struct alc_spec *spec = codec->spec;
11222 const struct hda_input_mux *imux = spec->input_mux;
11223 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Kailang Yangd1a991a2007-08-15 16:21:59 +020011224 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011225 hda_nid_t nid = capture_mixers[adc_idx];
11226 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11227 unsigned int i, idx;
11228
11229 idx = ucontrol->value.enumerated.item[0];
11230 if (idx >= imux->num_items)
11231 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011232 if (*cur_val == idx)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011233 return 0;
11234 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +020011235 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11236 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11237 imux->items[i].index,
11238 HDA_AMP_MUTE, v);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011239 }
11240 *cur_val = idx;
11241 return 1;
11242}
11243/*
11244 * 2ch mode
11245 */
11246static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11247 { 2, NULL }
11248};
11249
11250/*
11251 * 2ch mode
11252 */
11253static struct hda_verb alc662_3ST_ch2_init[] = {
11254 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11255 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11256 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11257 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11258 { } /* end */
11259};
11260
11261/*
11262 * 6ch mode
11263 */
11264static struct hda_verb alc662_3ST_ch6_init[] = {
11265 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11266 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11267 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11268 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11269 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11270 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11271 { } /* end */
11272};
11273
11274static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11275 { 2, alc662_3ST_ch2_init },
11276 { 6, alc662_3ST_ch6_init },
11277};
11278
11279/*
11280 * 2ch mode
11281 */
11282static struct hda_verb alc662_sixstack_ch6_init[] = {
11283 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11284 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11285 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11286 { } /* end */
11287};
11288
11289/*
11290 * 6ch mode
11291 */
11292static struct hda_verb alc662_sixstack_ch8_init[] = {
11293 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11294 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11295 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11296 { } /* end */
11297};
11298
11299static struct hda_channel_mode alc662_5stack_modes[2] = {
11300 { 2, alc662_sixstack_ch6_init },
11301 { 6, alc662_sixstack_ch8_init },
11302};
11303
11304/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11305 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11306 */
11307
11308static struct snd_kcontrol_new alc662_base_mixer[] = {
11309 /* output mixer control */
11310 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11311 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11312 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11313 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11314 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11315 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11316 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11317 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11319
11320 /*Input mixer control */
11321 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11322 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11323 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11324 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11325 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11326 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11327 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11328 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11329
11330 /* Capture mixer control */
11331 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11332 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11333 {
11334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11335 .name = "Capture Source",
11336 .count = 1,
11337 .info = alc_mux_enum_info,
11338 .get = alc_mux_enum_get,
11339 .put = alc_mux_enum_put,
11340 },
11341 { } /* end */
11342};
11343
11344static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11345 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11346 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11354 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11355 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11356 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11357 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11358 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11359 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11360 {
11361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11362 /* .name = "Capture Source", */
11363 .name = "Input Source",
11364 .count = 1,
11365 .info = alc662_mux_enum_info,
11366 .get = alc662_mux_enum_get,
11367 .put = alc662_mux_enum_put,
11368 },
11369 { } /* end */
11370};
11371
11372static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11373 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11374 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11375 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11376 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11377 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11378 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11379 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11380 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11382 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11383 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11384 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11385 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11388 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11389 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11390 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11391 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11392 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11393 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11394 {
11395 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11396 /* .name = "Capture Source", */
11397 .name = "Input Source",
11398 .count = 1,
11399 .info = alc662_mux_enum_info,
11400 .get = alc662_mux_enum_get,
11401 .put = alc662_mux_enum_put,
11402 },
11403 { } /* end */
11404};
11405
11406static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11407 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11408 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11409 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11410 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11412 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11413 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11416 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11417 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11418 {
11419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11420 /* .name = "Capture Source", */
11421 .name = "Input Source",
11422 .count = 1,
11423 .info = alc662_mux_enum_info,
11424 .get = alc662_mux_enum_get,
11425 .put = alc662_mux_enum_put,
11426 },
11427 { } /* end */
11428};
11429
11430static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11431 {
11432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11433 .name = "Channel Mode",
11434 .info = alc_ch_mode_info,
11435 .get = alc_ch_mode_get,
11436 .put = alc_ch_mode_put,
11437 },
11438 { } /* end */
11439};
11440
11441static struct hda_verb alc662_init_verbs[] = {
11442 /* ADC: mute amp left and right */
11443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11444 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11445 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11446
Takashi Iwaicb53c622007-08-10 17:21:45 +020011447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011452
11453 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11454 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11455 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11456 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11457 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11458 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11459
11460 /* Front Pin: output 0 (0x0c) */
11461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11462 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11463
11464 /* Rear Pin: output 1 (0x0d) */
11465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11467
11468 /* CLFE Pin: output 2 (0x0e) */
11469 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11471
11472 /* Mic (rear) pin: input vref at 80% */
11473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11475 /* Front Mic pin: input vref at 80% */
11476 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11477 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11478 /* Line In pin: input */
11479 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11480 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11481 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11482 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11483 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11484 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11485 /* CD pin widget for input */
11486 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11487
11488 /* FIXME: use matrix-type input source selection */
11489 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11490 /* Input mixer */
11491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11495 { }
11496};
11497
11498static struct hda_verb alc662_sue_init_verbs[] = {
11499 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11500 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11501 {}
11502};
11503
11504/*
11505 * generic initialization of ADC, input mixers and output mixers
11506 */
11507static struct hda_verb alc662_auto_init_verbs[] = {
11508 /*
11509 * Unmute ADC and set the default input to mic-in
11510 */
11511 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11512 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11513
11514 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11515 * mixer widget
11516 * Note: PASD motherboards uses the Line In 2 as the input for front
11517 * panel mic (mic 2)
11518 */
11519 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011525
11526 /*
11527 * Set up output mixers (0x0c - 0x0f)
11528 */
11529 /* set vol=0 to output mixers */
11530 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11531 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11532 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11533
11534 /* set up input amps for analog loopback */
11535 /* Amp Indices: DAC = 0, mixer = 1 */
11536 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11537 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11538 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11539 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11540 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11541 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11542
11543
11544 /* FIXME: use matrix-type input source selection */
11545 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11546 /* Input mixer */
11547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020011548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011549 { }
11550};
11551
11552/* capture mixer elements */
11553static struct snd_kcontrol_new alc662_capture_mixer[] = {
11554 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11555 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11556 {
11557 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11558 /* The multiple "Capture Source" controls confuse alsamixer
11559 * So call somewhat different..
11560 * FIXME: the controls appear in the "playback" view!
11561 */
11562 /* .name = "Capture Source", */
11563 .name = "Input Source",
11564 .count = 1,
11565 .info = alc882_mux_enum_info,
11566 .get = alc882_mux_enum_get,
11567 .put = alc882_mux_enum_put,
11568 },
11569 { } /* end */
11570};
11571
11572static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11573{
11574 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011575 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011576
11577 present = snd_hda_codec_read(codec, 0x14, 0,
11578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011579 bits = present ? HDA_AMP_MUTE : 0;
11580 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11581 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011582}
11583
11584static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11585{
11586 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011587 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011588
11589 present = snd_hda_codec_read(codec, 0x1b, 0,
11590 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020011591 bits = present ? HDA_AMP_MUTE : 0;
11592 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11593 HDA_AMP_MUTE, bits);
11594 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11595 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011596}
11597
11598static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11599 unsigned int res)
11600{
11601 if ((res >> 26) == ALC880_HP_EVENT)
11602 alc662_lenovo_101e_all_automute(codec);
11603 if ((res >> 26) == ALC880_FRONT_EVENT)
11604 alc662_lenovo_101e_ispeaker_automute(codec);
11605}
11606
Takashi Iwaicb53c622007-08-10 17:21:45 +020011607#ifdef CONFIG_SND_HDA_POWER_SAVE
11608#define alc662_loopbacks alc880_loopbacks
11609#endif
11610
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011611
11612/* pcm configuration: identiacal with ALC880 */
11613#define alc662_pcm_analog_playback alc880_pcm_analog_playback
11614#define alc662_pcm_analog_capture alc880_pcm_analog_capture
11615#define alc662_pcm_digital_playback alc880_pcm_digital_playback
11616#define alc662_pcm_digital_capture alc880_pcm_digital_capture
11617
11618/*
11619 * configuration and preset
11620 */
11621static const char *alc662_models[ALC662_MODEL_LAST] = {
11622 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11623 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11624 [ALC662_3ST_6ch] = "3stack-6ch",
11625 [ALC662_5ST_DIG] = "6stack-dig",
11626 [ALC662_LENOVO_101E] = "lenovo-101e",
11627 [ALC662_AUTO] = "auto",
11628};
11629
11630static struct snd_pci_quirk alc662_cfg_tbl[] = {
11631 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11632 {}
11633};
11634
11635static struct alc_config_preset alc662_presets[] = {
11636 [ALC662_3ST_2ch_DIG] = {
11637 .mixers = { alc662_3ST_2ch_mixer },
11638 .init_verbs = { alc662_init_verbs },
11639 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11640 .dac_nids = alc662_dac_nids,
11641 .dig_out_nid = ALC662_DIGOUT_NID,
11642 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11643 .adc_nids = alc662_adc_nids,
11644 .dig_in_nid = ALC662_DIGIN_NID,
11645 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11646 .channel_mode = alc662_3ST_2ch_modes,
11647 .input_mux = &alc662_capture_source,
11648 },
11649 [ALC662_3ST_6ch_DIG] = {
11650 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11651 .init_verbs = { alc662_init_verbs },
11652 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11653 .dac_nids = alc662_dac_nids,
11654 .dig_out_nid = ALC662_DIGOUT_NID,
11655 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11656 .adc_nids = alc662_adc_nids,
11657 .dig_in_nid = ALC662_DIGIN_NID,
11658 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11659 .channel_mode = alc662_3ST_6ch_modes,
11660 .need_dac_fix = 1,
11661 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011662 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011663 [ALC662_3ST_6ch] = {
11664 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11665 .init_verbs = { alc662_init_verbs },
11666 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11667 .dac_nids = alc662_dac_nids,
11668 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11669 .adc_nids = alc662_adc_nids,
11670 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11671 .channel_mode = alc662_3ST_6ch_modes,
11672 .need_dac_fix = 1,
11673 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011674 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011675 [ALC662_5ST_DIG] = {
11676 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11677 .init_verbs = { alc662_init_verbs },
11678 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11679 .dac_nids = alc662_dac_nids,
11680 .dig_out_nid = ALC662_DIGOUT_NID,
11681 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11682 .adc_nids = alc662_adc_nids,
11683 .dig_in_nid = ALC662_DIGIN_NID,
11684 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11685 .channel_mode = alc662_5stack_modes,
11686 .input_mux = &alc662_capture_source,
11687 },
11688 [ALC662_LENOVO_101E] = {
11689 .mixers = { alc662_lenovo_101e_mixer },
11690 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11691 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11692 .dac_nids = alc662_dac_nids,
11693 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11694 .adc_nids = alc662_adc_nids,
11695 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11696 .channel_mode = alc662_3ST_2ch_modes,
11697 .input_mux = &alc662_lenovo_101e_capture_source,
11698 .unsol_event = alc662_lenovo_101e_unsol_event,
11699 .init_hook = alc662_lenovo_101e_all_automute,
11700 },
11701
11702};
11703
11704
11705/*
11706 * BIOS auto configuration
11707 */
11708
11709/* add playback controls from the parsed DAC table */
11710static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11711 const struct auto_pin_cfg *cfg)
11712{
11713 char name[32];
11714 static const char *chname[4] = {
11715 "Front", "Surround", NULL /*CLFE*/, "Side"
11716 };
11717 hda_nid_t nid;
11718 int i, err;
11719
11720 for (i = 0; i < cfg->line_outs; i++) {
11721 if (!spec->multiout.dac_nids[i])
11722 continue;
Kailang Yang067b5a82007-07-05 12:35:15 +020011723 nid = alc880_idx_to_mixer(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011724 if (i == 2) {
11725 /* Center/LFE */
11726 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11727 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011728 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11729 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011730 if (err < 0)
11731 return err;
11732 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11733 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011734 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11735 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011736 if (err < 0)
11737 return err;
11738 err = add_control(spec, ALC_CTL_BIND_MUTE,
11739 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011740 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11741 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011742 if (err < 0)
11743 return err;
11744 err = add_control(spec, ALC_CTL_BIND_MUTE,
11745 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011746 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11747 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011748 if (err < 0)
11749 return err;
11750 } else {
11751 sprintf(name, "%s Playback Volume", chname[i]);
11752 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011753 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11754 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011755 if (err < 0)
11756 return err;
11757 sprintf(name, "%s Playback Switch", chname[i]);
11758 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011759 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11760 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011761 if (err < 0)
11762 return err;
11763 }
11764 }
11765 return 0;
11766}
11767
11768/* add playback controls for speaker and HP outputs */
11769static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11770 const char *pfx)
11771{
11772 hda_nid_t nid;
11773 int err;
11774 char name[32];
11775
11776 if (!pin)
11777 return 0;
11778
11779 if (alc880_is_fixed_pin(pin)) {
11780 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11781 /* printk("DAC nid=%x\n",nid); */
11782 /* specify the DAC as the extra output */
11783 if (!spec->multiout.hp_nid)
11784 spec->multiout.hp_nid = nid;
11785 else
11786 spec->multiout.extra_out_nid[0] = nid;
11787 /* control HP volume/switch on the output mixer amp */
11788 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11789 sprintf(name, "%s Playback Volume", pfx);
11790 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11791 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11792 if (err < 0)
11793 return err;
11794 sprintf(name, "%s Playback Switch", pfx);
11795 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11796 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11797 if (err < 0)
11798 return err;
11799 } else if (alc880_is_multi_pin(pin)) {
11800 /* set manual connection */
11801 /* we have only a switch on HP-out PIN */
11802 sprintf(name, "%s Playback Switch", pfx);
11803 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11804 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11805 if (err < 0)
11806 return err;
11807 }
11808 return 0;
11809}
11810
11811/* create playback/capture controls for input pins */
11812static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11813 const struct auto_pin_cfg *cfg)
11814{
11815 struct hda_input_mux *imux = &spec->private_imux;
11816 int i, err, idx;
11817
11818 for (i = 0; i < AUTO_PIN_LAST; i++) {
11819 if (alc880_is_input_pin(cfg->input_pins[i])) {
11820 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11821 err = new_analog_input(spec, cfg->input_pins[i],
11822 auto_pin_cfg_labels[i],
11823 idx, 0x0b);
11824 if (err < 0)
11825 return err;
11826 imux->items[imux->num_items].label =
11827 auto_pin_cfg_labels[i];
11828 imux->items[imux->num_items].index =
11829 alc880_input_pin_idx(cfg->input_pins[i]);
11830 imux->num_items++;
11831 }
11832 }
11833 return 0;
11834}
11835
11836static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11837 hda_nid_t nid, int pin_type,
11838 int dac_idx)
11839{
11840 /* set as output */
11841 snd_hda_codec_write(codec, nid, 0,
11842 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11843 snd_hda_codec_write(codec, nid, 0,
11844 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11845 /* need the manual connection? */
11846 if (alc880_is_multi_pin(nid)) {
11847 struct alc_spec *spec = codec->spec;
11848 int idx = alc880_multi_pin_idx(nid);
11849 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11850 AC_VERB_SET_CONNECT_SEL,
11851 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11852 }
11853}
11854
11855static void alc662_auto_init_multi_out(struct hda_codec *codec)
11856{
11857 struct alc_spec *spec = codec->spec;
11858 int i;
11859
11860 for (i = 0; i <= HDA_SIDE; i++) {
11861 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011862 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011863 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020011864 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011865 i);
11866 }
11867}
11868
11869static void alc662_auto_init_hp_out(struct hda_codec *codec)
11870{
11871 struct alc_spec *spec = codec->spec;
11872 hda_nid_t pin;
11873
11874 pin = spec->autocfg.hp_pins[0];
11875 if (pin) /* connect to front */
11876 /* use dac 0 */
11877 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11878}
11879
11880#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11881#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11882
11883static void alc662_auto_init_analog_input(struct hda_codec *codec)
11884{
11885 struct alc_spec *spec = codec->spec;
11886 int i;
11887
11888 for (i = 0; i < AUTO_PIN_LAST; i++) {
11889 hda_nid_t nid = spec->autocfg.input_pins[i];
11890 if (alc662_is_input_pin(nid)) {
11891 snd_hda_codec_write(codec, nid, 0,
11892 AC_VERB_SET_PIN_WIDGET_CONTROL,
11893 (i <= AUTO_PIN_FRONT_MIC ?
11894 PIN_VREF80 : PIN_IN));
11895 if (nid != ALC662_PIN_CD_NID)
11896 snd_hda_codec_write(codec, nid, 0,
11897 AC_VERB_SET_AMP_GAIN_MUTE,
11898 AMP_OUT_MUTE);
11899 }
11900 }
11901}
11902
11903static int alc662_parse_auto_config(struct hda_codec *codec)
11904{
11905 struct alc_spec *spec = codec->spec;
11906 int err;
11907 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11908
11909 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11910 alc662_ignore);
11911 if (err < 0)
11912 return err;
11913 if (!spec->autocfg.line_outs)
11914 return 0; /* can't find valid BIOS pin config */
11915
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011916 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11917 if (err < 0)
11918 return err;
11919 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11920 if (err < 0)
11921 return err;
11922 err = alc662_auto_create_extra_out(spec,
11923 spec->autocfg.speaker_pins[0],
11924 "Speaker");
11925 if (err < 0)
11926 return err;
11927 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11928 "Headphone");
11929 if (err < 0)
11930 return err;
11931 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11932 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011933 return err;
11934
11935 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11936
11937 if (spec->autocfg.dig_out_pin)
11938 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11939
11940 if (spec->kctl_alloc)
11941 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11942
11943 spec->num_mux_defs = 1;
11944 spec->input_mux = &spec->private_imux;
11945
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011946 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011947 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11948 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011949 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011950}
11951
11952/* additional initialization for auto-configuration model */
11953static void alc662_auto_init(struct hda_codec *codec)
11954{
11955 alc662_auto_init_multi_out(codec);
11956 alc662_auto_init_hp_out(codec);
11957 alc662_auto_init_analog_input(codec);
11958}
11959
11960static int patch_alc662(struct hda_codec *codec)
11961{
11962 struct alc_spec *spec;
11963 int err, board_config;
11964
11965 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11966 if (!spec)
11967 return -ENOMEM;
11968
11969 codec->spec = spec;
11970
11971 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11972 alc662_models,
11973 alc662_cfg_tbl);
11974 if (board_config < 0) {
11975 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11976 "trying auto-probe from BIOS...\n");
11977 board_config = ALC662_AUTO;
11978 }
11979
11980 if (board_config == ALC662_AUTO) {
11981 /* automatic parse from the BIOS config */
11982 err = alc662_parse_auto_config(codec);
11983 if (err < 0) {
11984 alc_free(codec);
11985 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020011986 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020011987 printk(KERN_INFO
11988 "hda_codec: Cannot set up configuration "
11989 "from BIOS. Using base mode...\n");
11990 board_config = ALC662_3ST_2ch_DIG;
11991 }
11992 }
11993
11994 if (board_config != ALC662_AUTO)
11995 setup_preset(spec, &alc662_presets[board_config]);
11996
11997 spec->stream_name_analog = "ALC662 Analog";
11998 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11999 spec->stream_analog_capture = &alc662_pcm_analog_capture;
12000
12001 spec->stream_name_digital = "ALC662 Digital";
12002 spec->stream_digital_playback = &alc662_pcm_digital_playback;
12003 spec->stream_digital_capture = &alc662_pcm_digital_capture;
12004
12005 if (!spec->adc_nids && spec->input_mux) {
12006 spec->adc_nids = alc662_adc_nids;
12007 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
12008 }
12009
12010 codec->patch_ops = alc_patch_ops;
12011 if (board_config == ALC662_AUTO)
12012 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012013#ifdef CONFIG_SND_HDA_POWER_SAVE
12014 if (!spec->loopback.amplist)
12015 spec->loopback.amplist = alc662_loopbacks;
12016#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012017
12018 return 0;
12019}
12020
12021/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070012022 * patch entries
12023 */
12024struct hda_codec_preset snd_hda_preset_realtek[] = {
12025 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012026 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yanga361d842007-06-05 12:30:55 +020012027 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012028 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012029 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012030 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
12031 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
12032 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012033 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
12034 .patch = patch_alc883 },
12035 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
12036 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010012037 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070012038 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012039 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012040 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012041 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070012042 {} /* terminator */
12043};