blob: cf6c100940dcebc2c5b8db6df1b898769ff238ef [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
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
35
36/* ALC880 board config type */
37enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ALC880_3ST,
39 ALC880_3ST_DIG,
40 ALC880_5ST,
41 ALC880_5ST_DIG,
42 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020043 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020044 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020045 ALC880_6ST_DIG,
46 ALC880_F1734,
47 ALC880_ASUS,
48 ALC880_ASUS_DIG,
49 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010050 ALC880_ASUS_DIG2,
Takashi Iwai16ded522005-06-10 19:58:24 +020051 ALC880_UNIWILL_DIG,
Kailang Yangdf694da2005-12-05 19:42:22 +010052 ALC880_CLEVO,
53 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010054 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010055 ALC880_LG_LW,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020056#ifdef CONFIG_SND_DEBUG
57 ALC880_TEST,
58#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020060 ALC880_MODEL_LAST /* last tag */
61};
62
63/* ALC260 models */
64enum {
65 ALC260_BASIC,
66 ALC260_HP,
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC260_HP_3013,
68 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010069 ALC260_ACER,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010070#ifdef CONFIG_SND_DEBUG
71 ALC260_TEST,
72#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010073 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020074 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Kailang Yangdf694da2005-12-05 19:42:22 +010077/* ALC262 models */
78enum {
79 ALC262_BASIC,
Takashi Iwai834be882006-03-01 14:16:17 +010080 ALC262_FUJITSU,
Kailang Yangdf694da2005-12-05 19:42:22 +010081 ALC262_AUTO,
82 ALC262_MODEL_LAST /* last tag */
83};
84
85/* ALC861 models */
86enum {
87 ALC861_3ST,
88 ALC861_3ST_DIG,
89 ALC861_6ST_DIG,
90 ALC861_AUTO,
91 ALC861_MODEL_LAST,
92};
93
94/* ALC882 models */
95enum {
96 ALC882_3ST_DIG,
97 ALC882_6ST_DIG,
98 ALC882_AUTO,
99 ALC882_MODEL_LAST,
100};
101
102/* for GPIO Poll */
103#define GPIO_MASK 0x03
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105struct alc_spec {
106 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100107 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 unsigned int num_mixers;
109
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200111 * don't forget NULL termination!
112 */
113 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Takashi Iwai16ded522005-06-10 19:58:24 +0200115 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 struct hda_pcm_stream *stream_analog_playback;
117 struct hda_pcm_stream *stream_analog_capture;
118
Takashi Iwai16ded522005-06-10 19:58:24 +0200119 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 struct hda_pcm_stream *stream_digital_playback;
121 struct hda_pcm_stream *stream_digital_capture;
122
123 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200124 struct hda_multi_out multiout; /* playback set-up
125 * max_channels, dacs must be set
126 * dig_out_nid and hp_nid are optional
127 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129 /* capture */
130 unsigned int num_adc_nids;
131 hda_nid_t *adc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200132 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
134 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200135 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 const struct hda_input_mux *input_mux;
137 unsigned int cur_mux[3];
138
139 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100140 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 int num_channel_mode;
142
143 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100144 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200145
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200146 /* dynamic controls, init_verbs and input_mux */
147 struct auto_pin_cfg autocfg;
148 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100149 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200150 struct hda_input_mux private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +0100151 hda_nid_t private_dac_nids[5];
Takashi Iwai834be882006-03-01 14:16:17 +0100152
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100153 /* hooks */
154 void (*init_hook)(struct hda_codec *codec);
155 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
156
Takashi Iwai834be882006-03-01 14:16:17 +0100157 /* for pin sensing */
158 unsigned int sense_updated: 1;
159 unsigned int jack_present: 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100160};
161
162/*
163 * configuration template - to be copied to the spec instance
164 */
165struct alc_config_preset {
166 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
167 const struct hda_verb *init_verbs[5];
168 unsigned int num_dacs;
169 hda_nid_t *dac_nids;
170 hda_nid_t dig_out_nid; /* optional */
171 hda_nid_t hp_nid; /* optional */
172 unsigned int num_adc_nids;
173 hda_nid_t *adc_nids;
174 hda_nid_t dig_in_nid;
175 unsigned int num_channel_mode;
176 const struct hda_channel_mode *channel_mode;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200177 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100178 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100179 void (*unsol_event)(struct hda_codec *, unsigned int);
180 void (*init_hook)(struct hda_codec *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181};
182
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184/*
185 * input MUX handling
186 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100187static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188{
189 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
190 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200191 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
192 if (mux_idx >= spec->num_mux_defs)
193 mux_idx = 0;
194 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195}
196
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100197static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198{
199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
200 struct alc_spec *spec = codec->spec;
201 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
202
203 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
204 return 0;
205}
206
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100207static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208{
209 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
210 struct alc_spec *spec = codec->spec;
211 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200212 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
213 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
215}
216
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200217
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218/*
219 * channel mode setting
220 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100221static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222{
223 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
224 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100225 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
226 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227}
228
Kailang Yangdf694da2005-12-05 19:42:22 +0100229static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230{
231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
232 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100233 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
234 spec->num_channel_mode, spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235}
236
Kailang Yangdf694da2005-12-05 19:42:22 +0100237static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
239 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
240 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100241 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
242 spec->num_channel_mode, &spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}
244
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100246 * Control the mode of pin widget settings via the mixer. "pc" is used
247 * instead of "%" to avoid consequences of accidently treating the % as
248 * being part of a format specifier. Maximum allowed length of a value is
249 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100250 *
251 * Note: some retasking pin complexes seem to ignore requests for input
252 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
253 * are requested. Therefore order this list so that this behaviour will not
254 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200255 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
256 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200257 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100258static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100259 "Mic 50pc bias", "Mic 80pc bias",
260 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100261};
262static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100263 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100264};
265/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200266 * in the pin being assumed to be exclusively an input or an output pin. In
267 * addition, "input" pins may or may not process the mic bias option
268 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
269 * accept requests for bias as of chip versions up to March 2006) and/or
270 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100271 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200272#define ALC_PIN_DIR_IN 0x00
273#define ALC_PIN_DIR_OUT 0x01
274#define ALC_PIN_DIR_INOUT 0x02
275#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
276#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100277
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200278/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100279 * For each direction the minimum and maximum values are given.
280 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200281static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100282 { 0, 2 }, /* ALC_PIN_DIR_IN */
283 { 3, 4 }, /* ALC_PIN_DIR_OUT */
284 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200285 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
286 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100287};
288#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
289#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
290#define alc_pin_mode_n_items(_dir) \
291 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
292
293static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200294{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100295 unsigned int item_num = uinfo->value.enumerated.item;
296 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
297
298 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200299 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100300 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
301
302 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
303 item_num = alc_pin_mode_min(dir);
304 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200305 return 0;
306}
307
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100308static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200309{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100310 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
312 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100313 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200314 long *valp = ucontrol->value.integer.value;
315 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200316
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100317 /* Find enumerated value for current pinctl setting */
318 i = alc_pin_mode_min(dir);
319 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
320 i++;
321 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
322 return 0;
323}
324
325static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
326{
327 signed int change;
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
329 hda_nid_t nid = kcontrol->private_value & 0xffff;
330 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
331 long val = *ucontrol->value.integer.value;
332 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
333
334 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
335 val = alc_pin_mode_min(dir);
336
337 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100338 if (change) {
339 /* Set pin mode to that requested */
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200340 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100341 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100342
343 /* Also enable the retasking pin's input/output as required
344 * for the requested pin mode. Enum values of 2 or less are
345 * input modes.
346 *
347 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200348 * reduces noise slightly (particularly on input) so we'll
349 * do it. However, having both input and output buffers
350 * enabled simultaneously doesn't seem to be problematic if
351 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100352 */
353 if (val <= 2) {
354 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
355 AMP_OUT_MUTE);
356 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
357 AMP_IN_UNMUTE(0));
358 } else {
359 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
360 AMP_IN_MUTE(0));
361 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
362 AMP_OUT_UNMUTE);
363 }
364 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200365 return change;
366}
367
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100368#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200369 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100370 .info = alc_pin_mode_info, \
371 .get = alc_pin_mode_get, \
372 .put = alc_pin_mode_put, \
373 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100374
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100375/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
376 * together using a mask with more than one bit set. This control is
377 * currently used only by the ALC260 test model. At this stage they are not
378 * needed for any "production" models.
379 */
380#ifdef CONFIG_SND_DEBUG
381static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
382{
383 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
384 uinfo->count = 1;
385 uinfo->value.integer.min = 0;
386 uinfo->value.integer.max = 1;
387 return 0;
388}
389static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
390{
391 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
392 hda_nid_t nid = kcontrol->private_value & 0xffff;
393 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
394 long *valp = ucontrol->value.integer.value;
395 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
396
397 *valp = (val & mask) != 0;
398 return 0;
399}
400static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
401{
402 signed int change;
403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
404 hda_nid_t nid = kcontrol->private_value & 0xffff;
405 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
406 long val = *ucontrol->value.integer.value;
407 unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
408
409 /* Set/unset the masked GPIO bit(s) as needed */
410 change = (val==0?0:mask) != (gpio_data & mask);
411 if (val==0)
412 gpio_data &= ~mask;
413 else
414 gpio_data |= mask;
415 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data);
416
417 return change;
418}
419#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
420 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
421 .info = alc_gpio_data_info, \
422 .get = alc_gpio_data_get, \
423 .put = alc_gpio_data_put, \
424 .private_value = nid | (mask<<16) }
425#endif /* CONFIG_SND_DEBUG */
426
Jonathan Woithe92621f12006-02-28 11:47:47 +0100427/* A switch control to allow the enabling of the digital IO pins on the
428 * ALC260. This is incredibly simplistic; the intention of this control is
429 * to provide something in the test model allowing digital outputs to be
430 * identified if present. If models are found which can utilise these
431 * outputs a more complete mixer control can be devised for those models if
432 * necessary.
433 */
434#ifdef CONFIG_SND_DEBUG
435static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
436{
437 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
438 uinfo->count = 1;
439 uinfo->value.integer.min = 0;
440 uinfo->value.integer.max = 1;
441 return 0;
442}
443static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
444{
445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
446 hda_nid_t nid = kcontrol->private_value & 0xffff;
447 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
448 long *valp = ucontrol->value.integer.value;
449 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
450
451 *valp = (val & mask) != 0;
452 return 0;
453}
454static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
455{
456 signed int change;
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
458 hda_nid_t nid = kcontrol->private_value & 0xffff;
459 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
460 long val = *ucontrol->value.integer.value;
461 unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
462
463 /* Set/unset the masked control bit(s) as needed */
464 change = (val==0?0:mask) != (ctrl_data & mask);
465 if (val==0)
466 ctrl_data &= ~mask;
467 else
468 ctrl_data |= mask;
469 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
470
471 return change;
472}
473#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
474 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
475 .info = alc_spdif_ctrl_info, \
476 .get = alc_spdif_ctrl_get, \
477 .put = alc_spdif_ctrl_put, \
478 .private_value = nid | (mask<<16) }
479#endif /* CONFIG_SND_DEBUG */
480
Kailang Yangdf694da2005-12-05 19:42:22 +0100481/*
482 * set up from the preset table
483 */
484static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
485{
486 int i;
487
488 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
489 spec->mixers[spec->num_mixers++] = preset->mixers[i];
490 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
491 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
492
493 spec->channel_mode = preset->channel_mode;
494 spec->num_channel_mode = preset->num_channel_mode;
495
496 spec->multiout.max_channels = spec->channel_mode[0].channels;
497
498 spec->multiout.num_dacs = preset->num_dacs;
499 spec->multiout.dac_nids = preset->dac_nids;
500 spec->multiout.dig_out_nid = preset->dig_out_nid;
501 spec->multiout.hp_nid = preset->hp_nid;
502
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200503 spec->num_mux_defs = preset->num_mux_defs;
504 if (! spec->num_mux_defs)
505 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100506 spec->input_mux = preset->input_mux;
507
508 spec->num_adc_nids = preset->num_adc_nids;
509 spec->adc_nids = preset->adc_nids;
510 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100511
512 spec->unsol_event = preset->unsol_event;
513 spec->init_hook = preset->init_hook;
Kailang Yangdf694da2005-12-05 19:42:22 +0100514}
515
Takashi Iwai41e41f12005-06-08 14:48:49 +0200516/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200517 * ALC880 3-stack model
518 *
519 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
520 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
521 * HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 */
523
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200524static hda_nid_t alc880_dac_nids[4] = {
525 /* front, rear, clfe, rear_surr */
526 0x02, 0x05, 0x04, 0x03
527};
528
529static hda_nid_t alc880_adc_nids[3] = {
530 /* ADC0-2 */
531 0x07, 0x08, 0x09,
532};
533
534/* The datasheet says the node 0x07 is connected from inputs,
535 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +0100536 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200538static hda_nid_t alc880_adc_nids_alt[2] = {
539 /* ADC1-2 */
540 0x08, 0x09,
541};
542
543#define ALC880_DIGOUT_NID 0x06
544#define ALC880_DIGIN_NID 0x0a
545
546static struct hda_input_mux alc880_capture_source = {
547 .num_items = 4,
548 .items = {
549 { "Mic", 0x0 },
550 { "Front Mic", 0x3 },
551 { "Line", 0x2 },
552 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200554};
555
556/* channel source setting (2/6 channel selection for 3-stack) */
557/* 2ch mode */
558static struct hda_verb alc880_threestack_ch2_init[] = {
559 /* set line-in to input, mute it */
560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
562 /* set mic-in to input vref 80%, mute it */
563 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
564 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 { } /* end */
566};
567
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200568/* 6ch mode */
569static struct hda_verb alc880_threestack_ch6_init[] = {
570 /* set line-in to output, unmute it */
571 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
572 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
573 /* set mic-in to output, unmute it */
574 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
575 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
576 { } /* end */
577};
578
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100579static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200580 { 2, alc880_threestack_ch2_init },
581 { 6, alc880_threestack_ch6_init },
582};
583
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100584static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +0200585 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100586 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200587 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100588 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +0200589 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
590 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100591 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
592 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
594 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
595 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
596 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
598 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
599 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
601 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
602 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200604 {
605 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
606 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100607 .info = alc_ch_mode_info,
608 .get = alc_ch_mode_get,
609 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200610 },
611 { } /* end */
612};
613
614/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100615static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200616 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
617 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
618 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
619 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
620 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
621 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
622 {
623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
624 /* The multiple "Capture Source" controls confuse alsamixer
625 * So call somewhat different..
626 * FIXME: the controls appear in the "playback" view!
627 */
628 /* .name = "Capture Source", */
629 .name = "Input Source",
630 .count = 3,
631 .info = alc_mux_enum_info,
632 .get = alc_mux_enum_get,
633 .put = alc_mux_enum_put,
634 },
635 { } /* end */
636};
637
638/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100639static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200640 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
641 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
642 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
643 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 {
645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
646 /* The multiple "Capture Source" controls confuse alsamixer
647 * So call somewhat different..
648 * FIXME: the controls appear in the "playback" view!
649 */
650 /* .name = "Capture Source", */
651 .name = "Input Source",
652 .count = 2,
653 .info = alc_mux_enum_info,
654 .get = alc_mux_enum_get,
655 .put = alc_mux_enum_put,
656 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 { } /* end */
658};
659
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200660
661
662/*
663 * ALC880 5-stack model
664 *
665 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
666 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
667 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
668 */
669
670/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100671static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200672 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100673 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 { } /* end */
675};
676
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200677/* channel source setting (6/8 channel selection for 5-stack) */
678/* 6ch mode */
679static struct hda_verb alc880_fivestack_ch6_init[] = {
680 /* set line-in to input, mute it */
681 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
682 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +0200683 { } /* end */
684};
685
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200686/* 8ch mode */
687static struct hda_verb alc880_fivestack_ch8_init[] = {
688 /* set line-in to output, unmute it */
689 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
690 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
691 { } /* end */
692};
693
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100694static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200695 { 6, alc880_fivestack_ch6_init },
696 { 8, alc880_fivestack_ch8_init },
697};
698
699
700/*
701 * ALC880 6-stack model
702 *
703 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
704 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
705 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
706 */
707
708static hda_nid_t alc880_6st_dac_nids[4] = {
709 /* front, rear, clfe, rear_surr */
710 0x02, 0x03, 0x04, 0x05
711};
712
713static struct hda_input_mux alc880_6stack_capture_source = {
714 .num_items = 4,
715 .items = {
716 { "Mic", 0x0 },
717 { "Front Mic", 0x1 },
718 { "Line", 0x2 },
719 { "CD", 0x4 },
720 },
721};
722
723/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100724static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200725 { 8, NULL },
726};
727
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100728static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100730 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200731 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100732 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200733 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
734 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100735 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
736 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200737 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100738 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200739 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
740 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
741 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
742 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
747 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
748 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200749 {
750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
751 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100752 .info = alc_ch_mode_info,
753 .get = alc_ch_mode_get,
754 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200755 },
756 { } /* end */
757};
758
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200759
760/*
761 * ALC880 W810 model
762 *
763 * W810 has rear IO for:
764 * Front (DAC 02)
765 * Surround (DAC 03)
766 * Center/LFE (DAC 04)
767 * Digital out (06)
768 *
769 * The system also has a pair of internal speakers, and a headphone jack.
770 * These are both connected to Line2 on the codec, hence to DAC 02.
771 *
772 * There is a variable resistor to control the speaker or headphone
773 * volume. This is a hardware-only device without a software API.
774 *
775 * Plugging headphones in will disable the internal speakers. This is
776 * implemented in hardware, not via the driver using jack sense. In
777 * a similar fashion, plugging into the rear socket marked "front" will
778 * disable both the speakers and headphones.
779 *
780 * For input, there's a microphone jack, and an "audio in" jack.
781 * These may not do anything useful with this driver yet, because I
782 * haven't setup any initialization verbs for these yet...
783 */
784
785static hda_nid_t alc880_w810_dac_nids[3] = {
786 /* front, rear/surround, clfe */
787 0x02, 0x03, 0x04
788};
789
790/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100791static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200792 { 6, NULL }
793};
794
795/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100796static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100798 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200799 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100800 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200801 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
802 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100803 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
804 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
806 { } /* end */
807};
808
809
810/*
811 * Z710V model
812 *
813 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
814 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
815 */
816
817static hda_nid_t alc880_z71v_dac_nids[1] = {
818 0x02
819};
820#define ALC880_Z71V_HP_DAC 0x03
821
822/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100823static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200824 { 2, NULL }
825};
826
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100827static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200828 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100829 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200830 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100831 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
836 { } /* end */
837};
838
839
840/* FIXME! */
841/*
842 * ALC880 F1734 model
843 *
844 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
845 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
846 */
847
848static hda_nid_t alc880_f1734_dac_nids[1] = {
849 0x03
850};
851#define ALC880_F1734_HP_DAC 0x02
852
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100853static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200856 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100857 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200862 { } /* end */
863};
864
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200865
866/* FIXME! */
867/*
868 * ALC880 ASUS model
869 *
870 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
871 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
872 * Mic = 0x18, Line = 0x1a
873 */
874
875#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
876#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
877
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100878static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100882 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +0100885 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
886 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200893 {
894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
895 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +0100896 .info = alc_ch_mode_info,
897 .get = alc_ch_mode_get,
898 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +0200899 },
900 { } /* end */
901};
902
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200903/* FIXME! */
904/*
905 * ALC880 ASUS W1V model
906 *
907 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
908 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
909 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
910 */
911
912/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100913static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +0200914 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
915 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +0200916 { } /* end */
917};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200918
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200919/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100920static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +0200921 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
922 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
923 { } /* end */
924};
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200925
Kailang Yangdf694da2005-12-05 19:42:22 +0100926/* TCL S700 */
927static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
929 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
932 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
935 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
936 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
937 {
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
939 /* The multiple "Capture Source" controls confuse alsamixer
940 * So call somewhat different..
941 * FIXME: the controls appear in the "playback" view!
942 */
943 /* .name = "Capture Source", */
944 .name = "Input Source",
945 .count = 1,
946 .info = alc_mux_enum_info,
947 .get = alc_mux_enum_get,
948 .put = alc_mux_enum_put,
949 },
950 { } /* end */
951};
952
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200954 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 */
956static int alc_build_controls(struct hda_codec *codec)
957{
958 struct alc_spec *spec = codec->spec;
959 int err;
960 int i;
961
962 for (i = 0; i < spec->num_mixers; i++) {
963 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
964 if (err < 0)
965 return err;
966 }
967
968 if (spec->multiout.dig_out_nid) {
969 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
970 if (err < 0)
971 return err;
972 }
973 if (spec->dig_in_nid) {
974 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
975 if (err < 0)
976 return err;
977 }
978 return 0;
979}
980
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200981
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982/*
983 * initialize the codec volumes, etc
984 */
985
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200986/*
987 * generic initialization of ADC, input mixers and output mixers
988 */
989static struct hda_verb alc880_volume_init_verbs[] = {
990 /*
991 * Unmute ADC0-2 and set the default input to mic-in
992 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200993 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200995 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200996 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +0200997 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001000 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1001 * mixer widget
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 * Note: PASD motherboards uses the Line In 2 as the input for front panel
1003 * mic (mic 2)
1004 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001005 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001012 /*
1013 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001015 /* set vol=0 to output mixers */
1016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1020 /* set up input amps for analog loopback */
1021 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001024 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1025 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001026 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1027 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001028 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1029 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030
1031 { }
1032};
1033
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001034/*
1035 * 3-stack pin configuration:
1036 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1037 */
1038static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1039 /*
1040 * preset connection lists of input pins
1041 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1042 */
1043 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1044 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1045 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1046
1047 /*
1048 * Set pin mode and muting
1049 */
1050 /* set front pin widgets 0x14 for output */
1051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1053 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1054 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1055 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1056 /* Mic2 (as headphone out) for HP output */
1057 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1058 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1059 /* Line In pin widget for input */
1060 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1061 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1062 /* Line2 (as front mic) pin widget for input and vref at 80% */
1063 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1064 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1065 /* CD pin widget for input */
1066 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1067
1068 { }
1069};
1070
1071/*
1072 * 5-stack pin configuration:
1073 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1074 * line-in/side = 0x1a, f-mic = 0x1b
1075 */
1076static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1077 /*
1078 * preset connection lists of input pins
1079 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1080 */
1081 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1082 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1083
1084 /*
1085 * Set pin mode and muting
1086 */
1087 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1090 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1091 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001092 /* unmute pins for output (no gain on this amp) */
1093 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1095 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1096 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1097
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1101 /* Mic2 (as headphone out) for HP output */
1102 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001104 /* Line In pin widget for input */
1105 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1107 /* Line2 (as front mic) pin widget for input and vref at 80% */
1108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1110 /* CD pin widget for input */
1111 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112
1113 { }
1114};
1115
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001116/*
1117 * W810 pin configuration:
1118 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1119 */
1120static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 /* hphone/speaker input selector: front DAC */
1122 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1123
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1128 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1130
1131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001132 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 { }
1135};
1136
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001137/*
1138 * Z71V pin configuration:
1139 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1140 */
1141static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001143 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001145 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001146
Takashi Iwai16ded522005-06-10 19:58:24 +02001147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001148 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001149 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001150 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001151
1152 { }
1153};
1154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001155/*
1156 * 6-stack pin configuration:
1157 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
1158 * line = 0x1a, HP = 0x1b
1159 */
1160static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1161 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1162
Takashi Iwai16ded522005-06-10 19:58:24 +02001163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001164 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001166 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001168 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001169 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001170 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1171
Takashi Iwai16ded522005-06-10 19:58:24 +02001172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001173 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001174 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001175 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001179 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001180 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1181
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001182 { }
1183};
Takashi Iwai16ded522005-06-10 19:58:24 +02001184
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001185/* FIXME! */
1186/*
1187 * F1734 pin configuration:
1188 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1189 */
1190static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1191 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1192 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1193 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1194 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1195
1196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1200
1201 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1202 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1203 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1204 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1207 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1208 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1209 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001210
1211 { }
1212};
1213
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001214/* FIXME! */
1215/*
1216 * ASUS pin configuration:
1217 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1218 */
1219static struct hda_verb alc880_pin_asus_init_verbs[] = {
1220 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1221 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1222 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1223 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1224
1225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1229 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1231 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1233
1234 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1236 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1237 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1240 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1242 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1243
1244 { }
1245};
1246
1247/* Enable GPIO mask and set output */
1248static struct hda_verb alc880_gpio1_init_verbs[] = {
1249 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1250 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1251 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
Kailang Yangdf694da2005-12-05 19:42:22 +01001252
1253 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001254};
1255
1256/* Enable GPIO mask and set output */
1257static struct hda_verb alc880_gpio2_init_verbs[] = {
1258 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1259 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1260 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
Kailang Yangdf694da2005-12-05 19:42:22 +01001261
1262 { }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001263};
1264
Kailang Yangdf694da2005-12-05 19:42:22 +01001265/* Clevo m520g init */
1266static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1267 /* headphone output */
1268 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1269 /* line-out */
1270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1272 /* Line-in */
1273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1275 /* CD */
1276 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1277 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1278 /* Mic1 (rear panel) */
1279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1281 /* Mic2 (front panel) */
1282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1284 /* headphone */
1285 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1286 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 /* change to EAPD mode */
1288 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1289 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1290
1291 { }
1292};
1293
1294static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1295 /* Headphone output */
1296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1297 /* Front output*/
1298 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1299 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1300
1301 /* Line In pin widget for input */
1302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1303 /* CD pin widget for input */
1304 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1305 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1307
1308 /* change to EAPD mode */
1309 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1310 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1311
1312 { }
1313};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001314
1315/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001316 * LG m1 express dual
1317 *
1318 * Pin assignment:
1319 * Rear Line-In/Out (blue): 0x14
1320 * Build-in Mic-In: 0x15
1321 * Speaker-out: 0x17
1322 * HP-Out (green): 0x1b
1323 * Mic-In/Out (red): 0x19
1324 * SPDIF-Out: 0x1e
1325 */
1326
1327/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1328static hda_nid_t alc880_lg_dac_nids[3] = {
1329 0x05, 0x02, 0x03
1330};
1331
1332/* seems analog CD is not working */
1333static struct hda_input_mux alc880_lg_capture_source = {
1334 .num_items = 3,
1335 .items = {
1336 { "Mic", 0x1 },
1337 { "Line", 0x5 },
1338 { "Internal Mic", 0x6 },
1339 },
1340};
1341
1342/* 2,4,6 channel modes */
1343static struct hda_verb alc880_lg_ch2_init[] = {
1344 /* set line-in and mic-in to input */
1345 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1346 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1347 { }
1348};
1349
1350static struct hda_verb alc880_lg_ch4_init[] = {
1351 /* set line-in to out and mic-in to input */
1352 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1353 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1354 { }
1355};
1356
1357static struct hda_verb alc880_lg_ch6_init[] = {
1358 /* set line-in and mic-in to output */
1359 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1360 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1361 { }
1362};
1363
1364static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1365 { 2, alc880_lg_ch2_init },
1366 { 4, alc880_lg_ch4_init },
1367 { 6, alc880_lg_ch6_init },
1368};
1369
1370static struct snd_kcontrol_new alc880_lg_mixer[] = {
1371 /* FIXME: it's not really "master" but front channels */
1372 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1373 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1374 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1375 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1376 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1377 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1378 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1379 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1384 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1385 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1386 {
1387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1388 .name = "Channel Mode",
1389 .info = alc_ch_mode_info,
1390 .get = alc_ch_mode_get,
1391 .put = alc_ch_mode_put,
1392 },
1393 { } /* end */
1394};
1395
1396static struct hda_verb alc880_lg_init_verbs[] = {
1397 /* set capture source to mic-in */
1398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1399 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1401 /* mute all amp mixer inputs */
1402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1404 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1405 /* line-in to input */
1406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1407 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1408 /* built-in mic */
1409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1411 /* speaker-out */
1412 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1413 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1414 /* mic-in to input */
1415 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1416 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1418 /* HP-out */
1419 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1420 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1421 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1422 /* jack sense */
1423 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1424 { }
1425};
1426
1427/* toggle speaker-output according to the hp-jack state */
1428static void alc880_lg_automute(struct hda_codec *codec)
1429{
1430 unsigned int present;
1431
1432 present = snd_hda_codec_read(codec, 0x1b, 0,
1433 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1434 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1435 0x80, present ? 0x80 : 0);
1436 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1437 0x80, present ? 0x80 : 0);
1438}
1439
1440static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1441{
1442 /* Looks like the unsol event is incompatible with the standard
1443 * definition. 4bit tag is placed at 28 bit!
1444 */
1445 if ((res >> 28) == 0x01)
1446 alc880_lg_automute(codec);
1447}
1448
1449/*
Takashi Iwaid6815182006-03-23 16:06:23 +01001450 * LG LW20
1451 *
1452 * Pin assignment:
1453 * Speaker-out: 0x14
1454 * Mic-In: 0x18
1455 * Built-in Mic-In: 0x19 (?)
1456 * HP-Out: 0x1b
1457 * SPDIF-Out: 0x1e
1458 */
1459
1460/* seems analog CD is not working */
1461static struct hda_input_mux alc880_lg_lw_capture_source = {
1462 .num_items = 2,
1463 .items = {
1464 { "Mic", 0x0 },
1465 { "Internal Mic", 0x1 },
1466 },
1467};
1468
1469static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1470 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1471 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1474 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1475 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1476 { } /* end */
1477};
1478
1479static struct hda_verb alc880_lg_lw_init_verbs[] = {
1480 /* set capture source to mic-in */
1481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1483 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1485 /* speaker-out */
1486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488 /* HP-out */
1489 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1490 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 /* mic-in to input */
1493 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1494 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 /* built-in mic */
1496 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 /* jack sense */
1499 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1500 { }
1501};
1502
1503/* toggle speaker-output according to the hp-jack state */
1504static void alc880_lg_lw_automute(struct hda_codec *codec)
1505{
1506 unsigned int present;
1507
1508 present = snd_hda_codec_read(codec, 0x1b, 0,
1509 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1510 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1511 0x80, present ? 0x80 : 0);
1512 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1513 0x80, present ? 0x80 : 0);
1514}
1515
1516static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1517{
1518 /* Looks like the unsol event is incompatible with the standard
1519 * definition. 4bit tag is placed at 28 bit!
1520 */
1521 if ((res >> 28) == 0x01)
1522 alc880_lg_lw_automute(codec);
1523}
1524
1525/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001526 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001527 */
Takashi Iwai16ded522005-06-10 19:58:24 +02001528
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529static int alc_init(struct hda_codec *codec)
1530{
1531 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001532 unsigned int i;
1533
1534 for (i = 0; i < spec->num_init_verbs; i++)
1535 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001536
1537 if (spec->init_hook)
1538 spec->init_hook(codec);
1539
Linus Torvalds1da177e2005-04-16 15:20:36 -07001540 return 0;
1541}
1542
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001543static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1544{
1545 struct alc_spec *spec = codec->spec;
1546
1547 if (spec->unsol_event)
1548 spec->unsol_event(codec, res);
1549}
1550
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551#ifdef CONFIG_PM
1552/*
1553 * resume
1554 */
1555static int alc_resume(struct hda_codec *codec)
1556{
1557 struct alc_spec *spec = codec->spec;
1558 int i;
1559
1560 alc_init(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001561 for (i = 0; i < spec->num_mixers; i++)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 snd_hda_resume_ctls(codec, spec->mixers[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 if (spec->multiout.dig_out_nid)
1564 snd_hda_resume_spdif_out(codec);
1565 if (spec->dig_in_nid)
1566 snd_hda_resume_spdif_in(codec);
1567
1568 return 0;
1569}
1570#endif
1571
1572/*
1573 * Analog playback callbacks
1574 */
1575static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1576 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001577 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578{
1579 struct alc_spec *spec = codec->spec;
1580 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1581}
1582
1583static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1584 struct hda_codec *codec,
1585 unsigned int stream_tag,
1586 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001587 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588{
1589 struct alc_spec *spec = codec->spec;
1590 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1591 format, substream);
1592}
1593
1594static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1595 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001596 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597{
1598 struct alc_spec *spec = codec->spec;
1599 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1600}
1601
1602/*
1603 * Digital out
1604 */
1605static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1606 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001607 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001608{
1609 struct alc_spec *spec = codec->spec;
1610 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1611}
1612
1613static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1614 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001615 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001616{
1617 struct alc_spec *spec = codec->spec;
1618 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1619}
1620
1621/*
1622 * Analog capture
1623 */
1624static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1625 struct hda_codec *codec,
1626 unsigned int stream_tag,
1627 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001628 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001629{
1630 struct alc_spec *spec = codec->spec;
1631
1632 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1633 stream_tag, 0, format);
1634 return 0;
1635}
1636
1637static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1638 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001639 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640{
1641 struct alc_spec *spec = codec->spec;
1642
1643 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1644 return 0;
1645}
1646
1647
1648/*
1649 */
1650static struct hda_pcm_stream alc880_pcm_analog_playback = {
1651 .substreams = 1,
1652 .channels_min = 2,
1653 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 .ops = {
1656 .open = alc880_playback_pcm_open,
1657 .prepare = alc880_playback_pcm_prepare,
1658 .cleanup = alc880_playback_pcm_cleanup
1659 },
1660};
1661
1662static struct hda_pcm_stream alc880_pcm_analog_capture = {
1663 .substreams = 2,
1664 .channels_min = 2,
1665 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001666 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667 .ops = {
1668 .prepare = alc880_capture_pcm_prepare,
1669 .cleanup = alc880_capture_pcm_cleanup
1670 },
1671};
1672
1673static struct hda_pcm_stream alc880_pcm_digital_playback = {
1674 .substreams = 1,
1675 .channels_min = 2,
1676 .channels_max = 2,
1677 /* NID is set in alc_build_pcms */
1678 .ops = {
1679 .open = alc880_dig_playback_pcm_open,
1680 .close = alc880_dig_playback_pcm_close
1681 },
1682};
1683
1684static struct hda_pcm_stream alc880_pcm_digital_capture = {
1685 .substreams = 1,
1686 .channels_min = 2,
1687 .channels_max = 2,
1688 /* NID is set in alc_build_pcms */
1689};
1690
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001691/* Used by alc_build_pcms to flag that a PCM has no playback stream */
1692static struct hda_pcm_stream alc_pcm_null_playback = {
1693 .substreams = 0,
1694 .channels_min = 0,
1695 .channels_max = 0,
1696};
1697
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698static int alc_build_pcms(struct hda_codec *codec)
1699{
1700 struct alc_spec *spec = codec->spec;
1701 struct hda_pcm *info = spec->pcm_rec;
1702 int i;
1703
1704 codec->num_pcms = 1;
1705 codec->pcm_info = info;
1706
1707 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001708 if (spec->stream_analog_playback) {
1709 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1710 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1711 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1712 }
1713 if (spec->stream_analog_capture) {
1714 snd_assert(spec->adc_nids, return -EINVAL);
1715 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1716 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1717 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718
Takashi Iwai4a471b72005-12-07 13:56:29 +01001719 if (spec->channel_mode) {
1720 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1721 for (i = 0; i < spec->num_channel_mode; i++) {
1722 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1723 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1724 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 }
1726 }
1727
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01001728 /* If the use of more than one ADC is requested for the current
1729 * model, configure a second analog capture-only PCM.
1730 */
1731 if (spec->num_adc_nids > 1) {
1732 codec->num_pcms++;
1733 info++;
1734 info->name = spec->stream_name_analog;
1735 /* No playback stream for second PCM */
1736 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1737 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1738 if (spec->stream_analog_capture) {
1739 snd_assert(spec->adc_nids, return -EINVAL);
1740 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1741 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1742 }
1743 }
1744
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1746 codec->num_pcms++;
1747 info++;
1748 info->name = spec->stream_name_digital;
Takashi Iwai4a471b72005-12-07 13:56:29 +01001749 if (spec->multiout.dig_out_nid &&
1750 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1752 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1753 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01001754 if (spec->dig_in_nid &&
1755 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1757 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1758 }
1759 }
1760
1761 return 0;
1762}
1763
1764static void alc_free(struct hda_codec *codec)
1765{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001766 struct alc_spec *spec = codec->spec;
1767 unsigned int i;
1768
1769 if (! spec)
1770 return;
1771
1772 if (spec->kctl_alloc) {
1773 for (i = 0; i < spec->num_kctl_used; i++)
1774 kfree(spec->kctl_alloc[i].name);
1775 kfree(spec->kctl_alloc);
1776 }
1777 kfree(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778}
1779
1780/*
1781 */
1782static struct hda_codec_ops alc_patch_ops = {
1783 .build_controls = alc_build_controls,
1784 .build_pcms = alc_build_pcms,
1785 .init = alc_init,
1786 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001787 .unsol_event = alc_unsol_event,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788#ifdef CONFIG_PM
1789 .resume = alc_resume,
1790#endif
1791};
1792
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001793
1794/*
1795 * Test configuration for debugging
1796 *
1797 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1798 * enum controls.
1799 */
1800#ifdef CONFIG_SND_DEBUG
1801static hda_nid_t alc880_test_dac_nids[4] = {
1802 0x02, 0x03, 0x04, 0x05
1803};
1804
1805static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001806 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001807 .items = {
1808 { "In-1", 0x0 },
1809 { "In-2", 0x1 },
1810 { "In-3", 0x2 },
1811 { "In-4", 0x3 },
1812 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01001813 { "Front", 0x5 },
1814 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001815 },
1816};
1817
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001818static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001819 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001820 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001821 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02001822 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001823};
1824
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001825static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001826{
1827 static char *texts[] = {
1828 "N/A", "Line Out", "HP Out",
1829 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1830 };
1831 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1832 uinfo->count = 1;
1833 uinfo->value.enumerated.items = 8;
1834 if (uinfo->value.enumerated.item >= 8)
1835 uinfo->value.enumerated.item = 7;
1836 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1837 return 0;
1838}
1839
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001840static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001841{
1842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1843 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1844 unsigned int pin_ctl, item = 0;
1845
1846 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1847 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1848 if (pin_ctl & AC_PINCTL_OUT_EN) {
1849 if (pin_ctl & AC_PINCTL_HP_EN)
1850 item = 2;
1851 else
1852 item = 1;
1853 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1854 switch (pin_ctl & AC_PINCTL_VREFEN) {
1855 case AC_PINCTL_VREF_HIZ: item = 3; break;
1856 case AC_PINCTL_VREF_50: item = 4; break;
1857 case AC_PINCTL_VREF_GRD: item = 5; break;
1858 case AC_PINCTL_VREF_80: item = 6; break;
1859 case AC_PINCTL_VREF_100: item = 7; break;
1860 }
1861 }
1862 ucontrol->value.enumerated.item[0] = item;
1863 return 0;
1864}
1865
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001866static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001867{
1868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1869 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1870 static unsigned int ctls[] = {
1871 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1872 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1873 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1874 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1875 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1876 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1877 };
1878 unsigned int old_ctl, new_ctl;
1879
1880 old_ctl = snd_hda_codec_read(codec, nid, 0,
1881 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1882 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1883 if (old_ctl != new_ctl) {
1884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1885 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1886 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1887 return 1;
1888 }
1889 return 0;
1890}
1891
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001892static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001893{
1894 static char *texts[] = {
1895 "Front", "Surround", "CLFE", "Side"
1896 };
1897 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1898 uinfo->count = 1;
1899 uinfo->value.enumerated.items = 4;
1900 if (uinfo->value.enumerated.item >= 4)
1901 uinfo->value.enumerated.item = 3;
1902 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1903 return 0;
1904}
1905
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001906static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001907{
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1910 unsigned int sel;
1911
1912 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1913 ucontrol->value.enumerated.item[0] = sel & 3;
1914 return 0;
1915}
1916
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001917static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001918{
1919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1920 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1921 unsigned int sel;
1922
1923 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1924 if (ucontrol->value.enumerated.item[0] != sel) {
1925 sel = ucontrol->value.enumerated.item[0] & 3;
1926 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1927 return 1;
1928 }
1929 return 0;
1930}
1931
1932#define PIN_CTL_TEST(xname,nid) { \
1933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1934 .name = xname, \
1935 .info = alc_test_pin_ctl_info, \
1936 .get = alc_test_pin_ctl_get, \
1937 .put = alc_test_pin_ctl_put, \
1938 .private_value = nid \
1939 }
1940
1941#define PIN_SRC_TEST(xname,nid) { \
1942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1943 .name = xname, \
1944 .info = alc_test_pin_src_info, \
1945 .get = alc_test_pin_src_get, \
1946 .put = alc_test_pin_src_put, \
1947 .private_value = nid \
1948 }
1949
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001950static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1952 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1953 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1954 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001955 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1956 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1957 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1958 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001959 PIN_CTL_TEST("Front Pin Mode", 0x14),
1960 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1961 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1962 PIN_CTL_TEST("Side Pin Mode", 0x17),
1963 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1964 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1965 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1966 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1967 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1968 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1969 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1970 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1971 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1972 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1973 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1974 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1975 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1976 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1977 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1978 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001981 {
1982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1983 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001984 .info = alc_ch_mode_info,
1985 .get = alc_ch_mode_get,
1986 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02001987 },
1988 { } /* end */
1989};
1990
1991static struct hda_verb alc880_test_init_verbs[] = {
1992 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02001993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002001 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2003 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2004 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2005 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002006 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2009 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2010 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002011 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002016 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2018 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002019 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2020 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2021 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002022 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002023 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2025 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2026 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002027 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002029 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002030 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002031 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002033 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002034 /* Analog input/passthru */
2035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002040 { }
2041};
2042#endif
2043
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044/*
2045 */
2046
2047static struct hda_board_config alc880_cfg_tbl[] = {
2048 /* Back 3 jack, front 2 jack */
2049 { .modelname = "3stack", .config = ALC880_3ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002050 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2051 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2052 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2053 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2054 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2055 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2056 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2057 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2058 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2059 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2060 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2061 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2062 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2063 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2064 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2065 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2066 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2067 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2068 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2069 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2070 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2071 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2072 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2073 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2074 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2075 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2076 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2077 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2078 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2079 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2080 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2081 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
Kailang Yangdf694da2005-12-05 19:42:22 +01002082 /* TCL S700 */
2083 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084
2085 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
Takashi Iwai72915482005-05-12 16:49:45 +02002086 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002087 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
Davide Libenzi0ca21612005-09-05 11:56:47 +02002088 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089
2090 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2091 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002092 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
Jaroslav Kysela5a47fe3c2005-08-15 20:01:40 +02002093 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002094 /* Clevo m520G NB */
2095 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096
2097 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
Takashi Iwai72915482005-05-12 16:49:45 +02002098 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2099 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2100 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101
2102 /* Back 5 jack, front 2 jack */
2103 { .modelname = "5stack", .config = ALC880_5ST },
Takashi Iwai72915482005-05-12 16:49:45 +02002104 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2105 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2106 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2107 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
Takashi Iwai16ded522005-06-10 19:58:24 +02002108 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109
2110 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2111 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
Takashi Iwai72915482005-05-12 16:49:45 +02002112 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2113 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2114 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2115 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2116 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2117 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2118 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2119 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002120 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
Takashi Iwaiede35312006-03-13 14:21:16 +01002121 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2122 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
Takashi Iwai7a318a72005-06-28 14:16:21 +02002123 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
Takashi Iwai16ded522005-06-10 19:58:24 +02002124 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002125 /* note subvendor = 0 below */
2126 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127
2128 { .modelname = "w810", .config = ALC880_W810 },
Takashi Iwai72915482005-05-12 16:49:45 +02002129 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002131 { .modelname = "z71v", .config = ALC880_Z71V },
Takashi Iwai72915482005-05-12 16:49:45 +02002132 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002133
Takashi Iwaib6482d42005-06-27 15:32:43 +02002134 { .modelname = "6stack", .config = ALC880_6ST },
Takashi Iwai7632c7b2005-12-07 18:25:47 +01002135 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
Kailang Yangdf694da2005-12-05 19:42:22 +01002136 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
Takashi Iwai7a318a72005-06-28 14:16:21 +02002137 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
Arnaud Patardbae2bdb2006-01-27 12:05:02 +01002138 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
Takashi Iwaib6482d42005-06-27 15:32:43 +02002139
2140 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002141 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2143 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2144 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01002145 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2146 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2147 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2148 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
Takashi Iwai041dec02005-12-23 12:27:52 +01002149 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
Takashi Iwaia12606c2006-03-15 18:24:43 +01002150 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
Takashi Iwai531213a2006-04-18 13:46:08 +02002151 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
Takashi Iwai16ded522005-06-10 19:58:24 +02002152
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002153 { .modelname = "asus", .config = ALC880_ASUS },
Takashi Iwai16ded522005-06-10 19:58:24 +02002154 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2155 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2156 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2157 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
Takashi Iwai86488112005-09-09 13:56:32 +02002158 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
Takashi Iwai16ded522005-06-10 19:58:24 +02002159 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2160 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2161 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2162 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2163 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2164 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
Takashi Iwai84f34302006-03-21 19:12:53 +01002165 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
Kailang Yangdf694da2005-12-05 19:42:22 +01002166 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002167
2168 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2169 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2170
2171 { .modelname = "F1734", .config = ALC880_F1734 },
2172 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002173 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002174
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002175 { .modelname = "lg", .config = ALC880_LG },
2176 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2177
Takashi Iwaid6815182006-03-23 16:06:23 +01002178 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2179 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2180
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002181#ifdef CONFIG_SND_DEBUG
2182 { .modelname = "test", .config = ALC880_TEST },
2183#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01002184 { .modelname = "auto", .config = ALC880_AUTO },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002185
Linus Torvalds1da177e2005-04-16 15:20:36 -07002186 {}
2187};
2188
Takashi Iwai16ded522005-06-10 19:58:24 +02002189/*
Kailang Yangdf694da2005-12-05 19:42:22 +01002190 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02002191 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002192static struct alc_config_preset alc880_presets[] = {
2193 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 .mixers = { alc880_three_stack_mixer },
2195 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002196 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002197 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002198 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2199 .channel_mode = alc880_threestack_modes,
2200 .input_mux = &alc880_capture_source,
2201 },
2202 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002203 .mixers = { alc880_three_stack_mixer },
2204 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002205 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02002206 .dac_nids = alc880_dac_nids,
2207 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002208 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2209 .channel_mode = alc880_threestack_modes,
2210 .input_mux = &alc880_capture_source,
2211 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002212 [ALC880_TCL_S700] = {
2213 .mixers = { alc880_tcl_s700_mixer },
2214 .init_verbs = { alc880_volume_init_verbs,
2215 alc880_pin_tcl_S700_init_verbs,
2216 alc880_gpio2_init_verbs },
2217 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2218 .dac_nids = alc880_dac_nids,
2219 .hp_nid = 0x03,
2220 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2221 .channel_mode = alc880_2_jack_modes,
2222 .input_mux = &alc880_capture_source,
2223 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002224 [ALC880_5ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002225 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2226 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002227 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2228 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002229 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2230 .channel_mode = alc880_fivestack_modes,
2231 .input_mux = &alc880_capture_source,
2232 },
2233 [ALC880_5ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002234 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2235 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002236 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2237 .dac_nids = alc880_dac_nids,
2238 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002239 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2240 .channel_mode = alc880_fivestack_modes,
2241 .input_mux = &alc880_capture_source,
2242 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02002243 [ALC880_6ST] = {
2244 .mixers = { alc880_six_stack_mixer },
2245 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2246 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2247 .dac_nids = alc880_6st_dac_nids,
2248 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2249 .channel_mode = alc880_sixstack_modes,
2250 .input_mux = &alc880_6stack_capture_source,
2251 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002252 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253 .mixers = { alc880_six_stack_mixer },
2254 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002255 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2256 .dac_nids = alc880_6st_dac_nids,
2257 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002258 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2259 .channel_mode = alc880_sixstack_modes,
2260 .input_mux = &alc880_6stack_capture_source,
2261 },
2262 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002263 .mixers = { alc880_w810_base_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002264 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2265 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002266 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2267 .dac_nids = alc880_w810_dac_nids,
2268 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2270 .channel_mode = alc880_w810_modes,
2271 .input_mux = &alc880_capture_source,
2272 },
2273 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002274 .mixers = { alc880_z71v_mixer },
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002275 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2277 .dac_nids = alc880_z71v_dac_nids,
2278 .dig_out_nid = ALC880_DIGOUT_NID,
2279 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002280 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2281 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002282 .input_mux = &alc880_capture_source,
2283 },
2284 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002285 .mixers = { alc880_f1734_mixer },
2286 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2287 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2288 .dac_nids = alc880_f1734_dac_nids,
2289 .hp_nid = 0x02,
2290 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2291 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002292 .input_mux = &alc880_capture_source,
2293 },
2294 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002295 .mixers = { alc880_asus_mixer },
2296 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2297 alc880_gpio1_init_verbs },
2298 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2299 .dac_nids = alc880_asus_dac_nids,
2300 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2301 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 .input_mux = &alc880_capture_source,
2303 },
2304 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002305 .mixers = { alc880_asus_mixer },
2306 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2307 alc880_gpio1_init_verbs },
2308 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2309 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002310 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002311 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2312 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002313 .input_mux = &alc880_capture_source,
2314 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002315 [ALC880_ASUS_DIG2] = {
2316 .mixers = { alc880_asus_mixer },
2317 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2318 alc880_gpio2_init_verbs }, /* use GPIO2 */
2319 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2320 .dac_nids = alc880_asus_dac_nids,
2321 .dig_out_nid = ALC880_DIGOUT_NID,
2322 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2323 .channel_mode = alc880_asus_modes,
2324 .input_mux = &alc880_capture_source,
2325 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002326 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002327 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2328 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2329 alc880_gpio1_init_verbs },
2330 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2331 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002332 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002333 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2334 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002335 .input_mux = &alc880_capture_source,
2336 },
2337 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02002338 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002339 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2340 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2341 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02002342 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002343 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2344 .channel_mode = alc880_asus_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02002345 .input_mux = &alc880_capture_source,
2346 },
Kailang Yangdf694da2005-12-05 19:42:22 +01002347 [ALC880_CLEVO] = {
2348 .mixers = { alc880_three_stack_mixer },
2349 .init_verbs = { alc880_volume_init_verbs,
2350 alc880_pin_clevo_init_verbs },
2351 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2352 .dac_nids = alc880_dac_nids,
2353 .hp_nid = 0x03,
2354 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2355 .channel_mode = alc880_threestack_modes,
2356 .input_mux = &alc880_capture_source,
2357 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002358 [ALC880_LG] = {
2359 .mixers = { alc880_lg_mixer },
2360 .init_verbs = { alc880_volume_init_verbs,
2361 alc880_lg_init_verbs },
2362 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2363 .dac_nids = alc880_lg_dac_nids,
2364 .dig_out_nid = ALC880_DIGOUT_NID,
2365 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2366 .channel_mode = alc880_lg_ch_modes,
2367 .input_mux = &alc880_lg_capture_source,
2368 .unsol_event = alc880_lg_unsol_event,
2369 .init_hook = alc880_lg_automute,
2370 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002371 [ALC880_LG_LW] = {
2372 .mixers = { alc880_lg_lw_mixer },
2373 .init_verbs = { alc880_volume_init_verbs,
2374 alc880_lg_lw_init_verbs },
2375 .num_dacs = 1,
2376 .dac_nids = alc880_dac_nids,
2377 .dig_out_nid = ALC880_DIGOUT_NID,
2378 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2379 .channel_mode = alc880_2_jack_modes,
2380 .input_mux = &alc880_lg_lw_capture_source,
2381 .unsol_event = alc880_lg_lw_unsol_event,
2382 .init_hook = alc880_lg_lw_automute,
2383 },
Takashi Iwai16ded522005-06-10 19:58:24 +02002384#ifdef CONFIG_SND_DEBUG
2385 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002386 .mixers = { alc880_test_mixer },
2387 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02002388 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2389 .dac_nids = alc880_test_dac_nids,
2390 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02002391 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2392 .channel_mode = alc880_test_modes,
2393 .input_mux = &alc880_test_capture_source,
2394 },
2395#endif
2396};
2397
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002398/*
2399 * Automatic parse of I/O pins from the BIOS configuration
2400 */
2401
2402#define NUM_CONTROL_ALLOC 32
2403#define NUM_VERB_ALLOC 32
2404
2405enum {
2406 ALC_CTL_WIDGET_VOL,
2407 ALC_CTL_WIDGET_MUTE,
2408 ALC_CTL_BIND_MUTE,
2409};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002410static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002411 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2412 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01002413 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002414};
2415
2416/* add dynamic controls */
2417static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2418{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002419 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002420
2421 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2422 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2423
2424 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2425 if (! knew)
2426 return -ENOMEM;
2427 if (spec->kctl_alloc) {
2428 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2429 kfree(spec->kctl_alloc);
2430 }
2431 spec->kctl_alloc = knew;
2432 spec->num_kctl_alloc = num;
2433 }
2434
2435 knew = &spec->kctl_alloc[spec->num_kctl_used];
2436 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07002437 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438 if (! knew->name)
2439 return -ENOMEM;
2440 knew->private_value = val;
2441 spec->num_kctl_used++;
2442 return 0;
2443}
2444
2445#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2446#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2447#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2448#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2449#define alc880_is_input_pin(nid) ((nid) >= 0x18)
2450#define alc880_input_pin_idx(nid) ((nid) - 0x18)
2451#define alc880_idx_to_dac(nid) ((nid) + 0x02)
2452#define alc880_dac_to_idx(nid) ((nid) - 0x02)
2453#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2454#define alc880_idx_to_selector(nid) ((nid) + 0x10)
2455#define ALC880_PIN_CD_NID 0x1c
2456
2457/* fill in the dac_nids table from the parsed pin configuration */
2458static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2459{
2460 hda_nid_t nid;
2461 int assigned[4];
2462 int i, j;
2463
2464 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02002465 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002466
2467 /* check the pins hardwired to audio widget */
2468 for (i = 0; i < cfg->line_outs; i++) {
2469 nid = cfg->line_out_pins[i];
2470 if (alc880_is_fixed_pin(nid)) {
2471 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01002472 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002473 assigned[idx] = 1;
2474 }
2475 }
2476 /* left pins can be connect to any audio widget */
2477 for (i = 0; i < cfg->line_outs; i++) {
2478 nid = cfg->line_out_pins[i];
2479 if (alc880_is_fixed_pin(nid))
2480 continue;
2481 /* search for an empty channel */
2482 for (j = 0; j < cfg->line_outs; j++) {
2483 if (! assigned[j]) {
2484 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2485 assigned[j] = 1;
2486 break;
2487 }
2488 }
2489 }
2490 spec->multiout.num_dacs = cfg->line_outs;
2491 return 0;
2492}
2493
2494/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01002495static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2496 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002497{
2498 char name[32];
2499 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2500 hda_nid_t nid;
2501 int i, err;
2502
2503 for (i = 0; i < cfg->line_outs; i++) {
2504 if (! spec->multiout.dac_nids[i])
2505 continue;
2506 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2507 if (i == 2) {
2508 /* Center/LFE */
2509 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2510 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2511 return err;
2512 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2513 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2514 return err;
2515 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2516 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2517 return err;
2518 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2519 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2520 return err;
2521 } else {
2522 sprintf(name, "%s Playback Volume", chname[i]);
2523 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2524 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2525 return err;
2526 sprintf(name, "%s Playback Switch", chname[i]);
2527 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2528 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2529 return err;
2530 }
2531 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532 return 0;
2533}
2534
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002535/* add playback controls for speaker and HP outputs */
2536static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2537 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538{
2539 hda_nid_t nid;
2540 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002541 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002542
2543 if (! pin)
2544 return 0;
2545
2546 if (alc880_is_fixed_pin(pin)) {
2547 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01002548 /* specify the DAC as the extra output */
2549 if (! spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002550 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002551 else
2552 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002553 /* control HP volume/switch on the output mixer amp */
2554 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002555 sprintf(name, "%s Playback Volume", pfx);
2556 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2558 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002559 sprintf(name, "%s Playback Switch", pfx);
2560 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002561 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2562 return err;
2563 } else if (alc880_is_multi_pin(pin)) {
2564 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002565 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002566 sprintf(name, "%s Playback Switch", pfx);
2567 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002568 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2569 return err;
2570 }
2571 return 0;
2572}
2573
2574/* create input playback/capture controls for the given pin */
Kailang Yangdf694da2005-12-05 19:42:22 +01002575static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2576 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002577{
2578 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01002579 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002580
2581 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002582 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002583 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002584 return err;
2585 sprintf(name, "%s Playback Switch", ctlname);
2586 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yangdf694da2005-12-05 19:42:22 +01002587 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588 return err;
2589 return 0;
2590}
2591
2592/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01002593static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2594 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002595{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002596 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01002597 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598
2599 for (i = 0; i < AUTO_PIN_LAST; i++) {
2600 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01002601 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01002602 err = new_analog_input(spec, cfg->input_pins[i],
2603 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01002604 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002605 if (err < 0)
2606 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002607 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2609 imux->num_items++;
2610 }
2611 }
2612 return 0;
2613}
2614
Kailang Yangdf694da2005-12-05 19:42:22 +01002615static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2616 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002617 int dac_idx)
2618{
2619 /* set as output */
2620 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2621 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2622 /* need the manual connection? */
2623 if (alc880_is_multi_pin(nid)) {
2624 struct alc_spec *spec = codec->spec;
2625 int idx = alc880_multi_pin_idx(nid);
2626 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2627 AC_VERB_SET_CONNECT_SEL,
2628 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2629 }
2630}
2631
2632static void alc880_auto_init_multi_out(struct hda_codec *codec)
2633{
2634 struct alc_spec *spec = codec->spec;
2635 int i;
2636
2637 for (i = 0; i < spec->autocfg.line_outs; i++) {
2638 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2639 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2640 }
2641}
2642
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002643static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644{
2645 struct alc_spec *spec = codec->spec;
2646 hda_nid_t pin;
2647
Takashi Iwai82bc9552006-03-21 11:24:42 +01002648 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002649 if (pin) /* connect to front */
2650 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002651 pin = spec->autocfg.hp_pin;
2652 if (pin) /* connect to front */
2653 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2654}
2655
2656static void alc880_auto_init_analog_input(struct hda_codec *codec)
2657{
2658 struct alc_spec *spec = codec->spec;
2659 int i;
2660
2661 for (i = 0; i < AUTO_PIN_LAST; i++) {
2662 hda_nid_t nid = spec->autocfg.input_pins[i];
2663 if (alc880_is_input_pin(nid)) {
2664 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2665 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2666 if (nid != ALC880_PIN_CD_NID)
2667 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2668 AMP_OUT_MUTE);
2669 }
2670 }
2671}
2672
2673/* parse the BIOS configuration and set up the alc_spec */
2674/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2675static int alc880_parse_auto_config(struct hda_codec *codec)
2676{
2677 struct alc_spec *spec = codec->spec;
2678 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01002679 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680
Kailang Yangdf694da2005-12-05 19:42:22 +01002681 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2682 alc880_ignore)) < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002683 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01002684 if (! spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002685 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01002686
2687 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2688 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002689 (err = alc880_auto_create_extra_out(spec,
2690 spec->autocfg.speaker_pins[0],
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002691 "Speaker")) < 0 ||
Takashi Iwai82bc9552006-03-21 11:24:42 +01002692 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002693 "Headphone")) < 0 ||
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2695 return err;
2696
2697 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2698
2699 if (spec->autocfg.dig_out_pin)
2700 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2701 if (spec->autocfg.dig_in_pin)
2702 spec->dig_in_nid = ALC880_DIGIN_NID;
2703
2704 if (spec->kctl_alloc)
2705 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2706
2707 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2708
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002709 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 spec->input_mux = &spec->private_imux;
2711
2712 return 1;
2713}
2714
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002715/* additional initialization for auto-configuration model */
2716static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002717{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002718 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01002719 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 alc880_auto_init_analog_input(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721}
2722
2723/*
2724 * OK, here we have finally the patch for ALC880
2725 */
2726
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727static int patch_alc880(struct hda_codec *codec)
2728{
2729 struct alc_spec *spec;
2730 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01002731 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002732
Takashi Iwaie560d8d2005-09-09 14:21:46 +02002733 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002734 if (spec == NULL)
2735 return -ENOMEM;
2736
2737 codec->spec = spec;
2738
2739 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
Takashi Iwai16ded522005-06-10 19:58:24 +02002740 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002741 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2742 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743 }
2744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745 if (board_config == ALC880_AUTO) {
2746 /* automatic parse from the BIOS config */
2747 err = alc880_parse_auto_config(codec);
2748 if (err < 0) {
2749 alc_free(codec);
2750 return err;
2751 } else if (! err) {
2752 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2753 board_config = ALC880_3ST;
2754 }
2755 }
2756
Kailang Yangdf694da2005-12-05 19:42:22 +01002757 if (board_config != ALC880_AUTO)
2758 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002759
2760 spec->stream_name_analog = "ALC880 Analog";
2761 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2762 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2763
2764 spec->stream_name_digital = "ALC880 Digital";
2765 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2766 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2767
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002768 if (! spec->adc_nids && spec->input_mux) {
2769 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01002770 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002771 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2772 if (wcap != AC_WID_AUD_IN) {
2773 spec->adc_nids = alc880_adc_nids_alt;
2774 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2775 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2776 spec->num_mixers++;
2777 } else {
2778 spec->adc_nids = alc880_adc_nids;
2779 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2780 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2781 spec->num_mixers++;
2782 }
2783 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002784
2785 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002786 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002787 spec->init_hook = alc880_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002788
2789 return 0;
2790}
2791
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002792
Linus Torvalds1da177e2005-04-16 15:20:36 -07002793/*
2794 * ALC260 support
2795 */
2796
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797static hda_nid_t alc260_dac_nids[1] = {
2798 /* front */
2799 0x02,
2800};
2801
2802static hda_nid_t alc260_adc_nids[1] = {
2803 /* ADC0 */
2804 0x04,
2805};
2806
Kailang Yangdf694da2005-12-05 19:42:22 +01002807static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002808 /* ADC1 */
2809 0x05,
2810};
2811
Kailang Yangdf694da2005-12-05 19:42:22 +01002812static hda_nid_t alc260_hp_adc_nids[2] = {
2813 /* ADC1, 0 */
2814 0x05, 0x04
2815};
2816
Jonathan Woithed57fdac2006-02-28 11:38:35 +01002817/* NIDs used when simultaneous access to both ADCs makes sense. Note that
2818 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2819 */
2820static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002821 /* ADC0, ADC1 */
2822 0x04, 0x05
2823};
2824
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002825#define ALC260_DIGOUT_NID 0x03
2826#define ALC260_DIGIN_NID 0x06
2827
2828static struct hda_input_mux alc260_capture_source = {
2829 .num_items = 4,
2830 .items = {
2831 { "Mic", 0x0 },
2832 { "Front Mic", 0x1 },
2833 { "Line", 0x2 },
2834 { "CD", 0x4 },
2835 },
2836};
2837
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01002838/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002839 * headphone jack and the internal CD lines since these are the only pins at
2840 * which audio can appear. For flexibility, also allow the option of
2841 * recording the mixer output on the second ADC (ADC0 doesn't have a
2842 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002843 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002844static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2845 {
2846 .num_items = 3,
2847 .items = {
2848 { "Mic/Line", 0x0 },
2849 { "CD", 0x4 },
2850 { "Headphone", 0x2 },
2851 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002852 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002853 {
2854 .num_items = 4,
2855 .items = {
2856 { "Mic/Line", 0x0 },
2857 { "CD", 0x4 },
2858 { "Headphone", 0x2 },
2859 { "Mixer", 0x5 },
2860 },
2861 },
2862
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002863};
2864
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002865/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2866 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002867 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002868static struct hda_input_mux alc260_acer_capture_sources[2] = {
2869 {
2870 .num_items = 4,
2871 .items = {
2872 { "Mic", 0x0 },
2873 { "Line", 0x2 },
2874 { "CD", 0x4 },
2875 { "Headphone", 0x5 },
2876 },
2877 },
2878 {
2879 .num_items = 5,
2880 .items = {
2881 { "Mic", 0x0 },
2882 { "Line", 0x2 },
2883 { "CD", 0x4 },
2884 { "Headphone", 0x6 },
2885 { "Mixer", 0x5 },
2886 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002887 },
2888};
Linus Torvalds1da177e2005-04-16 15:20:36 -07002889/*
2890 * This is just place-holder, so there's something for alc_build_pcms to look
2891 * at when it calculates the maximum number of channels. ALC260 has no mixer
2892 * element which allows changing the channel mode, so the verb list is
2893 * never used.
2894 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002895static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896 { 2, NULL },
2897};
2898
Kailang Yangdf694da2005-12-05 19:42:22 +01002899
2900/* Mixer combinations
2901 *
2902 * basic: base_output + input + pc_beep + capture
2903 * HP: base_output + input + capture_alt
2904 * HP_3013: hp_3013 + input + capture
2905 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002906 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01002907 */
2908
2909static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002910 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002911 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002912 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2913 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2914 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2915 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2916 { } /* end */
2917};
2918
2919static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2921 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2922 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2923 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2925 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002928 { } /* end */
2929};
2930
Kailang Yangdf694da2005-12-05 19:42:22 +01002931static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2932 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2933 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2934 { } /* end */
2935};
2936
2937static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2938 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2939 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2940 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2941 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2942 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2944 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2945 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002946 { } /* end */
2947};
2948
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002949/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
2950 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
2951 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002952static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002953 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002954 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002955 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002956 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2957 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2958 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2959 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002960 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02002961 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2962 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2963 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002964 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002965 { } /* end */
2966};
2967
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002968/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
2969 * versions of the ALC260 don't act on requests to enable mic bias from NID
2970 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
2971 * datasheet doesn't mention this restriction. At this stage it's not clear
2972 * whether this behaviour is intentional or is a hardware bug in chip
2973 * revisions available in early 2006. Therefore for now allow the
2974 * "Headphone Jack Mode" control to span all choices, but if it turns out
2975 * that the lack of mic bias for this NID is intentional we could change the
2976 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
2977 *
2978 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
2979 * don't appear to make the mic bias available from the "line" jack, even
2980 * though the NID used for this jack (0x14) can supply it. The theory is
2981 * that perhaps Acer have included blocking capacitors between the ALC260
2982 * and the output jack. If this turns out to be the case for all such
2983 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
2984 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
2985 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002986static struct snd_kcontrol_new alc260_acer_mixer[] = {
2987 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2988 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02002989 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01002990 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2991 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2993 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2994 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
2995 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2996 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2997 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
2998 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2999 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3000 { } /* end */
3001};
3002
Kailang Yangdf694da2005-12-05 19:42:22 +01003003/* capture mixer elements */
3004static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003005 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3006 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01003007 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3008 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003009 {
3010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01003011 /* The multiple "Capture Source" controls confuse alsamixer
3012 * So call somewhat different..
3013 * FIXME: the controls appear in the "playback" view!
3014 */
3015 /* .name = "Capture Source", */
3016 .name = "Input Source",
3017 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003018 .info = alc_mux_enum_info,
3019 .get = alc_mux_enum_get,
3020 .put = alc_mux_enum_put,
3021 },
3022 { } /* end */
3023};
3024
Kailang Yangdf694da2005-12-05 19:42:22 +01003025static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3026 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3027 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3028 {
3029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3030 /* The multiple "Capture Source" controls confuse alsamixer
3031 * So call somewhat different..
3032 * FIXME: the controls appear in the "playback" view!
3033 */
3034 /* .name = "Capture Source", */
3035 .name = "Input Source",
3036 .count = 1,
3037 .info = alc_mux_enum_info,
3038 .get = alc_mux_enum_get,
3039 .put = alc_mux_enum_put,
3040 },
3041 { } /* end */
3042};
3043
3044/*
3045 * initialization verbs
3046 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003047static struct hda_verb alc260_init_verbs[] = {
3048 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003050 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02003051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003052 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003053 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003054 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003055 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003056 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02003057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01003059 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003060 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02003061 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003062 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02003063 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003064 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02003065 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3066 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02003067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068 /* set connection select to line in (default select for this ADC) */
3069 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02003070 /* mute capture amp left and right */
3071 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3072 /* set connection select to line in (default select for this ADC) */
3073 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02003074 /* set vol=0 Line-Out mixer amp left and right */
3075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3076 /* unmute pin widget amp left and right (no gain on this amp) */
3077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3078 /* set vol=0 HP mixer amp left and right */
3079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3080 /* unmute pin widget amp left and right (no gain on this amp) */
3081 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3082 /* set vol=0 Mono mixer amp left and right */
3083 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3084 /* unmute pin widget amp left and right (no gain on this amp) */
3085 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3086 /* unmute LINE-2 out pin */
3087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003088 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003089 /* mute CD */
Takashi Iwai16ded522005-06-10 19:58:24 +02003090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003091 /* mute Line In */
Takashi Iwai16ded522005-06-10 19:58:24 +02003092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003093 /* mute Mic */
Takashi Iwai16ded522005-06-10 19:58:24 +02003094 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003096 /* mute Front out path */
3097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3099 /* mute Headphone out path */
3100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3101 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3102 /* mute Mono out path */
3103 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3104 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003105 { }
3106};
3107
Kailang Yangdf694da2005-12-05 19:42:22 +01003108static struct hda_verb alc260_hp_init_verbs[] = {
3109 /* Headphone and output */
3110 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3111 /* mono output */
3112 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3113 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3114 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3115 /* Mic2 (front panel) pin widget for input and vref at 80% */
3116 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3117 /* Line In pin widget for input */
3118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3119 /* Line-2 pin widget for output */
3120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3121 /* CD pin widget for input */
3122 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3123 /* unmute amp left and right */
3124 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3125 /* set connection select to line in (default select for this ADC) */
3126 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3127 /* unmute Line-Out mixer amp left and right (volume = 0) */
3128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3129 /* mute pin widget amp left and right (no gain on this amp) */
3130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3131 /* unmute HP mixer amp left and right (volume = 0) */
3132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3133 /* mute pin widget amp left and right (no gain on this amp) */
3134 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3135 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3136 /* unmute CD */
3137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3138 /* unmute Line In */
3139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3140 /* unmute Mic */
3141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3142 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3143 /* Unmute Front out path */
3144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3146 /* Unmute Headphone out path */
3147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3149 /* Unmute Mono out path */
3150 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3151 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3152 { }
3153};
3154
3155static struct hda_verb alc260_hp_3013_init_verbs[] = {
3156 /* Line out and output */
3157 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3158 /* mono output */
3159 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3160 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3161 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3162 /* Mic2 (front panel) pin widget for input and vref at 80% */
3163 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3164 /* Line In pin widget for input */
3165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3166 /* Headphone pin widget for output */
3167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3168 /* CD pin widget for input */
3169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3170 /* unmute amp left and right */
3171 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3172 /* set connection select to line in (default select for this ADC) */
3173 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3174 /* unmute Line-Out mixer amp left and right (volume = 0) */
3175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3176 /* mute pin widget amp left and right (no gain on this amp) */
3177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3178 /* unmute HP mixer amp left and right (volume = 0) */
3179 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3180 /* mute pin widget amp left and right (no gain on this amp) */
3181 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3182 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3183 /* unmute CD */
3184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3185 /* unmute Line In */
3186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3187 /* unmute Mic */
3188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3189 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3190 /* Unmute Front out path */
3191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3192 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3193 /* Unmute Headphone out path */
3194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3196 /* Unmute Mono out path */
3197 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3198 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3199 { }
3200};
3201
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003202/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003203 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3204 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003205 */
3206static struct hda_verb alc260_fujitsu_init_verbs[] = {
3207 /* Disable all GPIOs */
3208 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3209 /* Internal speaker is connected to headphone pin */
3210 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3211 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003213 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3214 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3215 /* Ensure all other unused pins are disabled and muted. */
3216 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3217 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003218 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003219 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003220 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003221 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003224
Jonathan Woithef7ace402006-02-28 11:46:14 +01003225 /* Disable digital (SPDIF) pins */
3226 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3227 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003228
Jonathan Woithef7ace402006-02-28 11:46:14 +01003229 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3230 * when acting as an output.
3231 */
3232 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3233
3234 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01003235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3242 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3243 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003244
Jonathan Woithef7ace402006-02-28 11:46:14 +01003245 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3246 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3247 /* Unmute Line1 pin widget output buffer since it starts as an output.
3248 * If the pin mode is changed by the user the pin mode control will
3249 * take care of enabling the pin's input/output buffers as needed.
3250 * Therefore there's no need to enable the input buffer at this
3251 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003252 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003254 /* Unmute input buffer of pin widget used for Line-in (no equiv
3255 * mixer ctrl)
3256 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01003257 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003258
Jonathan Woithef7ace402006-02-28 11:46:14 +01003259 /* Mute capture amp left and right */
3260 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3261 /* Set ADC connection select to match default mixer setting - line
3262 * in (on mic1 pin)
3263 */
3264 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003265
Jonathan Woithef7ace402006-02-28 11:46:14 +01003266 /* Do the same for the second ADC: mute capture input amp and
3267 * set ADC connection to line in (on mic1 pin)
3268 */
3269 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3270 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003271
Jonathan Woithef7ace402006-02-28 11:46:14 +01003272 /* Mute all inputs to mixer widget (even unconnected ones) */
3273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003281
3282 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003283};
3284
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003285/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3286 * similar laptops (adapted from Fujitsu init verbs).
3287 */
3288static struct hda_verb alc260_acer_init_verbs[] = {
3289 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3290 * the headphone jack. Turn this on and rely on the standard mute
3291 * methods whenever the user wants to turn these outputs off.
3292 */
3293 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3294 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3295 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3296 /* Internal speaker/Headphone jack is connected to Line-out pin */
3297 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3298 /* Internal microphone/Mic jack is connected to Mic1 pin */
3299 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3300 /* Line In jack is connected to Line1 pin */
3301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3302 /* Ensure all other unused pins are disabled and muted. */
3303 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3304 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3305 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3306 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3307 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3308 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3311 /* Disable digital (SPDIF) pins */
3312 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3313 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3314
3315 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3316 * bus when acting as outputs.
3317 */
3318 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3319 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3320
3321 /* Start with output sum widgets muted and their output gains at min */
3322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3323 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3328 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3329 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3330 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3331
3332 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3333 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3334 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3335 * inputs. If the pin mode is changed by the user the pin mode control
3336 * will take care of enabling the pin's input/output buffers as needed.
3337 * Therefore there's no need to enable the input buffer at this
3338 * stage.
3339 */
3340 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3342
3343 /* Mute capture amp left and right */
3344 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3345 /* Set ADC connection select to match default mixer setting - mic
3346 * (on mic1 pin)
3347 */
3348 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3349
3350 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003351 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003352 */
3353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003354 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003355
3356 /* Mute all inputs to mixer widget (even unconnected ones) */
3357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3365
3366 { }
3367};
3368
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003369/* Test configuration for debugging, modelled after the ALC880 test
3370 * configuration.
3371 */
3372#ifdef CONFIG_SND_DEBUG
3373static hda_nid_t alc260_test_dac_nids[1] = {
3374 0x02,
3375};
3376static hda_nid_t alc260_test_adc_nids[2] = {
3377 0x04, 0x05,
3378};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003379/* For testing the ALC260, each input MUX needs its own definition since
3380 * the signal assignments are different. This assumes that the first ADC
3381 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003382 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003383static struct hda_input_mux alc260_test_capture_sources[2] = {
3384 {
3385 .num_items = 7,
3386 .items = {
3387 { "MIC1 pin", 0x0 },
3388 { "MIC2 pin", 0x1 },
3389 { "LINE1 pin", 0x2 },
3390 { "LINE2 pin", 0x3 },
3391 { "CD pin", 0x4 },
3392 { "LINE-OUT pin", 0x5 },
3393 { "HP-OUT pin", 0x6 },
3394 },
3395 },
3396 {
3397 .num_items = 8,
3398 .items = {
3399 { "MIC1 pin", 0x0 },
3400 { "MIC2 pin", 0x1 },
3401 { "LINE1 pin", 0x2 },
3402 { "LINE2 pin", 0x3 },
3403 { "CD pin", 0x4 },
3404 { "Mixer", 0x5 },
3405 { "LINE-OUT pin", 0x6 },
3406 { "HP-OUT pin", 0x7 },
3407 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003408 },
3409};
3410static struct snd_kcontrol_new alc260_test_mixer[] = {
3411 /* Output driver widgets */
3412 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3413 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3414 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3415 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3416 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3417 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3418
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003419 /* Modes for retasking pin widgets
3420 * Note: the ALC260 doesn't seem to act on requests to enable mic
3421 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3422 * mention this restriction. At this stage it's not clear whether
3423 * this behaviour is intentional or is a hardware bug in chip
3424 * revisions available at least up until early 2006. Therefore for
3425 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3426 * choices, but if it turns out that the lack of mic bias for these
3427 * NIDs is intentional we could change their modes from
3428 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3429 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003430 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3431 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3432 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3433 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3434 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3435 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3436
3437 /* Loopback mixer controls */
3438 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3439 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3440 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3441 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3442 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3443 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3444 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3445 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3446 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3447 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3448 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3449 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3450 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3451 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3452 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3453 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003454
3455 /* Controls for GPIO pins, assuming they are configured as outputs */
3456 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3457 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3458 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3459 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3460
Jonathan Woithe92621f12006-02-28 11:47:47 +01003461 /* Switches to allow the digital IO pins to be enabled. The datasheet
3462 * is ambigious as to which NID is which; testing on laptops which
3463 * make this output available should provide clarification.
3464 */
3465 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3466 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3467
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003468 { } /* end */
3469};
3470static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01003471 /* Enable all GPIOs as outputs with an initial value of 0 */
3472 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3473 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3474 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3475
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003476 /* Enable retasking pins as output, initially without power amp */
3477 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3478 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3481 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3483
Jonathan Woithe92621f12006-02-28 11:47:47 +01003484 /* Disable digital (SPDIF) pins initially, but users can enable
3485 * them via a mixer switch. In the case of SPDIF-out, this initverb
3486 * payload also sets the generation to 0, output to be in "consumer"
3487 * PCM format, copyright asserted, no pre-emphasis and no validity
3488 * control.
3489 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003490 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3491 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3492
Jonathan Woithef7ace402006-02-28 11:46:14 +01003493 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003494 * OUT1 sum bus when acting as an output.
3495 */
3496 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3497 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3498 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3499 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3500
3501 /* Start with output sum widgets muted and their output gains at min */
3502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3510 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3511
Jonathan Woithecdcd9262006-02-28 11:36:42 +01003512 /* Unmute retasking pin widget output buffers since the default
3513 * state appears to be output. As the pin mode is changed by the
3514 * user the pin mode control will take care of enabling the pin's
3515 * input/output buffers as needed.
3516 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003517 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3522 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 /* Also unmute the mono-out pin widget */
3524 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3525
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003526 /* Mute capture amp left and right */
3527 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01003528 /* Set ADC connection select to match default mixer setting (mic1
3529 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003530 */
3531 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3532
3533 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01003534 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003535 */
3536 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3537 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3538
3539 /* Mute all inputs to mixer widget (even unconnected ones) */
3540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3548
3549 { }
3550};
3551#endif
3552
Linus Torvalds1da177e2005-04-16 15:20:36 -07003553static struct hda_pcm_stream alc260_pcm_analog_playback = {
3554 .substreams = 1,
3555 .channels_min = 2,
3556 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003557};
3558
3559static struct hda_pcm_stream alc260_pcm_analog_capture = {
3560 .substreams = 1,
3561 .channels_min = 2,
3562 .channels_max = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003563};
3564
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003565#define alc260_pcm_digital_playback alc880_pcm_digital_playback
3566#define alc260_pcm_digital_capture alc880_pcm_digital_capture
3567
Kailang Yangdf694da2005-12-05 19:42:22 +01003568/*
3569 * for BIOS auto-configuration
3570 */
3571
3572static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3573 const char *pfx)
3574{
3575 hda_nid_t nid_vol;
3576 unsigned long vol_val, sw_val;
3577 char name[32];
3578 int err;
3579
3580 if (nid >= 0x0f && nid < 0x11) {
3581 nid_vol = nid - 0x7;
3582 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3583 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3584 } else if (nid == 0x11) {
3585 nid_vol = nid - 0x7;
3586 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3587 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3588 } else if (nid >= 0x12 && nid <= 0x15) {
3589 nid_vol = 0x08;
3590 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3591 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3592 } else
3593 return 0; /* N/A */
3594
3595 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3596 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3597 return err;
3598 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3599 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3600 return err;
3601 return 1;
3602}
3603
3604/* add playback controls from the parsed DAC table */
3605static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3606 const struct auto_pin_cfg *cfg)
3607{
3608 hda_nid_t nid;
3609 int err;
3610
3611 spec->multiout.num_dacs = 1;
3612 spec->multiout.dac_nids = spec->private_dac_nids;
3613 spec->multiout.dac_nids[0] = 0x02;
3614
3615 nid = cfg->line_out_pins[0];
3616 if (nid) {
3617 err = alc260_add_playback_controls(spec, nid, "Front");
3618 if (err < 0)
3619 return err;
3620 }
3621
Takashi Iwai82bc9552006-03-21 11:24:42 +01003622 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003623 if (nid) {
3624 err = alc260_add_playback_controls(spec, nid, "Speaker");
3625 if (err < 0)
3626 return err;
3627 }
3628
3629 nid = cfg->hp_pin;
3630 if (nid) {
3631 err = alc260_add_playback_controls(spec, nid, "Headphone");
3632 if (err < 0)
3633 return err;
3634 }
3635 return 0;
3636}
3637
3638/* create playback/capture controls for input pins */
3639static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3640 const struct auto_pin_cfg *cfg)
3641{
Kailang Yangdf694da2005-12-05 19:42:22 +01003642 struct hda_input_mux *imux = &spec->private_imux;
3643 int i, err, idx;
3644
3645 for (i = 0; i < AUTO_PIN_LAST; i++) {
3646 if (cfg->input_pins[i] >= 0x12) {
3647 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003648 err = new_analog_input(spec, cfg->input_pins[i],
3649 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003650 if (err < 0)
3651 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003652 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003653 imux->items[imux->num_items].index = idx;
3654 imux->num_items++;
3655 }
3656 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3657 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003658 err = new_analog_input(spec, cfg->input_pins[i],
3659 auto_pin_cfg_labels[i], idx, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01003660 if (err < 0)
3661 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003662 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01003663 imux->items[imux->num_items].index = idx;
3664 imux->num_items++;
3665 }
3666 }
3667 return 0;
3668}
3669
3670static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3671 hda_nid_t nid, int pin_type,
3672 int sel_idx)
3673{
3674 /* set as output */
3675 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3676 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3677 /* need the manual connection? */
3678 if (nid >= 0x12) {
3679 int idx = nid - 0x12;
3680 snd_hda_codec_write(codec, idx + 0x0b, 0,
3681 AC_VERB_SET_CONNECT_SEL, sel_idx);
3682
3683 }
3684}
3685
3686static void alc260_auto_init_multi_out(struct hda_codec *codec)
3687{
3688 struct alc_spec *spec = codec->spec;
3689 hda_nid_t nid;
3690
3691 nid = spec->autocfg.line_out_pins[0];
3692 if (nid)
3693 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3694
Takashi Iwai82bc9552006-03-21 11:24:42 +01003695 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01003696 if (nid)
3697 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3698
3699 nid = spec->autocfg.hp_pin;
3700 if (nid)
3701 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3702}
3703
3704#define ALC260_PIN_CD_NID 0x16
3705static void alc260_auto_init_analog_input(struct hda_codec *codec)
3706{
3707 struct alc_spec *spec = codec->spec;
3708 int i;
3709
3710 for (i = 0; i < AUTO_PIN_LAST; i++) {
3711 hda_nid_t nid = spec->autocfg.input_pins[i];
3712 if (nid >= 0x12) {
3713 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3714 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3715 if (nid != ALC260_PIN_CD_NID)
3716 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3717 AMP_OUT_MUTE);
3718 }
3719 }
3720}
3721
3722/*
3723 * generic initialization of ADC, input mixers and output mixers
3724 */
3725static struct hda_verb alc260_volume_init_verbs[] = {
3726 /*
3727 * Unmute ADC0-1 and set the default input to mic-in
3728 */
3729 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3730 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3731 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3732 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3733
3734 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3735 * mixer widget
3736 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3737 * mic (mic 2)
3738 */
3739 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3743 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3745
3746 /*
3747 * Set up output mixers (0x08 - 0x0a)
3748 */
3749 /* set vol=0 to output mixers */
3750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3751 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3752 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3753 /* set up input amps for analog loopback */
3754 /* Amp Indices: DAC = 0, mixer = 1 */
3755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3759 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3760 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3761
3762 { }
3763};
3764
3765static int alc260_parse_auto_config(struct hda_codec *codec)
3766{
3767 struct alc_spec *spec = codec->spec;
3768 unsigned int wcap;
3769 int err;
3770 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3771
3772 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3773 alc260_ignore)) < 0)
3774 return err;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003775 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3776 return err;
3777 if (! spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01003778 return 0; /* can't find valid BIOS pin config */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003779 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01003780 return err;
3781
3782 spec->multiout.max_channels = 2;
3783
3784 if (spec->autocfg.dig_out_pin)
3785 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3786 if (spec->kctl_alloc)
3787 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3788
3789 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3790
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003791 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01003792 spec->input_mux = &spec->private_imux;
3793
3794 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01003795 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01003796 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3797 if (wcap != AC_WID_AUD_IN) {
3798 spec->adc_nids = alc260_adc_nids_alt;
3799 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3800 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003801 } else {
3802 spec->adc_nids = alc260_adc_nids;
3803 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3804 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01003805 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003806 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01003807
3808 return 1;
3809}
3810
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003811/* additional initialization for auto-configuration model */
3812static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01003813{
Kailang Yangdf694da2005-12-05 19:42:22 +01003814 alc260_auto_init_multi_out(codec);
3815 alc260_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01003816}
3817
3818/*
3819 * ALC260 configurations
3820 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003821static struct hda_board_config alc260_cfg_tbl[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01003822 { .modelname = "basic", .config = ALC260_BASIC },
Takashi Iwaib14e77e2006-01-11 18:10:50 +01003823 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3824 .config = ALC260_BASIC }, /* Sony VAIO */
Kenneth Crudup5e1b1512006-04-28 13:03:48 +02003825 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3826 .config = ALC260_BASIC }, /* Sony VAIO */
Takashi Iwaic1fc8042006-03-06 14:17:31 +01003827 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3828 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
Takashi Iwai16ded522005-06-10 19:58:24 +02003829 { .modelname = "hp", .config = ALC260_HP },
Kailang Yangdf694da2005-12-05 19:42:22 +01003830 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3831 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3832 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
3833 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3834 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3835 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3836 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3837 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3838 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003839 { .modelname = "acer", .config = ALC260_ACER },
3840 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003841#ifdef CONFIG_SND_DEBUG
3842 { .modelname = "test", .config = ALC260_TEST },
3843#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003844 { .modelname = "auto", .config = ALC260_AUTO },
Takashi Iwai16ded522005-06-10 19:58:24 +02003845 {}
3846};
3847
Kailang Yangdf694da2005-12-05 19:42:22 +01003848static struct alc_config_preset alc260_presets[] = {
3849 [ALC260_BASIC] = {
3850 .mixers = { alc260_base_output_mixer,
3851 alc260_input_mixer,
3852 alc260_pc_beep_mixer,
3853 alc260_capture_mixer },
3854 .init_verbs = { alc260_init_verbs },
3855 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3856 .dac_nids = alc260_dac_nids,
3857 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3858 .adc_nids = alc260_adc_nids,
3859 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3860 .channel_mode = alc260_modes,
3861 .input_mux = &alc260_capture_source,
3862 },
3863 [ALC260_HP] = {
3864 .mixers = { alc260_base_output_mixer,
3865 alc260_input_mixer,
3866 alc260_capture_alt_mixer },
3867 .init_verbs = { alc260_hp_init_verbs },
3868 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3869 .dac_nids = alc260_dac_nids,
3870 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3871 .adc_nids = alc260_hp_adc_nids,
3872 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3873 .channel_mode = alc260_modes,
3874 .input_mux = &alc260_capture_source,
3875 },
3876 [ALC260_HP_3013] = {
3877 .mixers = { alc260_hp_3013_mixer,
3878 alc260_input_mixer,
3879 alc260_capture_alt_mixer },
3880 .init_verbs = { alc260_hp_3013_init_verbs },
3881 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3882 .dac_nids = alc260_dac_nids,
3883 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3884 .adc_nids = alc260_hp_adc_nids,
3885 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3886 .channel_mode = alc260_modes,
3887 .input_mux = &alc260_capture_source,
3888 },
3889 [ALC260_FUJITSU_S702X] = {
3890 .mixers = { alc260_fujitsu_mixer,
3891 alc260_capture_mixer },
3892 .init_verbs = { alc260_fujitsu_init_verbs },
3893 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3894 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003895 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3896 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01003897 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3898 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003899 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
3900 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01003901 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003902 [ALC260_ACER] = {
3903 .mixers = { alc260_acer_mixer,
3904 alc260_capture_mixer },
3905 .init_verbs = { alc260_acer_init_verbs },
3906 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3907 .dac_nids = alc260_dac_nids,
3908 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3909 .adc_nids = alc260_dual_adc_nids,
3910 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3911 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003912 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
3913 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003914 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003915#ifdef CONFIG_SND_DEBUG
3916 [ALC260_TEST] = {
3917 .mixers = { alc260_test_mixer,
3918 alc260_capture_mixer },
3919 .init_verbs = { alc260_test_init_verbs },
3920 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
3921 .dac_nids = alc260_test_dac_nids,
3922 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
3923 .adc_nids = alc260_test_adc_nids,
3924 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3925 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003926 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
3927 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01003928 },
3929#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01003930};
3931
Linus Torvalds1da177e2005-04-16 15:20:36 -07003932static int patch_alc260(struct hda_codec *codec)
3933{
3934 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01003935 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003936
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003937 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003938 if (spec == NULL)
3939 return -ENOMEM;
3940
3941 codec->spec = spec;
3942
Takashi Iwai16ded522005-06-10 19:58:24 +02003943 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3944 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3945 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01003946 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02003947 }
3948
Kailang Yangdf694da2005-12-05 19:42:22 +01003949 if (board_config == ALC260_AUTO) {
3950 /* automatic parse from the BIOS config */
3951 err = alc260_parse_auto_config(codec);
3952 if (err < 0) {
3953 alc_free(codec);
3954 return err;
3955 } else if (! err) {
3956 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3957 board_config = ALC260_BASIC;
3958 }
Takashi Iwai16ded522005-06-10 19:58:24 +02003959 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003960
Kailang Yangdf694da2005-12-05 19:42:22 +01003961 if (board_config != ALC260_AUTO)
3962 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963
3964 spec->stream_name_analog = "ALC260 Analog";
3965 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3966 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3967
Takashi Iwaia3bcba32005-12-06 19:05:29 +01003968 spec->stream_name_digital = "ALC260 Digital";
3969 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3970 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3971
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01003973 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003974 spec->init_hook = alc260_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003975
3976 return 0;
3977}
3978
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003979
Linus Torvalds1da177e2005-04-16 15:20:36 -07003980/*
3981 * ALC882 support
3982 *
3983 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3984 * configuration. Each pin widget can choose any input DACs and a mixer.
3985 * Each ADC is connected from a mixer of all inputs. This makes possible
3986 * 6-channel independent captures.
3987 *
3988 * In addition, an independent DAC for the multi-playback (not used in this
3989 * driver yet).
3990 */
Kailang Yangdf694da2005-12-05 19:42:22 +01003991#define ALC882_DIGOUT_NID 0x06
3992#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07003993
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003994static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003995 { 8, NULL }
3996};
3997
3998static hda_nid_t alc882_dac_nids[4] = {
3999 /* front, rear, clfe, rear_surr */
4000 0x02, 0x03, 0x04, 0x05
4001};
4002
Kailang Yangdf694da2005-12-05 19:42:22 +01004003/* identical with ALC880 */
4004#define alc882_adc_nids alc880_adc_nids
4005#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07004006
4007/* input MUX */
4008/* FIXME: should be a matrix-type input source selection */
4009
4010static struct hda_input_mux alc882_capture_source = {
4011 .num_items = 4,
4012 .items = {
4013 { "Mic", 0x0 },
4014 { "Front Mic", 0x1 },
4015 { "Line", 0x2 },
4016 { "CD", 0x4 },
4017 },
4018};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004019#define alc882_mux_enum_info alc_mux_enum_info
4020#define alc882_mux_enum_get alc_mux_enum_get
4021
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004022static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004023{
4024 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4025 struct alc_spec *spec = codec->spec;
4026 const struct hda_input_mux *imux = spec->input_mux;
4027 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4028 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4029 hda_nid_t nid = capture_mixers[adc_idx];
4030 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4031 unsigned int i, idx;
4032
4033 idx = ucontrol->value.enumerated.item[0];
4034 if (idx >= imux->num_items)
4035 idx = imux->num_items - 1;
4036 if (*cur_val == idx && ! codec->in_resume)
4037 return 0;
4038 for (i = 0; i < imux->num_items; i++) {
4039 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4040 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4041 v | (imux->items[i].index << 8));
4042 }
4043 *cur_val = idx;
4044 return 1;
4045}
4046
Kailang Yangdf694da2005-12-05 19:42:22 +01004047/*
4048 * 6ch mode
4049 */
4050static struct hda_verb alc882_sixstack_ch6_init[] = {
4051 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4052 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4053 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4054 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4055 { } /* end */
4056};
4057
4058/*
4059 * 8ch mode
4060 */
4061static struct hda_verb alc882_sixstack_ch8_init[] = {
4062 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4063 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4064 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4065 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4066 { } /* end */
4067};
4068
4069static struct hda_channel_mode alc882_sixstack_modes[2] = {
4070 { 6, alc882_sixstack_ch6_init },
4071 { 8, alc882_sixstack_ch8_init },
4072};
4073
Linus Torvalds1da177e2005-04-16 15:20:36 -07004074/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4075 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4076 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004077static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004078 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004079 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004080 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004081 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004082 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4083 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004084 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4085 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02004086 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004087 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4091 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4092 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4094 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4095 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4097 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4098 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4099 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4100 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4101 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4102 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4103 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4104 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4105 {
4106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4107 /* .name = "Capture Source", */
4108 .name = "Input Source",
4109 .count = 3,
4110 .info = alc882_mux_enum_info,
4111 .get = alc882_mux_enum_get,
4112 .put = alc882_mux_enum_put,
4113 },
4114 { } /* end */
4115};
4116
Kailang Yangdf694da2005-12-05 19:42:22 +01004117static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4118 {
4119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4120 .name = "Channel Mode",
4121 .info = alc_ch_mode_info,
4122 .get = alc_ch_mode_get,
4123 .put = alc_ch_mode_put,
4124 },
4125 { } /* end */
4126};
4127
Linus Torvalds1da177e2005-04-16 15:20:36 -07004128static struct hda_verb alc882_init_verbs[] = {
4129 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004133 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004137 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004141 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02004142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004145
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004146 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004147 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004148 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004149 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004150 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004151 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004153 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004155 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004156 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004157 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004158 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02004159 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02004160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004161 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004162 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4165 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004167 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4168 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4171 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4174 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004175 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004176 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004177
4178 /* FIXME: use matrix-type input source selection */
4179 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4180 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02004181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004185 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004190 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4195 /* ADC1: mute amp left and right */
4196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004197 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004198 /* ADC2: mute amp left and right */
4199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004200 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004201 /* ADC3: mute amp left and right */
4202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004204
4205 { }
4206};
4207
Kailang Yangdf694da2005-12-05 19:42:22 +01004208/*
4209 * generic initialization of ADC, input mixers and output mixers
4210 */
4211static struct hda_verb alc882_auto_init_verbs[] = {
4212 /*
4213 * Unmute ADC0-2 and set the default input to mic-in
4214 */
4215 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4217 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4219 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4221
4222 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4223 * mixer widget
4224 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4225 * mic (mic 2)
4226 */
4227 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4233
4234 /*
4235 * Set up output mixers (0x0c - 0x0f)
4236 */
4237 /* set vol=0 to output mixers */
4238 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4239 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4242 /* set up input amps for analog loopback */
4243 /* Amp Indices: DAC = 0, mixer = 1 */
4244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4250 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4251 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4252 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4253 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4254
4255 /* FIXME: use matrix-type input source selection */
4256 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4257 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4258 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4259 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4260 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4261 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4262 /* Input mixer2 */
4263 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4264 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4265 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4266 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4267 /* Input mixer3 */
4268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4272
4273 { }
4274};
4275
4276/* capture mixer elements */
4277static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4278 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4279 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4280 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4281 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4282 {
4283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4284 /* The multiple "Capture Source" controls confuse alsamixer
4285 * So call somewhat different..
4286 * FIXME: the controls appear in the "playback" view!
4287 */
4288 /* .name = "Capture Source", */
4289 .name = "Input Source",
4290 .count = 2,
4291 .info = alc882_mux_enum_info,
4292 .get = alc882_mux_enum_get,
4293 .put = alc882_mux_enum_put,
4294 },
4295 { } /* end */
4296};
4297
4298static struct snd_kcontrol_new alc882_capture_mixer[] = {
4299 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4300 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4301 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4302 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4303 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4304 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4305 {
4306 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4307 /* The multiple "Capture Source" controls confuse alsamixer
4308 * So call somewhat different..
4309 * FIXME: the controls appear in the "playback" view!
4310 */
4311 /* .name = "Capture Source", */
4312 .name = "Input Source",
4313 .count = 3,
4314 .info = alc882_mux_enum_info,
4315 .get = alc882_mux_enum_get,
4316 .put = alc882_mux_enum_put,
4317 },
4318 { } /* end */
4319};
4320
4321/* pcm configuration: identiacal with ALC880 */
4322#define alc882_pcm_analog_playback alc880_pcm_analog_playback
4323#define alc882_pcm_analog_capture alc880_pcm_analog_capture
4324#define alc882_pcm_digital_playback alc880_pcm_digital_playback
4325#define alc882_pcm_digital_capture alc880_pcm_digital_capture
4326
4327/*
4328 * configuration and preset
4329 */
4330static struct hda_board_config alc882_cfg_tbl[] = {
Takashi Iwai1494a922006-01-31 10:58:46 +01004331 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4332 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
Kailang Yangdf694da2005-12-05 19:42:22 +01004333 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
4334 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
4335 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
Takashi Iwai1494a922006-01-31 10:58:46 +01004336 { .modelname = "auto", .config = ALC882_AUTO },
Kailang Yangdf694da2005-12-05 19:42:22 +01004337 {}
4338};
4339
4340static struct alc_config_preset alc882_presets[] = {
4341 [ALC882_3ST_DIG] = {
4342 .mixers = { alc882_base_mixer },
4343 .init_verbs = { alc882_init_verbs },
4344 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4345 .dac_nids = alc882_dac_nids,
4346 .dig_out_nid = ALC882_DIGOUT_NID,
4347 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4348 .adc_nids = alc882_adc_nids,
4349 .dig_in_nid = ALC882_DIGIN_NID,
4350 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4351 .channel_mode = alc882_ch_modes,
4352 .input_mux = &alc882_capture_source,
4353 },
4354 [ALC882_6ST_DIG] = {
4355 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4356 .init_verbs = { alc882_init_verbs },
4357 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4358 .dac_nids = alc882_dac_nids,
4359 .dig_out_nid = ALC882_DIGOUT_NID,
4360 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4361 .adc_nids = alc882_adc_nids,
4362 .dig_in_nid = ALC882_DIGIN_NID,
4363 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4364 .channel_mode = alc882_sixstack_modes,
4365 .input_mux = &alc882_capture_source,
4366 },
4367};
4368
4369
4370/*
4371 * BIOS auto configuration
4372 */
4373static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4374 hda_nid_t nid, int pin_type,
4375 int dac_idx)
4376{
4377 /* set as output */
4378 struct alc_spec *spec = codec->spec;
4379 int idx;
4380
4381 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4382 idx = 4;
4383 else
4384 idx = spec->multiout.dac_nids[dac_idx] - 2;
4385
4386 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4387 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4388 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4389
4390}
4391
4392static void alc882_auto_init_multi_out(struct hda_codec *codec)
4393{
4394 struct alc_spec *spec = codec->spec;
4395 int i;
4396
4397 for (i = 0; i <= HDA_SIDE; i++) {
4398 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4399 if (nid)
4400 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4401 }
4402}
4403
4404static void alc882_auto_init_hp_out(struct hda_codec *codec)
4405{
4406 struct alc_spec *spec = codec->spec;
4407 hda_nid_t pin;
4408
4409 pin = spec->autocfg.hp_pin;
4410 if (pin) /* connect to front */
4411 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4412}
4413
4414#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4415#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4416
4417static void alc882_auto_init_analog_input(struct hda_codec *codec)
4418{
4419 struct alc_spec *spec = codec->spec;
4420 int i;
4421
4422 for (i = 0; i < AUTO_PIN_LAST; i++) {
4423 hda_nid_t nid = spec->autocfg.input_pins[i];
4424 if (alc882_is_input_pin(nid)) {
4425 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4426 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4427 if (nid != ALC882_PIN_CD_NID)
4428 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4429 AMP_OUT_MUTE);
4430 }
4431 }
4432}
4433
4434/* almost identical with ALC880 parser... */
4435static int alc882_parse_auto_config(struct hda_codec *codec)
4436{
4437 struct alc_spec *spec = codec->spec;
4438 int err = alc880_parse_auto_config(codec);
4439
4440 if (err < 0)
4441 return err;
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004442 else if (err > 0)
4443 /* hack - override the init verbs */
4444 spec->init_verbs[0] = alc882_auto_init_verbs;
4445 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004446}
4447
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004448/* additional initialization for auto-configuration model */
4449static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004450{
Kailang Yangdf694da2005-12-05 19:42:22 +01004451 alc882_auto_init_multi_out(codec);
4452 alc882_auto_init_hp_out(codec);
4453 alc882_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004454}
4455
4456/*
4457 * ALC882 Headphone poll in 3.5.1a or 3.5.2
4458 */
4459
Linus Torvalds1da177e2005-04-16 15:20:36 -07004460static int patch_alc882(struct hda_codec *codec)
4461{
4462 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01004463 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004464
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004465 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004466 if (spec == NULL)
4467 return -ENOMEM;
4468
Linus Torvalds1da177e2005-04-16 15:20:36 -07004469 codec->spec = spec;
4470
Kailang Yangdf694da2005-12-05 19:42:22 +01004471 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004472
Kailang Yangdf694da2005-12-05 19:42:22 +01004473 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4474 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
4475 board_config = ALC882_AUTO;
4476 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477
Kailang Yangdf694da2005-12-05 19:42:22 +01004478 if (board_config == ALC882_AUTO) {
4479 /* automatic parse from the BIOS config */
4480 err = alc882_parse_auto_config(codec);
4481 if (err < 0) {
4482 alc_free(codec);
4483 return err;
4484 } else if (! err) {
4485 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4486 board_config = ALC882_3ST_DIG;
4487 }
4488 }
4489
4490 if (board_config != ALC882_AUTO)
4491 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004492
4493 spec->stream_name_analog = "ALC882 Analog";
Kailang Yangdf694da2005-12-05 19:42:22 +01004494 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4495 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004496
4497 spec->stream_name_digital = "ALC882 Digital";
Kailang Yangdf694da2005-12-05 19:42:22 +01004498 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4499 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004500
Kailang Yangdf694da2005-12-05 19:42:22 +01004501 if (! spec->adc_nids && spec->input_mux) {
4502 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004503 unsigned int wcap = get_wcaps(codec, 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01004504 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4505 if (wcap != AC_WID_AUD_IN) {
4506 spec->adc_nids = alc882_adc_nids_alt;
4507 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4508 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4509 spec->num_mixers++;
4510 } else {
4511 spec->adc_nids = alc882_adc_nids;
4512 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4513 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4514 spec->num_mixers++;
4515 }
4516 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004517
4518 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01004519 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004520 spec->init_hook = alc882_auto_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004521
4522 return 0;
4523}
4524
4525/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004526 * ALC262 support
4527 */
4528
4529#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
4530#define ALC262_DIGIN_NID ALC880_DIGIN_NID
4531
4532#define alc262_dac_nids alc260_dac_nids
4533#define alc262_adc_nids alc882_adc_nids
4534#define alc262_adc_nids_alt alc882_adc_nids_alt
4535
4536#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01004537#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01004538
4539static struct snd_kcontrol_new alc262_base_mixer[] = {
4540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4541 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4542 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4543 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4544 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4545 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4548 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
4549 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
4550 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
4551 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
4552 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
4553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4554 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4555 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004556 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01004557};
4558
Kailang Yangdf694da2005-12-05 19:42:22 +01004559#define alc262_capture_mixer alc882_capture_mixer
4560#define alc262_capture_alt_mixer alc882_capture_alt_mixer
4561
4562/*
4563 * generic initialization of ADC, input mixers and output mixers
4564 */
4565static struct hda_verb alc262_init_verbs[] = {
4566 /*
4567 * Unmute ADC0-2 and set the default input to mic-in
4568 */
4569 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4571 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4573 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4575
4576 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4577 * mixer widget
4578 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4579 * mic (mic 2)
4580 */
4581 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4584 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4585 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4586 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4587
4588 /*
4589 * Set up output mixers (0x0c - 0x0e)
4590 */
4591 /* set vol=0 to output mixers */
4592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4593 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4594 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4595 /* set up input amps for analog loopback */
4596 /* Amp Indices: DAC = 0, mixer = 1 */
4597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4599 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4600 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4601 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4602 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4603
4604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4606 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4607 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4608 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4609 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4610
4611 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4612 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4613 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4614 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4615 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4616
4617 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4619
4620 /* FIXME: use matrix-type input source selection */
4621 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4622 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4623 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4624 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4625 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4627 /* Input mixer2 */
4628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4629 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4630 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4631 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4632 /* Input mixer3 */
4633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4634 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4637
4638 { }
4639};
4640
Takashi Iwai834be882006-03-01 14:16:17 +01004641/*
4642 * fujitsu model
4643 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
4644 */
4645
4646#define ALC_HP_EVENT 0x37
4647
4648static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
4649 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
4650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4651 {}
4652};
4653
4654static struct hda_input_mux alc262_fujitsu_capture_source = {
4655 .num_items = 2,
4656 .items = {
4657 { "Mic", 0x0 },
4658 { "CD", 0x4 },
4659 },
4660};
4661
4662/* mute/unmute internal speaker according to the hp jack and mute state */
4663static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
4664{
4665 struct alc_spec *spec = codec->spec;
4666 unsigned int mute;
4667
4668 if (force || ! spec->sense_updated) {
4669 unsigned int present;
4670 /* need to execute and sync at first */
4671 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
4672 present = snd_hda_codec_read(codec, 0x14, 0,
4673 AC_VERB_GET_PIN_SENSE, 0);
4674 spec->jack_present = (present & 0x80000000) != 0;
4675 spec->sense_updated = 1;
4676 }
4677 if (spec->jack_present) {
4678 /* mute internal speaker */
4679 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4680 0x80, 0x80);
4681 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4682 0x80, 0x80);
4683 } else {
4684 /* unmute internal speaker if necessary */
4685 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
4686 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4687 0x80, mute & 0x80);
4688 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
4689 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4690 0x80, mute & 0x80);
4691 }
4692}
4693
4694/* unsolicited event for HP jack sensing */
4695static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
4696 unsigned int res)
4697{
4698 if ((res >> 26) != ALC_HP_EVENT)
4699 return;
4700 alc262_fujitsu_automute(codec, 1);
4701}
4702
4703/* bind volumes of both NID 0x0c and 0x0d */
4704static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
4705 struct snd_ctl_elem_value *ucontrol)
4706{
4707 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4708 long *valp = ucontrol->value.integer.value;
4709 int change;
4710
4711 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
4712 0x7f, valp[0] & 0x7f);
4713 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
4714 0x7f, valp[1] & 0x7f);
4715 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
4716 0x7f, valp[0] & 0x7f);
4717 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
4718 0x7f, valp[1] & 0x7f);
4719 return change;
4720}
4721
4722/* bind hp and internal speaker mute (with plug check) */
4723static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
4724 struct snd_ctl_elem_value *ucontrol)
4725{
4726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4727 long *valp = ucontrol->value.integer.value;
4728 int change;
4729
4730 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
4731 0x80, valp[0] ? 0 : 0x80);
4732 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
4733 0x80, valp[1] ? 0 : 0x80);
4734 if (change || codec->in_resume)
4735 alc262_fujitsu_automute(codec, codec->in_resume);
4736 return change;
4737}
4738
4739static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
4740 {
4741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4742 .name = "Master Playback Volume",
4743 .info = snd_hda_mixer_amp_volume_info,
4744 .get = snd_hda_mixer_amp_volume_get,
4745 .put = alc262_fujitsu_master_vol_put,
4746 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
4747 },
4748 {
4749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4750 .name = "Master Playback Switch",
4751 .info = snd_hda_mixer_amp_switch_info,
4752 .get = snd_hda_mixer_amp_switch_get,
4753 .put = alc262_fujitsu_master_sw_put,
4754 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
4755 },
4756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4758 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4761 { } /* end */
4762};
4763
Kailang Yangdf694da2005-12-05 19:42:22 +01004764/* add playback controls from the parsed DAC table */
4765static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4766{
4767 hda_nid_t nid;
4768 int err;
4769
4770 spec->multiout.num_dacs = 1; /* only use one dac */
4771 spec->multiout.dac_nids = spec->private_dac_nids;
4772 spec->multiout.dac_nids[0] = 2;
4773
4774 nid = cfg->line_out_pins[0];
4775 if (nid) {
4776 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
4777 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4778 return err;
4779 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
4780 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4781 return err;
4782 }
4783
Takashi Iwai82bc9552006-03-21 11:24:42 +01004784 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004785 if (nid) {
4786 if (nid == 0x16) {
4787 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4788 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4789 return err;
4790 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4791 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4792 return err;
4793 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01004794 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4795 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4796 return err;
4797 }
4798 }
4799 nid = cfg->hp_pin;
4800 if (nid) {
4801 /* spec->multiout.hp_nid = 2; */
4802 if (nid == 0x16) {
4803 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4804 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4805 return err;
4806 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4807 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4808 return err;
4809 } else {
Kailang Yangdf694da2005-12-05 19:42:22 +01004810 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4811 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4812 return err;
4813 }
4814 }
4815 return 0;
4816}
4817
4818/* identical with ALC880 */
4819#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
4820
4821/*
4822 * generic initialization of ADC, input mixers and output mixers
4823 */
4824static struct hda_verb alc262_volume_init_verbs[] = {
4825 /*
4826 * Unmute ADC0-2 and set the default input to mic-in
4827 */
4828 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4830 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4832 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4833 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4834
4835 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4836 * mixer widget
4837 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4838 * mic (mic 2)
4839 */
4840 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4846
4847 /*
4848 * Set up output mixers (0x0c - 0x0f)
4849 */
4850 /* set vol=0 to output mixers */
4851 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4852 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4853 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4854
4855 /* set up input amps for analog loopback */
4856 /* Amp Indices: DAC = 0, mixer = 1 */
4857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4863
4864 /* FIXME: use matrix-type input source selection */
4865 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4866 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4868 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4869 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4870 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4871 /* Input mixer2 */
4872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4874 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4876 /* Input mixer3 */
4877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4879 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4881
4882 { }
4883};
4884
4885/* pcm configuration: identiacal with ALC880 */
4886#define alc262_pcm_analog_playback alc880_pcm_analog_playback
4887#define alc262_pcm_analog_capture alc880_pcm_analog_capture
4888#define alc262_pcm_digital_playback alc880_pcm_digital_playback
4889#define alc262_pcm_digital_capture alc880_pcm_digital_capture
4890
4891/*
4892 * BIOS auto configuration
4893 */
4894static int alc262_parse_auto_config(struct hda_codec *codec)
4895{
4896 struct alc_spec *spec = codec->spec;
4897 int err;
4898 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4899
4900 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4901 alc262_ignore)) < 0)
4902 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004903 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01004904 return 0; /* can't find valid BIOS pin config */
4905 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4906 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4907 return err;
4908
4909 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4910
4911 if (spec->autocfg.dig_out_pin)
4912 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
4913 if (spec->autocfg.dig_in_pin)
4914 spec->dig_in_nid = ALC262_DIGIN_NID;
4915
4916 if (spec->kctl_alloc)
4917 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4918
4919 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004920 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01004921 spec->input_mux = &spec->private_imux;
4922
4923 return 1;
4924}
4925
4926#define alc262_auto_init_multi_out alc882_auto_init_multi_out
4927#define alc262_auto_init_hp_out alc882_auto_init_hp_out
4928#define alc262_auto_init_analog_input alc882_auto_init_analog_input
4929
4930
4931/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004932static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01004933{
Kailang Yangdf694da2005-12-05 19:42:22 +01004934 alc262_auto_init_multi_out(codec);
4935 alc262_auto_init_hp_out(codec);
4936 alc262_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01004937}
4938
4939/*
4940 * configuration and preset
4941 */
4942static struct hda_board_config alc262_cfg_tbl[] = {
4943 { .modelname = "basic", .config = ALC262_BASIC },
Takashi Iwai834be882006-03-01 14:16:17 +01004944 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
4945 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
Kailang Yangdf694da2005-12-05 19:42:22 +01004946 { .modelname = "auto", .config = ALC262_AUTO },
4947 {}
4948};
4949
4950static struct alc_config_preset alc262_presets[] = {
4951 [ALC262_BASIC] = {
4952 .mixers = { alc262_base_mixer },
4953 .init_verbs = { alc262_init_verbs },
4954 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4955 .dac_nids = alc262_dac_nids,
4956 .hp_nid = 0x03,
4957 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4958 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004959 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +01004960 },
Takashi Iwai834be882006-03-01 14:16:17 +01004961 [ALC262_FUJITSU] = {
4962 .mixers = { alc262_fujitsu_mixer },
4963 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
4964 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4965 .dac_nids = alc262_dac_nids,
4966 .hp_nid = 0x03,
4967 .dig_out_nid = ALC262_DIGOUT_NID,
4968 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4969 .channel_mode = alc262_modes,
4970 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004971 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwai834be882006-03-01 14:16:17 +01004972 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004973};
4974
4975static int patch_alc262(struct hda_codec *codec)
4976{
4977 struct alc_spec *spec;
4978 int board_config;
4979 int err;
4980
4981 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4982 if (spec == NULL)
4983 return -ENOMEM;
4984
4985 codec->spec = spec;
4986#if 0
4987 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
4988 {
4989 int tmp;
4990 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4991 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4992 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4993 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4994 }
4995#endif
4996
4997 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
4998 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
4999 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
5000 board_config = ALC262_AUTO;
5001 }
5002
5003 if (board_config == ALC262_AUTO) {
5004 /* automatic parse from the BIOS config */
5005 err = alc262_parse_auto_config(codec);
5006 if (err < 0) {
5007 alc_free(codec);
5008 return err;
5009 } else if (! err) {
5010 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
5011 board_config = ALC262_BASIC;
5012 }
5013 }
5014
5015 if (board_config != ALC262_AUTO)
5016 setup_preset(spec, &alc262_presets[board_config]);
5017
5018 spec->stream_name_analog = "ALC262 Analog";
5019 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5020 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5021
5022 spec->stream_name_digital = "ALC262 Digital";
5023 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5024 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5025
5026 if (! spec->adc_nids && spec->input_mux) {
5027 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005028 unsigned int wcap = get_wcaps(codec, 0x07);
5029
Kailang Yangdf694da2005-12-05 19:42:22 +01005030 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5031 if (wcap != AC_WID_AUD_IN) {
5032 spec->adc_nids = alc262_adc_nids_alt;
5033 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5034 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5035 spec->num_mixers++;
5036 } else {
5037 spec->adc_nids = alc262_adc_nids;
5038 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5039 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5040 spec->num_mixers++;
5041 }
5042 }
5043
5044 codec->patch_ops = alc_patch_ops;
5045 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005046 spec->init_hook = alc262_auto_init;
Takashi Iwai834be882006-03-01 14:16:17 +01005047
Kailang Yangdf694da2005-12-05 19:42:22 +01005048 return 0;
5049}
5050
5051
5052/*
5053 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5054 */
5055
5056/*
5057 * set the path ways for 2 channel output
5058 * need to set the codec line out and mic 1 pin widgets to inputs
5059 */
5060static struct hda_verb alc861_threestack_ch2_init[] = {
5061 /* set pin widget 1Ah (line in) for input */
5062 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5063 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5064 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5065
5066 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5067 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
5068 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
5069 { } /* end */
5070};
5071/*
5072 * 6ch mode
5073 * need to set the codec line out and mic 1 pin widgets to outputs
5074 */
5075static struct hda_verb alc861_threestack_ch6_init[] = {
5076 /* set pin widget 1Ah (line in) for output (Back Surround)*/
5077 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5078 /* set pin widget 18h (mic1) for output (CLFE)*/
5079 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5080
5081 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
5082 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
5083
5084 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
5085 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
5086 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
5087 { } /* end */
5088};
5089
5090static struct hda_channel_mode alc861_threestack_modes[2] = {
5091 { 2, alc861_threestack_ch2_init },
5092 { 6, alc861_threestack_ch6_init },
5093};
5094
5095/* patch-ALC861 */
5096
5097static struct snd_kcontrol_new alc861_base_mixer[] = {
5098 /* output mixer control */
5099 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5100 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5101 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5102 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5103 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
5104
5105 /*Input mixer control */
5106 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5107 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5108 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5109 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5110 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5111 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5113 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5114 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
5115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
5116
5117 /* Capture mixer control */
5118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5120 {
5121 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5122 .name = "Capture Source",
5123 .count = 1,
5124 .info = alc_mux_enum_info,
5125 .get = alc_mux_enum_get,
5126 .put = alc_mux_enum_put,
5127 },
5128 { } /* end */
5129};
5130
5131static struct snd_kcontrol_new alc861_3ST_mixer[] = {
5132 /* output mixer control */
5133 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5134 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5135 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5136 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5137 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
5138
5139 /* Input mixer control */
5140 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5141 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5142 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5143 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5144 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5145 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5147 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
5149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
5150
5151 /* Capture mixer control */
5152 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5153 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5154 {
5155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5156 .name = "Capture Source",
5157 .count = 1,
5158 .info = alc_mux_enum_info,
5159 .get = alc_mux_enum_get,
5160 .put = alc_mux_enum_put,
5161 },
5162 {
5163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5164 .name = "Channel Mode",
5165 .info = alc_ch_mode_info,
5166 .get = alc_ch_mode_get,
5167 .put = alc_ch_mode_put,
5168 .private_value = ARRAY_SIZE(alc861_threestack_modes),
5169 },
5170 { } /* end */
5171};
5172
5173/*
5174 * generic initialization of ADC, input mixers and output mixers
5175 */
5176static struct hda_verb alc861_base_init_verbs[] = {
5177 /*
5178 * Unmute ADC0 and set the default input to mic-in
5179 */
5180 /* port-A for surround (rear panel) */
5181 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5182 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
5183 /* port-B for mic-in (rear panel) with vref */
5184 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5185 /* port-C for line-in (rear panel) */
5186 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5187 /* port-D for Front */
5188 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5189 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5190 /* port-E for HP out (front panel) */
5191 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5192 /* route front PCM to HP */
5193 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5194 /* port-F for mic-in (front panel) with vref */
5195 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5196 /* port-G for CLFE (rear panel) */
5197 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5198 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
5199 /* port-H for side (rear panel) */
5200 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5201 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
5202 /* CD-in */
5203 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5204 /* route front mic to ADC1*/
5205 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5207
5208 /* Unmute DAC0~3 & spdif out*/
5209 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5210 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5211 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5212 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5214
5215 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5216 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5217 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5218 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5219 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5220
5221 /* Unmute Stereo Mixer 15 */
5222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5226
5227 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5228 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5229 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5230 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5232 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5234 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5235 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5236 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5237
5238 { }
5239};
5240
5241static struct hda_verb alc861_threestack_init_verbs[] = {
5242 /*
5243 * Unmute ADC0 and set the default input to mic-in
5244 */
5245 /* port-A for surround (rear panel) */
5246 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5247 /* port-B for mic-in (rear panel) with vref */
5248 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5249 /* port-C for line-in (rear panel) */
5250 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5251 /* port-D for Front */
5252 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5253 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5254 /* port-E for HP out (front panel) */
5255 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5256 /* route front PCM to HP */
5257 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5258 /* port-F for mic-in (front panel) with vref */
5259 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5260 /* port-G for CLFE (rear panel) */
5261 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5262 /* port-H for side (rear panel) */
5263 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5264 /* CD-in */
5265 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5266 /* route front mic to ADC1*/
5267 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5268 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5269 /* Unmute DAC0~3 & spdif out*/
5270 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5271 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5272 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5273 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5275
5276 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5277 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5278 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5279 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5280 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5281
5282 /* Unmute Stereo Mixer 15 */
5283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5287
5288 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5289 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5290 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5291 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5292 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5293 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5294 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5295 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5296 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5297 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5298 { }
5299};
5300/*
5301 * generic initialization of ADC, input mixers and output mixers
5302 */
5303static struct hda_verb alc861_auto_init_verbs[] = {
5304 /*
5305 * Unmute ADC0 and set the default input to mic-in
5306 */
5307// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5308 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5309
5310 /* Unmute DAC0~3 & spdif out*/
5311 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5312 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5313 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5314 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5316
5317 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5318 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5319 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5320 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5321 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5322
5323 /* Unmute Stereo Mixer 15 */
5324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
5328
5329 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5330 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5331 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5332 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5334 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5335 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5336 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5337
5338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5342 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5343 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5344 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5345 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5346
5347 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
5348
5349 { }
5350};
5351
5352/* pcm configuration: identiacal with ALC880 */
5353#define alc861_pcm_analog_playback alc880_pcm_analog_playback
5354#define alc861_pcm_analog_capture alc880_pcm_analog_capture
5355#define alc861_pcm_digital_playback alc880_pcm_digital_playback
5356#define alc861_pcm_digital_capture alc880_pcm_digital_capture
5357
5358
5359#define ALC861_DIGOUT_NID 0x07
5360
5361static struct hda_channel_mode alc861_8ch_modes[1] = {
5362 { 8, NULL }
5363};
5364
5365static hda_nid_t alc861_dac_nids[4] = {
5366 /* front, surround, clfe, side */
5367 0x03, 0x06, 0x05, 0x04
5368};
5369
5370static hda_nid_t alc861_adc_nids[1] = {
5371 /* ADC0-2 */
5372 0x08,
5373};
5374
5375static struct hda_input_mux alc861_capture_source = {
5376 .num_items = 5,
5377 .items = {
5378 { "Mic", 0x0 },
5379 { "Front Mic", 0x3 },
5380 { "Line", 0x1 },
5381 { "CD", 0x4 },
5382 { "Mixer", 0x5 },
5383 },
5384};
5385
5386/* fill in the dac_nids table from the parsed pin configuration */
5387static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5388{
5389 int i;
5390 hda_nid_t nid;
5391
5392 spec->multiout.dac_nids = spec->private_dac_nids;
5393 for (i = 0; i < cfg->line_outs; i++) {
5394 nid = cfg->line_out_pins[i];
5395 if (nid) {
5396 if (i >= ARRAY_SIZE(alc861_dac_nids))
5397 continue;
5398 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
5399 }
5400 }
5401 spec->multiout.num_dacs = cfg->line_outs;
5402 return 0;
5403}
5404
5405/* add playback controls from the parsed DAC table */
5406static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
5407 const struct auto_pin_cfg *cfg)
5408{
5409 char name[32];
5410 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
5411 hda_nid_t nid;
5412 int i, idx, err;
5413
5414 for (i = 0; i < cfg->line_outs; i++) {
5415 nid = spec->multiout.dac_nids[i];
5416 if (! nid)
5417 continue;
5418 if (nid == 0x05) {
5419 /* Center/LFE */
5420 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
5421 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
5422 return err;
5423 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
5424 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5425 return err;
5426 } else {
5427 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
5428 if (nid == alc861_dac_nids[idx])
5429 break;
5430 sprintf(name, "%s Playback Switch", chname[idx]);
5431 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
5432 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5433 return err;
5434 }
5435 }
5436 return 0;
5437}
5438
5439static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
5440{
5441 int err;
5442 hda_nid_t nid;
5443
5444 if (! pin)
5445 return 0;
5446
5447 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
5448 nid = 0x03;
5449 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5450 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5451 return err;
5452 spec->multiout.hp_nid = nid;
5453 }
5454 return 0;
5455}
5456
5457/* create playback/capture controls for input pins */
5458static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5459{
Kailang Yangdf694da2005-12-05 19:42:22 +01005460 struct hda_input_mux *imux = &spec->private_imux;
5461 int i, err, idx, idx1;
5462
5463 for (i = 0; i < AUTO_PIN_LAST; i++) {
5464 switch(cfg->input_pins[i]) {
5465 case 0x0c:
5466 idx1 = 1;
5467 idx = 2; // Line In
5468 break;
5469 case 0x0f:
5470 idx1 = 2;
5471 idx = 2; // Line In
5472 break;
5473 case 0x0d:
5474 idx1 = 0;
5475 idx = 1; // Mic In
5476 break;
5477 case 0x10:
5478 idx1 = 3;
5479 idx = 1; // Mic In
5480 break;
5481 case 0x11:
5482 idx1 = 4;
5483 idx = 0; // CD
5484 break;
5485 default:
5486 continue;
5487 }
5488
Takashi Iwai4a471b72005-12-07 13:56:29 +01005489 err = new_analog_input(spec, cfg->input_pins[i],
5490 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +01005491 if (err < 0)
5492 return err;
5493
Takashi Iwai4a471b72005-12-07 13:56:29 +01005494 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005495 imux->items[imux->num_items].index = idx1;
5496 imux->num_items++;
5497 }
5498 return 0;
5499}
5500
5501static struct snd_kcontrol_new alc861_capture_mixer[] = {
5502 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5503 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5504
5505 {
5506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5507 /* The multiple "Capture Source" controls confuse alsamixer
5508 * So call somewhat different..
5509 *FIXME: the controls appear in the "playback" view!
5510 */
5511 /* .name = "Capture Source", */
5512 .name = "Input Source",
5513 .count = 1,
5514 .info = alc_mux_enum_info,
5515 .get = alc_mux_enum_get,
5516 .put = alc_mux_enum_put,
5517 },
5518 { } /* end */
5519};
5520
5521static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
5522 int pin_type, int dac_idx)
5523{
5524 /* set as output */
5525
5526 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
5527 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5528
5529}
5530
5531static void alc861_auto_init_multi_out(struct hda_codec *codec)
5532{
5533 struct alc_spec *spec = codec->spec;
5534 int i;
5535
5536 for (i = 0; i < spec->autocfg.line_outs; i++) {
5537 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5538 if (nid)
5539 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
5540 }
5541}
5542
5543static void alc861_auto_init_hp_out(struct hda_codec *codec)
5544{
5545 struct alc_spec *spec = codec->spec;
5546 hda_nid_t pin;
5547
5548 pin = spec->autocfg.hp_pin;
5549 if (pin) /* connect to front */
5550 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
5551}
5552
5553static void alc861_auto_init_analog_input(struct hda_codec *codec)
5554{
5555 struct alc_spec *spec = codec->spec;
5556 int i;
5557
5558 for (i = 0; i < AUTO_PIN_LAST; i++) {
5559 hda_nid_t nid = spec->autocfg.input_pins[i];
5560 if ((nid>=0x0c) && (nid <=0x11)) {
5561 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5562 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
5563 }
5564 }
5565}
5566
5567/* parse the BIOS configuration and set up the alc_spec */
5568/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
5569static int alc861_parse_auto_config(struct hda_codec *codec)
5570{
5571 struct alc_spec *spec = codec->spec;
5572 int err;
5573 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
5574
5575 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5576 alc861_ignore)) < 0)
5577 return err;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005578 if (! spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005579 return 0; /* can't find valid BIOS pin config */
5580
5581 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
5582 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5583 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
5584 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5585 return err;
5586
5587 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5588
5589 if (spec->autocfg.dig_out_pin)
5590 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
5591
5592 if (spec->kctl_alloc)
5593 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5594
5595 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
5596
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005597 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005598 spec->input_mux = &spec->private_imux;
5599
5600 spec->adc_nids = alc861_adc_nids;
5601 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
5602 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
5603 spec->num_mixers++;
5604
5605 return 1;
5606}
5607
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005608/* additional initialization for auto-configuration model */
5609static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005610{
Kailang Yangdf694da2005-12-05 19:42:22 +01005611 alc861_auto_init_multi_out(codec);
5612 alc861_auto_init_hp_out(codec);
5613 alc861_auto_init_analog_input(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005614}
5615
5616
5617/*
5618 * configuration and preset
5619 */
5620static struct hda_board_config alc861_cfg_tbl[] = {
5621 { .modelname = "3stack", .config = ALC861_3ST },
5622 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
5623 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
5624 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
5625 { .modelname = "auto", .config = ALC861_AUTO },
5626 {}
5627};
5628
5629static struct alc_config_preset alc861_presets[] = {
5630 [ALC861_3ST] = {
5631 .mixers = { alc861_3ST_mixer },
5632 .init_verbs = { alc861_threestack_init_verbs },
5633 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5634 .dac_nids = alc861_dac_nids,
5635 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5636 .channel_mode = alc861_threestack_modes,
5637 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5638 .adc_nids = alc861_adc_nids,
5639 .input_mux = &alc861_capture_source,
5640 },
5641 [ALC861_3ST_DIG] = {
5642 .mixers = { alc861_base_mixer },
5643 .init_verbs = { alc861_threestack_init_verbs },
5644 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5645 .dac_nids = alc861_dac_nids,
5646 .dig_out_nid = ALC861_DIGOUT_NID,
5647 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5648 .channel_mode = alc861_threestack_modes,
5649 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5650 .adc_nids = alc861_adc_nids,
5651 .input_mux = &alc861_capture_source,
5652 },
5653 [ALC861_6ST_DIG] = {
5654 .mixers = { alc861_base_mixer },
5655 .init_verbs = { alc861_base_init_verbs },
5656 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5657 .dac_nids = alc861_dac_nids,
5658 .dig_out_nid = ALC861_DIGOUT_NID,
5659 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
5660 .channel_mode = alc861_8ch_modes,
5661 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5662 .adc_nids = alc861_adc_nids,
5663 .input_mux = &alc861_capture_source,
5664 },
5665};
5666
5667
5668static int patch_alc861(struct hda_codec *codec)
5669{
5670 struct alc_spec *spec;
5671 int board_config;
5672 int err;
5673
5674 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5675 if (spec == NULL)
5676 return -ENOMEM;
5677
5678 codec->spec = spec;
5679
5680 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
5681 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
5682 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
5683 board_config = ALC861_AUTO;
5684 }
5685
5686 if (board_config == ALC861_AUTO) {
5687 /* automatic parse from the BIOS config */
5688 err = alc861_parse_auto_config(codec);
5689 if (err < 0) {
5690 alc_free(codec);
5691 return err;
5692 } else if (! err) {
5693 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
5694 board_config = ALC861_3ST_DIG;
5695 }
5696 }
5697
5698 if (board_config != ALC861_AUTO)
5699 setup_preset(spec, &alc861_presets[board_config]);
5700
5701 spec->stream_name_analog = "ALC861 Analog";
5702 spec->stream_analog_playback = &alc861_pcm_analog_playback;
5703 spec->stream_analog_capture = &alc861_pcm_analog_capture;
5704
5705 spec->stream_name_digital = "ALC861 Digital";
5706 spec->stream_digital_playback = &alc861_pcm_digital_playback;
5707 spec->stream_digital_capture = &alc861_pcm_digital_capture;
5708
5709 codec->patch_ops = alc_patch_ops;
5710 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005711 spec->init_hook = alc861_auto_init;
Kailang Yangdf694da2005-12-05 19:42:22 +01005712
5713 return 0;
5714}
5715
5716/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07005717 * patch entries
5718 */
5719struct hda_codec_preset snd_hda_preset_realtek[] = {
5720 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005721 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07005722 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
5723 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005724 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
5725 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
5726 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07005727 {} /* terminator */
5728};