blob: 4776de93928b4b55fa78a2b570b40715a54b1f4d [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 Yangdf694da2005-12-05 19:42:22 +010097 ALC262_AUTO,
98 ALC262_MODEL_LAST /* last tag */
99};
100
101/* ALC861 models */
102enum {
103 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200104 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100105 ALC861_3ST_DIG,
106 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200107 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200108 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200109 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100110 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100111 ALC861_AUTO,
112 ALC861_MODEL_LAST,
113};
114
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100115/* ALC861-VD models */
116enum {
117 ALC660VD_3ST,
118 ALC861VD_3ST,
119 ALC861VD_3ST_DIG,
120 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200121 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200122 ALC861VD_DALLAS,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100123 ALC861VD_AUTO,
124 ALC861VD_MODEL_LAST,
125};
126
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200127/* ALC662 models */
128enum {
129 ALC662_3ST_2ch_DIG,
130 ALC662_3ST_6ch_DIG,
131 ALC662_3ST_6ch,
132 ALC662_5ST_DIG,
133 ALC662_LENOVO_101E,
134 ALC662_AUTO,
135 ALC662_MODEL_LAST,
136};
137
Kailang Yangdf694da2005-12-05 19:42:22 +0100138/* ALC882 models */
139enum {
140 ALC882_3ST_DIG,
141 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200142 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200143 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200144 ALC882_TARGA,
145 ALC882_ASUS_A7J,
Tobin Davis9102cd12006-12-15 10:02:12 +0100146 ALC885_MACPRO,
Kailang Yang272a5272007-05-14 11:00:38 +0200147 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC882_MODEL_LAST,
149};
150
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200151/* ALC883 models */
152enum {
153 ALC883_3ST_2ch_DIG,
154 ALC883_3ST_6ch_DIG,
155 ALC883_3ST_6ch,
156 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200157 ALC883_TARGA_DIG,
158 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200159 ALC883_ACER,
Tobin Davisc07584c2006-10-13 12:32:16 +0200160 ALC883_MEDION,
Kailang Yang272a5272007-05-14 11:00:38 +0200161 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100162 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200163 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200164 ALC883_LENOVO_NB0763,
165 ALC888_LENOVO_MS7195_DIG,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200166 ALC883_AUTO,
167 ALC883_MODEL_LAST,
168};
169
Kailang Yangdf694da2005-12-05 19:42:22 +0100170/* for GPIO Poll */
171#define GPIO_MASK 0x03
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173struct alc_spec {
174 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100175 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 unsigned int num_mixers;
177
Kailang Yangdf694da2005-12-05 19:42:22 +0100178 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200179 * don't forget NULL
180 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200181 */
182 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Takashi Iwai16ded522005-06-10 19:58:24 +0200184 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 struct hda_pcm_stream *stream_analog_playback;
186 struct hda_pcm_stream *stream_analog_capture;
187
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200188 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 struct hda_pcm_stream *stream_digital_playback;
190 struct hda_pcm_stream *stream_digital_capture;
191
192 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200193 struct hda_multi_out multiout; /* playback set-up
194 * max_channels, dacs must be set
195 * dig_out_nid and hp_nid are optional
196 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
198 /* capture */
199 unsigned int num_adc_nids;
200 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200201 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
203 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200204 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 const struct hda_input_mux *input_mux;
206 unsigned int cur_mux[3];
207
208 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100209 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200211 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
213 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100214 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200215
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200216 /* dynamic controls, init_verbs and input_mux */
217 struct auto_pin_cfg autocfg;
218 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100219 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200220 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100221 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100222
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100223 /* hooks */
224 void (*init_hook)(struct hda_codec *codec);
225 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
226
Takashi Iwai834be882006-03-01 14:16:17 +0100227 /* for pin sensing */
228 unsigned int sense_updated: 1;
229 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100230};
231
232/*
233 * configuration template - to be copied to the spec instance
234 */
235struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200236 struct snd_kcontrol_new *mixers[5]; /* should be identical size
237 * with spec
238 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100239 const struct hda_verb *init_verbs[5];
240 unsigned int num_dacs;
241 hda_nid_t *dac_nids;
242 hda_nid_t dig_out_nid; /* optional */
243 hda_nid_t hp_nid; /* optional */
244 unsigned int num_adc_nids;
245 hda_nid_t *adc_nids;
246 hda_nid_t dig_in_nid;
247 unsigned int num_channel_mode;
248 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200249 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200250 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100251 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100252 void (*unsol_event)(struct hda_codec *, unsigned int);
253 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254};
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
257/*
258 * input MUX handling
259 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200260static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
261 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262{
263 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
264 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200265 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
266 if (mux_idx >= spec->num_mux_defs)
267 mux_idx = 0;
268 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269}
270
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200271static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
272 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273{
274 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
275 struct alc_spec *spec = codec->spec;
276 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
277
278 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
279 return 0;
280}
281
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200282static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
283 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284{
285 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
286 struct alc_spec *spec = codec->spec;
287 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200288 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
289 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200290 spec->adc_nids[adc_idx],
291 &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292}
293
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200294
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295/*
296 * channel mode setting
297 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200298static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
299 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300{
301 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
302 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100303 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
304 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200307static int alc_ch_mode_get(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;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100312 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200313 spec->num_channel_mode,
314 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315}
316
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200317static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
318 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319{
320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
321 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200322 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
323 spec->num_channel_mode,
324 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200325 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200326 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
327 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328}
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100331 * Control the mode of pin widget settings via the mixer. "pc" is used
332 * instead of "%" to avoid consequences of accidently treating the % as
333 * being part of a format specifier. Maximum allowed length of a value is
334 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100335 *
336 * Note: some retasking pin complexes seem to ignore requests for input
337 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
338 * are requested. Therefore order this list so that this behaviour will not
339 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200340 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
341 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200342 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100343static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100344 "Mic 50pc bias", "Mic 80pc bias",
345 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100346};
347static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100348 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100349};
350/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200351 * in the pin being assumed to be exclusively an input or an output pin. In
352 * addition, "input" pins may or may not process the mic bias option
353 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
354 * accept requests for bias as of chip versions up to March 2006) and/or
355 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100356 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200357#define ALC_PIN_DIR_IN 0x00
358#define ALC_PIN_DIR_OUT 0x01
359#define ALC_PIN_DIR_INOUT 0x02
360#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
361#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100362
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200363/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100364 * For each direction the minimum and maximum values are given.
365 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200366static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100367 { 0, 2 }, /* ALC_PIN_DIR_IN */
368 { 3, 4 }, /* ALC_PIN_DIR_OUT */
369 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200370 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
371 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100372};
373#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
374#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
375#define alc_pin_mode_n_items(_dir) \
376 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
377
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200378static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
379 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200380{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100381 unsigned int item_num = uinfo->value.enumerated.item;
382 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
383
384 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200385 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100386 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
387
388 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
389 item_num = alc_pin_mode_min(dir);
390 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200391 return 0;
392}
393
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200394static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
395 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200396{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100397 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
399 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100400 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200401 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
403 AC_VERB_GET_PIN_WIDGET_CONTROL,
404 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200405
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100406 /* Find enumerated value for current pinctl setting */
407 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200408 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100409 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200410 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100411 return 0;
412}
413
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200414static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
415 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100416{
417 signed int change;
418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
419 hda_nid_t nid = kcontrol->private_value & 0xffff;
420 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
421 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200422 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
423 AC_VERB_GET_PIN_WIDGET_CONTROL,
424 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100425
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200426 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100427 val = alc_pin_mode_min(dir);
428
429 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100430 if (change) {
431 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200432 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200433 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100434
435 /* Also enable the retasking pin's input/output as required
436 * for the requested pin mode. Enum values of 2 or less are
437 * input modes.
438 *
439 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200440 * reduces noise slightly (particularly on input) so we'll
441 * do it. However, having both input and output buffers
442 * enabled simultaneously doesn't seem to be problematic if
443 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100444 */
445 if (val <= 2) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446 snd_hda_codec_write(codec, nid, 0,
447 AC_VERB_SET_AMP_GAIN_MUTE,
448 AMP_OUT_MUTE);
449 snd_hda_codec_write(codec, nid, 0,
450 AC_VERB_SET_AMP_GAIN_MUTE,
451 AMP_IN_UNMUTE(0));
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100452 } else {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200453 snd_hda_codec_write(codec, nid, 0,
454 AC_VERB_SET_AMP_GAIN_MUTE,
455 AMP_IN_MUTE(0));
456 snd_hda_codec_write(codec, nid, 0,
457 AC_VERB_SET_AMP_GAIN_MUTE,
458 AMP_OUT_UNMUTE);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100459 }
460 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200461 return change;
462}
463
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100464#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200465 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100466 .info = alc_pin_mode_info, \
467 .get = alc_pin_mode_get, \
468 .put = alc_pin_mode_put, \
469 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100470
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100471/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
472 * together using a mask with more than one bit set. This control is
473 * currently used only by the ALC260 test model. At this stage they are not
474 * needed for any "production" models.
475 */
476#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100479{
480 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
481 uinfo->count = 1;
482 uinfo->value.integer.min = 0;
483 uinfo->value.integer.max = 1;
484 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200485}
486
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200487static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100489{
490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
491 hda_nid_t nid = kcontrol->private_value & 0xffff;
492 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
493 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200494 unsigned int val = snd_hda_codec_read(codec, nid, 0,
495 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100496
497 *valp = (val & mask) != 0;
498 return 0;
499}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200500static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
501 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100502{
503 signed int change;
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 val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200508 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
509 AC_VERB_GET_GPIO_DATA,
510 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100511
512 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200513 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
514 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100515 gpio_data &= ~mask;
516 else
517 gpio_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200518 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100519
520 return change;
521}
522#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
523 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
524 .info = alc_gpio_data_info, \
525 .get = alc_gpio_data_get, \
526 .put = alc_gpio_data_put, \
527 .private_value = nid | (mask<<16) }
528#endif /* CONFIG_SND_DEBUG */
529
Jonathan Woithe92621f12006-02-28 11:47:47 +0100530/* A switch control to allow the enabling of the digital IO pins on the
531 * ALC260. This is incredibly simplistic; the intention of this control is
532 * to provide something in the test model allowing digital outputs to be
533 * identified if present. If models are found which can utilise these
534 * outputs a more complete mixer control can be devised for those models if
535 * necessary.
536 */
537#ifdef CONFIG_SND_DEBUG
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200538static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_info *uinfo)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100540{
541 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
542 uinfo->count = 1;
543 uinfo->value.integer.min = 0;
544 uinfo->value.integer.max = 1;
545 return 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200546}
547
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100550{
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 hda_nid_t nid = kcontrol->private_value & 0xffff;
553 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
554 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555 unsigned int val = snd_hda_codec_read(codec, nid, 0,
556 AC_VERB_GET_DIGI_CONVERT, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100557
558 *valp = (val & mask) != 0;
559 return 0;
560}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200561static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
562 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100563{
564 signed int change;
565 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
566 hda_nid_t nid = kcontrol->private_value & 0xffff;
567 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
568 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200569 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
570 AC_VERB_GET_DIGI_CONVERT,
571 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100572
573 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100575 if (val==0)
576 ctrl_data &= ~mask;
577 else
578 ctrl_data |= mask;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200579 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
580 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100581
582 return change;
583}
584#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
585 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
586 .info = alc_spdif_ctrl_info, \
587 .get = alc_spdif_ctrl_get, \
588 .put = alc_spdif_ctrl_put, \
589 .private_value = nid | (mask<<16) }
590#endif /* CONFIG_SND_DEBUG */
591
Kailang Yangdf694da2005-12-05 19:42:22 +0100592/*
593 * set up from the preset table
594 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595static void setup_preset(struct alc_spec *spec,
596 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100597{
598 int i;
599
600 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
601 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200602 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
603 i++)
604 spec->init_verbs[spec->num_init_verbs++] =
605 preset->init_verbs[i];
Kailang Yangdf694da2005-12-05 19:42:22 +0100606
607 spec->channel_mode = preset->channel_mode;
608 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200609 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100610
611 spec->multiout.max_channels = spec->channel_mode[0].channels;
612
613 spec->multiout.num_dacs = preset->num_dacs;
614 spec->multiout.dac_nids = preset->dac_nids;
615 spec->multiout.dig_out_nid = preset->dig_out_nid;
616 spec->multiout.hp_nid = preset->hp_nid;
617
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200618 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200619 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200620 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100621 spec->input_mux = preset->input_mux;
622
623 spec->num_adc_nids = preset->num_adc_nids;
624 spec->adc_nids = preset->adc_nids;
625 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100626
627 spec->unsol_event = preset->unsol_event;
628 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100629}
630
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200631/* Enable GPIO mask and set output */
632static struct hda_verb alc_gpio1_init_verbs[] = {
633 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
634 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
635 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
636 { }
637};
638
639static struct hda_verb alc_gpio2_init_verbs[] = {
640 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
641 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
642 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
643 { }
644};
645
Kailang Yangbdd148a2007-05-08 15:19:08 +0200646static struct hda_verb alc_gpio3_init_verbs[] = {
647 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
648 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
649 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
650 { }
651};
652
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200653/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
654 * 31 ~ 16 : Manufacture ID
655 * 15 ~ 8 : SKU ID
656 * 7 ~ 0 : Assembly ID
657 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
658 */
659static void alc_subsystem_id(struct hda_codec *codec,
660 unsigned int porta, unsigned int porte,
661 unsigned int portd)
662{
663 unsigned int ass, tmp;
664
665 ass = codec->subsystem_id;
666 if (!(ass & 1))
667 return;
668
669 /* Override */
670 tmp = (ass & 0x38) >> 3; /* external Amp control */
671 switch (tmp) {
672 case 1:
673 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
674 break;
675 case 3:
676 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
677 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200678 case 7:
679 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
680 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200681 case 5:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200682 switch (codec->vendor_id) {
683 case 0x10ec0862:
684 case 0x10ec0660:
685 case 0x10ec0662:
686 case 0x10ec0267:
687 case 0x10ec0268:
688 snd_hda_codec_write(codec, 0x14, 0,
689 AC_VERB_SET_EAPD_BTLENABLE, 2);
690 snd_hda_codec_write(codec, 0x15, 0,
691 AC_VERB_SET_EAPD_BTLENABLE, 2);
692 return;
693 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200694 case 6:
695 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
696 hda_nid_t port = 0;
697 tmp = (ass & 0x1800) >> 11;
698 switch (tmp) {
699 case 0: port = porta; break;
700 case 1: port = porte; break;
701 case 2: port = portd; break;
702 }
703 if (port)
704 snd_hda_codec_write(codec, port, 0,
705 AC_VERB_SET_EAPD_BTLENABLE,
706 2);
707 }
708 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
709 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
710 (tmp == 5 ? 0x3040 : 0x3050));
711 break;
712 }
713}
714
Takashi Iwai41e41f12005-06-08 14:48:49 +0200715/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200716 * ALC880 3-stack model
717 *
718 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
720 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 */
722
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200723static hda_nid_t alc880_dac_nids[4] = {
724 /* front, rear, clfe, rear_surr */
725 0x02, 0x05, 0x04, 0x03
726};
727
728static hda_nid_t alc880_adc_nids[3] = {
729 /* ADC0-2 */
730 0x07, 0x08, 0x09,
731};
732
733/* The datasheet says the node 0x07 is connected from inputs,
734 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100735 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200737static hda_nid_t alc880_adc_nids_alt[2] = {
738 /* ADC1-2 */
739 0x08, 0x09,
740};
741
742#define ALC880_DIGOUT_NID 0x06
743#define ALC880_DIGIN_NID 0x0a
744
745static struct hda_input_mux alc880_capture_source = {
746 .num_items = 4,
747 .items = {
748 { "Mic", 0x0 },
749 { "Front Mic", 0x3 },
750 { "Line", 0x2 },
751 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200753};
754
755/* channel source setting (2/6 channel selection for 3-stack) */
756/* 2ch mode */
757static struct hda_verb alc880_threestack_ch2_init[] = {
758 /* set line-in to input, mute it */
759 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
760 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
761 /* set mic-in to input vref 80%, mute it */
762 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
763 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 { } /* end */
765};
766
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200767/* 6ch mode */
768static struct hda_verb alc880_threestack_ch6_init[] = {
769 /* set line-in to output, unmute it */
770 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
771 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
772 /* set mic-in to output, unmute it */
773 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
774 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
775 { } /* end */
776};
777
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100778static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200779 { 2, alc880_threestack_ch2_init },
780 { 6, alc880_threestack_ch6_init },
781};
782
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100783static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200784 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100785 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200786 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100787 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200788 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
789 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100790 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
791 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
800 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
801 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200803 {
804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
805 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100806 .info = alc_ch_mode_info,
807 .get = alc_ch_mode_get,
808 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200809 },
810 { } /* end */
811};
812
813/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100814static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200815 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
816 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
817 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
818 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
819 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
820 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
821 {
822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
823 /* The multiple "Capture Source" controls confuse alsamixer
824 * So call somewhat different..
825 * FIXME: the controls appear in the "playback" view!
826 */
827 /* .name = "Capture Source", */
828 .name = "Input Source",
829 .count = 3,
830 .info = alc_mux_enum_info,
831 .get = alc_mux_enum_get,
832 .put = alc_mux_enum_put,
833 },
834 { } /* end */
835};
836
837/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100838static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200839 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
840 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
841 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
842 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 {
844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
845 /* The multiple "Capture Source" controls confuse alsamixer
846 * So call somewhat different..
847 * FIXME: the controls appear in the "playback" view!
848 */
849 /* .name = "Capture Source", */
850 .name = "Input Source",
851 .count = 2,
852 .info = alc_mux_enum_info,
853 .get = alc_mux_enum_get,
854 .put = alc_mux_enum_put,
855 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 { } /* end */
857};
858
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200859
860
861/*
862 * ALC880 5-stack model
863 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200864 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
865 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200866 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
867 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
868 */
869
870/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100871static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200872 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100873 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 { } /* end */
875};
876
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200877/* channel source setting (6/8 channel selection for 5-stack) */
878/* 6ch mode */
879static struct hda_verb alc880_fivestack_ch6_init[] = {
880 /* set line-in to input, mute it */
881 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
882 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200883 { } /* end */
884};
885
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200886/* 8ch mode */
887static struct hda_verb alc880_fivestack_ch8_init[] = {
888 /* set line-in to output, unmute it */
889 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
890 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
891 { } /* end */
892};
893
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100894static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200895 { 6, alc880_fivestack_ch6_init },
896 { 8, alc880_fivestack_ch8_init },
897};
898
899
900/*
901 * ALC880 6-stack model
902 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200903 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
904 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200905 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
906 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
907 */
908
909static hda_nid_t alc880_6st_dac_nids[4] = {
910 /* front, rear, clfe, rear_surr */
911 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200912};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200913
914static struct hda_input_mux alc880_6stack_capture_source = {
915 .num_items = 4,
916 .items = {
917 { "Mic", 0x0 },
918 { "Front Mic", 0x1 },
919 { "Line", 0x2 },
920 { "CD", 0x4 },
921 },
922};
923
924/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100925static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200926 { 8, NULL },
927};
928
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100929static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200930 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100931 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200932 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100933 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200934 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
935 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100936 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
937 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200938 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100939 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200940 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
941 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
942 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
943 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
946 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
947 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
948 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
949 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200950 {
951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
952 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100953 .info = alc_ch_mode_info,
954 .get = alc_ch_mode_get,
955 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200956 },
957 { } /* end */
958};
959
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200960
961/*
962 * ALC880 W810 model
963 *
964 * W810 has rear IO for:
965 * Front (DAC 02)
966 * Surround (DAC 03)
967 * Center/LFE (DAC 04)
968 * Digital out (06)
969 *
970 * The system also has a pair of internal speakers, and a headphone jack.
971 * These are both connected to Line2 on the codec, hence to DAC 02.
972 *
973 * There is a variable resistor to control the speaker or headphone
974 * volume. This is a hardware-only device without a software API.
975 *
976 * Plugging headphones in will disable the internal speakers. This is
977 * implemented in hardware, not via the driver using jack sense. In
978 * a similar fashion, plugging into the rear socket marked "front" will
979 * disable both the speakers and headphones.
980 *
981 * For input, there's a microphone jack, and an "audio in" jack.
982 * These may not do anything useful with this driver yet, because I
983 * haven't setup any initialization verbs for these yet...
984 */
985
986static hda_nid_t alc880_w810_dac_nids[3] = {
987 /* front, rear/surround, clfe */
988 0x02, 0x03, 0x04
989};
990
991/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100992static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200993 { 6, NULL }
994};
995
996/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100997static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100999 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001000 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001001 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001002 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1003 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001004 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1005 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1007 { } /* end */
1008};
1009
1010
1011/*
1012 * Z710V model
1013 *
1014 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001015 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1016 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001017 */
1018
1019static hda_nid_t alc880_z71v_dac_nids[1] = {
1020 0x02
1021};
1022#define ALC880_Z71V_HP_DAC 0x03
1023
1024/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001025static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001026 { 2, NULL }
1027};
1028
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001029static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001032 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001033 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001034 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1035 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1036 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1038 { } /* end */
1039};
1040
1041
1042/* FIXME! */
1043/*
1044 * ALC880 F1734 model
1045 *
1046 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1047 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1048 */
1049
1050static hda_nid_t alc880_f1734_dac_nids[1] = {
1051 0x03
1052};
1053#define ALC880_F1734_HP_DAC 0x02
1054
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001055static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001057 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001058 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001059 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001060 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1061 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001064 { } /* end */
1065};
1066
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001067
1068/* FIXME! */
1069/*
1070 * ALC880 ASUS model
1071 *
1072 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1073 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1074 * Mic = 0x18, Line = 0x1a
1075 */
1076
1077#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1078#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1079
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001080static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001082 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001083 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001084 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001085 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1086 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001087 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1088 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1091 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1092 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1094 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001095 {
1096 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1097 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001098 .info = alc_ch_mode_info,
1099 .get = alc_ch_mode_get,
1100 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001101 },
1102 { } /* end */
1103};
1104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001105/* FIXME! */
1106/*
1107 * ALC880 ASUS W1V model
1108 *
1109 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1110 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1111 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1112 */
1113
1114/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001115static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001116 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1117 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001118 { } /* end */
1119};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001120
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001121/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001122static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001123 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1124 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1125 { } /* end */
1126};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001127
Kailang Yangdf694da2005-12-05 19:42:22 +01001128/* TCL S700 */
1129static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1130 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1134 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1137 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1138 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1139 {
1140 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1141 /* The multiple "Capture Source" controls confuse alsamixer
1142 * So call somewhat different..
1143 * FIXME: the controls appear in the "playback" view!
1144 */
1145 /* .name = "Capture Source", */
1146 .name = "Input Source",
1147 .count = 1,
1148 .info = alc_mux_enum_info,
1149 .get = alc_mux_enum_get,
1150 .put = alc_mux_enum_put,
1151 },
1152 { } /* end */
1153};
1154
Kailang Yangccc656c2006-10-17 12:32:26 +02001155/* Uniwill */
1156static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1157 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1158 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1159 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1160 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1161 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1162 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1163 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1164 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1165 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1166 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1167 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1168 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1171 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1172 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1173 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1174 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1175 {
1176 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1177 .name = "Channel Mode",
1178 .info = alc_ch_mode_info,
1179 .get = alc_ch_mode_get,
1180 .put = alc_ch_mode_put,
1181 },
1182 { } /* end */
1183};
1184
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001185static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1186 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1187 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1188 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1189 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1190 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1191 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1192 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1193 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1194 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1195 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1196 { } /* end */
1197};
1198
Kailang Yangccc656c2006-10-17 12:32:26 +02001199static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1200 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1201 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1202 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1206 { } /* end */
1207};
1208
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001210 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 */
1212static int alc_build_controls(struct hda_codec *codec)
1213{
1214 struct alc_spec *spec = codec->spec;
1215 int err;
1216 int i;
1217
1218 for (i = 0; i < spec->num_mixers; i++) {
1219 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1220 if (err < 0)
1221 return err;
1222 }
1223
1224 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001225 err = snd_hda_create_spdif_out_ctls(codec,
1226 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 if (err < 0)
1228 return err;
1229 }
1230 if (spec->dig_in_nid) {
1231 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1232 if (err < 0)
1233 return err;
1234 }
1235 return 0;
1236}
1237
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001238
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239/*
1240 * initialize the codec volumes, etc
1241 */
1242
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001243/*
1244 * generic initialization of ADC, input mixers and output mixers
1245 */
1246static struct hda_verb alc880_volume_init_verbs[] = {
1247 /*
1248 * Unmute ADC0-2 and set the default input to mic-in
1249 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001250 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001252 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001254 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001257 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1258 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001259 * Note: PASD motherboards uses the Line In 2 as the input for front
1260 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001262 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001269 /*
1270 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001272 /* set vol=0 to output mixers */
1273 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1276 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1277 /* set up input amps for analog loopback */
1278 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001285 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1286 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287
1288 { }
1289};
1290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001291/*
1292 * 3-stack pin configuration:
1293 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1294 */
1295static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1296 /*
1297 * preset connection lists of input pins
1298 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1299 */
1300 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1301 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1302 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1303
1304 /*
1305 * Set pin mode and muting
1306 */
1307 /* set front pin widgets 0x14 for output */
1308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1310 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1311 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1312 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1313 /* Mic2 (as headphone out) for HP output */
1314 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1315 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1316 /* Line In pin widget for input */
1317 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1318 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1319 /* Line2 (as front mic) pin widget for input and vref at 80% */
1320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1321 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1322 /* CD pin widget for input */
1323 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1324
1325 { }
1326};
1327
1328/*
1329 * 5-stack pin configuration:
1330 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1331 * line-in/side = 0x1a, f-mic = 0x1b
1332 */
1333static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1334 /*
1335 * preset connection lists of input pins
1336 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1337 */
1338 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1339 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1340
1341 /*
1342 * Set pin mode and muting
1343 */
1344 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1347 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1348 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001349 /* unmute pins for output (no gain on this amp) */
1350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1354
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001357 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1358 /* Mic2 (as headphone out) for HP output */
1359 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001360 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001361 /* Line In pin widget for input */
1362 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1363 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1364 /* Line2 (as front mic) pin widget for input and vref at 80% */
1365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1366 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1367 /* CD pin widget for input */
1368 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369
1370 { }
1371};
1372
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001373/*
1374 * W810 pin configuration:
1375 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1376 */
1377static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 /* hphone/speaker input selector: front DAC */
1379 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1385 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1386 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1387
1388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001389 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 { }
1392};
1393
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001394/*
1395 * Z71V pin configuration:
1396 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1397 */
1398static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001399 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001400 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001401 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001403
Takashi Iwai16ded522005-06-10 19:58:24 +02001404 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001406 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001407 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001408
1409 { }
1410};
1411
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001412/*
1413 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001414 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1415 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001416 */
1417static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1418 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1419
Takashi Iwai16ded522005-06-10 19:58:24 +02001420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001421 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001424 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001425 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001426 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001427 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1428
Takashi Iwai16ded522005-06-10 19:58:24 +02001429 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001430 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001431 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001433 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001434 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001435 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001436 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001437 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1438
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001439 { }
1440};
Takashi Iwai16ded522005-06-10 19:58:24 +02001441
Kailang Yangccc656c2006-10-17 12:32:26 +02001442/*
1443 * Uniwill pin configuration:
1444 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1445 * line = 0x1a
1446 */
1447static struct hda_verb alc880_uniwill_init_verbs[] = {
1448 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1449
1450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1451 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1452 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1454 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1455 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1456 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1457 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1464
1465 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1466 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1467 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1469 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1470 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1471 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1472 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1473 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1474
1475 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1476 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1477
1478 { }
1479};
1480
1481/*
1482* Uniwill P53
1483* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1484 */
1485static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1486 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1487
1488 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1489 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1490 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1497 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1499 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1500
1501 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1502 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1503 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1504 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1507
1508 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1509 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1510
1511 { }
1512};
1513
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001514static struct hda_verb alc880_beep_init_verbs[] = {
1515 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1516 { }
1517};
1518
Kailang Yangccc656c2006-10-17 12:32:26 +02001519/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001520static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001521{
1522 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001523 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001524
1525 present = snd_hda_codec_read(codec, 0x14, 0,
1526 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001527 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001528 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001529 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001530 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001531 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001532 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001533 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001534 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001535 0x80, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001536}
1537
1538/* auto-toggle front mic */
1539static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1540{
1541 unsigned int present;
1542 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001543
1544 present = snd_hda_codec_read(codec, 0x18, 0,
1545 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001546 bits = present ? 0x80 : 0;
1547 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1548 0x80, bits);
1549 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1550 0x80, bits);
1551}
1552
1553static void alc880_uniwill_automute(struct hda_codec *codec)
1554{
1555 alc880_uniwill_hp_automute(codec);
1556 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001557}
1558
1559static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1560 unsigned int res)
1561{
1562 /* Looks like the unsol event is incompatible with the standard
1563 * definition. 4bit tag is placed at 28 bit!
1564 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001565 switch (res >> 28) {
1566 case ALC880_HP_EVENT:
1567 alc880_uniwill_hp_automute(codec);
1568 break;
1569 case ALC880_MIC_EVENT:
1570 alc880_uniwill_mic_automute(codec);
1571 break;
1572 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001573}
1574
1575static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1576{
1577 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001578 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001579
1580 present = snd_hda_codec_read(codec, 0x14, 0,
1581 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001582 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02001583 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001584 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001585 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001586 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001587}
1588
1589static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1590{
1591 unsigned int present;
1592
1593 present = snd_hda_codec_read(codec, 0x21, 0,
1594 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1595
1596 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1597 0x7f, present);
1598 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1599 0x7f, present);
1600
1601 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1602 0x7f, present);
1603 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1604 0x7f, present);
1605
1606}
1607static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1608 unsigned int res)
1609{
1610 /* Looks like the unsol event is incompatible with the standard
1611 * definition. 4bit tag is placed at 28 bit!
1612 */
1613 if ((res >> 28) == ALC880_HP_EVENT)
1614 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001615 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001616 alc880_uniwill_p53_dcvol_automute(codec);
1617}
1618
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001619/* FIXME! */
1620/*
1621 * F1734 pin configuration:
1622 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1623 */
1624static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1625 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1626 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1627 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1628 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1629
1630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1631 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1634
1635 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1637 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1638 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1641 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001644
1645 { }
1646};
1647
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001648/* FIXME! */
1649/*
1650 * ASUS pin configuration:
1651 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1652 */
1653static struct hda_verb alc880_pin_asus_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 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1664 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1665 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1666 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1667
1668 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1670 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1673 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1675 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1676 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1677
1678 { }
1679};
1680
1681/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001682#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1683#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001684
Kailang Yangdf694da2005-12-05 19:42:22 +01001685/* Clevo m520g init */
1686static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1687 /* headphone output */
1688 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1689 /* line-out */
1690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 /* Line-in */
1693 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1694 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 /* CD */
1696 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1697 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1698 /* Mic1 (rear panel) */
1699 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1700 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1701 /* Mic2 (front panel) */
1702 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1703 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704 /* headphone */
1705 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1706 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 /* change to EAPD mode */
1708 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1709 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1710
1711 { }
1712};
1713
1714static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02001715 /* change to EAPD mode */
1716 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1717 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1718
Kailang Yangdf694da2005-12-05 19:42:22 +01001719 /* Headphone output */
1720 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1721 /* Front output*/
1722 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1723 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1724
1725 /* Line In pin widget for input */
1726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1727 /* CD pin widget for input */
1728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1729 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1730 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1731
1732 /* change to EAPD mode */
1733 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1734 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1735
1736 { }
1737};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001738
1739/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001740 * LG m1 express dual
1741 *
1742 * Pin assignment:
1743 * Rear Line-In/Out (blue): 0x14
1744 * Build-in Mic-In: 0x15
1745 * Speaker-out: 0x17
1746 * HP-Out (green): 0x1b
1747 * Mic-In/Out (red): 0x19
1748 * SPDIF-Out: 0x1e
1749 */
1750
1751/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1752static hda_nid_t alc880_lg_dac_nids[3] = {
1753 0x05, 0x02, 0x03
1754};
1755
1756/* seems analog CD is not working */
1757static struct hda_input_mux alc880_lg_capture_source = {
1758 .num_items = 3,
1759 .items = {
1760 { "Mic", 0x1 },
1761 { "Line", 0x5 },
1762 { "Internal Mic", 0x6 },
1763 },
1764};
1765
1766/* 2,4,6 channel modes */
1767static struct hda_verb alc880_lg_ch2_init[] = {
1768 /* set line-in and mic-in to input */
1769 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1770 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1771 { }
1772};
1773
1774static struct hda_verb alc880_lg_ch4_init[] = {
1775 /* set line-in to out and mic-in to input */
1776 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1777 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1778 { }
1779};
1780
1781static struct hda_verb alc880_lg_ch6_init[] = {
1782 /* set line-in and mic-in to output */
1783 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1784 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1785 { }
1786};
1787
1788static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1789 { 2, alc880_lg_ch2_init },
1790 { 4, alc880_lg_ch4_init },
1791 { 6, alc880_lg_ch6_init },
1792};
1793
1794static struct snd_kcontrol_new alc880_lg_mixer[] = {
1795 /* FIXME: it's not really "master" but front channels */
1796 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1797 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1798 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1799 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1800 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1801 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1802 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1803 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1808 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1809 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1810 {
1811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1812 .name = "Channel Mode",
1813 .info = alc_ch_mode_info,
1814 .get = alc_ch_mode_get,
1815 .put = alc_ch_mode_put,
1816 },
1817 { } /* end */
1818};
1819
1820static struct hda_verb alc880_lg_init_verbs[] = {
1821 /* set capture source to mic-in */
1822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1823 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1825 /* mute all amp mixer inputs */
1826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1829 /* line-in to input */
1830 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1831 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1832 /* built-in mic */
1833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1835 /* speaker-out */
1836 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1837 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1838 /* mic-in to input */
1839 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1842 /* HP-out */
1843 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1846 /* jack sense */
1847 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1848 { }
1849};
1850
1851/* toggle speaker-output according to the hp-jack state */
1852static void alc880_lg_automute(struct hda_codec *codec)
1853{
1854 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001855 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001856
1857 present = snd_hda_codec_read(codec, 0x1b, 0,
1858 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001859 bits = present ? 0x80 : 0;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001860 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001861 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001862 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001863 0x80, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001864}
1865
1866static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1867{
1868 /* Looks like the unsol event is incompatible with the standard
1869 * definition. 4bit tag is placed at 28 bit!
1870 */
1871 if ((res >> 28) == 0x01)
1872 alc880_lg_automute(codec);
1873}
1874
1875/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001876 * LG LW20
1877 *
1878 * Pin assignment:
1879 * Speaker-out: 0x14
1880 * Mic-In: 0x18
1881 * Built-in Mic-In: 0x19 (?)
1882 * HP-Out: 0x1b
1883 * SPDIF-Out: 0x1e
1884 */
1885
1886/* seems analog CD is not working */
1887static struct hda_input_mux alc880_lg_lw_capture_source = {
1888 .num_items = 2,
1889 .items = {
1890 { "Mic", 0x0 },
1891 { "Internal Mic", 0x1 },
1892 },
1893};
1894
1895static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1896 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1897 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1900 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1901 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1902 { } /* end */
1903};
1904
1905static struct hda_verb alc880_lg_lw_init_verbs[] = {
1906 /* set capture source to mic-in */
1907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1908 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1909 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1911 /* speaker-out */
1912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1914 /* HP-out */
1915 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1918 /* mic-in to input */
1919 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1920 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1921 /* built-in mic */
1922 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1923 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1924 /* jack sense */
1925 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1926 { }
1927};
1928
1929/* toggle speaker-output according to the hp-jack state */
1930static void alc880_lg_lw_automute(struct hda_codec *codec)
1931{
1932 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001933 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01001934
1935 present = snd_hda_codec_read(codec, 0x1b, 0,
1936 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001937 bits = present ? 0x80 : 0;
Takashi Iwaid6815182006-03-23 16:06:23 +01001938 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001939 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001940 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001941 0x80, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01001942}
1943
1944static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1945{
1946 /* Looks like the unsol event is incompatible with the standard
1947 * definition. 4bit tag is placed at 28 bit!
1948 */
1949 if ((res >> 28) == 0x01)
1950 alc880_lg_lw_automute(codec);
1951}
1952
1953/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001954 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001955 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001956
Linus Torvalds1da177e2005-04-16 15:20:36 -07001957static int alc_init(struct hda_codec *codec)
1958{
1959 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001960 unsigned int i;
1961
1962 for (i = 0; i < spec->num_init_verbs; i++)
1963 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001964
1965 if (spec->init_hook)
1966 spec->init_hook(codec);
1967
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 return 0;
1969}
1970
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001971static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1972{
1973 struct alc_spec *spec = codec->spec;
1974
1975 if (spec->unsol_event)
1976 spec->unsol_event(codec, res);
1977}
1978
Linus Torvalds1da177e2005-04-16 15:20:36 -07001979#ifdef CONFIG_PM
1980/*
1981 * resume
1982 */
1983static int alc_resume(struct hda_codec *codec)
1984{
1985 struct alc_spec *spec = codec->spec;
1986 int i;
1987
1988 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001989 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991 if (spec->multiout.dig_out_nid)
1992 snd_hda_resume_spdif_out(codec);
1993 if (spec->dig_in_nid)
1994 snd_hda_resume_spdif_in(codec);
1995
1996 return 0;
1997}
1998#endif
1999
2000/*
2001 * Analog playback callbacks
2002 */
2003static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2004 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002005 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006{
2007 struct alc_spec *spec = codec->spec;
2008 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2009}
2010
2011static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2012 struct hda_codec *codec,
2013 unsigned int stream_tag,
2014 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002015 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002016{
2017 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002018 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2019 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002020}
2021
2022static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2023 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002024 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025{
2026 struct alc_spec *spec = codec->spec;
2027 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2028}
2029
2030/*
2031 * Digital out
2032 */
2033static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2034 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002035 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036{
2037 struct alc_spec *spec = codec->spec;
2038 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2039}
2040
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002041static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2042 struct hda_codec *codec,
2043 unsigned int stream_tag,
2044 unsigned int format,
2045 struct snd_pcm_substream *substream)
2046{
2047 struct alc_spec *spec = codec->spec;
2048 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2049 stream_tag, format, substream);
2050}
2051
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2053 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002054 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055{
2056 struct alc_spec *spec = codec->spec;
2057 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2058}
2059
2060/*
2061 * Analog capture
2062 */
2063static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2064 struct hda_codec *codec,
2065 unsigned int stream_tag,
2066 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002067 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002068{
2069 struct alc_spec *spec = codec->spec;
2070
2071 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2072 stream_tag, 0, format);
2073 return 0;
2074}
2075
2076static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2077 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002078 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079{
2080 struct alc_spec *spec = codec->spec;
2081
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002082 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2083 0, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084 return 0;
2085}
2086
2087
2088/*
2089 */
2090static struct hda_pcm_stream alc880_pcm_analog_playback = {
2091 .substreams = 1,
2092 .channels_min = 2,
2093 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002094 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 .ops = {
2096 .open = alc880_playback_pcm_open,
2097 .prepare = alc880_playback_pcm_prepare,
2098 .cleanup = alc880_playback_pcm_cleanup
2099 },
2100};
2101
2102static struct hda_pcm_stream alc880_pcm_analog_capture = {
2103 .substreams = 2,
2104 .channels_min = 2,
2105 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002106 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107 .ops = {
2108 .prepare = alc880_capture_pcm_prepare,
2109 .cleanup = alc880_capture_pcm_cleanup
2110 },
2111};
2112
2113static struct hda_pcm_stream alc880_pcm_digital_playback = {
2114 .substreams = 1,
2115 .channels_min = 2,
2116 .channels_max = 2,
2117 /* NID is set in alc_build_pcms */
2118 .ops = {
2119 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002120 .close = alc880_dig_playback_pcm_close,
2121 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002122 },
2123};
2124
2125static struct hda_pcm_stream alc880_pcm_digital_capture = {
2126 .substreams = 1,
2127 .channels_min = 2,
2128 .channels_max = 2,
2129 /* NID is set in alc_build_pcms */
2130};
2131
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002132/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2133static struct hda_pcm_stream alc_pcm_null_playback = {
2134 .substreams = 0,
2135 .channels_min = 0,
2136 .channels_max = 0,
2137};
2138
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139static int alc_build_pcms(struct hda_codec *codec)
2140{
2141 struct alc_spec *spec = codec->spec;
2142 struct hda_pcm *info = spec->pcm_rec;
2143 int i;
2144
2145 codec->num_pcms = 1;
2146 codec->pcm_info = info;
2147
2148 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002149 if (spec->stream_analog_playback) {
2150 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2151 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2152 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2153 }
2154 if (spec->stream_analog_capture) {
2155 snd_assert(spec->adc_nids, return -EINVAL);
2156 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2157 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2158 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159
Takashi Iwai4a471b72005-12-07 13:56:29 +01002160 if (spec->channel_mode) {
2161 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2162 for (i = 0; i < spec->num_channel_mode; i++) {
2163 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2164 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2165 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002166 }
2167 }
2168
Takashi Iwaie08a0072006-09-07 17:52:14 +02002169 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002171 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002172 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002174 if (spec->multiout.dig_out_nid &&
2175 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2177 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2178 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002179 if (spec->dig_in_nid &&
2180 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002181 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2182 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2183 }
2184 }
2185
Takashi Iwaie08a0072006-09-07 17:52:14 +02002186 /* If the use of more than one ADC is requested for the current
2187 * model, configure a second analog capture-only PCM.
2188 */
2189 /* Additional Analaog capture for index #2 */
2190 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2191 spec->adc_nids) {
2192 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002193 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002194 info->name = spec->stream_name_analog;
2195 /* No playback stream for second PCM */
2196 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2197 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2198 if (spec->stream_analog_capture) {
2199 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2200 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2201 }
2202 }
2203
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 return 0;
2205}
2206
2207static void alc_free(struct hda_codec *codec)
2208{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 struct alc_spec *spec = codec->spec;
2210 unsigned int i;
2211
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002212 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213 return;
2214
2215 if (spec->kctl_alloc) {
2216 for (i = 0; i < spec->num_kctl_used; i++)
2217 kfree(spec->kctl_alloc[i].name);
2218 kfree(spec->kctl_alloc);
2219 }
2220 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221}
2222
2223/*
2224 */
2225static struct hda_codec_ops alc_patch_ops = {
2226 .build_controls = alc_build_controls,
2227 .build_pcms = alc_build_pcms,
2228 .init = alc_init,
2229 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002230 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231#ifdef CONFIG_PM
2232 .resume = alc_resume,
2233#endif
2234};
2235
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002236
2237/*
2238 * Test configuration for debugging
2239 *
2240 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2241 * enum controls.
2242 */
2243#ifdef CONFIG_SND_DEBUG
2244static hda_nid_t alc880_test_dac_nids[4] = {
2245 0x02, 0x03, 0x04, 0x05
2246};
2247
2248static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002249 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002250 .items = {
2251 { "In-1", 0x0 },
2252 { "In-2", 0x1 },
2253 { "In-3", 0x2 },
2254 { "In-4", 0x3 },
2255 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002256 { "Front", 0x5 },
2257 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002258 },
2259};
2260
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002261static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002262 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002263 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002264 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002265 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002266};
2267
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002268static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2269 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002270{
2271 static char *texts[] = {
2272 "N/A", "Line Out", "HP Out",
2273 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2274 };
2275 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2276 uinfo->count = 1;
2277 uinfo->value.enumerated.items = 8;
2278 if (uinfo->value.enumerated.item >= 8)
2279 uinfo->value.enumerated.item = 7;
2280 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2281 return 0;
2282}
2283
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002284static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2285 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002286{
2287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2288 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2289 unsigned int pin_ctl, item = 0;
2290
2291 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2292 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2293 if (pin_ctl & AC_PINCTL_OUT_EN) {
2294 if (pin_ctl & AC_PINCTL_HP_EN)
2295 item = 2;
2296 else
2297 item = 1;
2298 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2299 switch (pin_ctl & AC_PINCTL_VREFEN) {
2300 case AC_PINCTL_VREF_HIZ: item = 3; break;
2301 case AC_PINCTL_VREF_50: item = 4; break;
2302 case AC_PINCTL_VREF_GRD: item = 5; break;
2303 case AC_PINCTL_VREF_80: item = 6; break;
2304 case AC_PINCTL_VREF_100: item = 7; break;
2305 }
2306 }
2307 ucontrol->value.enumerated.item[0] = item;
2308 return 0;
2309}
2310
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002311static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2312 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002313{
2314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2315 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2316 static unsigned int ctls[] = {
2317 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2318 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2319 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2320 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2321 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2322 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2323 };
2324 unsigned int old_ctl, new_ctl;
2325
2326 old_ctl = snd_hda_codec_read(codec, nid, 0,
2327 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2328 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2329 if (old_ctl != new_ctl) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002330 snd_hda_codec_write(codec, nid, 0,
2331 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002332 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002333 (ucontrol->value.enumerated.item[0] >= 3 ?
2334 0xb080 : 0xb000));
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002335 return 1;
2336 }
2337 return 0;
2338}
2339
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002340static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2341 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002342{
2343 static char *texts[] = {
2344 "Front", "Surround", "CLFE", "Side"
2345 };
2346 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2347 uinfo->count = 1;
2348 uinfo->value.enumerated.items = 4;
2349 if (uinfo->value.enumerated.item >= 4)
2350 uinfo->value.enumerated.item = 3;
2351 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2352 return 0;
2353}
2354
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002355static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2356 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002357{
2358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2359 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2360 unsigned int sel;
2361
2362 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2363 ucontrol->value.enumerated.item[0] = sel & 3;
2364 return 0;
2365}
2366
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002367static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2368 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002369{
2370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2371 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2372 unsigned int sel;
2373
2374 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2375 if (ucontrol->value.enumerated.item[0] != sel) {
2376 sel = ucontrol->value.enumerated.item[0] & 3;
2377 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2378 return 1;
2379 }
2380 return 0;
2381}
2382
2383#define PIN_CTL_TEST(xname,nid) { \
2384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2385 .name = xname, \
2386 .info = alc_test_pin_ctl_info, \
2387 .get = alc_test_pin_ctl_get, \
2388 .put = alc_test_pin_ctl_put, \
2389 .private_value = nid \
2390 }
2391
2392#define PIN_SRC_TEST(xname,nid) { \
2393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2394 .name = xname, \
2395 .info = alc_test_pin_src_info, \
2396 .get = alc_test_pin_src_get, \
2397 .put = alc_test_pin_src_put, \
2398 .private_value = nid \
2399 }
2400
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002401static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002402 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2403 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2404 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2405 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002406 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2407 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2408 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2409 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002410 PIN_CTL_TEST("Front Pin Mode", 0x14),
2411 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2412 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2413 PIN_CTL_TEST("Side Pin Mode", 0x17),
2414 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2415 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2416 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2417 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2418 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2419 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2420 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2421 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2422 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2423 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2424 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2425 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2426 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2427 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2428 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2429 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2430 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2431 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002432 {
2433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2434 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002435 .info = alc_ch_mode_info,
2436 .get = alc_ch_mode_get,
2437 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002438 },
2439 { } /* end */
2440};
2441
2442static struct hda_verb alc880_test_init_verbs[] = {
2443 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2446 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2447 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2448 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2449 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2450 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2451 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002452 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2456 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002457 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2459 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2460 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2461 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002462 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2465 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2466 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002467 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002468 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2469 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002470 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2472 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002473 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002478 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002480 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002482 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002483 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002484 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002485 /* Analog input/passthru */
2486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2487 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002491 { }
2492};
2493#endif
2494
Linus Torvalds1da177e2005-04-16 15:20:36 -07002495/*
2496 */
2497
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002498static const char *alc880_models[ALC880_MODEL_LAST] = {
2499 [ALC880_3ST] = "3stack",
2500 [ALC880_TCL_S700] = "tcl",
2501 [ALC880_3ST_DIG] = "3stack-digout",
2502 [ALC880_CLEVO] = "clevo",
2503 [ALC880_5ST] = "5stack",
2504 [ALC880_5ST_DIG] = "5stack-digout",
2505 [ALC880_W810] = "w810",
2506 [ALC880_Z71V] = "z71v",
2507 [ALC880_6ST] = "6stack",
2508 [ALC880_6ST_DIG] = "6stack-digout",
2509 [ALC880_ASUS] = "asus",
2510 [ALC880_ASUS_W1V] = "asus-w1v",
2511 [ALC880_ASUS_DIG] = "asus-dig",
2512 [ALC880_ASUS_DIG2] = "asus-dig2",
2513 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002514 [ALC880_UNIWILL_P53] = "uniwill-p53",
2515 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002516 [ALC880_F1734] = "F1734",
2517 [ALC880_LG] = "lg",
2518 [ALC880_LG_LW] = "lg-lw",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002519#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002520 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002521#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002522 [ALC880_AUTO] = "auto",
2523};
2524
2525static struct snd_pci_quirk alc880_cfg_tbl[] = {
2526 /* Broken BIOS configuration */
2527 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2528 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2529
2530 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2531 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
Tobin Davis4dc53e22006-12-18 13:24:37 +01002532 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002533 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2534 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2535 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2536 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2537 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2538 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2539
2540 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2541 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2542
2543 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2544 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2545 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2546 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2547 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2548 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2549 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2550 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2551 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2552 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Tobin Davis0e4ceb72007-01-08 10:54:26 +01002553 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002554 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2555 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2556 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2557 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2558
2559 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2560 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2561 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2562 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2563 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2564 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2565 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2566 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2567 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2568 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2569 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2570 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2571 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2572 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2573 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2574 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2575 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2576 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2577
2578 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2579 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2580 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2581 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2582
2583 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2584 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2585 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002586 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01002587
2588 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2589 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2590 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2591 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2592
2593 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2594 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2595 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2596 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2597 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2598 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2599 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2600 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2601 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2602 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2603 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002604
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 {}
2606};
2607
Takashi Iwai16ded522005-06-10 19:58:24 +02002608/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002609 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002610 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002611static struct alc_config_preset alc880_presets[] = {
2612 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002614 .init_verbs = { alc880_volume_init_verbs,
2615 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002616 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002617 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002618 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2619 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002620 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002621 .input_mux = &alc880_capture_source,
2622 },
2623 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002625 .init_verbs = { alc880_volume_init_verbs,
2626 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002627 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002628 .dac_nids = alc880_dac_nids,
2629 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002630 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2631 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002632 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002633 .input_mux = &alc880_capture_source,
2634 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002635 [ALC880_TCL_S700] = {
2636 .mixers = { alc880_tcl_s700_mixer },
2637 .init_verbs = { alc880_volume_init_verbs,
2638 alc880_pin_tcl_S700_init_verbs,
2639 alc880_gpio2_init_verbs },
2640 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2641 .dac_nids = alc880_dac_nids,
2642 .hp_nid = 0x03,
2643 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2644 .channel_mode = alc880_2_jack_modes,
2645 .input_mux = &alc880_capture_source,
2646 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002647 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002648 .mixers = { alc880_three_stack_mixer,
2649 alc880_five_stack_mixer},
2650 .init_verbs = { alc880_volume_init_verbs,
2651 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002652 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2653 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002654 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2655 .channel_mode = alc880_fivestack_modes,
2656 .input_mux = &alc880_capture_source,
2657 },
2658 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002659 .mixers = { alc880_three_stack_mixer,
2660 alc880_five_stack_mixer },
2661 .init_verbs = { alc880_volume_init_verbs,
2662 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002663 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2664 .dac_nids = alc880_dac_nids,
2665 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002666 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2667 .channel_mode = alc880_fivestack_modes,
2668 .input_mux = &alc880_capture_source,
2669 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002670 [ALC880_6ST] = {
2671 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002672 .init_verbs = { alc880_volume_init_verbs,
2673 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002674 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2675 .dac_nids = alc880_6st_dac_nids,
2676 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2677 .channel_mode = alc880_sixstack_modes,
2678 .input_mux = &alc880_6stack_capture_source,
2679 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002680 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002681 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002682 .init_verbs = { alc880_volume_init_verbs,
2683 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2685 .dac_nids = alc880_6st_dac_nids,
2686 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002687 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2688 .channel_mode = alc880_sixstack_modes,
2689 .input_mux = &alc880_6stack_capture_source,
2690 },
2691 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002692 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002693 .init_verbs = { alc880_volume_init_verbs,
2694 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002695 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002696 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2697 .dac_nids = alc880_w810_dac_nids,
2698 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002699 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2700 .channel_mode = alc880_w810_modes,
2701 .input_mux = &alc880_capture_source,
2702 },
2703 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002705 .init_verbs = { alc880_volume_init_verbs,
2706 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002707 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2708 .dac_nids = alc880_z71v_dac_nids,
2709 .dig_out_nid = ALC880_DIGOUT_NID,
2710 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2712 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002713 .input_mux = &alc880_capture_source,
2714 },
2715 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002716 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002717 .init_verbs = { alc880_volume_init_verbs,
2718 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002719 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2720 .dac_nids = alc880_f1734_dac_nids,
2721 .hp_nid = 0x02,
2722 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2723 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002724 .input_mux = &alc880_capture_source,
2725 },
2726 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002727 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002728 .init_verbs = { alc880_volume_init_verbs,
2729 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 alc880_gpio1_init_verbs },
2731 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2732 .dac_nids = alc880_asus_dac_nids,
2733 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2734 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002735 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002736 .input_mux = &alc880_capture_source,
2737 },
2738 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002739 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002740 .init_verbs = { alc880_volume_init_verbs,
2741 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002742 alc880_gpio1_init_verbs },
2743 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2744 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002745 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2747 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002748 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002749 .input_mux = &alc880_capture_source,
2750 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002751 [ALC880_ASUS_DIG2] = {
2752 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002753 .init_verbs = { alc880_volume_init_verbs,
2754 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01002755 alc880_gpio2_init_verbs }, /* use GPIO2 */
2756 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2757 .dac_nids = alc880_asus_dac_nids,
2758 .dig_out_nid = ALC880_DIGOUT_NID,
2759 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2760 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002761 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002762 .input_mux = &alc880_capture_source,
2763 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002764 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002765 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002766 .init_verbs = { alc880_volume_init_verbs,
2767 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002768 alc880_gpio1_init_verbs },
2769 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2770 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002771 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2773 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002774 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002775 .input_mux = &alc880_capture_source,
2776 },
2777 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002778 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02002779 .init_verbs = { alc880_volume_init_verbs,
2780 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2782 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002783 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2785 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002786 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02002787 .input_mux = &alc880_capture_source,
2788 },
Kailang Yangccc656c2006-10-17 12:32:26 +02002789 [ALC880_UNIWILL] = {
2790 .mixers = { alc880_uniwill_mixer },
2791 .init_verbs = { alc880_volume_init_verbs,
2792 alc880_uniwill_init_verbs },
2793 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2794 .dac_nids = alc880_asus_dac_nids,
2795 .dig_out_nid = ALC880_DIGOUT_NID,
2796 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2797 .channel_mode = alc880_threestack_modes,
2798 .need_dac_fix = 1,
2799 .input_mux = &alc880_capture_source,
2800 .unsol_event = alc880_uniwill_unsol_event,
2801 .init_hook = alc880_uniwill_automute,
2802 },
2803 [ALC880_UNIWILL_P53] = {
2804 .mixers = { alc880_uniwill_p53_mixer },
2805 .init_verbs = { alc880_volume_init_verbs,
2806 alc880_uniwill_p53_init_verbs },
2807 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2808 .dac_nids = alc880_asus_dac_nids,
2809 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002810 .channel_mode = alc880_threestack_modes,
2811 .input_mux = &alc880_capture_source,
2812 .unsol_event = alc880_uniwill_p53_unsol_event,
2813 .init_hook = alc880_uniwill_p53_hp_automute,
2814 },
2815 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002816 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002817 alc880_pcbeep_mixer, },
2818 .init_verbs = { alc880_volume_init_verbs,
2819 alc880_uniwill_p53_init_verbs,
2820 alc880_beep_init_verbs },
2821 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2822 .dac_nids = alc880_dac_nids,
2823 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2824 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02002825 .input_mux = &alc880_capture_source,
2826 .unsol_event = alc880_uniwill_p53_unsol_event,
2827 .init_hook = alc880_uniwill_p53_hp_automute,
2828 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002829 [ALC880_CLEVO] = {
2830 .mixers = { alc880_three_stack_mixer },
2831 .init_verbs = { alc880_volume_init_verbs,
2832 alc880_pin_clevo_init_verbs },
2833 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2834 .dac_nids = alc880_dac_nids,
2835 .hp_nid = 0x03,
2836 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2837 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002838 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01002839 .input_mux = &alc880_capture_source,
2840 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002841 [ALC880_LG] = {
2842 .mixers = { alc880_lg_mixer },
2843 .init_verbs = { alc880_volume_init_verbs,
2844 alc880_lg_init_verbs },
2845 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2846 .dac_nids = alc880_lg_dac_nids,
2847 .dig_out_nid = ALC880_DIGOUT_NID,
2848 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2849 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02002850 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002851 .input_mux = &alc880_lg_capture_source,
2852 .unsol_event = alc880_lg_unsol_event,
2853 .init_hook = alc880_lg_automute,
2854 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002855 [ALC880_LG_LW] = {
2856 .mixers = { alc880_lg_lw_mixer },
2857 .init_verbs = { alc880_volume_init_verbs,
2858 alc880_lg_lw_init_verbs },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002859 .num_dacs = 1,
Takashi Iwaid6815182006-03-23 16:06:23 +01002860 .dac_nids = alc880_dac_nids,
2861 .dig_out_nid = ALC880_DIGOUT_NID,
2862 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2863 .channel_mode = alc880_2_jack_modes,
2864 .input_mux = &alc880_lg_lw_capture_source,
2865 .unsol_event = alc880_lg_lw_unsol_event,
2866 .init_hook = alc880_lg_lw_automute,
2867 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002868#ifdef CONFIG_SND_DEBUG
2869 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002870 .mixers = { alc880_test_mixer },
2871 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002872 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2873 .dac_nids = alc880_test_dac_nids,
2874 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002875 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2876 .channel_mode = alc880_test_modes,
2877 .input_mux = &alc880_test_capture_source,
2878 },
2879#endif
2880};
2881
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882/*
2883 * Automatic parse of I/O pins from the BIOS configuration
2884 */
2885
2886#define NUM_CONTROL_ALLOC 32
2887#define NUM_VERB_ALLOC 32
2888
2889enum {
2890 ALC_CTL_WIDGET_VOL,
2891 ALC_CTL_WIDGET_MUTE,
2892 ALC_CTL_BIND_MUTE,
2893};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002894static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002895 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2896 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002897 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898};
2899
2900/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002901static int add_control(struct alc_spec *spec, int type, const char *name,
2902 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002903{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002904 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002905
2906 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2907 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2908
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002909 /* array + terminator */
2910 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2911 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002912 return -ENOMEM;
2913 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002914 memcpy(knew, spec->kctl_alloc,
2915 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002916 kfree(spec->kctl_alloc);
2917 }
2918 spec->kctl_alloc = knew;
2919 spec->num_kctl_alloc = num;
2920 }
2921
2922 knew = &spec->kctl_alloc[spec->num_kctl_used];
2923 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002924 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002925 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002926 return -ENOMEM;
2927 knew->private_value = val;
2928 spec->num_kctl_used++;
2929 return 0;
2930}
2931
2932#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2933#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2934#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2935#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2936#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2937#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2938#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2939#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2940#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2941#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2942#define ALC880_PIN_CD_NID 0x1c
2943
2944/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002945static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2946 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002947{
2948 hda_nid_t nid;
2949 int assigned[4];
2950 int i, j;
2951
2952 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002953 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954
2955 /* check the pins hardwired to audio widget */
2956 for (i = 0; i < cfg->line_outs; i++) {
2957 nid = cfg->line_out_pins[i];
2958 if (alc880_is_fixed_pin(nid)) {
2959 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002960 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961 assigned[idx] = 1;
2962 }
2963 }
2964 /* left pins can be connect to any audio widget */
2965 for (i = 0; i < cfg->line_outs; i++) {
2966 nid = cfg->line_out_pins[i];
2967 if (alc880_is_fixed_pin(nid))
2968 continue;
2969 /* search for an empty channel */
2970 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002971 if (!assigned[j]) {
2972 spec->multiout.dac_nids[i] =
2973 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974 assigned[j] = 1;
2975 break;
2976 }
2977 }
2978 }
2979 spec->multiout.num_dacs = cfg->line_outs;
2980 return 0;
2981}
2982
2983/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002984static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2985 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002986{
2987 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002988 static const char *chname[4] = {
2989 "Front", "Surround", NULL /*CLFE*/, "Side"
2990 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002991 hda_nid_t nid;
2992 int i, err;
2993
2994 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002995 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002996 continue;
2997 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2998 if (i == 2) {
2999 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003000 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3001 "Center Playback Volume",
3002 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3003 HDA_OUTPUT));
3004 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003005 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003006 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3007 "LFE Playback Volume",
3008 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3009 HDA_OUTPUT));
3010 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003011 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003012 err = add_control(spec, ALC_CTL_BIND_MUTE,
3013 "Center Playback Switch",
3014 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3015 HDA_INPUT));
3016 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003017 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003018 err = add_control(spec, ALC_CTL_BIND_MUTE,
3019 "LFE Playback Switch",
3020 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3021 HDA_INPUT));
3022 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003023 return err;
3024 } else {
3025 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003026 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3027 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3028 HDA_OUTPUT));
3029 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003030 return err;
3031 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003032 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3033 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3034 HDA_INPUT));
3035 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003036 return err;
3037 }
3038 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003039 return 0;
3040}
3041
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003042/* add playback controls for speaker and HP outputs */
3043static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3044 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003045{
3046 hda_nid_t nid;
3047 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003048 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003049
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003050 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003051 return 0;
3052
3053 if (alc880_is_fixed_pin(pin)) {
3054 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003055 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003056 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003057 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003058 else
3059 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 /* control HP volume/switch on the output mixer amp */
3061 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003062 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003063 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3064 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3065 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003066 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003067 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003068 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3069 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3070 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003071 return err;
3072 } else if (alc880_is_multi_pin(pin)) {
3073 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003074 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003075 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003076 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3077 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3078 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 return err;
3080 }
3081 return 0;
3082}
3083
3084/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003085static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3086 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003087 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088{
3089 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003090 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091
3092 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003093 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3094 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3095 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096 return err;
3097 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003098 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3099 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3100 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003101 return err;
3102 return 0;
3103}
3104
3105/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003106static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3107 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003110 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003111
3112 for (i = 0; i < AUTO_PIN_LAST; i++) {
3113 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003114 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003115 err = new_analog_input(spec, cfg->input_pins[i],
3116 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003117 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 if (err < 0)
3119 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003120 imux->items[imux->num_items].label =
3121 auto_pin_cfg_labels[i];
3122 imux->items[imux->num_items].index =
3123 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 imux->num_items++;
3125 }
3126 }
3127 return 0;
3128}
3129
Kailang Yangdf694da2005-12-05 19:42:22 +01003130static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3131 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003132 int dac_idx)
3133{
3134 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003135 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3136 pin_type);
3137 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3138 AMP_OUT_UNMUTE);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003139 /* need the manual connection? */
3140 if (alc880_is_multi_pin(nid)) {
3141 struct alc_spec *spec = codec->spec;
3142 int idx = alc880_multi_pin_idx(nid);
3143 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3144 AC_VERB_SET_CONNECT_SEL,
3145 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3146 }
3147}
3148
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003149static int get_pin_type(int line_out_type)
3150{
3151 if (line_out_type == AUTO_PIN_HP_OUT)
3152 return PIN_HP;
3153 else
3154 return PIN_OUT;
3155}
3156
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003157static void alc880_auto_init_multi_out(struct hda_codec *codec)
3158{
3159 struct alc_spec *spec = codec->spec;
3160 int i;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003161
3162 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003163 for (i = 0; i < spec->autocfg.line_outs; i++) {
3164 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003165 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3166 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003167 }
3168}
3169
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003170static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003171{
3172 struct alc_spec *spec = codec->spec;
3173 hda_nid_t pin;
3174
Takashi Iwai82bc9552006-03-21 11:24:42 +01003175 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003176 if (pin) /* connect to front */
3177 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003178 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003179 if (pin) /* connect to front */
3180 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3181}
3182
3183static void alc880_auto_init_analog_input(struct hda_codec *codec)
3184{
3185 struct alc_spec *spec = codec->spec;
3186 int i;
3187
3188 for (i = 0; i < AUTO_PIN_LAST; i++) {
3189 hda_nid_t nid = spec->autocfg.input_pins[i];
3190 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003191 snd_hda_codec_write(codec, nid, 0,
3192 AC_VERB_SET_PIN_WIDGET_CONTROL,
3193 i <= AUTO_PIN_FRONT_MIC ?
3194 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003195 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003196 snd_hda_codec_write(codec, nid, 0,
3197 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198 AMP_OUT_MUTE);
3199 }
3200 }
3201}
3202
3203/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003204/* return 1 if successful, 0 if the proper config is not found,
3205 * or a negative error code
3206 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003207static int alc880_parse_auto_config(struct hda_codec *codec)
3208{
3209 struct alc_spec *spec = codec->spec;
3210 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003211 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003212
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003213 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3214 alc880_ignore);
3215 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003216 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003217 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003218 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003219
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003220 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3221 if (err < 0)
3222 return err;
3223 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3224 if (err < 0)
3225 return err;
3226 err = alc880_auto_create_extra_out(spec,
3227 spec->autocfg.speaker_pins[0],
3228 "Speaker");
3229 if (err < 0)
3230 return err;
3231 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3232 "Headphone");
3233 if (err < 0)
3234 return err;
3235 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3236 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237 return err;
3238
3239 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3240
3241 if (spec->autocfg.dig_out_pin)
3242 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3243 if (spec->autocfg.dig_in_pin)
3244 spec->dig_in_nid = ALC880_DIGIN_NID;
3245
3246 if (spec->kctl_alloc)
3247 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3248
3249 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3250
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003251 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 spec->input_mux = &spec->private_imux;
3253
3254 return 1;
3255}
3256
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003257/* additional initialization for auto-configuration model */
3258static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003260 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003261 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263}
3264
3265/*
3266 * OK, here we have finally the patch for ALC880
3267 */
3268
Linus Torvalds1da177e2005-04-16 15:20:36 -07003269static int patch_alc880(struct hda_codec *codec)
3270{
3271 struct alc_spec *spec;
3272 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003273 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003274
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003275 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003276 if (spec == NULL)
3277 return -ENOMEM;
3278
3279 codec->spec = spec;
3280
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003281 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3282 alc880_models,
3283 alc880_cfg_tbl);
3284 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003285 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3286 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003287 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003288 }
3289
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003290 if (board_config == ALC880_AUTO) {
3291 /* automatic parse from the BIOS config */
3292 err = alc880_parse_auto_config(codec);
3293 if (err < 0) {
3294 alc_free(codec);
3295 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003296 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003297 printk(KERN_INFO
3298 "hda_codec: Cannot set up configuration "
3299 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003300 board_config = ALC880_3ST;
3301 }
3302 }
3303
Kailang Yangdf694da2005-12-05 19:42:22 +01003304 if (board_config != ALC880_AUTO)
3305 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003306
3307 spec->stream_name_analog = "ALC880 Analog";
3308 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3309 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3310
3311 spec->stream_name_digital = "ALC880 Digital";
3312 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3313 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3314
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003315 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003317 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003318 /* get type */
3319 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003320 if (wcap != AC_WID_AUD_IN) {
3321 spec->adc_nids = alc880_adc_nids_alt;
3322 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003323 spec->mixers[spec->num_mixers] =
3324 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003325 spec->num_mixers++;
3326 } else {
3327 spec->adc_nids = alc880_adc_nids;
3328 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3329 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3330 spec->num_mixers++;
3331 }
3332 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003333
3334 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003335 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003336 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003337
3338 return 0;
3339}
3340
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003341
Linus Torvalds1da177e2005-04-16 15:20:36 -07003342/*
3343 * ALC260 support
3344 */
3345
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003346static hda_nid_t alc260_dac_nids[1] = {
3347 /* front */
3348 0x02,
3349};
3350
3351static hda_nid_t alc260_adc_nids[1] = {
3352 /* ADC0 */
3353 0x04,
3354};
3355
Kailang Yangdf694da2005-12-05 19:42:22 +01003356static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003357 /* ADC1 */
3358 0x05,
3359};
3360
Kailang Yangdf694da2005-12-05 19:42:22 +01003361static hda_nid_t alc260_hp_adc_nids[2] = {
3362 /* ADC1, 0 */
3363 0x05, 0x04
3364};
3365
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003366/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3367 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3368 */
3369static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003370 /* ADC0, ADC1 */
3371 0x04, 0x05
3372};
3373
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003374#define ALC260_DIGOUT_NID 0x03
3375#define ALC260_DIGIN_NID 0x06
3376
3377static struct hda_input_mux alc260_capture_source = {
3378 .num_items = 4,
3379 .items = {
3380 { "Mic", 0x0 },
3381 { "Front Mic", 0x1 },
3382 { "Line", 0x2 },
3383 { "CD", 0x4 },
3384 },
3385};
3386
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003387/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003388 * headphone jack and the internal CD lines since these are the only pins at
3389 * which audio can appear. For flexibility, also allow the option of
3390 * recording the mixer output on the second ADC (ADC0 doesn't have a
3391 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003392 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003393static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3394 {
3395 .num_items = 3,
3396 .items = {
3397 { "Mic/Line", 0x0 },
3398 { "CD", 0x4 },
3399 { "Headphone", 0x2 },
3400 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003401 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003402 {
3403 .num_items = 4,
3404 .items = {
3405 { "Mic/Line", 0x0 },
3406 { "CD", 0x4 },
3407 { "Headphone", 0x2 },
3408 { "Mixer", 0x5 },
3409 },
3410 },
3411
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003412};
3413
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003414/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3415 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003416 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003417static struct hda_input_mux alc260_acer_capture_sources[2] = {
3418 {
3419 .num_items = 4,
3420 .items = {
3421 { "Mic", 0x0 },
3422 { "Line", 0x2 },
3423 { "CD", 0x4 },
3424 { "Headphone", 0x5 },
3425 },
3426 },
3427 {
3428 .num_items = 5,
3429 .items = {
3430 { "Mic", 0x0 },
3431 { "Line", 0x2 },
3432 { "CD", 0x4 },
3433 { "Headphone", 0x6 },
3434 { "Mixer", 0x5 },
3435 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003436 },
3437};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438/*
3439 * This is just place-holder, so there's something for alc_build_pcms to look
3440 * at when it calculates the maximum number of channels. ALC260 has no mixer
3441 * element which allows changing the channel mode, so the verb list is
3442 * never used.
3443 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003444static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445 { 2, NULL },
3446};
3447
Kailang Yangdf694da2005-12-05 19:42:22 +01003448
3449/* Mixer combinations
3450 *
3451 * basic: base_output + input + pc_beep + capture
3452 * HP: base_output + input + capture_alt
3453 * HP_3013: hp_3013 + input + capture
3454 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003455 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01003456 */
3457
3458static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003459 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003460 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3462 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3463 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3464 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3465 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003466};
Kailang Yangdf694da2005-12-05 19:42:22 +01003467
3468static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003469 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3470 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3471 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3472 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3473 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3474 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3475 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3476 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003477 { } /* end */
3478};
3479
Kailang Yangdf694da2005-12-05 19:42:22 +01003480static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3481 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3482 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3483 { } /* end */
3484};
3485
3486static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3487 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3488 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3489 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3490 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3491 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3492 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3493 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3494 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02003495 { } /* end */
3496};
3497
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003498/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3499 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3500 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003501static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003502 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003503 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003504 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003505 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3506 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3507 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3508 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003509 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003510 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3511 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3512 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003513 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003514 { } /* end */
3515};
3516
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003517/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3518 * versions of the ALC260 don't act on requests to enable mic bias from NID
3519 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3520 * datasheet doesn't mention this restriction. At this stage it's not clear
3521 * whether this behaviour is intentional or is a hardware bug in chip
3522 * revisions available in early 2006. Therefore for now allow the
3523 * "Headphone Jack Mode" control to span all choices, but if it turns out
3524 * that the lack of mic bias for this NID is intentional we could change the
3525 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3526 *
3527 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3528 * don't appear to make the mic bias available from the "line" jack, even
3529 * though the NID used for this jack (0x14) can supply it. The theory is
3530 * that perhaps Acer have included blocking capacitors between the ALC260
3531 * and the output jack. If this turns out to be the case for all such
3532 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3533 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01003534 *
3535 * The C20x Tablet series have a mono internal speaker which is controlled
3536 * via the chip's Mono sum widget and pin complex, so include the necessary
3537 * controls for such models. On models without a "mono speaker" the control
3538 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003539 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003540static struct snd_kcontrol_new alc260_acer_mixer[] = {
3541 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3542 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003543 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithebd869482006-11-28 11:35:52 +01003544 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3545 HDA_OUTPUT),
3546 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3547 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003548 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3549 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3551 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3552 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3553 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3554 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3555 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3556 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3557 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3558 { } /* end */
3559};
3560
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003561/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3562 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3563 */
3564static struct snd_kcontrol_new alc260_will_mixer[] = {
3565 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3566 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3568 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3569 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3570 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3571 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3572 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3573 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3574 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3575 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3576 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3577 { } /* end */
3578};
3579
3580/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3581 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3582 */
3583static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3584 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3585 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3587 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3588 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3589 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3590 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3591 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3592 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3593 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3594 { } /* end */
3595};
3596
Kailang Yangdf694da2005-12-05 19:42:22 +01003597/* capture mixer elements */
3598static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003599 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3600 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003601 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3602 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003603 {
3604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003605 /* The multiple "Capture Source" controls confuse alsamixer
3606 * So call somewhat different..
3607 * FIXME: the controls appear in the "playback" view!
3608 */
3609 /* .name = "Capture Source", */
3610 .name = "Input Source",
3611 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003612 .info = alc_mux_enum_info,
3613 .get = alc_mux_enum_get,
3614 .put = alc_mux_enum_put,
3615 },
3616 { } /* end */
3617};
3618
Kailang Yangdf694da2005-12-05 19:42:22 +01003619static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3620 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3621 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3622 {
3623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3624 /* The multiple "Capture Source" controls confuse alsamixer
3625 * So call somewhat different..
3626 * FIXME: the controls appear in the "playback" view!
3627 */
3628 /* .name = "Capture Source", */
3629 .name = "Input Source",
3630 .count = 1,
3631 .info = alc_mux_enum_info,
3632 .get = alc_mux_enum_get,
3633 .put = alc_mux_enum_put,
3634 },
3635 { } /* end */
3636};
3637
3638/*
3639 * initialization verbs
3640 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003641static struct hda_verb alc260_init_verbs[] = {
3642 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003644 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003645 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003646 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003647 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003648 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003649 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003650 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003651 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003652 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003653 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003654 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003655 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003656 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003657 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003658 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003659 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3660 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003661 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003662 /* set connection select to line in (default select for this ADC) */
3663 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003664 /* mute capture amp left and right */
3665 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3666 /* set connection select to line in (default select for this ADC) */
3667 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003668 /* set vol=0 Line-Out mixer amp left and right */
3669 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3670 /* unmute pin widget amp left and right (no gain on this amp) */
3671 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3672 /* set vol=0 HP mixer amp left and right */
3673 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3674 /* unmute pin widget amp left and right (no gain on this amp) */
3675 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3676 /* set vol=0 Mono mixer amp left and right */
3677 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3678 /* unmute pin widget amp left and right (no gain on this amp) */
3679 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3680 /* unmute LINE-2 out pin */
3681 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003682 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3683 * Line In 2 = 0x03
3684 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003685 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003686 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003687 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003688 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003689 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003691 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003692 /* mute Front out path */
3693 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3695 /* mute Headphone out path */
3696 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3697 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3698 /* mute Mono out path */
3699 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3700 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003701 { }
3702};
3703
Takashi Iwai474167d2006-05-17 17:17:43 +02003704#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01003705static struct hda_verb alc260_hp_init_verbs[] = {
3706 /* Headphone and output */
3707 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3708 /* mono output */
3709 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3710 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3711 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3712 /* Mic2 (front panel) pin widget for input and vref at 80% */
3713 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3714 /* Line In pin widget for input */
3715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3716 /* Line-2 pin widget for output */
3717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3718 /* CD pin widget for input */
3719 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3720 /* unmute amp left and right */
3721 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3722 /* set connection select to line in (default select for this ADC) */
3723 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3724 /* unmute Line-Out mixer amp left and right (volume = 0) */
3725 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3726 /* mute pin widget amp left and right (no gain on this amp) */
3727 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3728 /* unmute HP mixer amp left and right (volume = 0) */
3729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3730 /* mute pin widget amp left and right (no gain on this amp) */
3731 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003732 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3733 * Line In 2 = 0x03
3734 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003735 /* unmute CD */
3736 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3737 /* unmute Line In */
3738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3739 /* unmute Mic */
3740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3741 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3742 /* Unmute Front out path */
3743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3744 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3745 /* Unmute Headphone out path */
3746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3747 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3748 /* Unmute Mono out path */
3749 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3750 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3751 { }
3752};
Takashi Iwai474167d2006-05-17 17:17:43 +02003753#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003754
3755static struct hda_verb alc260_hp_3013_init_verbs[] = {
3756 /* Line out and output */
3757 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3758 /* mono output */
3759 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3760 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3761 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3762 /* Mic2 (front panel) pin widget for input and vref at 80% */
3763 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3764 /* Line In pin widget for input */
3765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3766 /* Headphone pin widget for output */
3767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3768 /* CD pin widget for input */
3769 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3770 /* unmute amp left and right */
3771 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3772 /* set connection select to line in (default select for this ADC) */
3773 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3774 /* unmute Line-Out mixer amp left and right (volume = 0) */
3775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3776 /* mute pin widget amp left and right (no gain on this amp) */
3777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3778 /* unmute HP mixer amp left and right (volume = 0) */
3779 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3780 /* mute pin widget amp left and right (no gain on this amp) */
3781 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003782 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3783 * Line In 2 = 0x03
3784 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003785 /* unmute CD */
3786 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3787 /* unmute Line In */
3788 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3789 /* unmute Mic */
3790 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3791 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3792 /* Unmute Front out path */
3793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3795 /* Unmute Headphone out path */
3796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3798 /* Unmute Mono out path */
3799 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3800 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3801 { }
3802};
3803
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003804/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003805 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3806 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003807 */
3808static struct hda_verb alc260_fujitsu_init_verbs[] = {
3809 /* Disable all GPIOs */
3810 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3811 /* Internal speaker is connected to headphone pin */
3812 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3813 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003815 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3816 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3817 /* Ensure all other unused pins are disabled and muted. */
3818 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003820 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003821 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003822 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003823 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003826
Jonathan Woithef7ace402006-02-28 11:46:14 +01003827 /* Disable digital (SPDIF) pins */
3828 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3829 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003830
Jonathan Woithef7ace402006-02-28 11:46:14 +01003831 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3832 * when acting as an output.
3833 */
3834 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3835
3836 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003837 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3838 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3839 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3840 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3841 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3842 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3843 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3844 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3845 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003846
Jonathan Woithef7ace402006-02-28 11:46:14 +01003847 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3848 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3849 /* Unmute Line1 pin widget output buffer since it starts as an output.
3850 * If the pin mode is changed by the user the pin mode control will
3851 * take care of enabling the pin's input/output buffers as needed.
3852 * Therefore there's no need to enable the input buffer at this
3853 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003854 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003856 /* Unmute input buffer of pin widget used for Line-in (no equiv
3857 * mixer ctrl)
3858 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003859 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003860
Jonathan Woithef7ace402006-02-28 11:46:14 +01003861 /* Mute capture amp left and right */
3862 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3863 /* Set ADC connection select to match default mixer setting - line
3864 * in (on mic1 pin)
3865 */
3866 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003867
Jonathan Woithef7ace402006-02-28 11:46:14 +01003868 /* Do the same for the second ADC: mute capture input amp and
3869 * set ADC connection to line in (on mic1 pin)
3870 */
3871 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3872 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003873
Jonathan Woithef7ace402006-02-28 11:46:14 +01003874 /* Mute all inputs to mixer widget (even unconnected ones) */
3875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3878 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3879 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3880 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3881 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3882 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003883
3884 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003885};
3886
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003887/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3888 * similar laptops (adapted from Fujitsu init verbs).
3889 */
3890static struct hda_verb alc260_acer_init_verbs[] = {
3891 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3892 * the headphone jack. Turn this on and rely on the standard mute
3893 * methods whenever the user wants to turn these outputs off.
3894 */
3895 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3896 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3897 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3898 /* Internal speaker/Headphone jack is connected to Line-out pin */
3899 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3900 /* Internal microphone/Mic jack is connected to Mic1 pin */
3901 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3902 /* Line In jack is connected to Line1 pin */
3903 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01003904 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3905 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003906 /* Ensure all other unused pins are disabled and muted. */
3907 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3908 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003909 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3910 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3913 /* Disable digital (SPDIF) pins */
3914 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3915 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3916
3917 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3918 * bus when acting as outputs.
3919 */
3920 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3921 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3922
3923 /* Start with output sum widgets muted and their output gains at min */
3924 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3925 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3926 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3927 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3928 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3930 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3931 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3932 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3933
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003934 /* Unmute Line-out pin widget amp left and right
3935 * (no equiv mixer ctrl)
3936 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01003938 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3939 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003940 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3941 * inputs. If the pin mode is changed by the user the pin mode control
3942 * will take care of enabling the pin's input/output buffers as needed.
3943 * Therefore there's no need to enable the input buffer at this
3944 * stage.
3945 */
3946 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3947 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3948
3949 /* Mute capture amp left and right */
3950 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3951 /* Set ADC connection select to match default mixer setting - mic
3952 * (on mic1 pin)
3953 */
3954 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3955
3956 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003957 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003958 */
3959 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003960 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003961
3962 /* Mute all inputs to mixer widget (even unconnected ones) */
3963 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3971
3972 { }
3973};
3974
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003975static struct hda_verb alc260_will_verbs[] = {
3976 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3977 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
3978 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
3979 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3980 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3981 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
3982 {}
3983};
3984
3985static struct hda_verb alc260_replacer_672v_verbs[] = {
3986 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3987 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3988 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
3989
3990 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3991 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3992 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3993
3994 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3995 {}
3996};
3997
3998/* toggle speaker-output according to the hp-jack state */
3999static void alc260_replacer_672v_automute(struct hda_codec *codec)
4000{
4001 unsigned int present;
4002
4003 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4004 present = snd_hda_codec_read(codec, 0x0f, 0,
4005 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4006 if (present) {
4007 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4008 snd_hda_codec_write(codec, 0x0f, 0,
4009 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4010 } else {
4011 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4012 snd_hda_codec_write(codec, 0x0f, 0,
4013 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4014 }
4015}
4016
4017static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4018 unsigned int res)
4019{
4020 if ((res >> 26) == ALC880_HP_EVENT)
4021 alc260_replacer_672v_automute(codec);
4022}
4023
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004024/* Test configuration for debugging, modelled after the ALC880 test
4025 * configuration.
4026 */
4027#ifdef CONFIG_SND_DEBUG
4028static hda_nid_t alc260_test_dac_nids[1] = {
4029 0x02,
4030};
4031static hda_nid_t alc260_test_adc_nids[2] = {
4032 0x04, 0x05,
4033};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004034/* For testing the ALC260, each input MUX needs its own definition since
4035 * the signal assignments are different. This assumes that the first ADC
4036 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004037 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004038static struct hda_input_mux alc260_test_capture_sources[2] = {
4039 {
4040 .num_items = 7,
4041 .items = {
4042 { "MIC1 pin", 0x0 },
4043 { "MIC2 pin", 0x1 },
4044 { "LINE1 pin", 0x2 },
4045 { "LINE2 pin", 0x3 },
4046 { "CD pin", 0x4 },
4047 { "LINE-OUT pin", 0x5 },
4048 { "HP-OUT pin", 0x6 },
4049 },
4050 },
4051 {
4052 .num_items = 8,
4053 .items = {
4054 { "MIC1 pin", 0x0 },
4055 { "MIC2 pin", 0x1 },
4056 { "LINE1 pin", 0x2 },
4057 { "LINE2 pin", 0x3 },
4058 { "CD pin", 0x4 },
4059 { "Mixer", 0x5 },
4060 { "LINE-OUT pin", 0x6 },
4061 { "HP-OUT pin", 0x7 },
4062 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004063 },
4064};
4065static struct snd_kcontrol_new alc260_test_mixer[] = {
4066 /* Output driver widgets */
4067 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4068 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4069 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4070 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4071 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4072 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4073
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004074 /* Modes for retasking pin widgets
4075 * Note: the ALC260 doesn't seem to act on requests to enable mic
4076 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4077 * mention this restriction. At this stage it's not clear whether
4078 * this behaviour is intentional or is a hardware bug in chip
4079 * revisions available at least up until early 2006. Therefore for
4080 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4081 * choices, but if it turns out that the lack of mic bias for these
4082 * NIDs is intentional we could change their modes from
4083 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4084 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004085 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4086 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4087 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4088 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4089 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4090 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4091
4092 /* Loopback mixer controls */
4093 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4094 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4095 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4096 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4097 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4098 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4099 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4100 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4101 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4102 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4103 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4104 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4105 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4106 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4107 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4108 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004109
4110 /* Controls for GPIO pins, assuming they are configured as outputs */
4111 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4112 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4113 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4114 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4115
Jonathan Woithe92621f12006-02-28 11:47:47 +01004116 /* Switches to allow the digital IO pins to be enabled. The datasheet
4117 * is ambigious as to which NID is which; testing on laptops which
4118 * make this output available should provide clarification.
4119 */
4120 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4121 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4122
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004123 { } /* end */
4124};
4125static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004126 /* Enable all GPIOs as outputs with an initial value of 0 */
4127 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4128 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4129 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4130
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004131 /* Enable retasking pins as output, initially without power amp */
4132 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4133 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4136 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4137 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4138
Jonathan Woithe92621f12006-02-28 11:47:47 +01004139 /* Disable digital (SPDIF) pins initially, but users can enable
4140 * them via a mixer switch. In the case of SPDIF-out, this initverb
4141 * payload also sets the generation to 0, output to be in "consumer"
4142 * PCM format, copyright asserted, no pre-emphasis and no validity
4143 * control.
4144 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004145 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4146 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4147
Jonathan Woithef7ace402006-02-28 11:46:14 +01004148 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004149 * OUT1 sum bus when acting as an output.
4150 */
4151 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4152 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4153 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4154 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4155
4156 /* Start with output sum widgets muted and their output gains at min */
4157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4158 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4160 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4163 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4164 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4166
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004167 /* Unmute retasking pin widget output buffers since the default
4168 * state appears to be output. As the pin mode is changed by the
4169 * user the pin mode control will take care of enabling the pin's
4170 * input/output buffers as needed.
4171 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004172 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4173 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4176 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4177 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4178 /* Also unmute the mono-out pin widget */
4179 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4180
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004181 /* Mute capture amp left and right */
4182 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004183 /* Set ADC connection select to match default mixer setting (mic1
4184 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004185 */
4186 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4187
4188 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004189 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004190 */
4191 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4192 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4193
4194 /* Mute all inputs to mixer widget (even unconnected ones) */
4195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4203
4204 { }
4205};
4206#endif
4207
Linus Torvalds1da177e2005-04-16 15:20:36 -07004208static struct hda_pcm_stream alc260_pcm_analog_playback = {
4209 .substreams = 1,
4210 .channels_min = 2,
4211 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004212};
4213
4214static struct hda_pcm_stream alc260_pcm_analog_capture = {
4215 .substreams = 1,
4216 .channels_min = 2,
4217 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004218};
4219
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004220#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4221#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4222
Kailang Yangdf694da2005-12-05 19:42:22 +01004223/*
4224 * for BIOS auto-configuration
4225 */
4226
4227static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4228 const char *pfx)
4229{
4230 hda_nid_t nid_vol;
4231 unsigned long vol_val, sw_val;
4232 char name[32];
4233 int err;
4234
4235 if (nid >= 0x0f && nid < 0x11) {
4236 nid_vol = nid - 0x7;
4237 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4238 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4239 } else if (nid == 0x11) {
4240 nid_vol = nid - 0x7;
4241 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4242 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4243 } else if (nid >= 0x12 && nid <= 0x15) {
4244 nid_vol = 0x08;
4245 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4246 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4247 } else
4248 return 0; /* N/A */
4249
4250 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004251 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4252 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004253 return err;
4254 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004255 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4256 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004257 return err;
4258 return 1;
4259}
4260
4261/* add playback controls from the parsed DAC table */
4262static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4263 const struct auto_pin_cfg *cfg)
4264{
4265 hda_nid_t nid;
4266 int err;
4267
4268 spec->multiout.num_dacs = 1;
4269 spec->multiout.dac_nids = spec->private_dac_nids;
4270 spec->multiout.dac_nids[0] = 0x02;
4271
4272 nid = cfg->line_out_pins[0];
4273 if (nid) {
4274 err = alc260_add_playback_controls(spec, nid, "Front");
4275 if (err < 0)
4276 return err;
4277 }
4278
Takashi Iwai82bc9552006-03-21 11:24:42 +01004279 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004280 if (nid) {
4281 err = alc260_add_playback_controls(spec, nid, "Speaker");
4282 if (err < 0)
4283 return err;
4284 }
4285
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004286 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004287 if (nid) {
4288 err = alc260_add_playback_controls(spec, nid, "Headphone");
4289 if (err < 0)
4290 return err;
4291 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004292 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01004293}
4294
4295/* create playback/capture controls for input pins */
4296static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4297 const struct auto_pin_cfg *cfg)
4298{
Kailang Yangdf694da2005-12-05 19:42:22 +01004299 struct hda_input_mux *imux = &spec->private_imux;
4300 int i, err, idx;
4301
4302 for (i = 0; i < AUTO_PIN_LAST; i++) {
4303 if (cfg->input_pins[i] >= 0x12) {
4304 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004305 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004306 auto_pin_cfg_labels[i], idx,
4307 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004308 if (err < 0)
4309 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004310 imux->items[imux->num_items].label =
4311 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004312 imux->items[imux->num_items].index = idx;
4313 imux->num_items++;
4314 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004315 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01004316 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004317 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004318 auto_pin_cfg_labels[i], idx,
4319 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004320 if (err < 0)
4321 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004322 imux->items[imux->num_items].label =
4323 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01004324 imux->items[imux->num_items].index = idx;
4325 imux->num_items++;
4326 }
4327 }
4328 return 0;
4329}
4330
4331static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4332 hda_nid_t nid, int pin_type,
4333 int sel_idx)
4334{
4335 /* set as output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004336 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4337 pin_type);
4338 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4339 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01004340 /* need the manual connection? */
4341 if (nid >= 0x12) {
4342 int idx = nid - 0x12;
4343 snd_hda_codec_write(codec, idx + 0x0b, 0,
4344 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01004345 }
4346}
4347
4348static void alc260_auto_init_multi_out(struct hda_codec *codec)
4349{
4350 struct alc_spec *spec = codec->spec;
4351 hda_nid_t nid;
4352
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004353 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004354 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004355 if (nid) {
4356 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4357 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4358 }
Kailang Yangdf694da2005-12-05 19:42:22 +01004359
Takashi Iwai82bc9552006-03-21 11:24:42 +01004360 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004361 if (nid)
4362 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4363
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004364 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004365 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004366 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004367}
Kailang Yangdf694da2005-12-05 19:42:22 +01004368
4369#define ALC260_PIN_CD_NID 0x16
4370static void alc260_auto_init_analog_input(struct hda_codec *codec)
4371{
4372 struct alc_spec *spec = codec->spec;
4373 int i;
4374
4375 for (i = 0; i < AUTO_PIN_LAST; i++) {
4376 hda_nid_t nid = spec->autocfg.input_pins[i];
4377 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004378 snd_hda_codec_write(codec, nid, 0,
4379 AC_VERB_SET_PIN_WIDGET_CONTROL,
4380 i <= AUTO_PIN_FRONT_MIC ?
4381 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01004382 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004383 snd_hda_codec_write(codec, nid, 0,
4384 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01004385 AMP_OUT_MUTE);
4386 }
4387 }
4388}
4389
4390/*
4391 * generic initialization of ADC, input mixers and output mixers
4392 */
4393static struct hda_verb alc260_volume_init_verbs[] = {
4394 /*
4395 * Unmute ADC0-1 and set the default input to mic-in
4396 */
4397 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4398 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4399 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4400 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4401
4402 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4403 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004404 * Note: PASD motherboards uses the Line In 2 as the input for
4405 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01004406 */
4407 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4413
4414 /*
4415 * Set up output mixers (0x08 - 0x0a)
4416 */
4417 /* set vol=0 to output mixers */
4418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4420 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4421 /* set up input amps for analog loopback */
4422 /* Amp Indices: DAC = 0, mixer = 1 */
4423 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4424 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4429
4430 { }
4431};
4432
4433static int alc260_parse_auto_config(struct hda_codec *codec)
4434{
4435 struct alc_spec *spec = codec->spec;
4436 unsigned int wcap;
4437 int err;
4438 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4439
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004440 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4441 alc260_ignore);
4442 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004443 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004444 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4445 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01004446 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01004448 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004449 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4450 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004451 return err;
4452
4453 spec->multiout.max_channels = 2;
4454
4455 if (spec->autocfg.dig_out_pin)
4456 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4457 if (spec->kctl_alloc)
4458 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4459
4460 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4461
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004462 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004463 spec->input_mux = &spec->private_imux;
4464
4465 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004466 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01004467 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4468 if (wcap != AC_WID_AUD_IN) {
4469 spec->adc_nids = alc260_adc_nids_alt;
4470 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4471 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004472 } else {
4473 spec->adc_nids = alc260_adc_nids;
4474 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4475 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01004476 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004477 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01004478
4479 return 1;
4480}
4481
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004482/* additional initialization for auto-configuration model */
4483static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004484{
Kailang Yangdf694da2005-12-05 19:42:22 +01004485 alc260_auto_init_multi_out(codec);
4486 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004487}
4488
4489/*
4490 * ALC260 configurations
4491 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004492static const char *alc260_models[ALC260_MODEL_LAST] = {
4493 [ALC260_BASIC] = "basic",
4494 [ALC260_HP] = "hp",
4495 [ALC260_HP_3013] = "hp-3013",
4496 [ALC260_FUJITSU_S702X] = "fujitsu",
4497 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004498 [ALC260_WILL] = "will",
4499 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004500#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004501 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004502#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004503 [ALC260_AUTO] = "auto",
4504};
4505
4506static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01004507 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004508 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01004509 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01004510 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004511 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4512 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4513 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4514 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4515 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4516 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4517 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4518 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4519 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4520 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4521 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4522 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004523 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4524 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwai16ded522005-06-10 19:58:24 +02004525 {}
4526};
4527
Kailang Yangdf694da2005-12-05 19:42:22 +01004528static struct alc_config_preset alc260_presets[] = {
4529 [ALC260_BASIC] = {
4530 .mixers = { alc260_base_output_mixer,
4531 alc260_input_mixer,
4532 alc260_pc_beep_mixer,
4533 alc260_capture_mixer },
4534 .init_verbs = { alc260_init_verbs },
4535 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4536 .dac_nids = alc260_dac_nids,
4537 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4538 .adc_nids = alc260_adc_nids,
4539 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4540 .channel_mode = alc260_modes,
4541 .input_mux = &alc260_capture_source,
4542 },
4543 [ALC260_HP] = {
4544 .mixers = { alc260_base_output_mixer,
4545 alc260_input_mixer,
4546 alc260_capture_alt_mixer },
Takashi Iwai474167d2006-05-17 17:17:43 +02004547 .init_verbs = { alc260_init_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01004548 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4549 .dac_nids = alc260_dac_nids,
4550 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4551 .adc_nids = alc260_hp_adc_nids,
4552 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4553 .channel_mode = alc260_modes,
4554 .input_mux = &alc260_capture_source,
4555 },
4556 [ALC260_HP_3013] = {
4557 .mixers = { alc260_hp_3013_mixer,
4558 alc260_input_mixer,
4559 alc260_capture_alt_mixer },
4560 .init_verbs = { alc260_hp_3013_init_verbs },
4561 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4562 .dac_nids = alc260_dac_nids,
4563 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4564 .adc_nids = alc260_hp_adc_nids,
4565 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4566 .channel_mode = alc260_modes,
4567 .input_mux = &alc260_capture_source,
4568 },
4569 [ALC260_FUJITSU_S702X] = {
4570 .mixers = { alc260_fujitsu_mixer,
4571 alc260_capture_mixer },
4572 .init_verbs = { alc260_fujitsu_init_verbs },
4573 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4574 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004575 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4576 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01004577 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4578 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004579 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4580 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01004581 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004582 [ALC260_ACER] = {
4583 .mixers = { alc260_acer_mixer,
4584 alc260_capture_mixer },
4585 .init_verbs = { alc260_acer_init_verbs },
4586 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4587 .dac_nids = alc260_dac_nids,
4588 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4589 .adc_nids = alc260_dual_adc_nids,
4590 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4591 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004592 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4593 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004594 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004595 [ALC260_WILL] = {
4596 .mixers = { alc260_will_mixer,
4597 alc260_capture_mixer },
4598 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4599 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4600 .dac_nids = alc260_dac_nids,
4601 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4602 .adc_nids = alc260_adc_nids,
4603 .dig_out_nid = ALC260_DIGOUT_NID,
4604 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4605 .channel_mode = alc260_modes,
4606 .input_mux = &alc260_capture_source,
4607 },
4608 [ALC260_REPLACER_672V] = {
4609 .mixers = { alc260_replacer_672v_mixer,
4610 alc260_capture_mixer },
4611 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4612 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4613 .dac_nids = alc260_dac_nids,
4614 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4615 .adc_nids = alc260_adc_nids,
4616 .dig_out_nid = ALC260_DIGOUT_NID,
4617 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4618 .channel_mode = alc260_modes,
4619 .input_mux = &alc260_capture_source,
4620 .unsol_event = alc260_replacer_672v_unsol_event,
4621 .init_hook = alc260_replacer_672v_automute,
4622 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004623#ifdef CONFIG_SND_DEBUG
4624 [ALC260_TEST] = {
4625 .mixers = { alc260_test_mixer,
4626 alc260_capture_mixer },
4627 .init_verbs = { alc260_test_init_verbs },
4628 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4629 .dac_nids = alc260_test_dac_nids,
4630 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4631 .adc_nids = alc260_test_adc_nids,
4632 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4633 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004634 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4635 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004636 },
4637#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004638};
4639
Linus Torvalds1da177e2005-04-16 15:20:36 -07004640static int patch_alc260(struct hda_codec *codec)
4641{
4642 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004643 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004644
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004645 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004646 if (spec == NULL)
4647 return -ENOMEM;
4648
4649 codec->spec = spec;
4650
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004651 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4652 alc260_models,
4653 alc260_cfg_tbl);
4654 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004655 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4656 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004657 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02004658 }
4659
Kailang Yangdf694da2005-12-05 19:42:22 +01004660 if (board_config == ALC260_AUTO) {
4661 /* automatic parse from the BIOS config */
4662 err = alc260_parse_auto_config(codec);
4663 if (err < 0) {
4664 alc_free(codec);
4665 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004666 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004667 printk(KERN_INFO
4668 "hda_codec: Cannot set up configuration "
4669 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01004670 board_config = ALC260_BASIC;
4671 }
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004673
Kailang Yangdf694da2005-12-05 19:42:22 +01004674 if (board_config != ALC260_AUTO)
4675 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004676
4677 spec->stream_name_analog = "ALC260 Analog";
4678 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4679 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4680
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004681 spec->stream_name_digital = "ALC260 Digital";
4682 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4683 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4684
Linus Torvalds1da177e2005-04-16 15:20:36 -07004685 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004686 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004687 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004688
4689 return 0;
4690}
4691
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004692
Linus Torvalds1da177e2005-04-16 15:20:36 -07004693/*
4694 * ALC882 support
4695 *
4696 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4697 * configuration. Each pin widget can choose any input DACs and a mixer.
4698 * Each ADC is connected from a mixer of all inputs. This makes possible
4699 * 6-channel independent captures.
4700 *
4701 * In addition, an independent DAC for the multi-playback (not used in this
4702 * driver yet).
4703 */
Kailang Yangdf694da2005-12-05 19:42:22 +01004704#define ALC882_DIGOUT_NID 0x06
4705#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07004706
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004707static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004708 { 8, NULL }
4709};
4710
4711static hda_nid_t alc882_dac_nids[4] = {
4712 /* front, rear, clfe, rear_surr */
4713 0x02, 0x03, 0x04, 0x05
4714};
4715
Kailang Yangdf694da2005-12-05 19:42:22 +01004716/* identical with ALC880 */
4717#define alc882_adc_nids alc880_adc_nids
4718#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004719
4720/* input MUX */
4721/* FIXME: should be a matrix-type input source selection */
4722
4723static struct hda_input_mux alc882_capture_source = {
4724 .num_items = 4,
4725 .items = {
4726 { "Mic", 0x0 },
4727 { "Front Mic", 0x1 },
4728 { "Line", 0x2 },
4729 { "CD", 0x4 },
4730 },
4731};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004732#define alc882_mux_enum_info alc_mux_enum_info
4733#define alc882_mux_enum_get alc_mux_enum_get
4734
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004735static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4736 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004737{
4738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4739 struct alc_spec *spec = codec->spec;
4740 const struct hda_input_mux *imux = spec->input_mux;
4741 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4742 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4743 hda_nid_t nid = capture_mixers[adc_idx];
4744 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4745 unsigned int i, idx;
4746
4747 idx = ucontrol->value.enumerated.item[0];
4748 if (idx >= imux->num_items)
4749 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004750 if (*cur_val == idx && !codec->in_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004751 return 0;
4752 for (i = 0; i < imux->num_items; i++) {
4753 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4754 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4755 v | (imux->items[i].index << 8));
4756 }
4757 *cur_val = idx;
4758 return 1;
4759}
4760
Kailang Yangdf694da2005-12-05 19:42:22 +01004761/*
Kailang Yang272a5272007-05-14 11:00:38 +02004762 * 2ch mode
4763 */
4764static struct hda_verb alc882_3ST_ch2_init[] = {
4765 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4766 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4769 { } /* end */
4770};
4771
4772/*
4773 * 6ch mode
4774 */
4775static struct hda_verb alc882_3ST_ch6_init[] = {
4776 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4777 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4778 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4779 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4780 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4781 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4782 { } /* end */
4783};
4784
4785static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4786 { 2, alc882_3ST_ch2_init },
4787 { 6, alc882_3ST_ch6_init },
4788};
4789
4790/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004791 * 6ch mode
4792 */
4793static struct hda_verb alc882_sixstack_ch6_init[] = {
4794 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4795 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4796 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4797 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4798 { } /* end */
4799};
4800
4801/*
4802 * 8ch mode
4803 */
4804static struct hda_verb alc882_sixstack_ch8_init[] = {
4805 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4806 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4807 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4808 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4809 { } /* end */
4810};
4811
4812static struct hda_channel_mode alc882_sixstack_modes[2] = {
4813 { 6, alc882_sixstack_ch6_init },
4814 { 8, alc882_sixstack_ch8_init },
4815};
4816
Linus Torvalds1da177e2005-04-16 15:20:36 -07004817/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4818 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4819 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004820static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004821 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004822 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004823 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004824 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004825 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4826 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004827 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4828 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004829 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004830 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4839 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01004840 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4842 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4843 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004844 { } /* end */
4845};
4846
Kailang Yangbdd148a2007-05-08 15:19:08 +02004847static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4849 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4850 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4851 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4852 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4853 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4854 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4856 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4857 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4858 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4859 { } /* end */
4860};
4861
Kailang Yang272a5272007-05-14 11:00:38 +02004862static struct snd_kcontrol_new alc882_targa_mixer[] = {
4863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4864 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4872 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4873 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4874 { } /* end */
4875};
4876
4877/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4878 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4879 */
4880static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4881 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4882 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4884 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4889 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4890 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4893 { } /* end */
4894};
4895
Kailang Yangdf694da2005-12-05 19:42:22 +01004896static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4897 {
4898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4899 .name = "Channel Mode",
4900 .info = alc_ch_mode_info,
4901 .get = alc_ch_mode_get,
4902 .put = alc_ch_mode_put,
4903 },
4904 { } /* end */
4905};
4906
Linus Torvalds1da177e2005-04-16 15:20:36 -07004907static struct hda_verb alc882_init_verbs[] = {
4908 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4910 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004912 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004913 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4914 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004916 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004920 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004921 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4922 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004924
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004925 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004928 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004929 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004933 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004936 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004937 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004938 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004940 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004941 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004943 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4944 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4947 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004948 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4950 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4952 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4953 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004954 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004955 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004956
4957 /* FIXME: use matrix-type input source selection */
4958 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4959 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4961 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4962 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4963 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004964 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4967 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4968 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004969 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4972 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4973 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4974 /* ADC1: mute amp left and right */
4975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004976 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004977 /* ADC2: mute amp left and right */
4978 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004979 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004980 /* ADC3: mute amp left and right */
4981 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004982 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004983
4984 { }
4985};
4986
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004987static struct hda_verb alc882_eapd_verbs[] = {
4988 /* change to EAPD mode */
4989 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01004990 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004991 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02004992};
4993
Tobin Davis9102cd12006-12-15 10:02:12 +01004994/* Mac Pro test */
4995static struct snd_kcontrol_new alc882_macpro_mixer[] = {
4996 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4997 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
4999 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5000 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5001 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5002 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5003 { } /* end */
5004};
5005
5006static struct hda_verb alc882_macpro_init_verbs[] = {
5007 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5008 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5009 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5010 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5011 /* Front Pin: output 0 (0x0c) */
5012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5014 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5015 /* Front Mic pin: input vref at 80% */
5016 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5018 /* Speaker: output */
5019 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5021 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5022 /* Headphone output (output 0 - 0x0c) */
5023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5024 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5025 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5026
5027 /* FIXME: use matrix-type input source selection */
5028 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5029 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5030 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5031 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5033 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5034 /* Input mixer2 */
5035 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5036 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5037 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5038 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5039 /* Input mixer3 */
5040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5044 /* ADC1: mute amp left and right */
5045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5046 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5047 /* ADC2: mute amp left and right */
5048 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5049 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5050 /* ADC3: mute amp left and right */
5051 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5052 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5053
5054 { }
5055};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005056
Kailang Yang272a5272007-05-14 11:00:38 +02005057static struct hda_verb alc882_targa_verbs[] = {
5058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5060
5061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5063
5064 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5065 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5066 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5067
5068 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5069 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5070 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5071 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5072 { } /* end */
5073};
5074
5075/* toggle speaker-output according to the hp-jack state */
5076static void alc882_targa_automute(struct hda_codec *codec)
5077{
5078 unsigned int present;
5079
5080 present = snd_hda_codec_read(codec, 0x14, 0,
5081 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5082 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5083 0x80, present ? 0x80 : 0);
5084 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5085 0x80, present ? 0x80 : 0);
5086 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5087}
5088
5089static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5090{
5091 /* Looks like the unsol event is incompatible with the standard
5092 * definition. 4bit tag is placed at 26 bit!
5093 */
5094 if (((res >> 26) == ALC880_HP_EVENT)) {
5095 alc882_targa_automute(codec);
5096 }
5097}
5098
5099static struct hda_verb alc882_asus_a7j_verbs[] = {
5100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5102
5103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5105 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5106
5107 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5108 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5109 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5110
5111 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5112 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5113 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5114 { } /* end */
5115};
5116
Tobin Davis9102cd12006-12-15 10:02:12 +01005117static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5118{
5119 unsigned int gpiostate, gpiomask, gpiodir;
5120
5121 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5122 AC_VERB_GET_GPIO_DATA, 0);
5123
5124 if (!muted)
5125 gpiostate |= (1 << pin);
5126 else
5127 gpiostate &= ~(1 << pin);
5128
5129 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5130 AC_VERB_GET_GPIO_MASK, 0);
5131 gpiomask |= (1 << pin);
5132
5133 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5134 AC_VERB_GET_GPIO_DIRECTION, 0);
5135 gpiodir |= (1 << pin);
5136
5137
5138 snd_hda_codec_write(codec, codec->afg, 0,
5139 AC_VERB_SET_GPIO_MASK, gpiomask);
5140 snd_hda_codec_write(codec, codec->afg, 0,
5141 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5142
5143 msleep(1);
5144
5145 snd_hda_codec_write(codec, codec->afg, 0,
5146 AC_VERB_SET_GPIO_DATA, gpiostate);
5147}
5148
Kailang Yangdf694da2005-12-05 19:42:22 +01005149/*
5150 * generic initialization of ADC, input mixers and output mixers
5151 */
5152static struct hda_verb alc882_auto_init_verbs[] = {
5153 /*
5154 * Unmute ADC0-2 and set the default input to mic-in
5155 */
5156 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5158 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5160 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5162
5163 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5164 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005165 * Note: PASD motherboards uses the Line In 2 as the input for
5166 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005167 */
5168 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5174
5175 /*
5176 * Set up output mixers (0x0c - 0x0f)
5177 */
5178 /* set vol=0 to output mixers */
5179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5182 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5183 /* set up input amps for analog loopback */
5184 /* Amp Indices: DAC = 0, mixer = 1 */
5185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5191 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5192 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5193 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5194 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5195
5196 /* FIXME: use matrix-type input source selection */
5197 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5198 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5203 /* Input mixer2 */
5204 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5208 /* Input mixer3 */
5209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5213
5214 { }
5215};
5216
5217/* capture mixer elements */
5218static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5219 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5220 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5221 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5222 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5223 {
5224 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5225 /* The multiple "Capture Source" controls confuse alsamixer
5226 * So call somewhat different..
5227 * FIXME: the controls appear in the "playback" view!
5228 */
5229 /* .name = "Capture Source", */
5230 .name = "Input Source",
5231 .count = 2,
5232 .info = alc882_mux_enum_info,
5233 .get = alc882_mux_enum_get,
5234 .put = alc882_mux_enum_put,
5235 },
5236 { } /* end */
5237};
5238
5239static struct snd_kcontrol_new alc882_capture_mixer[] = {
5240 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5241 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5242 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5243 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5244 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5245 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5246 {
5247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5248 /* The multiple "Capture Source" controls confuse alsamixer
5249 * So call somewhat different..
5250 * FIXME: the controls appear in the "playback" view!
5251 */
5252 /* .name = "Capture Source", */
5253 .name = "Input Source",
5254 .count = 3,
5255 .info = alc882_mux_enum_info,
5256 .get = alc882_mux_enum_get,
5257 .put = alc882_mux_enum_put,
5258 },
5259 { } /* end */
5260};
5261
5262/* pcm configuration: identiacal with ALC880 */
5263#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5264#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5265#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5266#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5267
5268/*
5269 * configuration and preset
5270 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005271static const char *alc882_models[ALC882_MODEL_LAST] = {
5272 [ALC882_3ST_DIG] = "3stack-dig",
5273 [ALC882_6ST_DIG] = "6stack-dig",
5274 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02005275 [ALC882_W2JC] = "w2jc",
Tobin Davis9102cd12006-12-15 10:02:12 +01005276 [ALC885_MACPRO] = "macpro",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005277 [ALC882_AUTO] = "auto",
5278};
5279
5280static struct snd_pci_quirk alc882_cfg_tbl[] = {
5281 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5282 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5283 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02005284 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005285 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yang272a5272007-05-14 11:00:38 +02005286 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Tobin Davis7b9470d2006-12-28 13:56:48 +01005287 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Kailang Yangbdd148a2007-05-08 15:19:08 +02005288 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Kailang Yangdf694da2005-12-05 19:42:22 +01005289 {}
5290};
5291
5292static struct alc_config_preset alc882_presets[] = {
5293 [ALC882_3ST_DIG] = {
5294 .mixers = { alc882_base_mixer },
5295 .init_verbs = { alc882_init_verbs },
5296 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5297 .dac_nids = alc882_dac_nids,
5298 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005299 .dig_in_nid = ALC882_DIGIN_NID,
5300 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5301 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02005302 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01005303 .input_mux = &alc882_capture_source,
5304 },
5305 [ALC882_6ST_DIG] = {
5306 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5307 .init_verbs = { alc882_init_verbs },
5308 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5309 .dac_nids = alc882_dac_nids,
5310 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01005311 .dig_in_nid = ALC882_DIGIN_NID,
5312 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5313 .channel_mode = alc882_sixstack_modes,
5314 .input_mux = &alc882_capture_source,
5315 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005316 [ALC882_ARIMA] = {
5317 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5318 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5319 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5320 .dac_nids = alc882_dac_nids,
5321 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5322 .channel_mode = alc882_sixstack_modes,
5323 .input_mux = &alc882_capture_source,
5324 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02005325 [ALC882_W2JC] = {
5326 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5327 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5328 alc880_gpio1_init_verbs },
5329 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5330 .dac_nids = alc882_dac_nids,
5331 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5332 .channel_mode = alc880_threestack_modes,
5333 .need_dac_fix = 1,
5334 .input_mux = &alc882_capture_source,
5335 .dig_out_nid = ALC882_DIGOUT_NID,
5336 },
Tobin Davis9102cd12006-12-15 10:02:12 +01005337 [ALC885_MACPRO] = {
5338 .mixers = { alc882_macpro_mixer },
5339 .init_verbs = { alc882_macpro_init_verbs },
5340 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5341 .dac_nids = alc882_dac_nids,
5342 .dig_out_nid = ALC882_DIGOUT_NID,
5343 .dig_in_nid = ALC882_DIGIN_NID,
5344 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5345 .channel_mode = alc882_ch_modes,
5346 .input_mux = &alc882_capture_source,
5347 },
Kailang Yang272a5272007-05-14 11:00:38 +02005348 [ALC882_TARGA] = {
5349 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5350 alc882_capture_mixer },
5351 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5352 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5353 .dac_nids = alc882_dac_nids,
5354 .dig_out_nid = ALC882_DIGOUT_NID,
5355 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5356 .adc_nids = alc882_adc_nids,
5357 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5358 .channel_mode = alc882_3ST_6ch_modes,
5359 .need_dac_fix = 1,
5360 .input_mux = &alc882_capture_source,
5361 .unsol_event = alc882_targa_unsol_event,
5362 .init_hook = alc882_targa_automute,
5363 },
5364 [ALC882_ASUS_A7J] = {
5365 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5366 alc882_capture_mixer },
5367 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5368 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5369 .dac_nids = alc882_dac_nids,
5370 .dig_out_nid = ALC882_DIGOUT_NID,
5371 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5372 .adc_nids = alc882_adc_nids,
5373 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5374 .channel_mode = alc882_3ST_6ch_modes,
5375 .need_dac_fix = 1,
5376 .input_mux = &alc882_capture_source,
5377 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005378};
5379
5380
5381/*
5382 * BIOS auto configuration
5383 */
5384static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5385 hda_nid_t nid, int pin_type,
5386 int dac_idx)
5387{
5388 /* set as output */
5389 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005390 int idx;
5391
Kailang Yangdf694da2005-12-05 19:42:22 +01005392 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5393 idx = 4;
5394 else
5395 idx = spec->multiout.dac_nids[dac_idx] - 2;
5396
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5398 pin_type);
5399 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5400 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01005401 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5402
5403}
5404
5405static void alc882_auto_init_multi_out(struct hda_codec *codec)
5406{
5407 struct alc_spec *spec = codec->spec;
5408 int i;
5409
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005410 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01005411 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005412 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005413 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005414 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005415 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005416 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01005417 }
5418}
5419
5420static void alc882_auto_init_hp_out(struct hda_codec *codec)
5421{
5422 struct alc_spec *spec = codec->spec;
5423 hda_nid_t pin;
5424
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005425 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005426 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005427 /* use dac 0 */
5428 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01005429}
5430
5431#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5432#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5433
5434static void alc882_auto_init_analog_input(struct hda_codec *codec)
5435{
5436 struct alc_spec *spec = codec->spec;
5437 int i;
5438
5439 for (i = 0; i < AUTO_PIN_LAST; i++) {
5440 hda_nid_t nid = spec->autocfg.input_pins[i];
5441 if (alc882_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005442 snd_hda_codec_write(codec, nid, 0,
5443 AC_VERB_SET_PIN_WIDGET_CONTROL,
5444 i <= AUTO_PIN_FRONT_MIC ?
5445 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005446 if (nid != ALC882_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005447 snd_hda_codec_write(codec, nid, 0,
5448 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005449 AMP_OUT_MUTE);
5450 }
5451 }
5452}
5453
5454/* almost identical with ALC880 parser... */
5455static int alc882_parse_auto_config(struct hda_codec *codec)
5456{
5457 struct alc_spec *spec = codec->spec;
5458 int err = alc880_parse_auto_config(codec);
5459
5460 if (err < 0)
5461 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01005462 else if (err > 0)
5463 /* hack - override the init verbs */
5464 spec->init_verbs[0] = alc882_auto_init_verbs;
5465 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005466}
5467
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005468/* additional initialization for auto-configuration model */
5469static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005470{
Kailang Yangdf694da2005-12-05 19:42:22 +01005471 alc882_auto_init_multi_out(codec);
5472 alc882_auto_init_hp_out(codec);
5473 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005474}
5475
Linus Torvalds1da177e2005-04-16 15:20:36 -07005476static int patch_alc882(struct hda_codec *codec)
5477{
5478 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005479 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005480
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005481 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005482 if (spec == NULL)
5483 return -ENOMEM;
5484
Linus Torvalds1da177e2005-04-16 15:20:36 -07005485 codec->spec = spec;
5486
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005487 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5488 alc882_models,
5489 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005490
Kailang Yangdf694da2005-12-05 19:42:22 +01005491 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01005492 /* Pick up systems that don't supply PCI SSID */
5493 switch (codec->subsystem_id) {
5494 case 0x106b0c00: /* Mac Pro */
5495 board_config = ALC885_MACPRO;
5496 break;
5497 default:
5498 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5499 "trying auto-probe from BIOS...\n");
5500 board_config = ALC882_AUTO;
5501 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005502 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005503
Kailang Yangdf694da2005-12-05 19:42:22 +01005504 if (board_config == ALC882_AUTO) {
5505 /* automatic parse from the BIOS config */
5506 err = alc882_parse_auto_config(codec);
5507 if (err < 0) {
5508 alc_free(codec);
5509 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005510 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005511 printk(KERN_INFO
5512 "hda_codec: Cannot set up configuration "
5513 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005514 board_config = ALC882_3ST_DIG;
5515 }
5516 }
5517
5518 if (board_config != ALC882_AUTO)
5519 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005520
Tobin Davis9102cd12006-12-15 10:02:12 +01005521 if (board_config == ALC885_MACPRO) {
5522 alc882_gpio_mute(codec, 0, 0);
5523 alc882_gpio_mute(codec, 1, 0);
5524 }
5525
Linus Torvalds1da177e2005-04-16 15:20:36 -07005526 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01005527 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5528 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005529
5530 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01005531 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5532 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005533
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005534 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005535 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005536 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005537 /* get type */
5538 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01005539 if (wcap != AC_WID_AUD_IN) {
5540 spec->adc_nids = alc882_adc_nids_alt;
5541 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005542 spec->mixers[spec->num_mixers] =
5543 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005544 spec->num_mixers++;
5545 } else {
5546 spec->adc_nids = alc882_adc_nids;
5547 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5548 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5549 spec->num_mixers++;
5550 }
5551 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005552
5553 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005554 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005555 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005556
5557 return 0;
5558}
5559
5560/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005561 * ALC883 support
5562 *
5563 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5564 * configuration. Each pin widget can choose any input DACs and a mixer.
5565 * Each ADC is connected from a mixer of all inputs. This makes possible
5566 * 6-channel independent captures.
5567 *
5568 * In addition, an independent DAC for the multi-playback (not used in this
5569 * driver yet).
5570 */
5571#define ALC883_DIGOUT_NID 0x06
5572#define ALC883_DIGIN_NID 0x0a
5573
5574static hda_nid_t alc883_dac_nids[4] = {
5575 /* front, rear, clfe, rear_surr */
5576 0x02, 0x04, 0x03, 0x05
5577};
5578
5579static hda_nid_t alc883_adc_nids[2] = {
5580 /* ADC1-2 */
5581 0x08, 0x09,
5582};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005583
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005584/* input MUX */
5585/* FIXME: should be a matrix-type input source selection */
5586
5587static struct hda_input_mux alc883_capture_source = {
5588 .num_items = 4,
5589 .items = {
5590 { "Mic", 0x0 },
5591 { "Front Mic", 0x1 },
5592 { "Line", 0x2 },
5593 { "CD", 0x4 },
5594 },
5595};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005596
5597static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5598 .num_items = 2,
5599 .items = {
5600 { "Mic", 0x1 },
5601 { "Line", 0x2 },
5602 },
5603};
5604
Kailang Yang272a5272007-05-14 11:00:38 +02005605static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5606 .num_items = 4,
5607 .items = {
5608 { "Mic", 0x0 },
5609 { "iMic", 0x1 },
5610 { "Line", 0x2 },
5611 { "CD", 0x4 },
5612 },
5613};
5614
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005615#define alc883_mux_enum_info alc_mux_enum_info
5616#define alc883_mux_enum_get alc_mux_enum_get
5617
5618static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5619 struct snd_ctl_elem_value *ucontrol)
5620{
5621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5622 struct alc_spec *spec = codec->spec;
5623 const struct hda_input_mux *imux = spec->input_mux;
5624 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5625 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5626 hda_nid_t nid = capture_mixers[adc_idx];
5627 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5628 unsigned int i, idx;
5629
5630 idx = ucontrol->value.enumerated.item[0];
5631 if (idx >= imux->num_items)
5632 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005633 if (*cur_val == idx && !codec->in_resume)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005634 return 0;
5635 for (i = 0; i < imux->num_items; i++) {
5636 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5637 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5638 v | (imux->items[i].index << 8));
5639 }
5640 *cur_val = idx;
5641 return 1;
5642}
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005643
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005644/*
5645 * 2ch mode
5646 */
5647static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5648 { 2, NULL }
5649};
5650
5651/*
5652 * 2ch mode
5653 */
5654static struct hda_verb alc883_3ST_ch2_init[] = {
5655 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5656 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5657 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5658 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5659 { } /* end */
5660};
5661
5662/*
5663 * 6ch mode
5664 */
5665static struct hda_verb alc883_3ST_ch6_init[] = {
5666 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5667 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5668 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5669 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5670 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5671 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5672 { } /* end */
5673};
5674
5675static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5676 { 2, alc883_3ST_ch2_init },
5677 { 6, alc883_3ST_ch6_init },
5678};
5679
5680/*
5681 * 6ch mode
5682 */
5683static struct hda_verb alc883_sixstack_ch6_init[] = {
5684 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5685 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5686 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5687 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5688 { } /* end */
5689};
5690
5691/*
5692 * 8ch mode
5693 */
5694static struct hda_verb alc883_sixstack_ch8_init[] = {
5695 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5696 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5697 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5698 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5699 { } /* end */
5700};
5701
5702static struct hda_channel_mode alc883_sixstack_modes[2] = {
5703 { 6, alc883_sixstack_ch6_init },
5704 { 8, alc883_sixstack_ch8_init },
5705};
5706
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005707static struct hda_verb alc883_medion_eapd_verbs[] = {
5708 /* eanable EAPD on medion laptop */
5709 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5710 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5711 { }
5712};
5713
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005714/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5715 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5716 */
5717
5718static struct snd_kcontrol_new alc883_base_mixer[] = {
5719 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5720 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5721 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5722 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5723 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5724 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5725 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5726 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5727 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5728 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5733 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005735 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5737 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005738 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5740 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5741 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5742 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5743 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5744 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5745 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5746 {
5747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5748 /* .name = "Capture Source", */
5749 .name = "Input Source",
5750 .count = 2,
5751 .info = alc883_mux_enum_info,
5752 .get = alc883_mux_enum_get,
5753 .put = alc883_mux_enum_put,
5754 },
5755 { } /* end */
5756};
5757
5758static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5760 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5761 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5762 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5763 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005767 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5769 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005770 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005771 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5772 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5773 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5774 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5775 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5776 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5777 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5778 {
5779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5780 /* .name = "Capture Source", */
5781 .name = "Input Source",
5782 .count = 2,
5783 .info = alc883_mux_enum_info,
5784 .get = alc883_mux_enum_get,
5785 .put = alc883_mux_enum_put,
5786 },
5787 { } /* end */
5788};
5789
5790static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5796 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5797 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5798 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5799 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5800 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5801 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005805 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5807 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005808 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005809 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5810 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5811 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5812 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5813 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5814 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5815 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5816 {
5817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5818 /* .name = "Capture Source", */
5819 .name = "Input Source",
5820 .count = 2,
5821 .info = alc883_mux_enum_info,
5822 .get = alc883_mux_enum_get,
5823 .put = alc883_mux_enum_put,
5824 },
5825 { } /* end */
5826};
5827
Takashi Iwaid1d985f2006-11-23 19:27:12 +01005828static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02005829 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5830 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5831 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5832 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5833 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5834 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5835 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5836 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5837 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5838 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5839 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5840 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5841 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5845 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005846 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02005847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5848 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5849 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5850 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5851 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5852
5853 {
5854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5855 /* .name = "Capture Source", */
5856 .name = "Input Source",
5857 .count = 1,
5858 .info = alc883_mux_enum_info,
5859 .get = alc883_mux_enum_get,
5860 .put = alc883_mux_enum_put,
5861 },
5862 { } /* end */
5863};
5864
Kailang Yangccc656c2006-10-17 12:32:26 +02005865static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5868 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5869 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5870 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5871 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5872 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5873 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5874 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5875 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5876 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5877 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5878 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5882 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5883 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5884 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5885 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5886 {
5887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5888 /* .name = "Capture Source", */
5889 .name = "Input Source",
5890 .count = 2,
5891 .info = alc883_mux_enum_info,
5892 .get = alc883_mux_enum_get,
5893 .put = alc883_mux_enum_put,
5894 },
5895 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005896};
Kailang Yangccc656c2006-10-17 12:32:26 +02005897
5898static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5899 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5901 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5902 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5903 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02005906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5907 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5908 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5909 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5910 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5911 {
5912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5913 /* .name = "Capture Source", */
5914 .name = "Input Source",
5915 .count = 2,
5916 .info = alc883_mux_enum_info,
5917 .get = alc883_mux_enum_get,
5918 .put = alc883_mux_enum_put,
5919 },
5920 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005921};
Kailang Yangccc656c2006-10-17 12:32:26 +02005922
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005923static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5924 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5925 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5926 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5927 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5930 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5932 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5933 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5934 {
5935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5936 /* .name = "Capture Source", */
5937 .name = "Input Source",
5938 .count = 1,
5939 .info = alc883_mux_enum_info,
5940 .get = alc883_mux_enum_get,
5941 .put = alc883_mux_enum_put,
5942 },
5943 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005944};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005945
Kailang Yang272a5272007-05-14 11:00:38 +02005946static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
5947 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5948 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
5949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5954 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5955 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5956 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5957 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5958 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5959 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5960 {
5961 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5962 /* .name = "Capture Source", */
5963 .name = "Input Source",
5964 .count = 2,
5965 .info = alc883_mux_enum_info,
5966 .get = alc883_mux_enum_get,
5967 .put = alc883_mux_enum_put,
5968 },
5969 { } /* end */
5970};
5971
5972static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
5973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5975 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5976 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5977 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5978 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5979 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5982 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5983 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5984 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5985 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5986 {
5987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5988 /* .name = "Capture Source", */
5989 .name = "Input Source",
5990 .count = 2,
5991 .info = alc883_mux_enum_info,
5992 .get = alc883_mux_enum_get,
5993 .put = alc883_mux_enum_put,
5994 },
5995 { } /* end */
5996};
5997
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005998static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5999 {
6000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6001 .name = "Channel Mode",
6002 .info = alc_ch_mode_info,
6003 .get = alc_ch_mode_get,
6004 .put = alc_ch_mode_put,
6005 },
6006 { } /* end */
6007};
6008
6009static struct hda_verb alc883_init_verbs[] = {
6010 /* ADC1: mute amp left and right */
6011 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6012 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6013 /* ADC2: mute amp left and right */
6014 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6015 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6016 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6020 /* Rear mixer */
6021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6024 /* CLFE mixer */
6025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6026 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6027 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6028 /* Side mixer */
6029 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6030 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6031 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6032
6033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6038
6039 /* Front Pin: output 0 (0x0c) */
6040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6041 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6042 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6043 /* Rear Pin: output 1 (0x0d) */
6044 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6045 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6046 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6047 /* CLFE Pin: output 2 (0x0e) */
6048 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6049 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6050 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6051 /* Side Pin: output 3 (0x0f) */
6052 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6053 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6054 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6055 /* Mic (rear) pin: input vref at 80% */
6056 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6057 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6058 /* Front Mic pin: input vref at 80% */
6059 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6060 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6061 /* Line In pin: input */
6062 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6063 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6064 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6065 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6066 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6067 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6068 /* CD pin widget for input */
6069 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6070
6071 /* FIXME: use matrix-type input source selection */
6072 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6073 /* Input mixer2 */
6074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6077 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6078 /* Input mixer3 */
6079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6083 { }
6084};
6085
Kailang Yangccc656c2006-10-17 12:32:26 +02006086static struct hda_verb alc883_tagra_verbs[] = {
6087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6089
6090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6091 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6092
6093 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6094 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6095 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6096
6097 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006098 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6099 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6100 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02006101
6102 { } /* end */
6103};
6104
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006105static struct hda_verb alc883_lenovo_101e_verbs[] = {
6106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6107 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6108 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6109 { } /* end */
6110};
6111
Kailang Yang272a5272007-05-14 11:00:38 +02006112static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6113 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6114 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6115 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6117 { } /* end */
6118};
6119
6120static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6123 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6124 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6125 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6126 { } /* end */
6127};
6128
6129/* toggle front-jack and RCA according to the hp-jack state */
6130static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6131{
6132 unsigned int present;
6133
6134 present = snd_hda_codec_read(codec, 0x1b, 0,
6135 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6136 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6137 0x80, present ? 0x80 : 0);
6138 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6139 0x80, present ? 0x80 : 0);
6140 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6141 0x80, present ? 0x80 : 0);
6142 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6143 0x80, present ? 0x80 : 0);
6144
6145}
6146
6147/* toggle RCA according to the front-jack state */
6148static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6149{
6150 unsigned int present;
6151
6152 present = snd_hda_codec_read(codec, 0x14, 0,
6153 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6154 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6155 0x80, present ? 0x80 : 0);
6156 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6157 0x80, present ? 0x80 : 0);
6158
6159}
6160static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6161 unsigned int res)
6162{
6163 if ((res >> 26) == ALC880_HP_EVENT)
6164 alc888_lenovo_ms7195_front_automute(codec);
6165 if ((res >> 26) == ALC880_FRONT_EVENT)
6166 alc888_lenovo_ms7195_rca_automute(codec);
6167}
6168
6169static struct hda_verb alc883_medion_md2_verbs[] = {
6170 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6172
6173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6174
6175 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6176 { } /* end */
6177};
6178
6179/* toggle speaker-output according to the hp-jack state */
6180static void alc883_medion_md2_automute(struct hda_codec *codec)
6181{
6182 unsigned int present;
6183
6184 present = snd_hda_codec_read(codec, 0x14, 0,
6185 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6186 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6187 0x80, present ? 0x80 : 0);
6188 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6189 0x80, present ? 0x80 : 0);
6190}
6191
6192static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6193 unsigned int res)
6194{
6195 if ((res >> 26) == ALC880_HP_EVENT)
6196 alc883_medion_md2_automute(codec);
6197}
6198
Kailang Yangccc656c2006-10-17 12:32:26 +02006199/* toggle speaker-output according to the hp-jack state */
6200static void alc883_tagra_automute(struct hda_codec *codec)
6201{
6202 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006203 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02006204
6205 present = snd_hda_codec_read(codec, 0x14, 0,
6206 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006207 bits = present ? 0x80 : 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02006208 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006209 0x80, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02006210 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006211 0x80, bits);
6212 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6213 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02006214}
6215
6216static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6217{
6218 if ((res >> 26) == ALC880_HP_EVENT)
6219 alc883_tagra_automute(codec);
6220}
6221
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006222static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6223{
6224 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006225 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006226
6227 present = snd_hda_codec_read(codec, 0x14, 0,
6228 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006229 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006230 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006231 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006232 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006233 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006234}
6235
6236static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6237{
6238 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006239 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006240
6241 present = snd_hda_codec_read(codec, 0x1b, 0,
6242 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006243 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006244 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006245 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006246 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006247 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006248 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006249 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006250 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006251 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006252}
6253
6254static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6255 unsigned int res)
6256{
6257 if ((res >> 26) == ALC880_HP_EVENT)
6258 alc883_lenovo_101e_all_automute(codec);
6259 if ((res >> 26) == ALC880_FRONT_EVENT)
6260 alc883_lenovo_101e_ispeaker_automute(codec);
6261}
6262
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006263/*
6264 * generic initialization of ADC, input mixers and output mixers
6265 */
6266static struct hda_verb alc883_auto_init_verbs[] = {
6267 /*
6268 * Unmute ADC0-2 and set the default input to mic-in
6269 */
6270 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6272 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6274
6275 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6276 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006277 * Note: PASD motherboards uses the Line In 2 as the input for
6278 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006279 */
6280 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6281 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6286
6287 /*
6288 * Set up output mixers (0x0c - 0x0f)
6289 */
6290 /* set vol=0 to output mixers */
6291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6295 /* set up input amps for analog loopback */
6296 /* Amp Indices: DAC = 0, mixer = 1 */
6297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6304 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6305 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6306 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6307
6308 /* FIXME: use matrix-type input source selection */
6309 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6310 /* Input mixer1 */
6311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006314 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6316 /* Input mixer2 */
6317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006320 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6322
6323 { }
6324};
6325
6326/* capture mixer elements */
6327static struct snd_kcontrol_new alc883_capture_mixer[] = {
6328 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6329 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6330 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6331 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6332 {
6333 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6334 /* The multiple "Capture Source" controls confuse alsamixer
6335 * So call somewhat different..
6336 * FIXME: the controls appear in the "playback" view!
6337 */
6338 /* .name = "Capture Source", */
6339 .name = "Input Source",
6340 .count = 2,
6341 .info = alc882_mux_enum_info,
6342 .get = alc882_mux_enum_get,
6343 .put = alc882_mux_enum_put,
6344 },
6345 { } /* end */
6346};
6347
6348/* pcm configuration: identiacal with ALC880 */
6349#define alc883_pcm_analog_playback alc880_pcm_analog_playback
6350#define alc883_pcm_analog_capture alc880_pcm_analog_capture
6351#define alc883_pcm_digital_playback alc880_pcm_digital_playback
6352#define alc883_pcm_digital_capture alc880_pcm_digital_capture
6353
6354/*
6355 * configuration and preset
6356 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006357static const char *alc883_models[ALC883_MODEL_LAST] = {
6358 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6359 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6360 [ALC883_3ST_6ch] = "3stack-6ch",
6361 [ALC883_6ST_DIG] = "6stack-dig",
6362 [ALC883_TARGA_DIG] = "targa-dig",
6363 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006364 [ALC883_ACER] = "acer",
6365 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02006366 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006367 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006368 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02006369 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6370 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006371 [ALC883_AUTO] = "auto",
6372};
6373
6374static struct snd_pci_quirk alc883_cfg_tbl[] = {
6375 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6376 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6377 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6378 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Tobin Davis57b14f22007-04-18 23:05:36 +02006379 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006380 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6381 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02006382 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01006383 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006384 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Baruch Evendd146a62007-05-25 12:18:49 +02006385 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006386 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6387 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6388 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6389 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6390 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6391 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6392 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6393 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6394 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6395 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
Daniel T Chene60623b2007-05-29 03:41:55 -04006396 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006397 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6398 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6399 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Kailang Yang272a5272007-05-14 11:00:38 +02006400 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6401 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6402 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6403 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006404 {}
6405};
6406
6407static struct alc_config_preset alc883_presets[] = {
6408 [ALC883_3ST_2ch_DIG] = {
6409 .mixers = { alc883_3ST_2ch_mixer },
6410 .init_verbs = { alc883_init_verbs },
6411 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6412 .dac_nids = alc883_dac_nids,
6413 .dig_out_nid = ALC883_DIGOUT_NID,
6414 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6415 .adc_nids = alc883_adc_nids,
6416 .dig_in_nid = ALC883_DIGIN_NID,
6417 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6418 .channel_mode = alc883_3ST_2ch_modes,
6419 .input_mux = &alc883_capture_source,
6420 },
6421 [ALC883_3ST_6ch_DIG] = {
6422 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6423 .init_verbs = { alc883_init_verbs },
6424 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6425 .dac_nids = alc883_dac_nids,
6426 .dig_out_nid = ALC883_DIGOUT_NID,
6427 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6428 .adc_nids = alc883_adc_nids,
6429 .dig_in_nid = ALC883_DIGIN_NID,
6430 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6431 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006432 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006433 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006434 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006435 [ALC883_3ST_6ch] = {
6436 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6437 .init_verbs = { alc883_init_verbs },
6438 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6439 .dac_nids = alc883_dac_nids,
6440 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6441 .adc_nids = alc883_adc_nids,
6442 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6443 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006444 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006445 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006446 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006447 [ALC883_6ST_DIG] = {
6448 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6449 .init_verbs = { alc883_init_verbs },
6450 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6451 .dac_nids = alc883_dac_nids,
6452 .dig_out_nid = ALC883_DIGOUT_NID,
6453 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6454 .adc_nids = alc883_adc_nids,
6455 .dig_in_nid = ALC883_DIGIN_NID,
6456 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6457 .channel_mode = alc883_sixstack_modes,
6458 .input_mux = &alc883_capture_source,
6459 },
Kailang Yangccc656c2006-10-17 12:32:26 +02006460 [ALC883_TARGA_DIG] = {
6461 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6462 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6463 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6464 .dac_nids = alc883_dac_nids,
6465 .dig_out_nid = ALC883_DIGOUT_NID,
6466 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6467 .adc_nids = alc883_adc_nids,
6468 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6469 .channel_mode = alc883_3ST_6ch_modes,
6470 .need_dac_fix = 1,
6471 .input_mux = &alc883_capture_source,
6472 .unsol_event = alc883_tagra_unsol_event,
6473 .init_hook = alc883_tagra_automute,
6474 },
6475 [ALC883_TARGA_2ch_DIG] = {
6476 .mixers = { alc883_tagra_2ch_mixer},
6477 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6478 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6479 .dac_nids = alc883_dac_nids,
6480 .dig_out_nid = ALC883_DIGOUT_NID,
6481 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6482 .adc_nids = alc883_adc_nids,
6483 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6484 .channel_mode = alc883_3ST_2ch_modes,
6485 .input_mux = &alc883_capture_source,
6486 .unsol_event = alc883_tagra_unsol_event,
6487 .init_hook = alc883_tagra_automute,
6488 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02006489 [ALC883_ACER] = {
6490 .mixers = { alc883_base_mixer,
6491 alc883_chmode_mixer },
6492 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6493 * and the headphone jack. Turn this on and rely on the
6494 * standard mute methods whenever the user wants to turn
6495 * these outputs off.
6496 */
6497 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6499 .dac_nids = alc883_dac_nids,
6500 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6501 .adc_nids = alc883_adc_nids,
6502 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6503 .channel_mode = alc883_3ST_2ch_modes,
6504 .input_mux = &alc883_capture_source,
6505 },
Tobin Davisc07584c2006-10-13 12:32:16 +02006506 [ALC883_MEDION] = {
6507 .mixers = { alc883_fivestack_mixer,
6508 alc883_chmode_mixer },
6509 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006510 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02006511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6512 .dac_nids = alc883_dac_nids,
6513 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6514 .adc_nids = alc883_adc_nids,
6515 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6516 .channel_mode = alc883_sixstack_modes,
6517 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006518 },
Kailang Yang272a5272007-05-14 11:00:38 +02006519 [ALC883_MEDION_MD2] = {
6520 .mixers = { alc883_medion_md2_mixer},
6521 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6523 .dac_nids = alc883_dac_nids,
6524 .dig_out_nid = ALC883_DIGOUT_NID,
6525 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6526 .adc_nids = alc883_adc_nids,
6527 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6528 .channel_mode = alc883_3ST_2ch_modes,
6529 .input_mux = &alc883_capture_source,
6530 .unsol_event = alc883_medion_md2_unsol_event,
6531 .init_hook = alc883_medion_md2_automute,
6532 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006533 [ALC883_LAPTOP_EAPD] = {
6534 .mixers = { alc883_base_mixer,
6535 alc883_chmode_mixer },
6536 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6538 .dac_nids = alc883_dac_nids,
6539 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6540 .adc_nids = alc883_adc_nids,
6541 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6542 .channel_mode = alc883_3ST_2ch_modes,
6543 .input_mux = &alc883_capture_source,
6544 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006545 [ALC883_LENOVO_101E_2ch] = {
6546 .mixers = { alc883_lenovo_101e_2ch_mixer},
6547 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6548 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6549 .dac_nids = alc883_dac_nids,
6550 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6551 .adc_nids = alc883_adc_nids,
6552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6553 .channel_mode = alc883_3ST_2ch_modes,
6554 .input_mux = &alc883_lenovo_101e_capture_source,
6555 .unsol_event = alc883_lenovo_101e_unsol_event,
6556 .init_hook = alc883_lenovo_101e_all_automute,
6557 },
Kailang Yang272a5272007-05-14 11:00:38 +02006558 [ALC883_LENOVO_NB0763] = {
6559 .mixers = { alc883_lenovo_nb0763_mixer },
6560 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6562 .dac_nids = alc883_dac_nids,
6563 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6564 .adc_nids = alc883_adc_nids,
6565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6566 .channel_mode = alc883_3ST_2ch_modes,
6567 .need_dac_fix = 1,
6568 .input_mux = &alc883_lenovo_nb0763_capture_source,
6569 .unsol_event = alc883_medion_md2_unsol_event,
6570 .init_hook = alc883_medion_md2_automute,
6571 },
6572 [ALC888_LENOVO_MS7195_DIG] = {
6573 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6574 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6576 .dac_nids = alc883_dac_nids,
6577 .dig_out_nid = ALC883_DIGOUT_NID,
6578 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6579 .adc_nids = alc883_adc_nids,
6580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6581 .channel_mode = alc883_3ST_6ch_modes,
6582 .need_dac_fix = 1,
6583 .input_mux = &alc883_capture_source,
6584 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6585 .init_hook = alc888_lenovo_ms7195_front_automute,
6586 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006587};
6588
6589
6590/*
6591 * BIOS auto configuration
6592 */
6593static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6594 hda_nid_t nid, int pin_type,
6595 int dac_idx)
6596{
6597 /* set as output */
6598 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006599 int idx;
6600
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006601 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6602 idx = 4;
6603 else
6604 idx = spec->multiout.dac_nids[dac_idx] - 2;
6605
6606 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6607 pin_type);
6608 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6609 AMP_OUT_UNMUTE);
6610 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6611
6612}
6613
6614static void alc883_auto_init_multi_out(struct hda_codec *codec)
6615{
6616 struct alc_spec *spec = codec->spec;
6617 int i;
6618
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006619 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006620 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006621 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006622 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006623 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006624 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006625 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006626 }
6627}
6628
6629static void alc883_auto_init_hp_out(struct hda_codec *codec)
6630{
6631 struct alc_spec *spec = codec->spec;
6632 hda_nid_t pin;
6633
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006634 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006635 if (pin) /* connect to front */
6636 /* use dac 0 */
6637 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6638}
6639
6640#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
6641#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
6642
6643static void alc883_auto_init_analog_input(struct hda_codec *codec)
6644{
6645 struct alc_spec *spec = codec->spec;
6646 int i;
6647
6648 for (i = 0; i < AUTO_PIN_LAST; i++) {
6649 hda_nid_t nid = spec->autocfg.input_pins[i];
6650 if (alc883_is_input_pin(nid)) {
6651 snd_hda_codec_write(codec, nid, 0,
6652 AC_VERB_SET_PIN_WIDGET_CONTROL,
6653 (i <= AUTO_PIN_FRONT_MIC ?
6654 PIN_VREF80 : PIN_IN));
6655 if (nid != ALC883_PIN_CD_NID)
6656 snd_hda_codec_write(codec, nid, 0,
6657 AC_VERB_SET_AMP_GAIN_MUTE,
6658 AMP_OUT_MUTE);
6659 }
6660 }
6661}
6662
6663/* almost identical with ALC880 parser... */
6664static int alc883_parse_auto_config(struct hda_codec *codec)
6665{
6666 struct alc_spec *spec = codec->spec;
6667 int err = alc880_parse_auto_config(codec);
6668
6669 if (err < 0)
6670 return err;
6671 else if (err > 0)
6672 /* hack - override the init verbs */
6673 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006674 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
6675 spec->num_mixers++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006676 return err;
6677}
6678
6679/* additional initialization for auto-configuration model */
6680static void alc883_auto_init(struct hda_codec *codec)
6681{
6682 alc883_auto_init_multi_out(codec);
6683 alc883_auto_init_hp_out(codec);
6684 alc883_auto_init_analog_input(codec);
6685}
6686
6687static int patch_alc883(struct hda_codec *codec)
6688{
6689 struct alc_spec *spec;
6690 int err, board_config;
6691
6692 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6693 if (spec == NULL)
6694 return -ENOMEM;
6695
6696 codec->spec = spec;
6697
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006698 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
6699 alc883_models,
6700 alc883_cfg_tbl);
6701 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006702 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
6703 "trying auto-probe from BIOS...\n");
6704 board_config = ALC883_AUTO;
6705 }
6706
6707 if (board_config == ALC883_AUTO) {
6708 /* automatic parse from the BIOS config */
6709 err = alc883_parse_auto_config(codec);
6710 if (err < 0) {
6711 alc_free(codec);
6712 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006713 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006714 printk(KERN_INFO
6715 "hda_codec: Cannot set up configuration "
6716 "from BIOS. Using base mode...\n");
6717 board_config = ALC883_3ST_2ch_DIG;
6718 }
6719 }
6720
6721 if (board_config != ALC883_AUTO)
6722 setup_preset(spec, &alc883_presets[board_config]);
6723
6724 spec->stream_name_analog = "ALC883 Analog";
6725 spec->stream_analog_playback = &alc883_pcm_analog_playback;
6726 spec->stream_analog_capture = &alc883_pcm_analog_capture;
6727
6728 spec->stream_name_digital = "ALC883 Digital";
6729 spec->stream_digital_playback = &alc883_pcm_digital_playback;
6730 spec->stream_digital_capture = &alc883_pcm_digital_capture;
6731
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006732 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006733 spec->adc_nids = alc883_adc_nids;
6734 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
6735 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006736
6737 codec->patch_ops = alc_patch_ops;
6738 if (board_config == ALC883_AUTO)
6739 spec->init_hook = alc883_auto_init;
6740
6741 return 0;
6742}
6743
6744/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006745 * ALC262 support
6746 */
6747
6748#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
6749#define ALC262_DIGIN_NID ALC880_DIGIN_NID
6750
6751#define alc262_dac_nids alc260_dac_nids
6752#define alc262_adc_nids alc882_adc_nids
6753#define alc262_adc_nids_alt alc882_adc_nids_alt
6754
6755#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01006756#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01006757
6758static struct snd_kcontrol_new alc262_base_mixer[] = {
6759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6760 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6761 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6762 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6763 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6764 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6766 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006767 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006768 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6769 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006770 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006771 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6772 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6773 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
6774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6775 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6776 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006777 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01006778};
6779
Kailang Yangccc656c2006-10-17 12:32:26 +02006780static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
6781 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6782 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6783 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6784 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6785 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6786 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006789 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006790 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6791 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006792 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02006793 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6794 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
6795 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
6796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6797 { } /* end */
6798};
6799
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006800static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
6801 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6802 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6804 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6805 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6806
6807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006812 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6817 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6818 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6819 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
6820 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
6821 { } /* end */
6822};
6823
Kailang Yangcd7509a2007-01-26 18:33:17 +01006824static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
6825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6826 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6827 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6829 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6830 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6831 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
6832 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006833 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6836 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6837 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6838 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
6839 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
6840 { } /* end */
6841};
6842
6843static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
6844 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6845 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01006846 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01006847 { } /* end */
6848};
6849
Kailang Yang272a5272007-05-14 11:00:38 +02006850static struct snd_kcontrol_new alc262_sony_mixer[] = {
6851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6852 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6855 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6856 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6857 { } /* end */
6858};
6859
6860
6861
Kailang Yangdf694da2005-12-05 19:42:22 +01006862#define alc262_capture_mixer alc882_capture_mixer
6863#define alc262_capture_alt_mixer alc882_capture_alt_mixer
6864
6865/*
6866 * generic initialization of ADC, input mixers and output mixers
6867 */
6868static struct hda_verb alc262_init_verbs[] = {
6869 /*
6870 * Unmute ADC0-2 and set the default input to mic-in
6871 */
6872 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6874 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6875 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6876 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6877 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6878
6879 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6880 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006881 * Note: PASD motherboards uses the Line In 2 as the input for
6882 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006883 */
6884 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6890
6891 /*
6892 * Set up output mixers (0x0c - 0x0e)
6893 */
6894 /* set vol=0 to output mixers */
6895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6898 /* set up input amps for analog loopback */
6899 /* Amp Indices: DAC = 0, mixer = 1 */
6900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6902 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6906
6907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6908 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6909 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6910 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6911 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6912 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6913
6914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6916 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6918 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6919
6920 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6922
6923 /* FIXME: use matrix-type input source selection */
6924 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6925 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6926 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6927 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6929 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6930 /* Input mixer2 */
6931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6934 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6935 /* Input mixer3 */
6936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01006940
6941 { }
6942};
6943
Kailang Yangccc656c2006-10-17 12:32:26 +02006944static struct hda_verb alc262_hippo_unsol_verbs[] = {
6945 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6946 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6947 {}
6948};
6949
6950static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6952 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6953 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6954
6955 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6957 {}
6958};
6959
Kailang Yang272a5272007-05-14 11:00:38 +02006960static struct hda_verb alc262_sony_unsol_verbs[] = {
6961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6962 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6963 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
6964
6965 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6967};
6968
Kailang Yangccc656c2006-10-17 12:32:26 +02006969/* mute/unmute internal speaker according to the hp jack and mute state */
6970static void alc262_hippo_automute(struct hda_codec *codec, int force)
6971{
6972 struct alc_spec *spec = codec->spec;
6973 unsigned int mute;
6974
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006975 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02006976 unsigned int present;
6977 /* need to execute and sync at first */
6978 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
6979 present = snd_hda_codec_read(codec, 0x15, 0,
6980 AC_VERB_GET_PIN_SENSE, 0);
6981 spec->jack_present = (present & 0x80000000) != 0;
6982 spec->sense_updated = 1;
6983 }
6984 if (spec->jack_present) {
6985 /* mute internal speaker */
6986 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6987 0x80, 0x80);
6988 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6989 0x80, 0x80);
6990 } else {
6991 /* unmute internal speaker if necessary */
6992 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
6993 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6994 0x80, mute & 0x80);
6995 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
6996 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6997 0x80, mute & 0x80);
6998 }
6999}
7000
7001/* unsolicited event for HP jack sensing */
7002static void alc262_hippo_unsol_event(struct hda_codec *codec,
7003 unsigned int res)
7004{
7005 if ((res >> 26) != ALC880_HP_EVENT)
7006 return;
7007 alc262_hippo_automute(codec, 1);
7008}
7009
7010static void alc262_hippo1_automute(struct hda_codec *codec, int force)
7011{
7012 struct alc_spec *spec = codec->spec;
7013 unsigned int mute;
7014
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007015 if (force || !spec->sense_updated) {
Kailang Yangccc656c2006-10-17 12:32:26 +02007016 unsigned int present;
7017 /* need to execute and sync at first */
7018 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7019 present = snd_hda_codec_read(codec, 0x1b, 0,
7020 AC_VERB_GET_PIN_SENSE, 0);
7021 spec->jack_present = (present & 0x80000000) != 0;
7022 spec->sense_updated = 1;
7023 }
7024 if (spec->jack_present) {
7025 /* mute internal speaker */
7026 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7027 0x80, 0x80);
7028 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7029 0x80, 0x80);
7030 } else {
7031 /* unmute internal speaker if necessary */
7032 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7033 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7034 0x80, mute & 0x80);
7035 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
7036 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7037 0x80, mute & 0x80);
7038 }
7039}
7040
7041/* unsolicited event for HP jack sensing */
7042static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7043 unsigned int res)
7044{
7045 if ((res >> 26) != ALC880_HP_EVENT)
7046 return;
7047 alc262_hippo1_automute(codec, 1);
7048}
7049
Takashi Iwai834be882006-03-01 14:16:17 +01007050/*
7051 * fujitsu model
7052 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7053 */
7054
7055#define ALC_HP_EVENT 0x37
7056
7057static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7058 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7060 {}
7061};
7062
7063static struct hda_input_mux alc262_fujitsu_capture_source = {
7064 .num_items = 2,
7065 .items = {
7066 { "Mic", 0x0 },
7067 { "CD", 0x4 },
7068 },
7069};
7070
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007071static struct hda_input_mux alc262_HP_capture_source = {
7072 .num_items = 5,
7073 .items = {
7074 { "Mic", 0x0 },
7075 { "Front Mic", 0x3 },
7076 { "Line", 0x2 },
7077 { "CD", 0x4 },
7078 { "AUX IN", 0x6 },
7079 },
7080};
7081
Takashi Iwai834be882006-03-01 14:16:17 +01007082/* mute/unmute internal speaker according to the hp jack and mute state */
7083static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7084{
7085 struct alc_spec *spec = codec->spec;
7086 unsigned int mute;
7087
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007088 if (force || !spec->sense_updated) {
Takashi Iwai834be882006-03-01 14:16:17 +01007089 unsigned int present;
7090 /* need to execute and sync at first */
7091 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7092 present = snd_hda_codec_read(codec, 0x14, 0,
7093 AC_VERB_GET_PIN_SENSE, 0);
7094 spec->jack_present = (present & 0x80000000) != 0;
7095 spec->sense_updated = 1;
7096 }
7097 if (spec->jack_present) {
7098 /* mute internal speaker */
7099 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7100 0x80, 0x80);
7101 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7102 0x80, 0x80);
7103 } else {
7104 /* unmute internal speaker if necessary */
7105 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7106 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
7107 0x80, mute & 0x80);
7108 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
7109 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
7110 0x80, mute & 0x80);
7111 }
7112}
7113
7114/* unsolicited event for HP jack sensing */
7115static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7116 unsigned int res)
7117{
7118 if ((res >> 26) != ALC_HP_EVENT)
7119 return;
7120 alc262_fujitsu_automute(codec, 1);
7121}
7122
7123/* bind volumes of both NID 0x0c and 0x0d */
7124static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
7125 struct snd_ctl_elem_value *ucontrol)
7126{
7127 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7128 long *valp = ucontrol->value.integer.value;
7129 int change;
7130
7131 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
7132 0x7f, valp[0] & 0x7f);
7133 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
7134 0x7f, valp[1] & 0x7f);
7135 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
7136 0x7f, valp[0] & 0x7f);
7137 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
7138 0x7f, valp[1] & 0x7f);
7139 return change;
7140}
7141
7142/* bind hp and internal speaker mute (with plug check) */
7143static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7144 struct snd_ctl_elem_value *ucontrol)
7145{
7146 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7147 long *valp = ucontrol->value.integer.value;
7148 int change;
7149
7150 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7151 0x80, valp[0] ? 0 : 0x80);
7152 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7153 0x80, valp[1] ? 0 : 0x80);
7154 if (change || codec->in_resume)
7155 alc262_fujitsu_automute(codec, codec->in_resume);
7156 return change;
7157}
7158
7159static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7160 {
7161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7162 .name = "Master Playback Volume",
7163 .info = snd_hda_mixer_amp_volume_info,
7164 .get = snd_hda_mixer_amp_volume_get,
7165 .put = alc262_fujitsu_master_vol_put,
Takashi Iwaic2566522006-08-17 18:21:36 +02007166 .tlv = { .c = snd_hda_mixer_amp_tlv },
Takashi Iwai834be882006-03-01 14:16:17 +01007167 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7168 },
7169 {
7170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7171 .name = "Master Playback Switch",
7172 .info = snd_hda_mixer_amp_switch_info,
7173 .get = snd_hda_mixer_amp_switch_get,
7174 .put = alc262_fujitsu_master_sw_put,
7175 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7176 },
7177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7179 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7182 { } /* end */
7183};
7184
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007185/* additional init verbs for Benq laptops */
7186static struct hda_verb alc262_EAPD_verbs[] = {
7187 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7188 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7189 {}
7190};
7191
Kailang Yangdf694da2005-12-05 19:42:22 +01007192/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007193static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7194 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01007195{
7196 hda_nid_t nid;
7197 int err;
7198
7199 spec->multiout.num_dacs = 1; /* only use one dac */
7200 spec->multiout.dac_nids = spec->private_dac_nids;
7201 spec->multiout.dac_nids[0] = 2;
7202
7203 nid = cfg->line_out_pins[0];
7204 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007205 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7206 "Front Playback Volume",
7207 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7208 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007209 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007210 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7211 "Front Playback Switch",
7212 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7213 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007214 return err;
7215 }
7216
Takashi Iwai82bc9552006-03-21 11:24:42 +01007217 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007218 if (nid) {
7219 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007220 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7221 "Speaker Playback Volume",
7222 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7223 HDA_OUTPUT));
7224 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007225 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007226 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7227 "Speaker Playback Switch",
7228 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7229 HDA_OUTPUT));
7230 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007231 return err;
7232 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007233 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7234 "Speaker Playback Switch",
7235 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7236 HDA_OUTPUT));
7237 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007238 return err;
7239 }
7240 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007241 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007242 if (nid) {
7243 /* spec->multiout.hp_nid = 2; */
7244 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007245 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7246 "Headphone Playback Volume",
7247 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7248 HDA_OUTPUT));
7249 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007250 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007251 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7252 "Headphone Playback Switch",
7253 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7254 HDA_OUTPUT));
7255 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007256 return err;
7257 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007258 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7259 "Headphone Playback Switch",
7260 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7261 HDA_OUTPUT));
7262 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007263 return err;
7264 }
7265 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007266 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01007267}
7268
7269/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007270#define alc262_auto_create_analog_input_ctls \
7271 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01007272
7273/*
7274 * generic initialization of ADC, input mixers and output mixers
7275 */
7276static struct hda_verb alc262_volume_init_verbs[] = {
7277 /*
7278 * Unmute ADC0-2 and set the default input to mic-in
7279 */
7280 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7282 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7283 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7284 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7285 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7286
7287 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7288 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007289 * Note: PASD motherboards uses the Line In 2 as the input for
7290 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007291 */
7292 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7298
7299 /*
7300 * Set up output mixers (0x0c - 0x0f)
7301 */
7302 /* set vol=0 to output mixers */
7303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7305 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7306
7307 /* set up input amps for analog loopback */
7308 /* Amp Indices: DAC = 0, mixer = 1 */
7309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7313 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7315
7316 /* FIXME: use matrix-type input source selection */
7317 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7318 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7323 /* Input mixer2 */
7324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7328 /* Input mixer3 */
7329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7333
7334 { }
7335};
7336
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007337static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7338 /*
7339 * Unmute ADC0-2 and set the default input to mic-in
7340 */
7341 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7343 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7344 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7345 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7346 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7347
7348 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7349 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007350 * Note: PASD motherboards uses the Line In 2 as the input for
7351 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007352 */
7353 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7361
7362 /*
7363 * Set up output mixers (0x0c - 0x0e)
7364 */
7365 /* set vol=0 to output mixers */
7366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7369
7370 /* set up input amps for analog loopback */
7371 /* Amp Indices: DAC = 0, mixer = 1 */
7372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7378
7379 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7380 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7381 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7382
7383 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7385
7386 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7387 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7388
7389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7390 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7391 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7392 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7393 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7394
7395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7396 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7397 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7398 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7399 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7400 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7401
7402
7403 /* FIXME: use matrix-type input source selection */
7404 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7405 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7406 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7410 /* Input mixer2 */
7411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7415 /* Input mixer3 */
7416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7420
7421 { }
7422};
7423
Kailang Yangcd7509a2007-01-26 18:33:17 +01007424static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7425 /*
7426 * Unmute ADC0-2 and set the default input to mic-in
7427 */
7428 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7430 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7432 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7434
7435 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7436 * mixer widget
7437 * Note: PASD motherboards uses the Line In 2 as the input for front
7438 * panel mic (mic 2)
7439 */
7440 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
7447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
7448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
7449 /*
7450 * Set up output mixers (0x0c - 0x0e)
7451 */
7452 /* set vol=0 to output mixers */
7453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7456
7457 /* set up input amps for analog loopback */
7458 /* Amp Indices: DAC = 0, mixer = 1 */
7459 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7462 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7463 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7464 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7465
7466
7467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7470 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7471 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7472 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7473 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7474
7475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7477
7478 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7479 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7480
7481 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7485 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7486 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7487
7488 /* FIXME: use matrix-type input source selection */
7489 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7490 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7491 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7496 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7498 /* Input mixer2 */
7499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7504 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7506 /* Input mixer3 */
7507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7512 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7514
7515 { }
7516};
7517
Kailang Yangdf694da2005-12-05 19:42:22 +01007518/* pcm configuration: identiacal with ALC880 */
7519#define alc262_pcm_analog_playback alc880_pcm_analog_playback
7520#define alc262_pcm_analog_capture alc880_pcm_analog_capture
7521#define alc262_pcm_digital_playback alc880_pcm_digital_playback
7522#define alc262_pcm_digital_capture alc880_pcm_digital_capture
7523
7524/*
7525 * BIOS auto configuration
7526 */
7527static int alc262_parse_auto_config(struct hda_codec *codec)
7528{
7529 struct alc_spec *spec = codec->spec;
7530 int err;
7531 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7532
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007533 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7534 alc262_ignore);
7535 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007536 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007537 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007538 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007539 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7540 if (err < 0)
7541 return err;
7542 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7543 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007544 return err;
7545
7546 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7547
7548 if (spec->autocfg.dig_out_pin)
7549 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7550 if (spec->autocfg.dig_in_pin)
7551 spec->dig_in_nid = ALC262_DIGIN_NID;
7552
7553 if (spec->kctl_alloc)
7554 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7555
7556 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007557 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01007558 spec->input_mux = &spec->private_imux;
7559
7560 return 1;
7561}
7562
7563#define alc262_auto_init_multi_out alc882_auto_init_multi_out
7564#define alc262_auto_init_hp_out alc882_auto_init_hp_out
7565#define alc262_auto_init_analog_input alc882_auto_init_analog_input
7566
7567
7568/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007569static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007570{
Kailang Yangdf694da2005-12-05 19:42:22 +01007571 alc262_auto_init_multi_out(codec);
7572 alc262_auto_init_hp_out(codec);
7573 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007574}
7575
7576/*
7577 * configuration and preset
7578 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007579static const char *alc262_models[ALC262_MODEL_LAST] = {
7580 [ALC262_BASIC] = "basic",
7581 [ALC262_HIPPO] = "hippo",
7582 [ALC262_HIPPO_1] = "hippo_1",
7583 [ALC262_FUJITSU] = "fujitsu",
7584 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01007585 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007586 [ALC262_BENQ_ED8] = "benq",
Kailang Yang272a5272007-05-14 11:00:38 +02007587 [ALC262_BENQ_ED8] = "sony-assamd",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007588 [ALC262_AUTO] = "auto",
7589};
7590
7591static struct snd_pci_quirk alc262_cfg_tbl[] = {
7592 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7593 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7594 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007595 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
7596 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01007597 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7598 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7599 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7600 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7601 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7602 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7603 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7604 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007605 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7606 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7607 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7608 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang272a5272007-05-14 11:00:38 +02007609 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
7610 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
7611 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Kailang Yangdf694da2005-12-05 19:42:22 +01007612 {}
7613};
7614
7615static struct alc_config_preset alc262_presets[] = {
7616 [ALC262_BASIC] = {
7617 .mixers = { alc262_base_mixer },
7618 .init_verbs = { alc262_init_verbs },
7619 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7620 .dac_nids = alc262_dac_nids,
7621 .hp_nid = 0x03,
7622 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7623 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007624 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01007625 },
Kailang Yangccc656c2006-10-17 12:32:26 +02007626 [ALC262_HIPPO] = {
7627 .mixers = { alc262_base_mixer },
7628 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
7629 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7630 .dac_nids = alc262_dac_nids,
7631 .hp_nid = 0x03,
7632 .dig_out_nid = ALC262_DIGOUT_NID,
7633 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7634 .channel_mode = alc262_modes,
7635 .input_mux = &alc262_capture_source,
7636 .unsol_event = alc262_hippo_unsol_event,
7637 },
7638 [ALC262_HIPPO_1] = {
7639 .mixers = { alc262_hippo1_mixer },
7640 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
7641 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7642 .dac_nids = alc262_dac_nids,
7643 .hp_nid = 0x02,
7644 .dig_out_nid = ALC262_DIGOUT_NID,
7645 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7646 .channel_mode = alc262_modes,
7647 .input_mux = &alc262_capture_source,
7648 .unsol_event = alc262_hippo1_unsol_event,
7649 },
Takashi Iwai834be882006-03-01 14:16:17 +01007650 [ALC262_FUJITSU] = {
7651 .mixers = { alc262_fujitsu_mixer },
7652 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
7653 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7654 .dac_nids = alc262_dac_nids,
7655 .hp_nid = 0x03,
7656 .dig_out_nid = ALC262_DIGOUT_NID,
7657 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7658 .channel_mode = alc262_modes,
7659 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007660 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01007661 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007662 [ALC262_HP_BPC] = {
7663 .mixers = { alc262_HP_BPC_mixer },
7664 .init_verbs = { alc262_HP_BPC_init_verbs },
7665 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7666 .dac_nids = alc262_dac_nids,
7667 .hp_nid = 0x03,
7668 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7669 .channel_mode = alc262_modes,
7670 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007671 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007672 [ALC262_HP_BPC_D7000_WF] = {
7673 .mixers = { alc262_HP_BPC_WildWest_mixer },
7674 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7675 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7676 .dac_nids = alc262_dac_nids,
7677 .hp_nid = 0x03,
7678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7679 .channel_mode = alc262_modes,
7680 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007681 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01007682 [ALC262_HP_BPC_D7000_WL] = {
7683 .mixers = { alc262_HP_BPC_WildWest_mixer,
7684 alc262_HP_BPC_WildWest_option_mixer },
7685 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
7686 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7687 .dac_nids = alc262_dac_nids,
7688 .hp_nid = 0x03,
7689 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7690 .channel_mode = alc262_modes,
7691 .input_mux = &alc262_HP_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007692 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +02007693 [ALC262_BENQ_ED8] = {
7694 .mixers = { alc262_base_mixer },
7695 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
7696 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7697 .dac_nids = alc262_dac_nids,
7698 .hp_nid = 0x03,
7699 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7700 .channel_mode = alc262_modes,
7701 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007702 },
Kailang Yang272a5272007-05-14 11:00:38 +02007703 [ALC262_SONY_ASSAMD] = {
7704 .mixers = { alc262_sony_mixer },
7705 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
7706 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
7707 .dac_nids = alc262_dac_nids,
7708 .hp_nid = 0x02,
7709 .num_channel_mode = ARRAY_SIZE(alc262_modes),
7710 .channel_mode = alc262_modes,
7711 .input_mux = &alc262_capture_source,
7712 .unsol_event = alc262_hippo_unsol_event,
7713 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007714};
7715
7716static int patch_alc262(struct hda_codec *codec)
7717{
7718 struct alc_spec *spec;
7719 int board_config;
7720 int err;
7721
Robert P. J. Daydc041e02006-12-19 14:44:15 +01007722 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01007723 if (spec == NULL)
7724 return -ENOMEM;
7725
7726 codec->spec = spec;
7727#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007728 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7729 * under-run
7730 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007731 {
7732 int tmp;
7733 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7734 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
7735 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
7736 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
7737 }
7738#endif
7739
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007740 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
7741 alc262_models,
7742 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +01007743
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007744 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007745 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
7746 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007747 board_config = ALC262_AUTO;
7748 }
7749
7750 if (board_config == ALC262_AUTO) {
7751 /* automatic parse from the BIOS config */
7752 err = alc262_parse_auto_config(codec);
7753 if (err < 0) {
7754 alc_free(codec);
7755 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007756 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007757 printk(KERN_INFO
7758 "hda_codec: Cannot set up configuration "
7759 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007760 board_config = ALC262_BASIC;
7761 }
7762 }
7763
7764 if (board_config != ALC262_AUTO)
7765 setup_preset(spec, &alc262_presets[board_config]);
7766
7767 spec->stream_name_analog = "ALC262 Analog";
7768 spec->stream_analog_playback = &alc262_pcm_analog_playback;
7769 spec->stream_analog_capture = &alc262_pcm_analog_capture;
7770
7771 spec->stream_name_digital = "ALC262 Digital";
7772 spec->stream_digital_playback = &alc262_pcm_digital_playback;
7773 spec->stream_digital_capture = &alc262_pcm_digital_capture;
7774
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007775 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007776 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007777 unsigned int wcap = get_wcaps(codec, 0x07);
7778
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007779 /* get type */
7780 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007781 if (wcap != AC_WID_AUD_IN) {
7782 spec->adc_nids = alc262_adc_nids_alt;
7783 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007784 spec->mixers[spec->num_mixers] =
7785 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01007786 spec->num_mixers++;
7787 } else {
7788 spec->adc_nids = alc262_adc_nids;
7789 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
7790 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
7791 spec->num_mixers++;
7792 }
7793 }
7794
7795 codec->patch_ops = alc_patch_ops;
7796 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007797 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01007798
Kailang Yangdf694da2005-12-05 19:42:22 +01007799 return 0;
7800}
7801
Kailang Yangdf694da2005-12-05 19:42:22 +01007802/*
7803 * ALC861 channel source setting (2/6 channel selection for 3-stack)
7804 */
7805
7806/*
7807 * set the path ways for 2 channel output
7808 * need to set the codec line out and mic 1 pin widgets to inputs
7809 */
7810static struct hda_verb alc861_threestack_ch2_init[] = {
7811 /* set pin widget 1Ah (line in) for input */
7812 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007813 /* set pin widget 18h (mic1/2) for input, for mic also enable
7814 * the vref
7815 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007816 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7817
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007818 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
7819#if 0
7820 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
7821 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
7822#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007823 { } /* end */
7824};
7825/*
7826 * 6ch mode
7827 * need to set the codec line out and mic 1 pin widgets to outputs
7828 */
7829static struct hda_verb alc861_threestack_ch6_init[] = {
7830 /* set pin widget 1Ah (line in) for output (Back Surround)*/
7831 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7832 /* set pin widget 18h (mic1) for output (CLFE)*/
7833 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7834
7835 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007836 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007837
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007838 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
7839#if 0
7840 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
7841 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
7842#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007843 { } /* end */
7844};
7845
7846static struct hda_channel_mode alc861_threestack_modes[2] = {
7847 { 2, alc861_threestack_ch2_init },
7848 { 6, alc861_threestack_ch6_init },
7849};
Takashi Iwai22309c32006-08-09 16:57:28 +02007850/* Set mic1 as input and unmute the mixer */
7851static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
7852 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7853 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
7854 { } /* end */
7855};
7856/* Set mic1 as output and mute mixer */
7857static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
7858 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7859 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
7860 { } /* end */
7861};
7862
7863static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
7864 { 2, alc861_uniwill_m31_ch2_init },
7865 { 4, alc861_uniwill_m31_ch4_init },
7866};
Kailang Yangdf694da2005-12-05 19:42:22 +01007867
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007868/* Set mic1 and line-in as input and unmute the mixer */
7869static struct hda_verb alc861_asus_ch2_init[] = {
7870 /* set pin widget 1Ah (line in) for input */
7871 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007872 /* set pin widget 18h (mic1/2) for input, for mic also enable
7873 * the vref
7874 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02007875 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7876
7877 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
7878#if 0
7879 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
7880 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
7881#endif
7882 { } /* end */
7883};
7884/* Set mic1 nad line-in as output and mute mixer */
7885static struct hda_verb alc861_asus_ch6_init[] = {
7886 /* set pin widget 1Ah (line in) for output (Back Surround)*/
7887 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7888 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
7889 /* set pin widget 18h (mic1) for output (CLFE)*/
7890 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7891 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
7892 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
7893 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
7894
7895 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
7896#if 0
7897 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
7898 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
7899#endif
7900 { } /* end */
7901};
7902
7903static struct hda_channel_mode alc861_asus_modes[2] = {
7904 { 2, alc861_asus_ch2_init },
7905 { 6, alc861_asus_ch6_init },
7906};
7907
Kailang Yangdf694da2005-12-05 19:42:22 +01007908/* patch-ALC861 */
7909
7910static struct snd_kcontrol_new alc861_base_mixer[] = {
7911 /* output mixer control */
7912 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7913 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7914 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7915 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7916 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
7917
7918 /*Input mixer control */
7919 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7920 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
7921 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7922 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7924 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7926 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007929
Kailang Yangdf694da2005-12-05 19:42:22 +01007930 /* Capture mixer control */
7931 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7932 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7933 {
7934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7935 .name = "Capture Source",
7936 .count = 1,
7937 .info = alc_mux_enum_info,
7938 .get = alc_mux_enum_get,
7939 .put = alc_mux_enum_put,
7940 },
7941 { } /* end */
7942};
7943
7944static struct snd_kcontrol_new alc861_3ST_mixer[] = {
7945 /* output mixer control */
7946 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7947 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7948 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7949 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7950 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
7951
7952 /* Input mixer control */
7953 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7954 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
7955 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7956 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7958 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7960 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7961 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007963
Kailang Yangdf694da2005-12-05 19:42:22 +01007964 /* Capture mixer control */
7965 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7966 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7967 {
7968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7969 .name = "Capture Source",
7970 .count = 1,
7971 .info = alc_mux_enum_info,
7972 .get = alc_mux_enum_get,
7973 .put = alc_mux_enum_put,
7974 },
7975 {
7976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7977 .name = "Channel Mode",
7978 .info = alc_ch_mode_info,
7979 .get = alc_ch_mode_get,
7980 .put = alc_ch_mode_put,
7981 .private_value = ARRAY_SIZE(alc861_threestack_modes),
7982 },
7983 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007984};
7985
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007986static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +02007987 /* output mixer control */
7988 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7990 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7991
7992 /*Capture mixer control */
7993 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7994 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7995 {
7996 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7997 .name = "Capture Source",
7998 .count = 1,
7999 .info = alc_mux_enum_info,
8000 .get = alc_mux_enum_get,
8001 .put = alc_mux_enum_put,
8002 },
8003
8004 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008005};
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008006
Takashi Iwai22309c32006-08-09 16:57:28 +02008007static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
8008 /* output mixer control */
8009 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8010 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8011 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8012 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8013 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8014
8015 /* Input mixer control */
8016 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8017 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8018 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8019 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8020 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8021 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8023 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8024 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008026
Takashi Iwai22309c32006-08-09 16:57:28 +02008027 /* Capture mixer control */
8028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8030 {
8031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8032 .name = "Capture Source",
8033 .count = 1,
8034 .info = alc_mux_enum_info,
8035 .get = alc_mux_enum_get,
8036 .put = alc_mux_enum_put,
8037 },
8038 {
8039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8040 .name = "Channel Mode",
8041 .info = alc_ch_mode_info,
8042 .get = alc_ch_mode_get,
8043 .put = alc_ch_mode_put,
8044 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
8045 },
8046 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008047};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008048
8049static struct snd_kcontrol_new alc861_asus_mixer[] = {
8050 /* output mixer control */
8051 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8052 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8053 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8054 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8055 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8056
8057 /* Input mixer control */
8058 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8059 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8060 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8061 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8062 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8063 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8065 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8066 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
8068
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008069 /* Capture mixer control */
8070 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8071 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8072 {
8073 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8074 .name = "Capture Source",
8075 .count = 1,
8076 .info = alc_mux_enum_info,
8077 .get = alc_mux_enum_get,
8078 .put = alc_mux_enum_put,
8079 },
8080 {
8081 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8082 .name = "Channel Mode",
8083 .info = alc_ch_mode_info,
8084 .get = alc_ch_mode_get,
8085 .put = alc_ch_mode_put,
8086 .private_value = ARRAY_SIZE(alc861_asus_modes),
8087 },
8088 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008089};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008090
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008091/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008092static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008093 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8094 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8095 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
8096 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
8097 { }
8098};
8099
Kailang Yangdf694da2005-12-05 19:42:22 +01008100/*
8101 * generic initialization of ADC, input mixers and output mixers
8102 */
8103static struct hda_verb alc861_base_init_verbs[] = {
8104 /*
8105 * Unmute ADC0 and set the default input to mic-in
8106 */
8107 /* port-A for surround (rear panel) */
8108 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8109 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
8110 /* port-B for mic-in (rear panel) with vref */
8111 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8112 /* port-C for line-in (rear panel) */
8113 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8114 /* port-D for Front */
8115 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8116 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8117 /* port-E for HP out (front panel) */
8118 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8119 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008120 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008121 /* port-F for mic-in (front panel) with vref */
8122 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8123 /* port-G for CLFE (rear panel) */
8124 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8125 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
8126 /* port-H for side (rear panel) */
8127 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8128 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
8129 /* CD-in */
8130 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8131 /* route front mic to ADC1*/
8132 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8134
8135 /* Unmute DAC0~3 & spdif out*/
8136 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8137 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8138 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8139 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8141
8142 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8143 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8144 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8145 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8146 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8147
8148 /* Unmute Stereo Mixer 15 */
8149 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8151 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008153
8154 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8155 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8156 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8157 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8159 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8160 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8161 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008162 /* hp used DAC 3 (Front) */
8163 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008164 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8165
8166 { }
8167};
8168
8169static struct hda_verb alc861_threestack_init_verbs[] = {
8170 /*
8171 * Unmute ADC0 and set the default input to mic-in
8172 */
8173 /* port-A for surround (rear panel) */
8174 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8175 /* port-B for mic-in (rear panel) with vref */
8176 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8177 /* port-C for line-in (rear panel) */
8178 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8179 /* port-D for Front */
8180 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8181 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8182 /* port-E for HP out (front panel) */
8183 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
8184 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008185 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +01008186 /* port-F for mic-in (front panel) with vref */
8187 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8188 /* port-G for CLFE (rear panel) */
8189 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8190 /* port-H for side (rear panel) */
8191 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8192 /* CD-in */
8193 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8194 /* route front mic to ADC1*/
8195 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8197 /* Unmute DAC0~3 & spdif out*/
8198 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8200 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8201 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8203
8204 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8205 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8206 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8207 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8208 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8209
8210 /* Unmute Stereo Mixer 15 */
8211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +01008215
8216 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8217 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8218 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8220 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8222 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008224 /* hp used DAC 3 (Front) */
8225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8227 { }
8228};
Takashi Iwai22309c32006-08-09 16:57:28 +02008229
8230static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
8231 /*
8232 * Unmute ADC0 and set the default input to mic-in
8233 */
8234 /* port-A for surround (rear panel) */
8235 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8236 /* port-B for mic-in (rear panel) with vref */
8237 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8238 /* port-C for line-in (rear panel) */
8239 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8240 /* port-D for Front */
8241 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8242 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8243 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008244 /* this has to be set to VREF80 */
8245 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008246 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008247 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008248 /* port-F for mic-in (front panel) with vref */
8249 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8250 /* port-G for CLFE (rear panel) */
8251 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8252 /* port-H for side (rear panel) */
8253 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8254 /* CD-in */
8255 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8256 /* route front mic to ADC1*/
8257 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8258 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8259 /* Unmute DAC0~3 & spdif out*/
8260 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8261 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8262 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8263 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8265
8266 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8267 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8268 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8269 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8270 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8271
8272 /* Unmute Stereo Mixer 15 */
8273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +02008277
8278 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8279 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8280 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8281 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8283 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8284 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8285 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008286 /* hp used DAC 3 (Front) */
8287 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +02008288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8289 { }
8290};
8291
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008292static struct hda_verb alc861_asus_init_verbs[] = {
8293 /*
8294 * Unmute ADC0 and set the default input to mic-in
8295 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008296 /* port-A for surround (rear panel)
8297 * according to codec#0 this is the HP jack
8298 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008299 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
8300 /* route front PCM to HP */
8301 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
8302 /* port-B for mic-in (rear panel) with vref */
8303 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8304 /* port-C for line-in (rear panel) */
8305 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8306 /* port-D for Front */
8307 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8308 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
8309 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008310 /* this has to be set to VREF80 */
8311 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008312 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +01008313 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008314 /* port-F for mic-in (front panel) with vref */
8315 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8316 /* port-G for CLFE (rear panel) */
8317 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8318 /* port-H for side (rear panel) */
8319 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8320 /* CD-in */
8321 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8322 /* route front mic to ADC1*/
8323 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8325 /* Unmute DAC0~3 & spdif out*/
8326 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8327 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8328 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8329 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8331 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8332 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8333 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8334 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8335 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8336
8337 /* Unmute Stereo Mixer 15 */
8338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008342
8343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8344 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8345 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8349 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008351 /* hp used DAC 3 (Front) */
8352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008353 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8354 { }
8355};
8356
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008357/* additional init verbs for ASUS laptops */
8358static struct hda_verb alc861_asus_laptop_init_verbs[] = {
8359 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
8360 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
8361 { }
8362};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008363
Kailang Yangdf694da2005-12-05 19:42:22 +01008364/*
8365 * generic initialization of ADC, input mixers and output mixers
8366 */
8367static struct hda_verb alc861_auto_init_verbs[] = {
8368 /*
8369 * Unmute ADC0 and set the default input to mic-in
8370 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008371 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +01008372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8373
8374 /* Unmute DAC0~3 & spdif out*/
8375 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8376 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8377 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8378 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8380
8381 /* Unmute Mixer 14 (mic) 1c (Line in)*/
8382 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8383 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8384 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8385 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8386
8387 /* Unmute Stereo Mixer 15 */
8388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
8392
8393 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8396 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8397 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8400 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8401
8402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8403 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8405 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008406 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8407 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008408 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8409 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008410
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008411 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008412
8413 { }
8414};
8415
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008416static struct hda_verb alc861_toshiba_init_verbs[] = {
8417 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008418
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008419 { }
8420};
8421
8422/* toggle speaker-output according to the hp-jack state */
8423static void alc861_toshiba_automute(struct hda_codec *codec)
8424{
8425 unsigned int present;
8426
8427 present = snd_hda_codec_read(codec, 0x0f, 0,
8428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8429 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
8430 0x80, present ? 0x80 : 0);
8431 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
8432 0x80, present ? 0x80 : 0);
8433 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
8434 0x80, present ? 0 : 0x80);
8435 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
8436 0x80, present ? 0 : 0x80);
8437}
8438
8439static void alc861_toshiba_unsol_event(struct hda_codec *codec,
8440 unsigned int res)
8441{
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008442 if ((res >> 26) == ALC880_HP_EVENT)
8443 alc861_toshiba_automute(codec);
8444}
8445
Kailang Yangdf694da2005-12-05 19:42:22 +01008446/* pcm configuration: identiacal with ALC880 */
8447#define alc861_pcm_analog_playback alc880_pcm_analog_playback
8448#define alc861_pcm_analog_capture alc880_pcm_analog_capture
8449#define alc861_pcm_digital_playback alc880_pcm_digital_playback
8450#define alc861_pcm_digital_capture alc880_pcm_digital_capture
8451
8452
8453#define ALC861_DIGOUT_NID 0x07
8454
8455static struct hda_channel_mode alc861_8ch_modes[1] = {
8456 { 8, NULL }
8457};
8458
8459static hda_nid_t alc861_dac_nids[4] = {
8460 /* front, surround, clfe, side */
8461 0x03, 0x06, 0x05, 0x04
8462};
8463
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008464static hda_nid_t alc660_dac_nids[3] = {
8465 /* front, clfe, surround */
8466 0x03, 0x05, 0x06
8467};
8468
Kailang Yangdf694da2005-12-05 19:42:22 +01008469static hda_nid_t alc861_adc_nids[1] = {
8470 /* ADC0-2 */
8471 0x08,
8472};
8473
8474static struct hda_input_mux alc861_capture_source = {
8475 .num_items = 5,
8476 .items = {
8477 { "Mic", 0x0 },
8478 { "Front Mic", 0x3 },
8479 { "Line", 0x1 },
8480 { "CD", 0x4 },
8481 { "Mixer", 0x5 },
8482 },
8483};
8484
8485/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008486static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
8487 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008488{
8489 int i;
8490 hda_nid_t nid;
8491
8492 spec->multiout.dac_nids = spec->private_dac_nids;
8493 for (i = 0; i < cfg->line_outs; i++) {
8494 nid = cfg->line_out_pins[i];
8495 if (nid) {
8496 if (i >= ARRAY_SIZE(alc861_dac_nids))
8497 continue;
8498 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
8499 }
8500 }
8501 spec->multiout.num_dacs = cfg->line_outs;
8502 return 0;
8503}
8504
8505/* add playback controls from the parsed DAC table */
8506static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
8507 const struct auto_pin_cfg *cfg)
8508{
8509 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008510 static const char *chname[4] = {
8511 "Front", "Surround", NULL /*CLFE*/, "Side"
8512 };
Kailang Yangdf694da2005-12-05 19:42:22 +01008513 hda_nid_t nid;
8514 int i, idx, err;
8515
8516 for (i = 0; i < cfg->line_outs; i++) {
8517 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008518 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +01008519 continue;
8520 if (nid == 0x05) {
8521 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008522 err = add_control(spec, ALC_CTL_BIND_MUTE,
8523 "Center Playback Switch",
8524 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
8525 HDA_OUTPUT));
8526 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008527 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008528 err = add_control(spec, ALC_CTL_BIND_MUTE,
8529 "LFE Playback Switch",
8530 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8531 HDA_OUTPUT));
8532 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008533 return err;
8534 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008535 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
8536 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +01008537 if (nid == alc861_dac_nids[idx])
8538 break;
8539 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008540 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8541 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8542 HDA_OUTPUT));
8543 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008544 return err;
8545 }
8546 }
8547 return 0;
8548}
8549
8550static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
8551{
8552 int err;
8553 hda_nid_t nid;
8554
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008555 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +01008556 return 0;
8557
8558 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
8559 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008560 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8561 "Headphone Playback Switch",
8562 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8563 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008564 return err;
8565 spec->multiout.hp_nid = nid;
8566 }
8567 return 0;
8568}
8569
8570/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008571static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
8572 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01008573{
Kailang Yangdf694da2005-12-05 19:42:22 +01008574 struct hda_input_mux *imux = &spec->private_imux;
8575 int i, err, idx, idx1;
8576
8577 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008578 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +01008579 case 0x0c:
8580 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008581 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01008582 break;
8583 case 0x0f:
8584 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008585 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +01008586 break;
8587 case 0x0d:
8588 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008589 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01008590 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008591 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +01008592 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008593 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +01008594 break;
8595 case 0x11:
8596 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008597 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +01008598 break;
8599 default:
8600 continue;
8601 }
8602
Takashi Iwai4a471b72005-12-07 13:56:29 +01008603 err = new_analog_input(spec, cfg->input_pins[i],
8604 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01008605 if (err < 0)
8606 return err;
8607
Takashi Iwai4a471b72005-12-07 13:56:29 +01008608 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01008609 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008610 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +01008611 }
8612 return 0;
8613}
8614
8615static struct snd_kcontrol_new alc861_capture_mixer[] = {
8616 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8617 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8618
8619 {
8620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8621 /* The multiple "Capture Source" controls confuse alsamixer
8622 * So call somewhat different..
8623 *FIXME: the controls appear in the "playback" view!
8624 */
8625 /* .name = "Capture Source", */
8626 .name = "Input Source",
8627 .count = 1,
8628 .info = alc_mux_enum_info,
8629 .get = alc_mux_enum_get,
8630 .put = alc_mux_enum_put,
8631 },
8632 { } /* end */
8633};
8634
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008635static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
8636 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +01008637 int pin_type, int dac_idx)
8638{
8639 /* set as output */
8640
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008641 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8642 pin_type);
8643 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8644 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01008645
8646}
8647
8648static void alc861_auto_init_multi_out(struct hda_codec *codec)
8649{
8650 struct alc_spec *spec = codec->spec;
8651 int i;
8652
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008653 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +01008654 for (i = 0; i < spec->autocfg.line_outs; i++) {
8655 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008656 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01008657 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008658 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008659 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +01008660 }
8661}
8662
8663static void alc861_auto_init_hp_out(struct hda_codec *codec)
8664{
8665 struct alc_spec *spec = codec->spec;
8666 hda_nid_t pin;
8667
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008668 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01008669 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008670 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
8671 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +01008672}
8673
8674static void alc861_auto_init_analog_input(struct hda_codec *codec)
8675{
8676 struct alc_spec *spec = codec->spec;
8677 int i;
8678
8679 for (i = 0; i < AUTO_PIN_LAST; i++) {
8680 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008681 if (nid >= 0x0c && nid <= 0x11) {
8682 snd_hda_codec_write(codec, nid, 0,
8683 AC_VERB_SET_PIN_WIDGET_CONTROL,
8684 i <= AUTO_PIN_FRONT_MIC ?
8685 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01008686 }
8687 }
8688}
8689
8690/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008691/* return 1 if successful, 0 if the proper config is not found,
8692 * or a negative error code
8693 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008694static int alc861_parse_auto_config(struct hda_codec *codec)
8695{
8696 struct alc_spec *spec = codec->spec;
8697 int err;
8698 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
8699
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008700 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8701 alc861_ignore);
8702 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008703 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008704 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01008705 return 0; /* can't find valid BIOS pin config */
8706
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008707 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
8708 if (err < 0)
8709 return err;
8710 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
8711 if (err < 0)
8712 return err;
8713 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
8714 if (err < 0)
8715 return err;
8716 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
8717 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01008718 return err;
8719
8720 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8721
8722 if (spec->autocfg.dig_out_pin)
8723 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
8724
8725 if (spec->kctl_alloc)
8726 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8727
8728 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
8729
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02008730 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01008731 spec->input_mux = &spec->private_imux;
8732
8733 spec->adc_nids = alc861_adc_nids;
8734 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
8735 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
8736 spec->num_mixers++;
8737
8738 return 1;
8739}
8740
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008741/* additional initialization for auto-configuration model */
8742static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01008743{
Kailang Yangdf694da2005-12-05 19:42:22 +01008744 alc861_auto_init_multi_out(codec);
8745 alc861_auto_init_hp_out(codec);
8746 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01008747}
8748
8749
8750/*
8751 * configuration and preset
8752 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008753static const char *alc861_models[ALC861_MODEL_LAST] = {
8754 [ALC861_3ST] = "3stack",
8755 [ALC660_3ST] = "3stack-660",
8756 [ALC861_3ST_DIG] = "3stack-dig",
8757 [ALC861_6ST_DIG] = "6stack-dig",
8758 [ALC861_UNIWILL_M31] = "uniwill-m31",
8759 [ALC861_TOSHIBA] = "toshiba",
8760 [ALC861_ASUS] = "asus",
8761 [ALC861_ASUS_LAPTOP] = "asus-laptop",
8762 [ALC861_AUTO] = "auto",
8763};
8764
8765static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +01008766 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008767 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
8768 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
Takashi Iwaif223a9f2007-04-25 13:38:31 +02008769 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008770 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Tobin Davisad5e7732007-01-08 10:57:32 +01008771 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008772 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
8773 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
Takashi Iwai4147dab2007-01-31 10:35:19 +01008774 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
Takashi Iwai07e038b2007-02-15 18:23:41 +01008775 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008776 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +01008777 {}
8778};
8779
8780static struct alc_config_preset alc861_presets[] = {
8781 [ALC861_3ST] = {
8782 .mixers = { alc861_3ST_mixer },
8783 .init_verbs = { alc861_threestack_init_verbs },
8784 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8785 .dac_nids = alc861_dac_nids,
8786 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
8787 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008788 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01008789 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8790 .adc_nids = alc861_adc_nids,
8791 .input_mux = &alc861_capture_source,
8792 },
8793 [ALC861_3ST_DIG] = {
8794 .mixers = { alc861_base_mixer },
8795 .init_verbs = { alc861_threestack_init_verbs },
8796 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8797 .dac_nids = alc861_dac_nids,
8798 .dig_out_nid = ALC861_DIGOUT_NID,
8799 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
8800 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008801 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01008802 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8803 .adc_nids = alc861_adc_nids,
8804 .input_mux = &alc861_capture_source,
8805 },
8806 [ALC861_6ST_DIG] = {
8807 .mixers = { alc861_base_mixer },
8808 .init_verbs = { alc861_base_init_verbs },
8809 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8810 .dac_nids = alc861_dac_nids,
8811 .dig_out_nid = ALC861_DIGOUT_NID,
8812 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
8813 .channel_mode = alc861_8ch_modes,
8814 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8815 .adc_nids = alc861_adc_nids,
8816 .input_mux = &alc861_capture_source,
8817 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008818 [ALC660_3ST] = {
8819 .mixers = { alc861_3ST_mixer },
8820 .init_verbs = { alc861_threestack_init_verbs },
8821 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
8822 .dac_nids = alc660_dac_nids,
8823 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
8824 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008825 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008826 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8827 .adc_nids = alc861_adc_nids,
8828 .input_mux = &alc861_capture_source,
8829 },
Takashi Iwai22309c32006-08-09 16:57:28 +02008830 [ALC861_UNIWILL_M31] = {
8831 .mixers = { alc861_uniwill_m31_mixer },
8832 .init_verbs = { alc861_uniwill_m31_init_verbs },
8833 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8834 .dac_nids = alc861_dac_nids,
8835 .dig_out_nid = ALC861_DIGOUT_NID,
8836 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
8837 .channel_mode = alc861_uniwill_m31_modes,
8838 .need_dac_fix = 1,
8839 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8840 .adc_nids = alc861_adc_nids,
8841 .input_mux = &alc861_capture_source,
8842 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008843 [ALC861_TOSHIBA] = {
8844 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008845 .init_verbs = { alc861_base_init_verbs,
8846 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +02008847 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8848 .dac_nids = alc861_dac_nids,
8849 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8850 .channel_mode = alc883_3ST_2ch_modes,
8851 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8852 .adc_nids = alc861_adc_nids,
8853 .input_mux = &alc861_capture_source,
8854 .unsol_event = alc861_toshiba_unsol_event,
8855 .init_hook = alc861_toshiba_automute,
8856 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +02008857 [ALC861_ASUS] = {
8858 .mixers = { alc861_asus_mixer },
8859 .init_verbs = { alc861_asus_init_verbs },
8860 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8861 .dac_nids = alc861_dac_nids,
8862 .dig_out_nid = ALC861_DIGOUT_NID,
8863 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
8864 .channel_mode = alc861_asus_modes,
8865 .need_dac_fix = 1,
8866 .hp_nid = 0x06,
8867 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8868 .adc_nids = alc861_adc_nids,
8869 .input_mux = &alc861_capture_source,
8870 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +01008871 [ALC861_ASUS_LAPTOP] = {
8872 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
8873 .init_verbs = { alc861_asus_init_verbs,
8874 alc861_asus_laptop_init_verbs },
8875 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
8876 .dac_nids = alc861_dac_nids,
8877 .dig_out_nid = ALC861_DIGOUT_NID,
8878 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8879 .channel_mode = alc883_3ST_2ch_modes,
8880 .need_dac_fix = 1,
8881 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
8882 .adc_nids = alc861_adc_nids,
8883 .input_mux = &alc861_capture_source,
8884 },
8885};
Kailang Yangdf694da2005-12-05 19:42:22 +01008886
8887
8888static int patch_alc861(struct hda_codec *codec)
8889{
8890 struct alc_spec *spec;
8891 int board_config;
8892 int err;
8893
Robert P. J. Daydc041e02006-12-19 14:44:15 +01008894 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +01008895 if (spec == NULL)
8896 return -ENOMEM;
8897
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008898 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01008899
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008900 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
8901 alc861_models,
8902 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008903
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008904 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008905 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
8906 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008907 board_config = ALC861_AUTO;
8908 }
8909
8910 if (board_config == ALC861_AUTO) {
8911 /* automatic parse from the BIOS config */
8912 err = alc861_parse_auto_config(codec);
8913 if (err < 0) {
8914 alc_free(codec);
8915 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008916 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008917 printk(KERN_INFO
8918 "hda_codec: Cannot set up configuration "
8919 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01008920 board_config = ALC861_3ST_DIG;
8921 }
8922 }
8923
8924 if (board_config != ALC861_AUTO)
8925 setup_preset(spec, &alc861_presets[board_config]);
8926
8927 spec->stream_name_analog = "ALC861 Analog";
8928 spec->stream_analog_playback = &alc861_pcm_analog_playback;
8929 spec->stream_analog_capture = &alc861_pcm_analog_capture;
8930
8931 spec->stream_name_digital = "ALC861 Digital";
8932 spec->stream_digital_playback = &alc861_pcm_digital_playback;
8933 spec->stream_digital_capture = &alc861_pcm_digital_capture;
8934
8935 codec->patch_ops = alc_patch_ops;
8936 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01008937 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01008938
8939 return 0;
8940}
8941
8942/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01008943 * ALC861-VD support
8944 *
8945 * Based on ALC882
8946 *
8947 * In addition, an independent DAC
8948 */
8949#define ALC861VD_DIGOUT_NID 0x06
8950
8951static hda_nid_t alc861vd_dac_nids[4] = {
8952 /* front, surr, clfe, side surr */
8953 0x02, 0x03, 0x04, 0x05
8954};
8955
8956/* dac_nids for ALC660vd are in a different order - according to
8957 * Realtek's driver.
8958 * This should probably tesult in a different mixer for 6stack models
8959 * of ALC660vd codecs, but for now there is only 3stack mixer
8960 * - and it is the same as in 861vd.
8961 * adc_nids in ALC660vd are (is) the same as in 861vd
8962 */
8963static hda_nid_t alc660vd_dac_nids[3] = {
8964 /* front, rear, clfe, rear_surr */
8965 0x02, 0x04, 0x03
8966};
8967
8968static hda_nid_t alc861vd_adc_nids[1] = {
8969 /* ADC0 */
8970 0x09,
8971};
8972
8973/* input MUX */
8974/* FIXME: should be a matrix-type input source selection */
8975static struct hda_input_mux alc861vd_capture_source = {
8976 .num_items = 4,
8977 .items = {
8978 { "Mic", 0x0 },
8979 { "Front Mic", 0x1 },
8980 { "Line", 0x2 },
8981 { "CD", 0x4 },
8982 },
8983};
8984
Kailang Yang272a5272007-05-14 11:00:38 +02008985static struct hda_input_mux alc861vd_dallas_capture_source = {
8986 .num_items = 3,
8987 .items = {
8988 { "Front Mic", 0x0 },
8989 { "ATAPI Mic", 0x1 },
8990 { "Line In", 0x5 },
8991 },
8992};
8993
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01008994#define alc861vd_mux_enum_info alc_mux_enum_info
8995#define alc861vd_mux_enum_get alc_mux_enum_get
8996
8997static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
8998 struct snd_ctl_elem_value *ucontrol)
8999{
9000 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9001 struct alc_spec *spec = codec->spec;
9002 const struct hda_input_mux *imux = spec->input_mux;
9003 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9004 static hda_nid_t capture_mixers[1] = { 0x22 };
9005 hda_nid_t nid = capture_mixers[adc_idx];
9006 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9007 unsigned int i, idx;
9008
9009 idx = ucontrol->value.enumerated.item[0];
9010 if (idx >= imux->num_items)
9011 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009012 if (*cur_val == idx && !codec->in_resume)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009013 return 0;
9014 for (i = 0; i < imux->num_items; i++) {
9015 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9016 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9017 v | (imux->items[i].index << 8));
9018 }
9019 *cur_val = idx;
9020 return 1;
9021}
9022
9023/*
9024 * 2ch mode
9025 */
9026static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
9027 { 2, NULL }
9028};
9029
9030/*
9031 * 6ch mode
9032 */
9033static struct hda_verb alc861vd_6stack_ch6_init[] = {
9034 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9035 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9036 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9037 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9038 { } /* end */
9039};
9040
9041/*
9042 * 8ch mode
9043 */
9044static struct hda_verb alc861vd_6stack_ch8_init[] = {
9045 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9046 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9047 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9048 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9049 { } /* end */
9050};
9051
9052static struct hda_channel_mode alc861vd_6stack_modes[2] = {
9053 { 6, alc861vd_6stack_ch6_init },
9054 { 8, alc861vd_6stack_ch8_init },
9055};
9056
9057static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
9058 {
9059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9060 .name = "Channel Mode",
9061 .info = alc_ch_mode_info,
9062 .get = alc_ch_mode_get,
9063 .put = alc_ch_mode_put,
9064 },
9065 { } /* end */
9066};
9067
9068static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
9069 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9070 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9071
9072 {
9073 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9074 /* The multiple "Capture Source" controls confuse alsamixer
9075 * So call somewhat different..
9076 *FIXME: the controls appear in the "playback" view!
9077 */
9078 /* .name = "Capture Source", */
9079 .name = "Input Source",
9080 .count = 1,
9081 .info = alc861vd_mux_enum_info,
9082 .get = alc861vd_mux_enum_get,
9083 .put = alc861vd_mux_enum_put,
9084 },
9085 { } /* end */
9086};
9087
9088/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9089 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9090 */
9091static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
9092 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9093 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9094
9095 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9096 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
9097
9098 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
9099 HDA_OUTPUT),
9100 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
9101 HDA_OUTPUT),
9102 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9103 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9104
9105 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
9106 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
9107
9108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9109
9110 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9113
9114 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9116 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9117
9118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9120
9121 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9122 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9123
9124 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9125 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9126
9127 { } /* end */
9128};
9129
9130static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
9131 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9132 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9133
9134 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9135
9136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9139
9140 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9141 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9142 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9143
9144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9146
9147 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9148 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9149
9150 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9151 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9152
9153 { } /* end */
9154};
9155
Kailang Yangbdd148a2007-05-08 15:19:08 +02009156static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
9157 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9158 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
9159 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9160
9161 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9162
9163 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9166
9167 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9168 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9169 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9170
9171 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9172 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9173
9174 { } /* end */
9175};
9176
Kailang Yang272a5272007-05-14 11:00:38 +02009177/* Pin assignment: Front=0x14, HP = 0x15,
9178 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
9179 */
9180static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
9181 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9182 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9183 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9184 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
9185 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9186 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9187 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9188 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9189 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
9190 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
9191 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9192 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9193 {
9194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9195 /* .name = "Capture Source", */
9196 .name = "Input Source",
9197 .count = 1,
9198 .info = alc882_mux_enum_info,
9199 .get = alc882_mux_enum_get,
9200 .put = alc882_mux_enum_put,
9201 },
9202 { } /* end */
9203};
9204
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009205/*
9206 * generic initialization of ADC, input mixers and output mixers
9207 */
9208static struct hda_verb alc861vd_volume_init_verbs[] = {
9209 /*
9210 * Unmute ADC0 and set the default input to mic-in
9211 */
9212 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9214
9215 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
9216 * the analog-loopback mixer widget
9217 */
9218 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9224
9225 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +02009226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9228 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009230
9231 /*
9232 * Set up output mixers (0x02 - 0x05)
9233 */
9234 /* set vol=0 to output mixers */
9235 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9236 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9237 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9238 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9239
9240 /* set up input amps for analog loopback */
9241 /* Amp Indices: DAC = 0, mixer = 1 */
9242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9246 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9247 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9248 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9249 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9250
9251 { }
9252};
9253
9254/*
9255 * 3-stack pin configuration:
9256 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
9257 */
9258static struct hda_verb alc861vd_3stack_init_verbs[] = {
9259 /*
9260 * Set pin mode and muting
9261 */
9262 /* set front pin widgets 0x14 for output */
9263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9265 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9266
9267 /* Mic (rear) pin: input vref at 80% */
9268 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9270 /* Front Mic pin: input vref at 80% */
9271 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9273 /* Line In pin: input */
9274 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9276 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9280 /* CD pin widget for input */
9281 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9282
9283 { }
9284};
9285
9286/*
9287 * 6-stack pin configuration:
9288 */
9289static struct hda_verb alc861vd_6stack_init_verbs[] = {
9290 /*
9291 * Set pin mode and muting
9292 */
9293 /* set front pin widgets 0x14 for output */
9294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9296 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9297
9298 /* Rear Pin: output 1 (0x0d) */
9299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9301 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9302 /* CLFE Pin: output 2 (0x0e) */
9303 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9305 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
9306 /* Side Pin: output 3 (0x0f) */
9307 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9308 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9309 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9310
9311 /* Mic (rear) pin: input vref at 80% */
9312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9313 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9314 /* Front Mic pin: input vref at 80% */
9315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9317 /* Line In pin: input */
9318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9320 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9321 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9322 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9323 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9324 /* CD pin widget for input */
9325 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9326
9327 { }
9328};
9329
Kailang Yangbdd148a2007-05-08 15:19:08 +02009330static struct hda_verb alc861vd_eapd_verbs[] = {
9331 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9332 { }
9333};
9334
9335static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
9336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9339 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9340 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9341 {}
9342};
9343
9344/* toggle speaker-output according to the hp-jack state */
9345static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
9346{
9347 unsigned int present;
9348 unsigned char bits;
9349
9350 present = snd_hda_codec_read(codec, 0x1b, 0,
9351 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9352 bits = present ? 0x80 : 0;
9353 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9354 0x80, bits);
9355 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9356 0x80, bits);
9357}
9358
9359static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
9360{
9361 unsigned int present;
9362 unsigned char bits;
9363
9364 present = snd_hda_codec_read(codec, 0x18, 0,
9365 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9366 bits = present ? 0x80 : 0;
9367 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
9368 0x80, bits);
9369 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
9370 0x80, bits);
9371}
9372
9373static void alc861vd_lenovo_automute(struct hda_codec *codec)
9374{
9375 alc861vd_lenovo_hp_automute(codec);
9376 alc861vd_lenovo_mic_automute(codec);
9377}
9378
9379static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
9380 unsigned int res)
9381{
9382 switch (res >> 26) {
9383 case ALC880_HP_EVENT:
9384 alc861vd_lenovo_hp_automute(codec);
9385 break;
9386 case ALC880_MIC_EVENT:
9387 alc861vd_lenovo_mic_automute(codec);
9388 break;
9389 }
9390}
9391
Kailang Yang272a5272007-05-14 11:00:38 +02009392static struct hda_verb alc861vd_dallas_verbs[] = {
9393 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9394 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9395 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9396 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9397
9398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9404 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9406
9407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9411 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9412 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9413 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9414 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9415
9416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9418 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
9419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9420 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9421 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9422 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9423 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9424
9425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9429
9430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9431 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9432 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9433
9434 { } /* end */
9435};
9436
9437/* toggle speaker-output according to the hp-jack state */
9438static void alc861vd_dallas_automute(struct hda_codec *codec)
9439{
9440 unsigned int present;
9441
9442 present = snd_hda_codec_read(codec, 0x15, 0,
9443 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9444 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9445 0x80, present ? 0x80 : 0);
9446 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9447 0x80, present ? 0x80 : 0);
9448}
9449
9450static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
9451{
9452 if ((res >> 26) == ALC880_HP_EVENT)
9453 alc861vd_dallas_automute(codec);
9454}
9455
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009456/* pcm configuration: identiacal with ALC880 */
9457#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
9458#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
9459#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
9460#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
9461
9462/*
9463 * configuration and preset
9464 */
9465static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
9466 [ALC660VD_3ST] = "3stack-660",
9467 [ALC861VD_3ST] = "3stack",
9468 [ALC861VD_3ST_DIG] = "3stack-digout",
9469 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +02009470 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +02009471 [ALC861VD_DALLAS] = "dallas",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009472 [ALC861VD_AUTO] = "auto",
9473};
9474
9475static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwai07e038b2007-02-15 18:23:41 +01009476 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009477 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Daniel Drake36c3b4e2007-05-21 12:27:57 +02009478 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009479 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
9480 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
9481
Kailang Yang272a5272007-05-14 11:00:38 +02009482 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
9483 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Kailang Yangbdd148a2007-05-08 15:19:08 +02009484 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
9485 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009486 {}
9487};
9488
9489static struct alc_config_preset alc861vd_presets[] = {
9490 [ALC660VD_3ST] = {
9491 .mixers = { alc861vd_3st_mixer },
9492 .init_verbs = { alc861vd_volume_init_verbs,
9493 alc861vd_3stack_init_verbs },
9494 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
9495 .dac_nids = alc660vd_dac_nids,
9496 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
9497 .adc_nids = alc861vd_adc_nids,
9498 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
9499 .channel_mode = alc861vd_3stack_2ch_modes,
9500 .input_mux = &alc861vd_capture_source,
9501 },
9502 [ALC861VD_3ST] = {
9503 .mixers = { alc861vd_3st_mixer },
9504 .init_verbs = { alc861vd_volume_init_verbs,
9505 alc861vd_3stack_init_verbs },
9506 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
9507 .dac_nids = alc861vd_dac_nids,
9508 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
9509 .channel_mode = alc861vd_3stack_2ch_modes,
9510 .input_mux = &alc861vd_capture_source,
9511 },
9512 [ALC861VD_3ST_DIG] = {
9513 .mixers = { alc861vd_3st_mixer },
9514 .init_verbs = { alc861vd_volume_init_verbs,
9515 alc861vd_3stack_init_verbs },
9516 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
9517 .dac_nids = alc861vd_dac_nids,
9518 .dig_out_nid = ALC861VD_DIGOUT_NID,
9519 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
9520 .channel_mode = alc861vd_3stack_2ch_modes,
9521 .input_mux = &alc861vd_capture_source,
9522 },
9523 [ALC861VD_6ST_DIG] = {
9524 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
9525 .init_verbs = { alc861vd_volume_init_verbs,
9526 alc861vd_6stack_init_verbs },
9527 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
9528 .dac_nids = alc861vd_dac_nids,
9529 .dig_out_nid = ALC861VD_DIGOUT_NID,
9530 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
9531 .channel_mode = alc861vd_6stack_modes,
9532 .input_mux = &alc861vd_capture_source,
9533 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02009534 [ALC861VD_LENOVO] = {
9535 .mixers = { alc861vd_lenovo_mixer },
9536 .init_verbs = { alc861vd_volume_init_verbs,
9537 alc861vd_3stack_init_verbs,
9538 alc861vd_eapd_verbs,
9539 alc861vd_lenovo_unsol_verbs },
9540 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
9541 .dac_nids = alc660vd_dac_nids,
9542 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
9543 .adc_nids = alc861vd_adc_nids,
9544 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
9545 .channel_mode = alc861vd_3stack_2ch_modes,
9546 .input_mux = &alc861vd_capture_source,
9547 .unsol_event = alc861vd_lenovo_unsol_event,
9548 .init_hook = alc861vd_lenovo_automute,
9549 },
Kailang Yang272a5272007-05-14 11:00:38 +02009550 [ALC861VD_DALLAS] = {
9551 .mixers = { alc861vd_dallas_mixer },
9552 .init_verbs = { alc861vd_dallas_verbs },
9553 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
9554 .dac_nids = alc861vd_dac_nids,
9555 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
9556 .adc_nids = alc861vd_adc_nids,
9557 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
9558 .channel_mode = alc861vd_3stack_2ch_modes,
9559 .input_mux = &alc861vd_dallas_capture_source,
9560 .unsol_event = alc861vd_dallas_unsol_event,
9561 .init_hook = alc861vd_dallas_automute,
9562 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009563};
9564
9565/*
9566 * BIOS auto configuration
9567 */
9568static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
9569 hda_nid_t nid, int pin_type, int dac_idx)
9570{
9571 /* set as output */
9572 snd_hda_codec_write(codec, nid, 0,
9573 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
9574 snd_hda_codec_write(codec, nid, 0,
9575 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
9576}
9577
9578static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
9579{
9580 struct alc_spec *spec = codec->spec;
9581 int i;
9582
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009583 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009584 for (i = 0; i <= HDA_SIDE; i++) {
9585 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009586 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009587 if (nid)
9588 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009589 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009590 }
9591}
9592
9593
9594static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
9595{
9596 struct alc_spec *spec = codec->spec;
9597 hda_nid_t pin;
9598
9599 pin = spec->autocfg.hp_pins[0];
9600 if (pin) /* connect to front and use dac 0 */
9601 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9602}
9603
9604#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
9605#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
9606
9607static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
9608{
9609 struct alc_spec *spec = codec->spec;
9610 int i;
9611
9612 for (i = 0; i < AUTO_PIN_LAST; i++) {
9613 hda_nid_t nid = spec->autocfg.input_pins[i];
9614 if (alc861vd_is_input_pin(nid)) {
9615 snd_hda_codec_write(codec, nid, 0,
9616 AC_VERB_SET_PIN_WIDGET_CONTROL,
9617 i <= AUTO_PIN_FRONT_MIC ?
9618 PIN_VREF80 : PIN_IN);
9619 if (nid != ALC861VD_PIN_CD_NID)
9620 snd_hda_codec_write(codec, nid, 0,
9621 AC_VERB_SET_AMP_GAIN_MUTE,
9622 AMP_OUT_MUTE);
9623 }
9624 }
9625}
9626
9627#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
9628#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
9629
9630/* add playback controls from the parsed DAC table */
9631/* Based on ALC880 version. But ALC861VD has separate,
9632 * different NIDs for mute/unmute switch and volume control */
9633static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
9634 const struct auto_pin_cfg *cfg)
9635{
9636 char name[32];
9637 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
9638 hda_nid_t nid_v, nid_s;
9639 int i, err;
9640
9641 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009642 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009643 continue;
9644 nid_v = alc861vd_idx_to_mixer_vol(
9645 alc880_dac_to_idx(
9646 spec->multiout.dac_nids[i]));
9647 nid_s = alc861vd_idx_to_mixer_switch(
9648 alc880_dac_to_idx(
9649 spec->multiout.dac_nids[i]));
9650
9651 if (i == 2) {
9652 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009653 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9654 "Center Playback Volume",
9655 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
9656 HDA_OUTPUT));
9657 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009658 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009659 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9660 "LFE Playback Volume",
9661 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
9662 HDA_OUTPUT));
9663 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009664 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009665 err = add_control(spec, ALC_CTL_BIND_MUTE,
9666 "Center Playback Switch",
9667 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
9668 HDA_INPUT));
9669 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009670 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009671 err = add_control(spec, ALC_CTL_BIND_MUTE,
9672 "LFE Playback Switch",
9673 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
9674 HDA_INPUT));
9675 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009676 return err;
9677 } else {
9678 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009679 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9680 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
9681 HDA_OUTPUT));
9682 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009683 return err;
9684 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009685 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +02009686 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009687 HDA_INPUT));
9688 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009689 return err;
9690 }
9691 }
9692 return 0;
9693}
9694
9695/* add playback controls for speaker and HP outputs */
9696/* Based on ALC880 version. But ALC861VD has separate,
9697 * different NIDs for mute/unmute switch and volume control */
9698static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
9699 hda_nid_t pin, const char *pfx)
9700{
9701 hda_nid_t nid_v, nid_s;
9702 int err;
9703 char name[32];
9704
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009705 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009706 return 0;
9707
9708 if (alc880_is_fixed_pin(pin)) {
9709 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
9710 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009711 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009712 spec->multiout.hp_nid = nid_v;
9713 else
9714 spec->multiout.extra_out_nid[0] = nid_v;
9715 /* control HP volume/switch on the output mixer amp */
9716 nid_v = alc861vd_idx_to_mixer_vol(
9717 alc880_fixed_pin_idx(pin));
9718 nid_s = alc861vd_idx_to_mixer_switch(
9719 alc880_fixed_pin_idx(pin));
9720
9721 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009722 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9723 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
9724 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009725 return err;
9726 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009727 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9728 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
9729 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009730 return err;
9731 } else if (alc880_is_multi_pin(pin)) {
9732 /* set manual connection */
9733 /* we have only a switch on HP-out PIN */
9734 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009735 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9736 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
9737 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009738 return err;
9739 }
9740 return 0;
9741}
9742
9743/* parse the BIOS configuration and set up the alc_spec
9744 * return 1 if successful, 0 if the proper config is not found,
9745 * or a negative error code
9746 * Based on ALC880 version - had to change it to override
9747 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
9748static int alc861vd_parse_auto_config(struct hda_codec *codec)
9749{
9750 struct alc_spec *spec = codec->spec;
9751 int err;
9752 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
9753
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009754 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9755 alc861vd_ignore);
9756 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009757 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009758 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009759 return 0; /* can't find valid BIOS pin config */
9760
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009761 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9762 if (err < 0)
9763 return err;
9764 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
9765 if (err < 0)
9766 return err;
9767 err = alc861vd_auto_create_extra_out(spec,
9768 spec->autocfg.speaker_pins[0],
9769 "Speaker");
9770 if (err < 0)
9771 return err;
9772 err = alc861vd_auto_create_extra_out(spec,
9773 spec->autocfg.hp_pins[0],
9774 "Headphone");
9775 if (err < 0)
9776 return err;
9777 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
9778 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009779 return err;
9780
9781 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9782
9783 if (spec->autocfg.dig_out_pin)
9784 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
9785
9786 if (spec->kctl_alloc)
9787 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9788
9789 spec->init_verbs[spec->num_init_verbs++]
9790 = alc861vd_volume_init_verbs;
9791
9792 spec->num_mux_defs = 1;
9793 spec->input_mux = &spec->private_imux;
9794
9795 return 1;
9796}
9797
9798/* additional initialization for auto-configuration model */
9799static void alc861vd_auto_init(struct hda_codec *codec)
9800{
9801 alc861vd_auto_init_multi_out(codec);
9802 alc861vd_auto_init_hp_out(codec);
9803 alc861vd_auto_init_analog_input(codec);
9804}
9805
9806static int patch_alc861vd(struct hda_codec *codec)
9807{
9808 struct alc_spec *spec;
9809 int err, board_config;
9810
9811 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9812 if (spec == NULL)
9813 return -ENOMEM;
9814
9815 codec->spec = spec;
9816
9817 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
9818 alc861vd_models,
9819 alc861vd_cfg_tbl);
9820
9821 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
9822 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
9823 "ALC861VD, trying auto-probe from BIOS...\n");
9824 board_config = ALC861VD_AUTO;
9825 }
9826
9827 if (board_config == ALC861VD_AUTO) {
9828 /* automatic parse from the BIOS config */
9829 err = alc861vd_parse_auto_config(codec);
9830 if (err < 0) {
9831 alc_free(codec);
9832 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009833 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +01009834 printk(KERN_INFO
9835 "hda_codec: Cannot set up configuration "
9836 "from BIOS. Using base mode...\n");
9837 board_config = ALC861VD_3ST;
9838 }
9839 }
9840
9841 if (board_config != ALC861VD_AUTO)
9842 setup_preset(spec, &alc861vd_presets[board_config]);
9843
9844 spec->stream_name_analog = "ALC861VD Analog";
9845 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
9846 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
9847
9848 spec->stream_name_digital = "ALC861VD Digital";
9849 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
9850 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
9851
9852 spec->adc_nids = alc861vd_adc_nids;
9853 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
9854
9855 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
9856 spec->num_mixers++;
9857
9858 codec->patch_ops = alc_patch_ops;
9859
9860 if (board_config == ALC861VD_AUTO)
9861 spec->init_hook = alc861vd_auto_init;
9862
9863 return 0;
9864}
9865
9866/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009867 * ALC662 support
9868 *
9869 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
9870 * configuration. Each pin widget can choose any input DACs and a mixer.
9871 * Each ADC is connected from a mixer of all inputs. This makes possible
9872 * 6-channel independent captures.
9873 *
9874 * In addition, an independent DAC for the multi-playback (not used in this
9875 * driver yet).
9876 */
9877#define ALC662_DIGOUT_NID 0x06
9878#define ALC662_DIGIN_NID 0x0a
9879
9880static hda_nid_t alc662_dac_nids[4] = {
9881 /* front, rear, clfe, rear_surr */
9882 0x02, 0x03, 0x04
9883};
9884
9885static hda_nid_t alc662_adc_nids[1] = {
9886 /* ADC1-2 */
9887 0x09,
9888};
9889/* input MUX */
9890/* FIXME: should be a matrix-type input source selection */
9891
9892static struct hda_input_mux alc662_capture_source = {
9893 .num_items = 4,
9894 .items = {
9895 { "Mic", 0x0 },
9896 { "Front Mic", 0x1 },
9897 { "Line", 0x2 },
9898 { "CD", 0x4 },
9899 },
9900};
9901
9902static struct hda_input_mux alc662_lenovo_101e_capture_source = {
9903 .num_items = 2,
9904 .items = {
9905 { "Mic", 0x1 },
9906 { "Line", 0x2 },
9907 },
9908};
9909#define alc662_mux_enum_info alc_mux_enum_info
9910#define alc662_mux_enum_get alc_mux_enum_get
9911
9912static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
9913 struct snd_ctl_elem_value *ucontrol)
9914{
9915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9916 struct alc_spec *spec = codec->spec;
9917 const struct hda_input_mux *imux = spec->input_mux;
9918 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9919 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
9920 hda_nid_t nid = capture_mixers[adc_idx];
9921 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9922 unsigned int i, idx;
9923
9924 idx = ucontrol->value.enumerated.item[0];
9925 if (idx >= imux->num_items)
9926 idx = imux->num_items - 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009927 if (*cur_val == idx && !codec->in_resume)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009928 return 0;
9929 for (i = 0; i < imux->num_items; i++) {
9930 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9931 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9932 v | (imux->items[i].index << 8));
9933 }
9934 *cur_val = idx;
9935 return 1;
9936}
9937/*
9938 * 2ch mode
9939 */
9940static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
9941 { 2, NULL }
9942};
9943
9944/*
9945 * 2ch mode
9946 */
9947static struct hda_verb alc662_3ST_ch2_init[] = {
9948 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9949 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9950 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9951 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9952 { } /* end */
9953};
9954
9955/*
9956 * 6ch mode
9957 */
9958static struct hda_verb alc662_3ST_ch6_init[] = {
9959 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9960 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9961 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
9962 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9963 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9964 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
9965 { } /* end */
9966};
9967
9968static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
9969 { 2, alc662_3ST_ch2_init },
9970 { 6, alc662_3ST_ch6_init },
9971};
9972
9973/*
9974 * 2ch mode
9975 */
9976static struct hda_verb alc662_sixstack_ch6_init[] = {
9977 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9978 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9979 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9980 { } /* end */
9981};
9982
9983/*
9984 * 6ch mode
9985 */
9986static struct hda_verb alc662_sixstack_ch8_init[] = {
9987 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9988 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9989 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9990 { } /* end */
9991};
9992
9993static struct hda_channel_mode alc662_5stack_modes[2] = {
9994 { 2, alc662_sixstack_ch6_init },
9995 { 6, alc662_sixstack_ch8_init },
9996};
9997
9998/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9999 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10000 */
10001
10002static struct snd_kcontrol_new alc662_base_mixer[] = {
10003 /* output mixer control */
10004 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
10006 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10007 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10008 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10009 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10010 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10011 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10013
10014 /*Input mixer control */
10015 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
10016 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
10017 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
10018 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
10019 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
10020 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
10021 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
10022 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
10023
10024 /* Capture mixer control */
10025 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10026 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10027 {
10028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10029 .name = "Capture Source",
10030 .count = 1,
10031 .info = alc_mux_enum_info,
10032 .get = alc_mux_enum_get,
10033 .put = alc_mux_enum_put,
10034 },
10035 { } /* end */
10036};
10037
10038static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
10039 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10040 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10050 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10051 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10053 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10054 {
10055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10056 /* .name = "Capture Source", */
10057 .name = "Input Source",
10058 .count = 1,
10059 .info = alc662_mux_enum_info,
10060 .get = alc662_mux_enum_get,
10061 .put = alc662_mux_enum_put,
10062 },
10063 { } /* end */
10064};
10065
10066static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
10067 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10068 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10069 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10070 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
10071 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
10072 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
10073 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
10074 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
10075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10076 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10077 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10078 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10079 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10081 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10082 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10083 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10084 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10085 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10086 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10087 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10088 {
10089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10090 /* .name = "Capture Source", */
10091 .name = "Input Source",
10092 .count = 1,
10093 .info = alc662_mux_enum_info,
10094 .get = alc662_mux_enum_get,
10095 .put = alc662_mux_enum_put,
10096 },
10097 { } /* end */
10098};
10099
10100static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
10101 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10102 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
10103 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10104 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
10105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10110 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10111 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10112 {
10113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10114 /* .name = "Capture Source", */
10115 .name = "Input Source",
10116 .count = 1,
10117 .info = alc662_mux_enum_info,
10118 .get = alc662_mux_enum_get,
10119 .put = alc662_mux_enum_put,
10120 },
10121 { } /* end */
10122};
10123
10124static struct snd_kcontrol_new alc662_chmode_mixer[] = {
10125 {
10126 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10127 .name = "Channel Mode",
10128 .info = alc_ch_mode_info,
10129 .get = alc_ch_mode_get,
10130 .put = alc_ch_mode_put,
10131 },
10132 { } /* end */
10133};
10134
10135static struct hda_verb alc662_init_verbs[] = {
10136 /* ADC: mute amp left and right */
10137 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10138 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10139 /* Front mixer: unmute input/output amp left and right (volume = 0) */
10140
10141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10146
10147 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10148 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10149 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10150 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10151 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10152 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10153
10154 /* Front Pin: output 0 (0x0c) */
10155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10157
10158 /* Rear Pin: output 1 (0x0d) */
10159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10161
10162 /* CLFE Pin: output 2 (0x0e) */
10163 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10165
10166 /* Mic (rear) pin: input vref at 80% */
10167 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10168 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10169 /* Front Mic pin: input vref at 80% */
10170 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10171 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10172 /* Line In pin: input */
10173 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10174 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10175 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10176 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10177 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10178 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10179 /* CD pin widget for input */
10180 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10181
10182 /* FIXME: use matrix-type input source selection */
10183 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10184 /* Input mixer */
10185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10189 { }
10190};
10191
10192static struct hda_verb alc662_sue_init_verbs[] = {
10193 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
10194 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
10195 {}
10196};
10197
10198/*
10199 * generic initialization of ADC, input mixers and output mixers
10200 */
10201static struct hda_verb alc662_auto_init_verbs[] = {
10202 /*
10203 * Unmute ADC and set the default input to mic-in
10204 */
10205 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10206 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10207
10208 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10209 * mixer widget
10210 * Note: PASD motherboards uses the Line In 2 as the input for front
10211 * panel mic (mic 2)
10212 */
10213 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10215 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10219
10220 /*
10221 * Set up output mixers (0x0c - 0x0f)
10222 */
10223 /* set vol=0 to output mixers */
10224 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10225 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10227
10228 /* set up input amps for analog loopback */
10229 /* Amp Indices: DAC = 0, mixer = 1 */
10230 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10231 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10232 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10233 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10235 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10236
10237
10238 /* FIXME: use matrix-type input source selection */
10239 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10240 /* Input mixer */
10241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10244 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
10245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10246
10247 { }
10248};
10249
10250/* capture mixer elements */
10251static struct snd_kcontrol_new alc662_capture_mixer[] = {
10252 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10253 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10254 {
10255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10256 /* The multiple "Capture Source" controls confuse alsamixer
10257 * So call somewhat different..
10258 * FIXME: the controls appear in the "playback" view!
10259 */
10260 /* .name = "Capture Source", */
10261 .name = "Input Source",
10262 .count = 1,
10263 .info = alc882_mux_enum_info,
10264 .get = alc882_mux_enum_get,
10265 .put = alc882_mux_enum_put,
10266 },
10267 { } /* end */
10268};
10269
10270static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
10271{
10272 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010273 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010274
10275 present = snd_hda_codec_read(codec, 0x14, 0,
10276 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010277 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010278 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010279 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010280 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010281 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010282}
10283
10284static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
10285{
10286 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010287 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010288
10289 present = snd_hda_codec_read(codec, 0x1b, 0,
10290 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010291 bits = present ? 0x80 : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010292 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010293 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010294 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010295 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010296 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010297 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010298 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010299 0x80, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010300}
10301
10302static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
10303 unsigned int res)
10304{
10305 if ((res >> 26) == ALC880_HP_EVENT)
10306 alc662_lenovo_101e_all_automute(codec);
10307 if ((res >> 26) == ALC880_FRONT_EVENT)
10308 alc662_lenovo_101e_ispeaker_automute(codec);
10309}
10310
10311
10312/* pcm configuration: identiacal with ALC880 */
10313#define alc662_pcm_analog_playback alc880_pcm_analog_playback
10314#define alc662_pcm_analog_capture alc880_pcm_analog_capture
10315#define alc662_pcm_digital_playback alc880_pcm_digital_playback
10316#define alc662_pcm_digital_capture alc880_pcm_digital_capture
10317
10318/*
10319 * configuration and preset
10320 */
10321static const char *alc662_models[ALC662_MODEL_LAST] = {
10322 [ALC662_3ST_2ch_DIG] = "3stack-dig",
10323 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
10324 [ALC662_3ST_6ch] = "3stack-6ch",
10325 [ALC662_5ST_DIG] = "6stack-dig",
10326 [ALC662_LENOVO_101E] = "lenovo-101e",
10327 [ALC662_AUTO] = "auto",
10328};
10329
10330static struct snd_pci_quirk alc662_cfg_tbl[] = {
10331 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
10332 {}
10333};
10334
10335static struct alc_config_preset alc662_presets[] = {
10336 [ALC662_3ST_2ch_DIG] = {
10337 .mixers = { alc662_3ST_2ch_mixer },
10338 .init_verbs = { alc662_init_verbs },
10339 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10340 .dac_nids = alc662_dac_nids,
10341 .dig_out_nid = ALC662_DIGOUT_NID,
10342 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10343 .adc_nids = alc662_adc_nids,
10344 .dig_in_nid = ALC662_DIGIN_NID,
10345 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10346 .channel_mode = alc662_3ST_2ch_modes,
10347 .input_mux = &alc662_capture_source,
10348 },
10349 [ALC662_3ST_6ch_DIG] = {
10350 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10351 .init_verbs = { alc662_init_verbs },
10352 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10353 .dac_nids = alc662_dac_nids,
10354 .dig_out_nid = ALC662_DIGOUT_NID,
10355 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10356 .adc_nids = alc662_adc_nids,
10357 .dig_in_nid = ALC662_DIGIN_NID,
10358 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10359 .channel_mode = alc662_3ST_6ch_modes,
10360 .need_dac_fix = 1,
10361 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010362 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010363 [ALC662_3ST_6ch] = {
10364 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
10365 .init_verbs = { alc662_init_verbs },
10366 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10367 .dac_nids = alc662_dac_nids,
10368 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10369 .adc_nids = alc662_adc_nids,
10370 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
10371 .channel_mode = alc662_3ST_6ch_modes,
10372 .need_dac_fix = 1,
10373 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010374 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010375 [ALC662_5ST_DIG] = {
10376 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
10377 .init_verbs = { alc662_init_verbs },
10378 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10379 .dac_nids = alc662_dac_nids,
10380 .dig_out_nid = ALC662_DIGOUT_NID,
10381 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10382 .adc_nids = alc662_adc_nids,
10383 .dig_in_nid = ALC662_DIGIN_NID,
10384 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
10385 .channel_mode = alc662_5stack_modes,
10386 .input_mux = &alc662_capture_source,
10387 },
10388 [ALC662_LENOVO_101E] = {
10389 .mixers = { alc662_lenovo_101e_mixer },
10390 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
10391 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
10392 .dac_nids = alc662_dac_nids,
10393 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
10394 .adc_nids = alc662_adc_nids,
10395 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
10396 .channel_mode = alc662_3ST_2ch_modes,
10397 .input_mux = &alc662_lenovo_101e_capture_source,
10398 .unsol_event = alc662_lenovo_101e_unsol_event,
10399 .init_hook = alc662_lenovo_101e_all_automute,
10400 },
10401
10402};
10403
10404
10405/*
10406 * BIOS auto configuration
10407 */
10408
10409/* add playback controls from the parsed DAC table */
10410static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
10411 const struct auto_pin_cfg *cfg)
10412{
10413 char name[32];
10414 static const char *chname[4] = {
10415 "Front", "Surround", NULL /*CLFE*/, "Side"
10416 };
10417 hda_nid_t nid;
10418 int i, err;
10419
10420 for (i = 0; i < cfg->line_outs; i++) {
10421 if (!spec->multiout.dac_nids[i])
10422 continue;
10423 nid = alc880_idx_to_dac(i);
10424 if (i == 2) {
10425 /* Center/LFE */
10426 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10427 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010428 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
10429 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010430 if (err < 0)
10431 return err;
10432 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10433 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010434 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10435 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010436 if (err < 0)
10437 return err;
10438 err = add_control(spec, ALC_CTL_BIND_MUTE,
10439 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010440 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
10441 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010442 if (err < 0)
10443 return err;
10444 err = add_control(spec, ALC_CTL_BIND_MUTE,
10445 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010446 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
10447 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010448 if (err < 0)
10449 return err;
10450 } else {
10451 sprintf(name, "%s Playback Volume", chname[i]);
10452 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010453 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10454 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010455 if (err < 0)
10456 return err;
10457 sprintf(name, "%s Playback Switch", chname[i]);
10458 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010459 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
10460 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010461 if (err < 0)
10462 return err;
10463 }
10464 }
10465 return 0;
10466}
10467
10468/* add playback controls for speaker and HP outputs */
10469static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
10470 const char *pfx)
10471{
10472 hda_nid_t nid;
10473 int err;
10474 char name[32];
10475
10476 if (!pin)
10477 return 0;
10478
10479 if (alc880_is_fixed_pin(pin)) {
10480 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10481 /* printk("DAC nid=%x\n",nid); */
10482 /* specify the DAC as the extra output */
10483 if (!spec->multiout.hp_nid)
10484 spec->multiout.hp_nid = nid;
10485 else
10486 spec->multiout.extra_out_nid[0] = nid;
10487 /* control HP volume/switch on the output mixer amp */
10488 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10489 sprintf(name, "%s Playback Volume", pfx);
10490 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10491 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10492 if (err < 0)
10493 return err;
10494 sprintf(name, "%s Playback Switch", pfx);
10495 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10496 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
10497 if (err < 0)
10498 return err;
10499 } else if (alc880_is_multi_pin(pin)) {
10500 /* set manual connection */
10501 /* we have only a switch on HP-out PIN */
10502 sprintf(name, "%s Playback Switch", pfx);
10503 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10504 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10505 if (err < 0)
10506 return err;
10507 }
10508 return 0;
10509}
10510
10511/* create playback/capture controls for input pins */
10512static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
10513 const struct auto_pin_cfg *cfg)
10514{
10515 struct hda_input_mux *imux = &spec->private_imux;
10516 int i, err, idx;
10517
10518 for (i = 0; i < AUTO_PIN_LAST; i++) {
10519 if (alc880_is_input_pin(cfg->input_pins[i])) {
10520 idx = alc880_input_pin_idx(cfg->input_pins[i]);
10521 err = new_analog_input(spec, cfg->input_pins[i],
10522 auto_pin_cfg_labels[i],
10523 idx, 0x0b);
10524 if (err < 0)
10525 return err;
10526 imux->items[imux->num_items].label =
10527 auto_pin_cfg_labels[i];
10528 imux->items[imux->num_items].index =
10529 alc880_input_pin_idx(cfg->input_pins[i]);
10530 imux->num_items++;
10531 }
10532 }
10533 return 0;
10534}
10535
10536static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
10537 hda_nid_t nid, int pin_type,
10538 int dac_idx)
10539{
10540 /* set as output */
10541 snd_hda_codec_write(codec, nid, 0,
10542 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10543 snd_hda_codec_write(codec, nid, 0,
10544 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10545 /* need the manual connection? */
10546 if (alc880_is_multi_pin(nid)) {
10547 struct alc_spec *spec = codec->spec;
10548 int idx = alc880_multi_pin_idx(nid);
10549 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
10550 AC_VERB_SET_CONNECT_SEL,
10551 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
10552 }
10553}
10554
10555static void alc662_auto_init_multi_out(struct hda_codec *codec)
10556{
10557 struct alc_spec *spec = codec->spec;
10558 int i;
10559
10560 for (i = 0; i <= HDA_SIDE; i++) {
10561 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010562 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010563 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010564 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010565 i);
10566 }
10567}
10568
10569static void alc662_auto_init_hp_out(struct hda_codec *codec)
10570{
10571 struct alc_spec *spec = codec->spec;
10572 hda_nid_t pin;
10573
10574 pin = spec->autocfg.hp_pins[0];
10575 if (pin) /* connect to front */
10576 /* use dac 0 */
10577 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10578}
10579
10580#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
10581#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
10582
10583static void alc662_auto_init_analog_input(struct hda_codec *codec)
10584{
10585 struct alc_spec *spec = codec->spec;
10586 int i;
10587
10588 for (i = 0; i < AUTO_PIN_LAST; i++) {
10589 hda_nid_t nid = spec->autocfg.input_pins[i];
10590 if (alc662_is_input_pin(nid)) {
10591 snd_hda_codec_write(codec, nid, 0,
10592 AC_VERB_SET_PIN_WIDGET_CONTROL,
10593 (i <= AUTO_PIN_FRONT_MIC ?
10594 PIN_VREF80 : PIN_IN));
10595 if (nid != ALC662_PIN_CD_NID)
10596 snd_hda_codec_write(codec, nid, 0,
10597 AC_VERB_SET_AMP_GAIN_MUTE,
10598 AMP_OUT_MUTE);
10599 }
10600 }
10601}
10602
10603static int alc662_parse_auto_config(struct hda_codec *codec)
10604{
10605 struct alc_spec *spec = codec->spec;
10606 int err;
10607 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
10608
10609 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10610 alc662_ignore);
10611 if (err < 0)
10612 return err;
10613 if (!spec->autocfg.line_outs)
10614 return 0; /* can't find valid BIOS pin config */
10615
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010616 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10617 if (err < 0)
10618 return err;
10619 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
10620 if (err < 0)
10621 return err;
10622 err = alc662_auto_create_extra_out(spec,
10623 spec->autocfg.speaker_pins[0],
10624 "Speaker");
10625 if (err < 0)
10626 return err;
10627 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10628 "Headphone");
10629 if (err < 0)
10630 return err;
10631 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
10632 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010633 return err;
10634
10635 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10636
10637 if (spec->autocfg.dig_out_pin)
10638 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
10639
10640 if (spec->kctl_alloc)
10641 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10642
10643 spec->num_mux_defs = 1;
10644 spec->input_mux = &spec->private_imux;
10645
10646 if (err < 0)
10647 return err;
10648 else if (err > 0)
10649 /* hack - override the init verbs */
10650 spec->init_verbs[0] = alc662_auto_init_verbs;
10651 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
10652 spec->num_mixers++;
10653 return err;
10654}
10655
10656/* additional initialization for auto-configuration model */
10657static void alc662_auto_init(struct hda_codec *codec)
10658{
10659 alc662_auto_init_multi_out(codec);
10660 alc662_auto_init_hp_out(codec);
10661 alc662_auto_init_analog_input(codec);
10662}
10663
10664static int patch_alc662(struct hda_codec *codec)
10665{
10666 struct alc_spec *spec;
10667 int err, board_config;
10668
10669 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10670 if (!spec)
10671 return -ENOMEM;
10672
10673 codec->spec = spec;
10674
10675 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
10676 alc662_models,
10677 alc662_cfg_tbl);
10678 if (board_config < 0) {
10679 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
10680 "trying auto-probe from BIOS...\n");
10681 board_config = ALC662_AUTO;
10682 }
10683
10684 if (board_config == ALC662_AUTO) {
10685 /* automatic parse from the BIOS config */
10686 err = alc662_parse_auto_config(codec);
10687 if (err < 0) {
10688 alc_free(codec);
10689 return err;
10690 } else if (err) {
10691 printk(KERN_INFO
10692 "hda_codec: Cannot set up configuration "
10693 "from BIOS. Using base mode...\n");
10694 board_config = ALC662_3ST_2ch_DIG;
10695 }
10696 }
10697
10698 if (board_config != ALC662_AUTO)
10699 setup_preset(spec, &alc662_presets[board_config]);
10700
10701 spec->stream_name_analog = "ALC662 Analog";
10702 spec->stream_analog_playback = &alc662_pcm_analog_playback;
10703 spec->stream_analog_capture = &alc662_pcm_analog_capture;
10704
10705 spec->stream_name_digital = "ALC662 Digital";
10706 spec->stream_digital_playback = &alc662_pcm_digital_playback;
10707 spec->stream_digital_capture = &alc662_pcm_digital_capture;
10708
10709 if (!spec->adc_nids && spec->input_mux) {
10710 spec->adc_nids = alc662_adc_nids;
10711 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
10712 }
10713
10714 codec->patch_ops = alc_patch_ops;
10715 if (board_config == ALC662_AUTO)
10716 spec->init_hook = alc662_auto_init;
10717
10718 return 0;
10719}
10720
10721/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070010722 * patch entries
10723 */
10724struct hda_codec_preset snd_hda_preset_realtek[] = {
10725 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010726 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010727 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010728 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010729 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
10730 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
10731 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010732 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
10733 .patch = patch_alc883 },
10734 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
10735 .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010010736 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070010737 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010738 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010739 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010740 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070010741 {} /* terminator */
10742};