2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
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.
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.
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
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"
36 /* ALC880 board config type */
56 #ifdef CONFIG_SND_DEBUG
60 ALC880_MODEL_LAST /* last tag */
70 #ifdef CONFIG_SND_DEBUG
74 ALC260_MODEL_LAST /* last tag */
84 ALC262_MODEL_LAST /* last tag */
118 #define GPIO_MASK 0x03
121 /* codec parameterization */
122 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
123 unsigned int num_mixers;
125 const struct hda_verb *init_verbs[5]; /* initialization verbs
129 unsigned int num_init_verbs;
131 char *stream_name_analog; /* analog PCM stream */
132 struct hda_pcm_stream *stream_analog_playback;
133 struct hda_pcm_stream *stream_analog_capture;
135 char *stream_name_digital; /* digital PCM stream */
136 struct hda_pcm_stream *stream_digital_playback;
137 struct hda_pcm_stream *stream_digital_capture;
140 struct hda_multi_out multiout; /* playback set-up
141 * max_channels, dacs must be set
142 * dig_out_nid and hp_nid are optional
146 unsigned int num_adc_nids;
148 hda_nid_t dig_in_nid; /* digital-in NID; optional */
151 unsigned int num_mux_defs;
152 const struct hda_input_mux *input_mux;
153 unsigned int cur_mux[3];
156 const struct hda_channel_mode *channel_mode;
157 int num_channel_mode;
160 /* PCM information */
161 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
163 /* dynamic controls, init_verbs and input_mux */
164 struct auto_pin_cfg autocfg;
165 unsigned int num_kctl_alloc, num_kctl_used;
166 struct snd_kcontrol_new *kctl_alloc;
167 struct hda_input_mux private_imux;
168 hda_nid_t private_dac_nids[5];
171 void (*init_hook)(struct hda_codec *codec);
172 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
174 /* for pin sensing */
175 unsigned int sense_updated: 1;
176 unsigned int jack_present: 1;
180 * configuration template - to be copied to the spec instance
182 struct alc_config_preset {
183 struct snd_kcontrol_new *mixers[5]; /* should be identical size
186 const struct hda_verb *init_verbs[5];
187 unsigned int num_dacs;
189 hda_nid_t dig_out_nid; /* optional */
190 hda_nid_t hp_nid; /* optional */
191 unsigned int num_adc_nids;
193 hda_nid_t dig_in_nid;
194 unsigned int num_channel_mode;
195 const struct hda_channel_mode *channel_mode;
197 unsigned int num_mux_defs;
198 const struct hda_input_mux *input_mux;
199 void (*unsol_event)(struct hda_codec *, unsigned int);
200 void (*init_hook)(struct hda_codec *);
207 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
208 struct snd_ctl_elem_info *uinfo)
210 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
211 struct alc_spec *spec = codec->spec;
212 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
213 if (mux_idx >= spec->num_mux_defs)
215 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
218 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
219 struct snd_ctl_elem_value *ucontrol)
221 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
222 struct alc_spec *spec = codec->spec;
223 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
225 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
229 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_value *ucontrol)
232 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
233 struct alc_spec *spec = codec->spec;
234 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
235 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
236 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
237 spec->adc_nids[adc_idx],
238 &spec->cur_mux[adc_idx]);
243 * channel mode setting
245 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
246 struct snd_ctl_elem_info *uinfo)
248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
249 struct alc_spec *spec = codec->spec;
250 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
251 spec->num_channel_mode);
254 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
255 struct snd_ctl_elem_value *ucontrol)
257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
258 struct alc_spec *spec = codec->spec;
259 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
260 spec->num_channel_mode,
261 spec->multiout.max_channels);
264 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
265 struct snd_ctl_elem_value *ucontrol)
267 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
268 struct alc_spec *spec = codec->spec;
269 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
270 spec->num_channel_mode,
271 &spec->multiout.max_channels);
272 if (! err && spec->need_dac_fix)
273 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
278 * Control the mode of pin widget settings via the mixer. "pc" is used
279 * instead of "%" to avoid consequences of accidently treating the % as
280 * being part of a format specifier. Maximum allowed length of a value is
281 * 63 characters plus NULL terminator.
283 * Note: some retasking pin complexes seem to ignore requests for input
284 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
285 * are requested. Therefore order this list so that this behaviour will not
286 * cause problems when mixer clients move through the enum sequentially.
287 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
290 static char *alc_pin_mode_names[] = {
291 "Mic 50pc bias", "Mic 80pc bias",
292 "Line in", "Line out", "Headphone out",
294 static unsigned char alc_pin_mode_values[] = {
295 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
297 /* The control can present all 5 options, or it can limit the options based
298 * in the pin being assumed to be exclusively an input or an output pin. In
299 * addition, "input" pins may or may not process the mic bias option
300 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
301 * accept requests for bias as of chip versions up to March 2006) and/or
302 * wiring in the computer.
304 #define ALC_PIN_DIR_IN 0x00
305 #define ALC_PIN_DIR_OUT 0x01
306 #define ALC_PIN_DIR_INOUT 0x02
307 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
308 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
310 /* Info about the pin modes supported by the different pin direction modes.
311 * For each direction the minimum and maximum values are given.
313 static signed char alc_pin_mode_dir_info[5][2] = {
314 { 0, 2 }, /* ALC_PIN_DIR_IN */
315 { 3, 4 }, /* ALC_PIN_DIR_OUT */
316 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
317 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
318 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
320 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
321 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
322 #define alc_pin_mode_n_items(_dir) \
323 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
325 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_info *uinfo)
328 unsigned int item_num = uinfo->value.enumerated.item;
329 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
331 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
333 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
335 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
336 item_num = alc_pin_mode_min(dir);
337 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
341 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
342 struct snd_ctl_elem_value *ucontrol)
345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
346 hda_nid_t nid = kcontrol->private_value & 0xffff;
347 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
348 long *valp = ucontrol->value.integer.value;
349 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
350 AC_VERB_GET_PIN_WIDGET_CONTROL,
353 /* Find enumerated value for current pinctl setting */
354 i = alc_pin_mode_min(dir);
355 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
357 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
361 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
362 struct snd_ctl_elem_value *ucontrol)
365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
366 hda_nid_t nid = kcontrol->private_value & 0xffff;
367 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
368 long val = *ucontrol->value.integer.value;
369 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
370 AC_VERB_GET_PIN_WIDGET_CONTROL,
373 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
374 val = alc_pin_mode_min(dir);
376 change = pinctl != alc_pin_mode_values[val];
378 /* Set pin mode to that requested */
379 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
380 alc_pin_mode_values[val]);
382 /* Also enable the retasking pin's input/output as required
383 * for the requested pin mode. Enum values of 2 or less are
386 * Dynamically switching the input/output buffers probably
387 * reduces noise slightly (particularly on input) so we'll
388 * do it. However, having both input and output buffers
389 * enabled simultaneously doesn't seem to be problematic if
390 * this turns out to be necessary in the future.
393 snd_hda_codec_write(codec, nid, 0,
394 AC_VERB_SET_AMP_GAIN_MUTE,
396 snd_hda_codec_write(codec, nid, 0,
397 AC_VERB_SET_AMP_GAIN_MUTE,
400 snd_hda_codec_write(codec, nid, 0,
401 AC_VERB_SET_AMP_GAIN_MUTE,
403 snd_hda_codec_write(codec, nid, 0,
404 AC_VERB_SET_AMP_GAIN_MUTE,
411 #define ALC_PIN_MODE(xname, nid, dir) \
412 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
413 .info = alc_pin_mode_info, \
414 .get = alc_pin_mode_get, \
415 .put = alc_pin_mode_put, \
416 .private_value = nid | (dir<<16) }
418 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
419 * together using a mask with more than one bit set. This control is
420 * currently used only by the ALC260 test model. At this stage they are not
421 * needed for any "production" models.
423 #ifdef CONFIG_SND_DEBUG
424 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo)
427 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
429 uinfo->value.integer.min = 0;
430 uinfo->value.integer.max = 1;
433 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
434 struct snd_ctl_elem_value *ucontrol)
436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
437 hda_nid_t nid = kcontrol->private_value & 0xffff;
438 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
439 long *valp = ucontrol->value.integer.value;
440 unsigned int val = snd_hda_codec_read(codec, nid, 0,
441 AC_VERB_GET_GPIO_DATA, 0x00);
443 *valp = (val & mask) != 0;
446 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_value *ucontrol)
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 hda_nid_t nid = kcontrol->private_value & 0xffff;
452 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
453 long val = *ucontrol->value.integer.value;
454 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
455 AC_VERB_GET_GPIO_DATA,
458 /* Set/unset the masked GPIO bit(s) as needed */
459 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
464 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
468 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
469 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
470 .info = alc_gpio_data_info, \
471 .get = alc_gpio_data_get, \
472 .put = alc_gpio_data_put, \
473 .private_value = nid | (mask<<16) }
474 #endif /* CONFIG_SND_DEBUG */
476 /* A switch control to allow the enabling of the digital IO pins on the
477 * ALC260. This is incredibly simplistic; the intention of this control is
478 * to provide something in the test model allowing digital outputs to be
479 * identified if present. If models are found which can utilise these
480 * outputs a more complete mixer control can be devised for those models if
483 #ifdef CONFIG_SND_DEBUG
484 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_info *uinfo)
487 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
489 uinfo->value.integer.min = 0;
490 uinfo->value.integer.max = 1;
493 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
494 struct snd_ctl_elem_value *ucontrol)
496 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
497 hda_nid_t nid = kcontrol->private_value & 0xffff;
498 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
499 long *valp = ucontrol->value.integer.value;
500 unsigned int val = snd_hda_codec_read(codec, nid, 0,
501 AC_VERB_GET_DIGI_CONVERT, 0x00);
503 *valp = (val & mask) != 0;
506 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 hda_nid_t nid = kcontrol->private_value & 0xffff;
512 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
513 long val = *ucontrol->value.integer.value;
514 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
515 AC_VERB_GET_DIGI_CONVERT,
518 /* Set/unset the masked control bit(s) as needed */
519 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
524 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
529 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
530 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
531 .info = alc_spdif_ctrl_info, \
532 .get = alc_spdif_ctrl_get, \
533 .put = alc_spdif_ctrl_put, \
534 .private_value = nid | (mask<<16) }
535 #endif /* CONFIG_SND_DEBUG */
538 * set up from the preset table
540 static void setup_preset(struct alc_spec *spec,
541 const struct alc_config_preset *preset)
545 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
546 spec->mixers[spec->num_mixers++] = preset->mixers[i];
547 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
549 spec->init_verbs[spec->num_init_verbs++] =
550 preset->init_verbs[i];
552 spec->channel_mode = preset->channel_mode;
553 spec->num_channel_mode = preset->num_channel_mode;
554 spec->need_dac_fix = preset->need_dac_fix;
556 spec->multiout.max_channels = spec->channel_mode[0].channels;
558 spec->multiout.num_dacs = preset->num_dacs;
559 spec->multiout.dac_nids = preset->dac_nids;
560 spec->multiout.dig_out_nid = preset->dig_out_nid;
561 spec->multiout.hp_nid = preset->hp_nid;
563 spec->num_mux_defs = preset->num_mux_defs;
564 if (! spec->num_mux_defs)
565 spec->num_mux_defs = 1;
566 spec->input_mux = preset->input_mux;
568 spec->num_adc_nids = preset->num_adc_nids;
569 spec->adc_nids = preset->adc_nids;
570 spec->dig_in_nid = preset->dig_in_nid;
572 spec->unsol_event = preset->unsol_event;
573 spec->init_hook = preset->init_hook;
577 * ALC880 3-stack model
579 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
580 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
581 * F-Mic = 0x1b, HP = 0x19
584 static hda_nid_t alc880_dac_nids[4] = {
585 /* front, rear, clfe, rear_surr */
586 0x02, 0x05, 0x04, 0x03
589 static hda_nid_t alc880_adc_nids[3] = {
594 /* The datasheet says the node 0x07 is connected from inputs,
595 * but it shows zero connection in the real implementation on some devices.
596 * Note: this is a 915GAV bug, fixed on 915GLV
598 static hda_nid_t alc880_adc_nids_alt[2] = {
603 #define ALC880_DIGOUT_NID 0x06
604 #define ALC880_DIGIN_NID 0x0a
606 static struct hda_input_mux alc880_capture_source = {
610 { "Front Mic", 0x3 },
616 /* channel source setting (2/6 channel selection for 3-stack) */
618 static struct hda_verb alc880_threestack_ch2_init[] = {
619 /* set line-in to input, mute it */
620 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
621 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
622 /* set mic-in to input vref 80%, mute it */
623 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
624 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
629 static struct hda_verb alc880_threestack_ch6_init[] = {
630 /* set line-in to output, unmute it */
631 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
632 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
633 /* set mic-in to output, unmute it */
634 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
635 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
639 static struct hda_channel_mode alc880_threestack_modes[2] = {
640 { 2, alc880_threestack_ch2_init },
641 { 6, alc880_threestack_ch6_init },
644 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
645 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
646 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
647 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
648 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
649 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
650 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
651 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
652 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
653 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
654 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
659 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
661 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
662 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
666 .name = "Channel Mode",
667 .info = alc_ch_mode_info,
668 .get = alc_ch_mode_get,
669 .put = alc_ch_mode_put,
674 /* capture mixer elements */
675 static struct snd_kcontrol_new alc880_capture_mixer[] = {
676 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
677 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
678 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
679 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
680 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
681 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
684 /* The multiple "Capture Source" controls confuse alsamixer
685 * So call somewhat different..
686 * FIXME: the controls appear in the "playback" view!
688 /* .name = "Capture Source", */
689 .name = "Input Source",
691 .info = alc_mux_enum_info,
692 .get = alc_mux_enum_get,
693 .put = alc_mux_enum_put,
698 /* capture mixer elements (in case NID 0x07 not available) */
699 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
700 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
701 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
702 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
703 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
706 /* The multiple "Capture Source" controls confuse alsamixer
707 * So call somewhat different..
708 * FIXME: the controls appear in the "playback" view!
710 /* .name = "Capture Source", */
711 .name = "Input Source",
713 .info = alc_mux_enum_info,
714 .get = alc_mux_enum_get,
715 .put = alc_mux_enum_put,
723 * ALC880 5-stack model
725 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
727 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
728 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
731 /* additional mixers to alc880_three_stack_mixer */
732 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
733 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
734 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
738 /* channel source setting (6/8 channel selection for 5-stack) */
740 static struct hda_verb alc880_fivestack_ch6_init[] = {
741 /* set line-in to input, mute it */
742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
748 static struct hda_verb alc880_fivestack_ch8_init[] = {
749 /* set line-in to output, unmute it */
750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
755 static struct hda_channel_mode alc880_fivestack_modes[2] = {
756 { 6, alc880_fivestack_ch6_init },
757 { 8, alc880_fivestack_ch8_init },
762 * ALC880 6-stack model
764 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
766 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
767 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
770 static hda_nid_t alc880_6st_dac_nids[4] = {
771 /* front, rear, clfe, rear_surr */
772 0x02, 0x03, 0x04, 0x05
775 static struct hda_input_mux alc880_6stack_capture_source = {
779 { "Front Mic", 0x1 },
785 /* fixed 8-channels */
786 static struct hda_channel_mode alc880_sixstack_modes[1] = {
790 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
796 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
797 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
798 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
799 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
800 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
802 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
803 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
804 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
807 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
808 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
809 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
810 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
813 .name = "Channel Mode",
814 .info = alc_ch_mode_info,
815 .get = alc_ch_mode_get,
816 .put = alc_ch_mode_put,
825 * W810 has rear IO for:
828 * Center/LFE (DAC 04)
831 * The system also has a pair of internal speakers, and a headphone jack.
832 * These are both connected to Line2 on the codec, hence to DAC 02.
834 * There is a variable resistor to control the speaker or headphone
835 * volume. This is a hardware-only device without a software API.
837 * Plugging headphones in will disable the internal speakers. This is
838 * implemented in hardware, not via the driver using jack sense. In
839 * a similar fashion, plugging into the rear socket marked "front" will
840 * disable both the speakers and headphones.
842 * For input, there's a microphone jack, and an "audio in" jack.
843 * These may not do anything useful with this driver yet, because I
844 * haven't setup any initialization verbs for these yet...
847 static hda_nid_t alc880_w810_dac_nids[3] = {
848 /* front, rear/surround, clfe */
852 /* fixed 6 channels */
853 static struct hda_channel_mode alc880_w810_modes[1] = {
857 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
858 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
861 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
862 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
863 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
875 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
876 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
880 static hda_nid_t alc880_z71v_dac_nids[1] = {
883 #define ALC880_Z71V_HP_DAC 0x03
885 /* fixed 2 channels */
886 static struct hda_channel_mode alc880_2_jack_modes[1] = {
890 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
892 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
893 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
894 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
895 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
896 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
907 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
908 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
911 static hda_nid_t alc880_f1734_dac_nids[1] = {
914 #define ALC880_F1734_HP_DAC 0x02
916 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
917 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
918 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
919 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
920 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
933 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
934 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
935 * Mic = 0x18, Line = 0x1a
938 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
939 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
941 static struct snd_kcontrol_new alc880_asus_mixer[] = {
942 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
943 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
944 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
945 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
946 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
947 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
948 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
949 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
958 .name = "Channel Mode",
959 .info = alc_ch_mode_info,
960 .get = alc_ch_mode_get,
961 .put = alc_ch_mode_put,
968 * ALC880 ASUS W1V model
970 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
971 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
972 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
975 /* additional mixers to alc880_asus_mixer */
976 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
977 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
978 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
982 /* additional mixers to alc880_asus_mixer */
983 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
984 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
985 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
990 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
995 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
998 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
999 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1002 /* The multiple "Capture Source" controls confuse alsamixer
1003 * So call somewhat different..
1004 * FIXME: the controls appear in the "playback" view!
1006 /* .name = "Capture Source", */
1007 .name = "Input Source",
1009 .info = alc_mux_enum_info,
1010 .get = alc_mux_enum_get,
1011 .put = alc_mux_enum_put,
1017 * build control elements
1019 static int alc_build_controls(struct hda_codec *codec)
1021 struct alc_spec *spec = codec->spec;
1025 for (i = 0; i < spec->num_mixers; i++) {
1026 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1031 if (spec->multiout.dig_out_nid) {
1032 err = snd_hda_create_spdif_out_ctls(codec,
1033 spec->multiout.dig_out_nid);
1037 if (spec->dig_in_nid) {
1038 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1047 * initialize the codec volumes, etc
1051 * generic initialization of ADC, input mixers and output mixers
1053 static struct hda_verb alc880_volume_init_verbs[] = {
1055 * Unmute ADC0-2 and set the default input to mic-in
1057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1059 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1061 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1064 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1066 * Note: PASD motherboards uses the Line In 2 as the input for front
1069 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1077 * Set up output mixers (0x0c - 0x0f)
1079 /* set vol=0 to output mixers */
1080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1084 /* set up input amps for analog loopback */
1085 /* Amp Indices: DAC = 0, mixer = 1 */
1086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1093 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1099 * 3-stack pin configuration:
1100 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1102 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1104 * preset connection lists of input pins
1105 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1107 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1108 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1109 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1112 * Set pin mode and muting
1114 /* set front pin widgets 0x14 for output */
1115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1116 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1117 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1118 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1120 /* Mic2 (as headphone out) for HP output */
1121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1123 /* Line In pin widget for input */
1124 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1126 /* Line2 (as front mic) pin widget for input and vref at 80% */
1127 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1129 /* CD pin widget for input */
1130 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1136 * 5-stack pin configuration:
1137 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1138 * line-in/side = 0x1a, f-mic = 0x1b
1140 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1142 * preset connection lists of input pins
1143 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1145 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1146 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1149 * Set pin mode and muting
1151 /* set pin widgets 0x14-0x17 for output */
1152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1154 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1155 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1156 /* unmute pins for output (no gain on this amp) */
1157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1163 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1165 /* Mic2 (as headphone out) for HP output */
1166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1167 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1168 /* Line In pin widget for input */
1169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1171 /* Line2 (as front mic) pin widget for input and vref at 80% */
1172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1174 /* CD pin widget for input */
1175 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1181 * W810 pin configuration:
1182 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1184 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1185 /* hphone/speaker input selector: front DAC */
1186 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1193 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1196 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1202 * Z71V pin configuration:
1203 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1205 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1211 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1214 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1220 * 6-stack pin configuration:
1221 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1222 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1224 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1225 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1232 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1233 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1234 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1236 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1237 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1238 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1239 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1241 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1244 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1251 * F1734 pin configuration:
1252 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1254 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1255 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1256 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1257 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1258 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1280 * ASUS pin configuration:
1281 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1283 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1284 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1285 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1286 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1287 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1293 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1299 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1306 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1311 /* Enable GPIO mask and set output */
1312 static struct hda_verb alc880_gpio1_init_verbs[] = {
1313 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1314 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1315 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1320 /* Enable GPIO mask and set output */
1321 static struct hda_verb alc880_gpio2_init_verbs[] = {
1322 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1323 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1324 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1329 /* Clevo m520g init */
1330 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1331 /* headphone output */
1332 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1337 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1340 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1341 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1342 /* Mic1 (rear panel) */
1343 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1345 /* Mic2 (front panel) */
1346 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 /* change to EAPD mode */
1352 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1353 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1358 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1359 /* change to EAPD mode */
1360 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1361 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1363 /* Headphone output */
1364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1366 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1367 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1369 /* Line In pin widget for input */
1370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1371 /* CD pin widget for input */
1372 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1373 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1376 /* change to EAPD mode */
1377 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1378 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1384 * LG m1 express dual
1387 * Rear Line-In/Out (blue): 0x14
1388 * Build-in Mic-In: 0x15
1390 * HP-Out (green): 0x1b
1391 * Mic-In/Out (red): 0x19
1395 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1396 static hda_nid_t alc880_lg_dac_nids[3] = {
1400 /* seems analog CD is not working */
1401 static struct hda_input_mux alc880_lg_capture_source = {
1406 { "Internal Mic", 0x6 },
1410 /* 2,4,6 channel modes */
1411 static struct hda_verb alc880_lg_ch2_init[] = {
1412 /* set line-in and mic-in to input */
1413 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1414 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1418 static struct hda_verb alc880_lg_ch4_init[] = {
1419 /* set line-in to out and mic-in to input */
1420 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1421 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1425 static struct hda_verb alc880_lg_ch6_init[] = {
1426 /* set line-in and mic-in to output */
1427 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1428 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1432 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1433 { 2, alc880_lg_ch2_init },
1434 { 4, alc880_lg_ch4_init },
1435 { 6, alc880_lg_ch6_init },
1438 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1439 /* FIXME: it's not really "master" but front channels */
1440 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1441 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1445 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1447 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1453 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1456 .name = "Channel Mode",
1457 .info = alc_ch_mode_info,
1458 .get = alc_ch_mode_get,
1459 .put = alc_ch_mode_put,
1464 static struct hda_verb alc880_lg_init_verbs[] = {
1465 /* set capture source to mic-in */
1466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1469 /* mute all amp mixer inputs */
1470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1473 /* line-in to input */
1474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1481 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 /* mic-in to input */
1483 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1484 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1495 /* toggle speaker-output according to the hp-jack state */
1496 static void alc880_lg_automute(struct hda_codec *codec)
1498 unsigned int present;
1500 present = snd_hda_codec_read(codec, 0x1b, 0,
1501 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1502 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1503 0x80, present ? 0x80 : 0);
1504 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1505 0x80, present ? 0x80 : 0);
1508 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1510 /* Looks like the unsol event is incompatible with the standard
1511 * definition. 4bit tag is placed at 28 bit!
1513 if ((res >> 28) == 0x01)
1514 alc880_lg_automute(codec);
1523 * Built-in Mic-In: 0x19 (?)
1528 /* seems analog CD is not working */
1529 static struct hda_input_mux alc880_lg_lw_capture_source = {
1533 { "Internal Mic", 0x1 },
1537 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1538 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1539 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1540 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1542 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1543 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1547 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1548 /* set capture source to mic-in */
1549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1557 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1560 /* mic-in to input */
1561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1567 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1571 /* toggle speaker-output according to the hp-jack state */
1572 static void alc880_lg_lw_automute(struct hda_codec *codec)
1574 unsigned int present;
1576 present = snd_hda_codec_read(codec, 0x1b, 0,
1577 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1578 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1579 0x80, present ? 0x80 : 0);
1580 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1581 0x80, present ? 0x80 : 0);
1584 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1586 /* Looks like the unsol event is incompatible with the standard
1587 * definition. 4bit tag is placed at 28 bit!
1589 if ((res >> 28) == 0x01)
1590 alc880_lg_lw_automute(codec);
1597 static int alc_init(struct hda_codec *codec)
1599 struct alc_spec *spec = codec->spec;
1602 for (i = 0; i < spec->num_init_verbs; i++)
1603 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1605 if (spec->init_hook)
1606 spec->init_hook(codec);
1611 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1613 struct alc_spec *spec = codec->spec;
1615 if (spec->unsol_event)
1616 spec->unsol_event(codec, res);
1623 static int alc_resume(struct hda_codec *codec)
1625 struct alc_spec *spec = codec->spec;
1629 for (i = 0; i < spec->num_mixers; i++)
1630 snd_hda_resume_ctls(codec, spec->mixers[i]);
1631 if (spec->multiout.dig_out_nid)
1632 snd_hda_resume_spdif_out(codec);
1633 if (spec->dig_in_nid)
1634 snd_hda_resume_spdif_in(codec);
1641 * Analog playback callbacks
1643 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1644 struct hda_codec *codec,
1645 struct snd_pcm_substream *substream)
1647 struct alc_spec *spec = codec->spec;
1648 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1651 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1652 struct hda_codec *codec,
1653 unsigned int stream_tag,
1654 unsigned int format,
1655 struct snd_pcm_substream *substream)
1657 struct alc_spec *spec = codec->spec;
1658 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1659 stream_tag, format, substream);
1662 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1663 struct hda_codec *codec,
1664 struct snd_pcm_substream *substream)
1666 struct alc_spec *spec = codec->spec;
1667 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1673 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1674 struct hda_codec *codec,
1675 struct snd_pcm_substream *substream)
1677 struct alc_spec *spec = codec->spec;
1678 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1681 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1682 struct hda_codec *codec,
1683 struct snd_pcm_substream *substream)
1685 struct alc_spec *spec = codec->spec;
1686 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1692 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1693 struct hda_codec *codec,
1694 unsigned int stream_tag,
1695 unsigned int format,
1696 struct snd_pcm_substream *substream)
1698 struct alc_spec *spec = codec->spec;
1700 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1701 stream_tag, 0, format);
1705 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1706 struct hda_codec *codec,
1707 struct snd_pcm_substream *substream)
1709 struct alc_spec *spec = codec->spec;
1711 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1719 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1723 /* NID is set in alc_build_pcms */
1725 .open = alc880_playback_pcm_open,
1726 .prepare = alc880_playback_pcm_prepare,
1727 .cleanup = alc880_playback_pcm_cleanup
1731 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1735 /* NID is set in alc_build_pcms */
1737 .prepare = alc880_capture_pcm_prepare,
1738 .cleanup = alc880_capture_pcm_cleanup
1742 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1746 /* NID is set in alc_build_pcms */
1748 .open = alc880_dig_playback_pcm_open,
1749 .close = alc880_dig_playback_pcm_close
1753 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1757 /* NID is set in alc_build_pcms */
1760 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1761 static struct hda_pcm_stream alc_pcm_null_playback = {
1767 static int alc_build_pcms(struct hda_codec *codec)
1769 struct alc_spec *spec = codec->spec;
1770 struct hda_pcm *info = spec->pcm_rec;
1773 codec->num_pcms = 1;
1774 codec->pcm_info = info;
1776 info->name = spec->stream_name_analog;
1777 if (spec->stream_analog_playback) {
1778 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1779 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1780 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1782 if (spec->stream_analog_capture) {
1783 snd_assert(spec->adc_nids, return -EINVAL);
1784 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1785 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1788 if (spec->channel_mode) {
1789 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1790 for (i = 0; i < spec->num_channel_mode; i++) {
1791 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1792 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1797 /* If the use of more than one ADC is requested for the current
1798 * model, configure a second analog capture-only PCM.
1800 if (spec->num_adc_nids > 1) {
1803 info->name = spec->stream_name_analog;
1804 /* No playback stream for second PCM */
1805 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1806 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1807 if (spec->stream_analog_capture) {
1808 snd_assert(spec->adc_nids, return -EINVAL);
1809 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1810 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1814 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1817 info->name = spec->stream_name_digital;
1818 if (spec->multiout.dig_out_nid &&
1819 spec->stream_digital_playback) {
1820 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1821 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1823 if (spec->dig_in_nid &&
1824 spec->stream_digital_capture) {
1825 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1826 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1833 static void alc_free(struct hda_codec *codec)
1835 struct alc_spec *spec = codec->spec;
1841 if (spec->kctl_alloc) {
1842 for (i = 0; i < spec->num_kctl_used; i++)
1843 kfree(spec->kctl_alloc[i].name);
1844 kfree(spec->kctl_alloc);
1851 static struct hda_codec_ops alc_patch_ops = {
1852 .build_controls = alc_build_controls,
1853 .build_pcms = alc_build_pcms,
1856 .unsol_event = alc_unsol_event,
1858 .resume = alc_resume,
1864 * Test configuration for debugging
1866 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1869 #ifdef CONFIG_SND_DEBUG
1870 static hda_nid_t alc880_test_dac_nids[4] = {
1871 0x02, 0x03, 0x04, 0x05
1874 static struct hda_input_mux alc880_test_capture_source = {
1883 { "Surround", 0x6 },
1887 static struct hda_channel_mode alc880_test_modes[4] = {
1894 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1895 struct snd_ctl_elem_info *uinfo)
1897 static char *texts[] = {
1898 "N/A", "Line Out", "HP Out",
1899 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1901 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1903 uinfo->value.enumerated.items = 8;
1904 if (uinfo->value.enumerated.item >= 8)
1905 uinfo->value.enumerated.item = 7;
1906 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1910 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1911 struct snd_ctl_elem_value *ucontrol)
1913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1914 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1915 unsigned int pin_ctl, item = 0;
1917 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1918 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1919 if (pin_ctl & AC_PINCTL_OUT_EN) {
1920 if (pin_ctl & AC_PINCTL_HP_EN)
1924 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1925 switch (pin_ctl & AC_PINCTL_VREFEN) {
1926 case AC_PINCTL_VREF_HIZ: item = 3; break;
1927 case AC_PINCTL_VREF_50: item = 4; break;
1928 case AC_PINCTL_VREF_GRD: item = 5; break;
1929 case AC_PINCTL_VREF_80: item = 6; break;
1930 case AC_PINCTL_VREF_100: item = 7; break;
1933 ucontrol->value.enumerated.item[0] = item;
1937 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1938 struct snd_ctl_elem_value *ucontrol)
1940 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1941 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1942 static unsigned int ctls[] = {
1943 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1944 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1945 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1946 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1947 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1948 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1950 unsigned int old_ctl, new_ctl;
1952 old_ctl = snd_hda_codec_read(codec, nid, 0,
1953 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1954 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1955 if (old_ctl != new_ctl) {
1956 snd_hda_codec_write(codec, nid, 0,
1957 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1958 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1959 (ucontrol->value.enumerated.item[0] >= 3 ?
1966 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1967 struct snd_ctl_elem_info *uinfo)
1969 static char *texts[] = {
1970 "Front", "Surround", "CLFE", "Side"
1972 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1974 uinfo->value.enumerated.items = 4;
1975 if (uinfo->value.enumerated.item >= 4)
1976 uinfo->value.enumerated.item = 3;
1977 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1981 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
1984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1985 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1988 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1989 ucontrol->value.enumerated.item[0] = sel & 3;
1993 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
1996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1997 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2000 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2001 if (ucontrol->value.enumerated.item[0] != sel) {
2002 sel = ucontrol->value.enumerated.item[0] & 3;
2003 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2009 #define PIN_CTL_TEST(xname,nid) { \
2010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2012 .info = alc_test_pin_ctl_info, \
2013 .get = alc_test_pin_ctl_get, \
2014 .put = alc_test_pin_ctl_put, \
2015 .private_value = nid \
2018 #define PIN_SRC_TEST(xname,nid) { \
2019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2021 .info = alc_test_pin_src_info, \
2022 .get = alc_test_pin_src_get, \
2023 .put = alc_test_pin_src_put, \
2024 .private_value = nid \
2027 static struct snd_kcontrol_new alc880_test_mixer[] = {
2028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2029 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2030 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2031 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2032 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2033 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2034 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2035 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2036 PIN_CTL_TEST("Front Pin Mode", 0x14),
2037 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2038 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2039 PIN_CTL_TEST("Side Pin Mode", 0x17),
2040 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2041 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2042 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2043 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2044 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2045 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2046 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2047 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2048 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2049 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2050 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2051 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2052 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2053 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2054 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2055 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2060 .name = "Channel Mode",
2061 .info = alc_ch_mode_info,
2062 .get = alc_ch_mode_get,
2063 .put = alc_ch_mode_put,
2068 static struct hda_verb alc880_test_init_verbs[] = {
2069 /* Unmute inputs of 0x0c - 0x0f */
2070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2078 /* Vol output for 0x0c-0x0f */
2079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2083 /* Set output pins 0x14-0x17 */
2084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 /* Unmute output pins 0x14-0x17 */
2089 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 /* Set input pins 0x18-0x1c */
2094 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2095 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2098 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2099 /* Mute input pins 0x18-0x1b */
2100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2106 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2110 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2111 /* Analog input/passthru */
2112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2124 static struct hda_board_config alc880_cfg_tbl[] = {
2125 /* Back 3 jack, front 2 jack */
2126 { .modelname = "3stack", .config = ALC880_3ST },
2127 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2128 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2154 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2160 { .modelname = "tcl", .config = ALC880_TCL_S700 },
2161 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2163 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2164 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2165 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2166 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2168 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2169 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2170 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2171 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2174 { .modelname = "clevo", .config = ALC880_CLEVO },
2175 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2176 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2177 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2178 .config = ALC880_CLEVO }, /* Clevo m665n */
2180 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2181 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2182 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2183 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2185 /* Back 5 jack, front 2 jack */
2186 { .modelname = "5stack", .config = ALC880_5ST },
2187 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2188 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2189 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2190 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2191 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2193 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2194 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2195 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2196 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2197 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2198 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2199 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2200 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2201 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2202 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2203 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2204 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2205 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2206 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2207 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2208 /* note subvendor = 0 below */
2209 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2211 { .modelname = "w810", .config = ALC880_W810 },
2212 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2214 { .modelname = "z71v", .config = ALC880_Z71V },
2215 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2217 { .modelname = "6stack", .config = ALC880_6ST },
2218 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2220 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2221 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2223 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2224 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2225 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2226 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2227 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2228 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2229 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2230 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2231 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2232 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2233 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2234 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2236 { .modelname = "asus", .config = ALC880_ASUS },
2237 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2238 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2239 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2240 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2241 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2242 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2243 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
2244 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2247 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2248 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
2249 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2250 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
2251 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2252 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
2253 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2255 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2256 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2258 { .modelname = "F1734", .config = ALC880_F1734 },
2259 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2260 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2262 { .modelname = "lg", .config = ALC880_LG },
2263 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2264 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
2266 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2267 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2269 #ifdef CONFIG_SND_DEBUG
2270 { .modelname = "test", .config = ALC880_TEST },
2272 { .modelname = "auto", .config = ALC880_AUTO },
2278 * ALC880 codec presets
2280 static struct alc_config_preset alc880_presets[] = {
2282 .mixers = { alc880_three_stack_mixer },
2283 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2284 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2285 .dac_nids = alc880_dac_nids,
2286 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2287 .channel_mode = alc880_threestack_modes,
2289 .input_mux = &alc880_capture_source,
2291 [ALC880_3ST_DIG] = {
2292 .mixers = { alc880_three_stack_mixer },
2293 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2294 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2295 .dac_nids = alc880_dac_nids,
2296 .dig_out_nid = ALC880_DIGOUT_NID,
2297 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2298 .channel_mode = alc880_threestack_modes,
2300 .input_mux = &alc880_capture_source,
2302 [ALC880_TCL_S700] = {
2303 .mixers = { alc880_tcl_s700_mixer },
2304 .init_verbs = { alc880_volume_init_verbs,
2305 alc880_pin_tcl_S700_init_verbs,
2306 alc880_gpio2_init_verbs },
2307 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2308 .dac_nids = alc880_dac_nids,
2310 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2311 .channel_mode = alc880_2_jack_modes,
2312 .input_mux = &alc880_capture_source,
2315 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2316 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2317 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2318 .dac_nids = alc880_dac_nids,
2319 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2320 .channel_mode = alc880_fivestack_modes,
2321 .input_mux = &alc880_capture_source,
2323 [ALC880_5ST_DIG] = {
2324 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2325 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2326 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2327 .dac_nids = alc880_dac_nids,
2328 .dig_out_nid = ALC880_DIGOUT_NID,
2329 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2330 .channel_mode = alc880_fivestack_modes,
2331 .input_mux = &alc880_capture_source,
2334 .mixers = { alc880_six_stack_mixer },
2335 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2336 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2337 .dac_nids = alc880_6st_dac_nids,
2338 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2339 .channel_mode = alc880_sixstack_modes,
2340 .input_mux = &alc880_6stack_capture_source,
2342 [ALC880_6ST_DIG] = {
2343 .mixers = { alc880_six_stack_mixer },
2344 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2345 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2346 .dac_nids = alc880_6st_dac_nids,
2347 .dig_out_nid = ALC880_DIGOUT_NID,
2348 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2349 .channel_mode = alc880_sixstack_modes,
2350 .input_mux = &alc880_6stack_capture_source,
2353 .mixers = { alc880_w810_base_mixer },
2354 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2355 alc880_gpio2_init_verbs },
2356 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2357 .dac_nids = alc880_w810_dac_nids,
2358 .dig_out_nid = ALC880_DIGOUT_NID,
2359 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2360 .channel_mode = alc880_w810_modes,
2361 .input_mux = &alc880_capture_source,
2364 .mixers = { alc880_z71v_mixer },
2365 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2366 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2367 .dac_nids = alc880_z71v_dac_nids,
2368 .dig_out_nid = ALC880_DIGOUT_NID,
2370 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2371 .channel_mode = alc880_2_jack_modes,
2372 .input_mux = &alc880_capture_source,
2375 .mixers = { alc880_f1734_mixer },
2376 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2377 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2378 .dac_nids = alc880_f1734_dac_nids,
2380 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2381 .channel_mode = alc880_2_jack_modes,
2382 .input_mux = &alc880_capture_source,
2385 .mixers = { alc880_asus_mixer },
2386 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2387 alc880_gpio1_init_verbs },
2388 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2389 .dac_nids = alc880_asus_dac_nids,
2390 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2391 .channel_mode = alc880_asus_modes,
2393 .input_mux = &alc880_capture_source,
2395 [ALC880_ASUS_DIG] = {
2396 .mixers = { alc880_asus_mixer },
2397 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2398 alc880_gpio1_init_verbs },
2399 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2400 .dac_nids = alc880_asus_dac_nids,
2401 .dig_out_nid = ALC880_DIGOUT_NID,
2402 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2403 .channel_mode = alc880_asus_modes,
2405 .input_mux = &alc880_capture_source,
2407 [ALC880_ASUS_DIG2] = {
2408 .mixers = { alc880_asus_mixer },
2409 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2410 alc880_gpio2_init_verbs }, /* use GPIO2 */
2411 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2412 .dac_nids = alc880_asus_dac_nids,
2413 .dig_out_nid = ALC880_DIGOUT_NID,
2414 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2415 .channel_mode = alc880_asus_modes,
2417 .input_mux = &alc880_capture_source,
2419 [ALC880_ASUS_W1V] = {
2420 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2421 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2422 alc880_gpio1_init_verbs },
2423 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2424 .dac_nids = alc880_asus_dac_nids,
2425 .dig_out_nid = ALC880_DIGOUT_NID,
2426 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2427 .channel_mode = alc880_asus_modes,
2429 .input_mux = &alc880_capture_source,
2431 [ALC880_UNIWILL_DIG] = {
2432 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2433 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2434 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2435 .dac_nids = alc880_asus_dac_nids,
2436 .dig_out_nid = ALC880_DIGOUT_NID,
2437 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2438 .channel_mode = alc880_asus_modes,
2440 .input_mux = &alc880_capture_source,
2443 .mixers = { alc880_three_stack_mixer },
2444 .init_verbs = { alc880_volume_init_verbs,
2445 alc880_pin_clevo_init_verbs },
2446 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2447 .dac_nids = alc880_dac_nids,
2449 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2450 .channel_mode = alc880_threestack_modes,
2452 .input_mux = &alc880_capture_source,
2455 .mixers = { alc880_lg_mixer },
2456 .init_verbs = { alc880_volume_init_verbs,
2457 alc880_lg_init_verbs },
2458 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2459 .dac_nids = alc880_lg_dac_nids,
2460 .dig_out_nid = ALC880_DIGOUT_NID,
2461 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2462 .channel_mode = alc880_lg_ch_modes,
2464 .input_mux = &alc880_lg_capture_source,
2465 .unsol_event = alc880_lg_unsol_event,
2466 .init_hook = alc880_lg_automute,
2469 .mixers = { alc880_lg_lw_mixer },
2470 .init_verbs = { alc880_volume_init_verbs,
2471 alc880_lg_lw_init_verbs },
2473 .dac_nids = alc880_dac_nids,
2474 .dig_out_nid = ALC880_DIGOUT_NID,
2475 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2476 .channel_mode = alc880_2_jack_modes,
2477 .input_mux = &alc880_lg_lw_capture_source,
2478 .unsol_event = alc880_lg_lw_unsol_event,
2479 .init_hook = alc880_lg_lw_automute,
2481 #ifdef CONFIG_SND_DEBUG
2483 .mixers = { alc880_test_mixer },
2484 .init_verbs = { alc880_test_init_verbs },
2485 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2486 .dac_nids = alc880_test_dac_nids,
2487 .dig_out_nid = ALC880_DIGOUT_NID,
2488 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2489 .channel_mode = alc880_test_modes,
2490 .input_mux = &alc880_test_capture_source,
2496 * Automatic parse of I/O pins from the BIOS configuration
2499 #define NUM_CONTROL_ALLOC 32
2500 #define NUM_VERB_ALLOC 32
2504 ALC_CTL_WIDGET_MUTE,
2507 static struct snd_kcontrol_new alc880_control_templates[] = {
2508 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2509 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2510 HDA_BIND_MUTE(NULL, 0, 0, 0),
2513 /* add dynamic controls */
2514 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2516 struct snd_kcontrol_new *knew;
2518 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2519 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2521 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2524 if (spec->kctl_alloc) {
2525 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2526 kfree(spec->kctl_alloc);
2528 spec->kctl_alloc = knew;
2529 spec->num_kctl_alloc = num;
2532 knew = &spec->kctl_alloc[spec->num_kctl_used];
2533 *knew = alc880_control_templates[type];
2534 knew->name = kstrdup(name, GFP_KERNEL);
2537 knew->private_value = val;
2538 spec->num_kctl_used++;
2542 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2543 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2544 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2545 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2546 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2547 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2548 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2549 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2550 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2551 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2552 #define ALC880_PIN_CD_NID 0x1c
2554 /* fill in the dac_nids table from the parsed pin configuration */
2555 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2561 memset(assigned, 0, sizeof(assigned));
2562 spec->multiout.dac_nids = spec->private_dac_nids;
2564 /* check the pins hardwired to audio widget */
2565 for (i = 0; i < cfg->line_outs; i++) {
2566 nid = cfg->line_out_pins[i];
2567 if (alc880_is_fixed_pin(nid)) {
2568 int idx = alc880_fixed_pin_idx(nid);
2569 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2573 /* left pins can be connect to any audio widget */
2574 for (i = 0; i < cfg->line_outs; i++) {
2575 nid = cfg->line_out_pins[i];
2576 if (alc880_is_fixed_pin(nid))
2578 /* search for an empty channel */
2579 for (j = 0; j < cfg->line_outs; j++) {
2580 if (! assigned[j]) {
2581 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2587 spec->multiout.num_dacs = cfg->line_outs;
2591 /* add playback controls from the parsed DAC table */
2592 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2593 const struct auto_pin_cfg *cfg)
2596 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2600 for (i = 0; i < cfg->line_outs; i++) {
2601 if (! spec->multiout.dac_nids[i])
2603 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2606 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2607 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2609 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2610 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2612 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2613 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2615 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2616 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2619 sprintf(name, "%s Playback Volume", chname[i]);
2620 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2621 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2623 sprintf(name, "%s Playback Switch", chname[i]);
2624 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2625 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2632 /* add playback controls for speaker and HP outputs */
2633 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2643 if (alc880_is_fixed_pin(pin)) {
2644 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2645 /* specify the DAC as the extra output */
2646 if (! spec->multiout.hp_nid)
2647 spec->multiout.hp_nid = nid;
2649 spec->multiout.extra_out_nid[0] = nid;
2650 /* control HP volume/switch on the output mixer amp */
2651 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2652 sprintf(name, "%s Playback Volume", pfx);
2653 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2654 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2656 sprintf(name, "%s Playback Switch", pfx);
2657 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2658 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2660 } else if (alc880_is_multi_pin(pin)) {
2661 /* set manual connection */
2662 /* we have only a switch on HP-out PIN */
2663 sprintf(name, "%s Playback Switch", pfx);
2664 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2665 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2671 /* create input playback/capture controls for the given pin */
2672 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2673 int idx, hda_nid_t mix_nid)
2678 sprintf(name, "%s Playback Volume", ctlname);
2679 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2680 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2682 sprintf(name, "%s Playback Switch", ctlname);
2683 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2684 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2689 /* create playback/capture controls for input pins */
2690 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2691 const struct auto_pin_cfg *cfg)
2693 struct hda_input_mux *imux = &spec->private_imux;
2696 for (i = 0; i < AUTO_PIN_LAST; i++) {
2697 if (alc880_is_input_pin(cfg->input_pins[i])) {
2698 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2699 err = new_analog_input(spec, cfg->input_pins[i],
2700 auto_pin_cfg_labels[i],
2704 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2705 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2712 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2713 hda_nid_t nid, int pin_type,
2717 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2718 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2719 /* need the manual connection? */
2720 if (alc880_is_multi_pin(nid)) {
2721 struct alc_spec *spec = codec->spec;
2722 int idx = alc880_multi_pin_idx(nid);
2723 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2724 AC_VERB_SET_CONNECT_SEL,
2725 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2729 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2731 struct alc_spec *spec = codec->spec;
2734 for (i = 0; i < spec->autocfg.line_outs; i++) {
2735 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2736 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2740 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2742 struct alc_spec *spec = codec->spec;
2745 pin = spec->autocfg.speaker_pins[0];
2746 if (pin) /* connect to front */
2747 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2748 pin = spec->autocfg.hp_pin;
2749 if (pin) /* connect to front */
2750 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2753 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2755 struct alc_spec *spec = codec->spec;
2758 for (i = 0; i < AUTO_PIN_LAST; i++) {
2759 hda_nid_t nid = spec->autocfg.input_pins[i];
2760 if (alc880_is_input_pin(nid)) {
2761 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2762 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2763 if (nid != ALC880_PIN_CD_NID)
2764 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2770 /* parse the BIOS configuration and set up the alc_spec */
2771 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2772 static int alc880_parse_auto_config(struct hda_codec *codec)
2774 struct alc_spec *spec = codec->spec;
2776 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2778 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2779 alc880_ignore)) < 0)
2781 if (! spec->autocfg.line_outs)
2782 return 0; /* can't find valid BIOS pin config */
2784 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2785 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2786 (err = alc880_auto_create_extra_out(spec,
2787 spec->autocfg.speaker_pins[0],
2789 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2790 "Headphone")) < 0 ||
2791 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2794 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2796 if (spec->autocfg.dig_out_pin)
2797 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2798 if (spec->autocfg.dig_in_pin)
2799 spec->dig_in_nid = ALC880_DIGIN_NID;
2801 if (spec->kctl_alloc)
2802 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2804 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2806 spec->num_mux_defs = 1;
2807 spec->input_mux = &spec->private_imux;
2812 /* additional initialization for auto-configuration model */
2813 static void alc880_auto_init(struct hda_codec *codec)
2815 alc880_auto_init_multi_out(codec);
2816 alc880_auto_init_extra_out(codec);
2817 alc880_auto_init_analog_input(codec);
2821 * OK, here we have finally the patch for ALC880
2824 static int patch_alc880(struct hda_codec *codec)
2826 struct alc_spec *spec;
2830 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2836 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2837 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2838 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2839 "trying auto-probe from BIOS...\n");
2840 board_config = ALC880_AUTO;
2843 if (board_config == ALC880_AUTO) {
2844 /* automatic parse from the BIOS config */
2845 err = alc880_parse_auto_config(codec);
2851 "hda_codec: Cannot set up configuration "
2852 "from BIOS. Using 3-stack mode...\n");
2853 board_config = ALC880_3ST;
2857 if (board_config != ALC880_AUTO)
2858 setup_preset(spec, &alc880_presets[board_config]);
2860 spec->stream_name_analog = "ALC880 Analog";
2861 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2862 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2864 spec->stream_name_digital = "ALC880 Digital";
2865 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2866 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2868 if (! spec->adc_nids && spec->input_mux) {
2869 /* check whether NID 0x07 is valid */
2870 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2871 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2872 if (wcap != AC_WID_AUD_IN) {
2873 spec->adc_nids = alc880_adc_nids_alt;
2874 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2875 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2878 spec->adc_nids = alc880_adc_nids;
2879 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2880 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2885 codec->patch_ops = alc_patch_ops;
2886 if (board_config == ALC880_AUTO)
2887 spec->init_hook = alc880_auto_init;
2897 static hda_nid_t alc260_dac_nids[1] = {
2902 static hda_nid_t alc260_adc_nids[1] = {
2907 static hda_nid_t alc260_adc_nids_alt[1] = {
2912 static hda_nid_t alc260_hp_adc_nids[2] = {
2917 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2918 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2920 static hda_nid_t alc260_dual_adc_nids[2] = {
2925 #define ALC260_DIGOUT_NID 0x03
2926 #define ALC260_DIGIN_NID 0x06
2928 static struct hda_input_mux alc260_capture_source = {
2932 { "Front Mic", 0x1 },
2938 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2939 * headphone jack and the internal CD lines since these are the only pins at
2940 * which audio can appear. For flexibility, also allow the option of
2941 * recording the mixer output on the second ADC (ADC0 doesn't have a
2942 * connection to the mixer output).
2944 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2948 { "Mic/Line", 0x0 },
2950 { "Headphone", 0x2 },
2956 { "Mic/Line", 0x0 },
2958 { "Headphone", 0x2 },
2965 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2966 * the Fujitsu S702x, but jacks are marked differently.
2968 static struct hda_input_mux alc260_acer_capture_sources[2] = {
2975 { "Headphone", 0x5 },
2984 { "Headphone", 0x6 },
2990 * This is just place-holder, so there's something for alc_build_pcms to look
2991 * at when it calculates the maximum number of channels. ALC260 has no mixer
2992 * element which allows changing the channel mode, so the verb list is
2995 static struct hda_channel_mode alc260_modes[1] = {
3000 /* Mixer combinations
3002 * basic: base_output + input + pc_beep + capture
3003 * HP: base_output + input + capture_alt
3004 * HP_3013: hp_3013 + input + capture
3005 * fujitsu: fujitsu + capture
3006 * acer: acer + capture
3009 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3010 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3011 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3012 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3013 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3014 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3019 static struct snd_kcontrol_new alc260_input_mixer[] = {
3020 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3021 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3022 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3023 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3025 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3026 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3027 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3031 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3032 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3033 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3037 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3038 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3039 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3040 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3041 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3042 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3043 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3045 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3049 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3050 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3052 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3053 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3054 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3055 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3056 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3057 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3058 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3059 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3060 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3061 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3062 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3063 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3064 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3068 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3069 * versions of the ALC260 don't act on requests to enable mic bias from NID
3070 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3071 * datasheet doesn't mention this restriction. At this stage it's not clear
3072 * whether this behaviour is intentional or is a hardware bug in chip
3073 * revisions available in early 2006. Therefore for now allow the
3074 * "Headphone Jack Mode" control to span all choices, but if it turns out
3075 * that the lack of mic bias for this NID is intentional we could change the
3076 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3078 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3079 * don't appear to make the mic bias available from the "line" jack, even
3080 * though the NID used for this jack (0x14) can supply it. The theory is
3081 * that perhaps Acer have included blocking capacitors between the ALC260
3082 * and the output jack. If this turns out to be the case for all such
3083 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3084 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3086 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3087 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3088 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3089 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3090 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3091 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3092 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3093 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3094 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3095 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3096 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3097 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3098 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3099 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3103 /* capture mixer elements */
3104 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3105 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3106 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3107 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3108 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3111 /* The multiple "Capture Source" controls confuse alsamixer
3112 * So call somewhat different..
3113 * FIXME: the controls appear in the "playback" view!
3115 /* .name = "Capture Source", */
3116 .name = "Input Source",
3118 .info = alc_mux_enum_info,
3119 .get = alc_mux_enum_get,
3120 .put = alc_mux_enum_put,
3125 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3126 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3127 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3129 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3130 /* The multiple "Capture Source" controls confuse alsamixer
3131 * So call somewhat different..
3132 * FIXME: the controls appear in the "playback" view!
3134 /* .name = "Capture Source", */
3135 .name = "Input Source",
3137 .info = alc_mux_enum_info,
3138 .get = alc_mux_enum_get,
3139 .put = alc_mux_enum_put,
3145 * initialization verbs
3147 static struct hda_verb alc260_init_verbs[] = {
3148 /* Line In pin widget for input */
3149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3150 /* CD pin widget for input */
3151 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3152 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3153 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3154 /* Mic2 (front panel) pin widget for input and vref at 80% */
3155 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3156 /* LINE-2 is used for line-out in rear */
3157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3158 /* select line-out */
3159 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3161 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3163 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3165 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3166 /* mute capture amp left and right */
3167 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3168 /* set connection select to line in (default select for this ADC) */
3169 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3170 /* mute capture amp left and right */
3171 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3172 /* set connection select to line in (default select for this ADC) */
3173 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3174 /* set vol=0 Line-Out mixer amp left and right */
3175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3176 /* unmute pin widget amp left and right (no gain on this amp) */
3177 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3178 /* set vol=0 HP mixer amp left and right */
3179 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3180 /* unmute pin widget amp left and right (no gain on this amp) */
3181 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3182 /* set vol=0 Mono mixer amp left and right */
3183 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3184 /* unmute pin widget amp left and right (no gain on this amp) */
3185 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186 /* unmute LINE-2 out pin */
3187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3192 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3195 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3196 /* mute Front out path */
3197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3199 /* mute Headphone out path */
3200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3202 /* mute Mono out path */
3203 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3204 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3208 #if 0 /* should be identical with alc260_init_verbs? */
3209 static struct hda_verb alc260_hp_init_verbs[] = {
3210 /* Headphone and output */
3211 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3213 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3214 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3215 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3216 /* Mic2 (front panel) pin widget for input and vref at 80% */
3217 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3218 /* Line In pin widget for input */
3219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3220 /* Line-2 pin widget for output */
3221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3222 /* CD pin widget for input */
3223 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3224 /* unmute amp left and right */
3225 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3226 /* set connection select to line in (default select for this ADC) */
3227 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3228 /* unmute Line-Out mixer amp left and right (volume = 0) */
3229 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3230 /* mute pin widget amp left and right (no gain on this amp) */
3231 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3232 /* unmute HP mixer amp left and right (volume = 0) */
3233 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3234 /* mute pin widget amp left and right (no gain on this amp) */
3235 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3236 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3239 /* unmute Line In */
3240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3243 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3244 /* Unmute Front out path */
3245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3246 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3247 /* Unmute Headphone out path */
3248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3249 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3250 /* Unmute Mono out path */
3251 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3252 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3257 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3258 /* Line out and output */
3259 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3261 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3262 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3263 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3264 /* Mic2 (front panel) pin widget for input and vref at 80% */
3265 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3266 /* Line In pin widget for input */
3267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3268 /* Headphone pin widget for output */
3269 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3270 /* CD pin widget for input */
3271 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3272 /* unmute amp left and right */
3273 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3274 /* set connection select to line in (default select for this ADC) */
3275 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3276 /* unmute Line-Out mixer amp left and right (volume = 0) */
3277 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3278 /* mute pin widget amp left and right (no gain on this amp) */
3279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3280 /* unmute HP mixer amp left and right (volume = 0) */
3281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3282 /* mute pin widget amp left and right (no gain on this amp) */
3283 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3284 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3287 /* unmute Line In */
3288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3291 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3292 /* Unmute Front out path */
3293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3295 /* Unmute Headphone out path */
3296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3298 /* Unmute Mono out path */
3299 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3300 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3304 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3305 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3306 * audio = 0x16, internal speaker = 0x10.
3308 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3309 /* Disable all GPIOs */
3310 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3311 /* Internal speaker is connected to headphone pin */
3312 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3313 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3315 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3316 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3317 /* Ensure all other unused pins are disabled and muted. */
3318 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3319 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3320 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3321 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3322 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3323 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3327 /* Disable digital (SPDIF) pins */
3328 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3329 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3331 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3332 * when acting as an output.
3334 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3336 /* Start with output sum widgets muted and their output gains at min */
3337 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3347 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3348 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3349 /* Unmute Line1 pin widget output buffer since it starts as an output.
3350 * If the pin mode is changed by the user the pin mode control will
3351 * take care of enabling the pin's input/output buffers as needed.
3352 * Therefore there's no need to enable the input buffer at this
3355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3356 /* Unmute input buffer of pin widget used for Line-in (no equiv
3359 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3361 /* Mute capture amp left and right */
3362 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3363 /* Set ADC connection select to match default mixer setting - line
3366 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3368 /* Do the same for the second ADC: mute capture input amp and
3369 * set ADC connection to line in (on mic1 pin)
3371 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3372 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3374 /* Mute all inputs to mixer widget (even unconnected ones) */
3375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3387 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3388 * similar laptops (adapted from Fujitsu init verbs).
3390 static struct hda_verb alc260_acer_init_verbs[] = {
3391 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3392 * the headphone jack. Turn this on and rely on the standard mute
3393 * methods whenever the user wants to turn these outputs off.
3395 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3396 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3397 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3398 /* Internal speaker/Headphone jack is connected to Line-out pin */
3399 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3400 /* Internal microphone/Mic jack is connected to Mic1 pin */
3401 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3402 /* Line In jack is connected to Line1 pin */
3403 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3404 /* Ensure all other unused pins are disabled and muted. */
3405 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3406 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3407 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3408 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3409 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3410 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3411 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3413 /* Disable digital (SPDIF) pins */
3414 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3415 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3417 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3418 * bus when acting as outputs.
3420 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3421 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3423 /* Start with output sum widgets muted and their output gains at min */
3424 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3430 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3431 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3432 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3434 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3435 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3436 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3437 * inputs. If the pin mode is changed by the user the pin mode control
3438 * will take care of enabling the pin's input/output buffers as needed.
3439 * Therefore there's no need to enable the input buffer at this
3442 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3443 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3445 /* Mute capture amp left and right */
3446 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3447 /* Set ADC connection select to match default mixer setting - mic
3450 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3452 /* Do similar with the second ADC: mute capture input amp and
3453 * set ADC connection to mic to match ALSA's default state.
3455 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3456 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3458 /* Mute all inputs to mixer widget (even unconnected ones) */
3459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3471 /* Test configuration for debugging, modelled after the ALC880 test
3474 #ifdef CONFIG_SND_DEBUG
3475 static hda_nid_t alc260_test_dac_nids[1] = {
3478 static hda_nid_t alc260_test_adc_nids[2] = {
3481 /* For testing the ALC260, each input MUX needs its own definition since
3482 * the signal assignments are different. This assumes that the first ADC
3485 static struct hda_input_mux alc260_test_capture_sources[2] = {
3489 { "MIC1 pin", 0x0 },
3490 { "MIC2 pin", 0x1 },
3491 { "LINE1 pin", 0x2 },
3492 { "LINE2 pin", 0x3 },
3494 { "LINE-OUT pin", 0x5 },
3495 { "HP-OUT pin", 0x6 },
3501 { "MIC1 pin", 0x0 },
3502 { "MIC2 pin", 0x1 },
3503 { "LINE1 pin", 0x2 },
3504 { "LINE2 pin", 0x3 },
3507 { "LINE-OUT pin", 0x6 },
3508 { "HP-OUT pin", 0x7 },
3512 static struct snd_kcontrol_new alc260_test_mixer[] = {
3513 /* Output driver widgets */
3514 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3515 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3516 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3517 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3518 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3519 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3521 /* Modes for retasking pin widgets
3522 * Note: the ALC260 doesn't seem to act on requests to enable mic
3523 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3524 * mention this restriction. At this stage it's not clear whether
3525 * this behaviour is intentional or is a hardware bug in chip
3526 * revisions available at least up until early 2006. Therefore for
3527 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3528 * choices, but if it turns out that the lack of mic bias for these
3529 * NIDs is intentional we could change their modes from
3530 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3532 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3533 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3534 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3535 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3536 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3537 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3539 /* Loopback mixer controls */
3540 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3541 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3542 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3543 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3544 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3545 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3546 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3547 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3548 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3549 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3550 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3551 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3552 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3553 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3554 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3555 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3557 /* Controls for GPIO pins, assuming they are configured as outputs */
3558 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3559 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3560 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3561 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3563 /* Switches to allow the digital IO pins to be enabled. The datasheet
3564 * is ambigious as to which NID is which; testing on laptops which
3565 * make this output available should provide clarification.
3567 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3568 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3572 static struct hda_verb alc260_test_init_verbs[] = {
3573 /* Enable all GPIOs as outputs with an initial value of 0 */
3574 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3575 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3576 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3578 /* Enable retasking pins as output, initially without power amp */
3579 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3580 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3583 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3584 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3586 /* Disable digital (SPDIF) pins initially, but users can enable
3587 * them via a mixer switch. In the case of SPDIF-out, this initverb
3588 * payload also sets the generation to 0, output to be in "consumer"
3589 * PCM format, copyright asserted, no pre-emphasis and no validity
3592 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3593 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3595 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3596 * OUT1 sum bus when acting as an output.
3598 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3599 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3600 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3601 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3603 /* Start with output sum widgets muted and their output gains at min */
3604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3610 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3612 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3614 /* Unmute retasking pin widget output buffers since the default
3615 * state appears to be output. As the pin mode is changed by the
3616 * user the pin mode control will take care of enabling the pin's
3617 * input/output buffers as needed.
3619 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3620 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3621 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3623 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3624 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3625 /* Also unmute the mono-out pin widget */
3626 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3628 /* Mute capture amp left and right */
3629 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3630 /* Set ADC connection select to match default mixer setting (mic1
3633 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3635 /* Do the same for the second ADC: mute capture input amp and
3636 * set ADC connection to mic1 pin
3638 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3639 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3641 /* Mute all inputs to mixer widget (even unconnected ones) */
3642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3655 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3661 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3667 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3668 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3671 * for BIOS auto-configuration
3674 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3678 unsigned long vol_val, sw_val;
3682 if (nid >= 0x0f && nid < 0x11) {
3683 nid_vol = nid - 0x7;
3684 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3685 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3686 } else if (nid == 0x11) {
3687 nid_vol = nid - 0x7;
3688 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3689 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3690 } else if (nid >= 0x12 && nid <= 0x15) {
3692 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3693 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3697 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3698 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3700 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3701 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3706 /* add playback controls from the parsed DAC table */
3707 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3708 const struct auto_pin_cfg *cfg)
3713 spec->multiout.num_dacs = 1;
3714 spec->multiout.dac_nids = spec->private_dac_nids;
3715 spec->multiout.dac_nids[0] = 0x02;
3717 nid = cfg->line_out_pins[0];
3719 err = alc260_add_playback_controls(spec, nid, "Front");
3724 nid = cfg->speaker_pins[0];
3726 err = alc260_add_playback_controls(spec, nid, "Speaker");
3733 err = alc260_add_playback_controls(spec, nid, "Headphone");
3740 /* create playback/capture controls for input pins */
3741 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3742 const struct auto_pin_cfg *cfg)
3744 struct hda_input_mux *imux = &spec->private_imux;
3747 for (i = 0; i < AUTO_PIN_LAST; i++) {
3748 if (cfg->input_pins[i] >= 0x12) {
3749 idx = cfg->input_pins[i] - 0x12;
3750 err = new_analog_input(spec, cfg->input_pins[i],
3751 auto_pin_cfg_labels[i], idx, 0x07);
3754 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3755 imux->items[imux->num_items].index = idx;
3758 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3759 idx = cfg->input_pins[i] - 0x09;
3760 err = new_analog_input(spec, cfg->input_pins[i],
3761 auto_pin_cfg_labels[i], idx, 0x07);
3764 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3765 imux->items[imux->num_items].index = idx;
3772 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3773 hda_nid_t nid, int pin_type,
3777 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3779 /* need the manual connection? */
3781 int idx = nid - 0x12;
3782 snd_hda_codec_write(codec, idx + 0x0b, 0,
3783 AC_VERB_SET_CONNECT_SEL, sel_idx);
3788 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3790 struct alc_spec *spec = codec->spec;
3793 nid = spec->autocfg.line_out_pins[0];
3795 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3797 nid = spec->autocfg.speaker_pins[0];
3799 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3801 nid = spec->autocfg.hp_pin;
3803 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3806 #define ALC260_PIN_CD_NID 0x16
3807 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3809 struct alc_spec *spec = codec->spec;
3812 for (i = 0; i < AUTO_PIN_LAST; i++) {
3813 hda_nid_t nid = spec->autocfg.input_pins[i];
3815 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3816 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3817 if (nid != ALC260_PIN_CD_NID)
3818 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3825 * generic initialization of ADC, input mixers and output mixers
3827 static struct hda_verb alc260_volume_init_verbs[] = {
3829 * Unmute ADC0-1 and set the default input to mic-in
3831 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3832 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3833 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3834 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3836 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3838 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3841 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3849 * Set up output mixers (0x08 - 0x0a)
3851 /* set vol=0 to output mixers */
3852 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3853 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3854 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3855 /* set up input amps for analog loopback */
3856 /* Amp Indices: DAC = 0, mixer = 1 */
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3867 static int alc260_parse_auto_config(struct hda_codec *codec)
3869 struct alc_spec *spec = codec->spec;
3872 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3874 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3875 alc260_ignore)) < 0)
3877 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3879 if (! spec->kctl_alloc)
3880 return 0; /* can't find valid BIOS pin config */
3881 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3884 spec->multiout.max_channels = 2;
3886 if (spec->autocfg.dig_out_pin)
3887 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3888 if (spec->kctl_alloc)
3889 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3891 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3893 spec->num_mux_defs = 1;
3894 spec->input_mux = &spec->private_imux;
3896 /* check whether NID 0x04 is valid */
3897 wcap = get_wcaps(codec, 0x04);
3898 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3899 if (wcap != AC_WID_AUD_IN) {
3900 spec->adc_nids = alc260_adc_nids_alt;
3901 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3902 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3904 spec->adc_nids = alc260_adc_nids;
3905 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3906 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3913 /* additional initialization for auto-configuration model */
3914 static void alc260_auto_init(struct hda_codec *codec)
3916 alc260_auto_init_multi_out(codec);
3917 alc260_auto_init_analog_input(codec);
3921 * ALC260 configurations
3923 static struct hda_board_config alc260_cfg_tbl[] = {
3924 { .modelname = "basic", .config = ALC260_BASIC },
3925 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3926 .config = ALC260_BASIC }, /* Sony VAIO */
3927 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3928 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
3929 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3930 .config = ALC260_BASIC }, /* Sony VAIO */
3931 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3932 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
3933 { .modelname = "hp", .config = ALC260_HP },
3934 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
3935 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
3936 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3937 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
3938 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3939 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3941 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3942 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3943 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3944 { .modelname = "acer", .config = ALC260_ACER },
3945 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
3946 #ifdef CONFIG_SND_DEBUG
3947 { .modelname = "test", .config = ALC260_TEST },
3949 { .modelname = "auto", .config = ALC260_AUTO },
3953 static struct alc_config_preset alc260_presets[] = {
3955 .mixers = { alc260_base_output_mixer,
3957 alc260_pc_beep_mixer,
3958 alc260_capture_mixer },
3959 .init_verbs = { alc260_init_verbs },
3960 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3961 .dac_nids = alc260_dac_nids,
3962 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3963 .adc_nids = alc260_adc_nids,
3964 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3965 .channel_mode = alc260_modes,
3966 .input_mux = &alc260_capture_source,
3969 .mixers = { alc260_base_output_mixer,
3971 alc260_capture_alt_mixer },
3972 .init_verbs = { alc260_init_verbs },
3973 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3974 .dac_nids = alc260_dac_nids,
3975 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3976 .adc_nids = alc260_hp_adc_nids,
3977 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3978 .channel_mode = alc260_modes,
3979 .input_mux = &alc260_capture_source,
3981 [ALC260_HP_3013] = {
3982 .mixers = { alc260_hp_3013_mixer,
3984 alc260_capture_alt_mixer },
3985 .init_verbs = { alc260_hp_3013_init_verbs },
3986 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3987 .dac_nids = alc260_dac_nids,
3988 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3989 .adc_nids = alc260_hp_adc_nids,
3990 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3991 .channel_mode = alc260_modes,
3992 .input_mux = &alc260_capture_source,
3994 [ALC260_FUJITSU_S702X] = {
3995 .mixers = { alc260_fujitsu_mixer,
3996 alc260_capture_mixer },
3997 .init_verbs = { alc260_fujitsu_init_verbs },
3998 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3999 .dac_nids = alc260_dac_nids,
4000 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4001 .adc_nids = alc260_dual_adc_nids,
4002 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4003 .channel_mode = alc260_modes,
4004 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4005 .input_mux = alc260_fujitsu_capture_sources,
4008 .mixers = { alc260_acer_mixer,
4009 alc260_capture_mixer },
4010 .init_verbs = { alc260_acer_init_verbs },
4011 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4012 .dac_nids = alc260_dac_nids,
4013 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4014 .adc_nids = alc260_dual_adc_nids,
4015 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4016 .channel_mode = alc260_modes,
4017 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4018 .input_mux = alc260_acer_capture_sources,
4020 #ifdef CONFIG_SND_DEBUG
4022 .mixers = { alc260_test_mixer,
4023 alc260_capture_mixer },
4024 .init_verbs = { alc260_test_init_verbs },
4025 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4026 .dac_nids = alc260_test_dac_nids,
4027 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4028 .adc_nids = alc260_test_adc_nids,
4029 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4030 .channel_mode = alc260_modes,
4031 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4032 .input_mux = alc260_test_capture_sources,
4037 static int patch_alc260(struct hda_codec *codec)
4039 struct alc_spec *spec;
4040 int err, board_config;
4042 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4048 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4049 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
4050 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4051 "trying auto-probe from BIOS...\n");
4052 board_config = ALC260_AUTO;
4055 if (board_config == ALC260_AUTO) {
4056 /* automatic parse from the BIOS config */
4057 err = alc260_parse_auto_config(codec);
4063 "hda_codec: Cannot set up configuration "
4064 "from BIOS. Using base mode...\n");
4065 board_config = ALC260_BASIC;
4069 if (board_config != ALC260_AUTO)
4070 setup_preset(spec, &alc260_presets[board_config]);
4072 spec->stream_name_analog = "ALC260 Analog";
4073 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4074 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4076 spec->stream_name_digital = "ALC260 Digital";
4077 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4078 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4080 codec->patch_ops = alc_patch_ops;
4081 if (board_config == ALC260_AUTO)
4082 spec->init_hook = alc260_auto_init;
4091 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4092 * configuration. Each pin widget can choose any input DACs and a mixer.
4093 * Each ADC is connected from a mixer of all inputs. This makes possible
4094 * 6-channel independent captures.
4096 * In addition, an independent DAC for the multi-playback (not used in this
4099 #define ALC882_DIGOUT_NID 0x06
4100 #define ALC882_DIGIN_NID 0x0a
4102 static struct hda_channel_mode alc882_ch_modes[1] = {
4106 static hda_nid_t alc882_dac_nids[4] = {
4107 /* front, rear, clfe, rear_surr */
4108 0x02, 0x03, 0x04, 0x05
4111 /* identical with ALC880 */
4112 #define alc882_adc_nids alc880_adc_nids
4113 #define alc882_adc_nids_alt alc880_adc_nids_alt
4116 /* FIXME: should be a matrix-type input source selection */
4118 static struct hda_input_mux alc882_capture_source = {
4122 { "Front Mic", 0x1 },
4127 #define alc882_mux_enum_info alc_mux_enum_info
4128 #define alc882_mux_enum_get alc_mux_enum_get
4130 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4132 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4133 struct alc_spec *spec = codec->spec;
4134 const struct hda_input_mux *imux = spec->input_mux;
4135 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4136 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4137 hda_nid_t nid = capture_mixers[adc_idx];
4138 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4139 unsigned int i, idx;
4141 idx = ucontrol->value.enumerated.item[0];
4142 if (idx >= imux->num_items)
4143 idx = imux->num_items - 1;
4144 if (*cur_val == idx && ! codec->in_resume)
4146 for (i = 0; i < imux->num_items; i++) {
4147 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4148 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4149 v | (imux->items[i].index << 8));
4158 static struct hda_verb alc882_sixstack_ch6_init[] = {
4159 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4160 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4161 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4169 static struct hda_verb alc882_sixstack_ch8_init[] = {
4170 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4171 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4172 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4173 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4177 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4178 { 6, alc882_sixstack_ch6_init },
4179 { 8, alc882_sixstack_ch8_init },
4182 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4183 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4185 static struct snd_kcontrol_new alc882_base_mixer[] = {
4186 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4188 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4189 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4190 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4191 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4192 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4193 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4194 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4195 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4196 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4199 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4200 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4203 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4205 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4206 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4210 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4213 .name = "Channel Mode",
4214 .info = alc_ch_mode_info,
4215 .get = alc_ch_mode_get,
4216 .put = alc_ch_mode_put,
4221 static struct hda_verb alc882_init_verbs[] = {
4222 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4231 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4235 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4239 /* Front Pin: output 0 (0x0c) */
4240 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4243 /* Rear Pin: output 1 (0x0d) */
4244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4245 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4247 /* CLFE Pin: output 2 (0x0e) */
4248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4249 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4250 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4251 /* Side Pin: output 3 (0x0f) */
4252 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4253 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4254 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4255 /* Mic (rear) pin: input vref at 80% */
4256 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4257 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4258 /* Front Mic pin: input vref at 80% */
4259 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4260 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4261 /* Line In pin: input */
4262 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4263 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4264 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4265 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4266 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4267 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4268 /* CD pin widget for input */
4269 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4271 /* FIXME: use matrix-type input source selection */
4272 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4273 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4288 /* ADC1: mute amp left and right */
4289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4290 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4291 /* ADC2: mute amp left and right */
4292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4293 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4294 /* ADC3: mute amp left and right */
4295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4296 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4301 static struct hda_verb alc882_eapd_verbs[] = {
4302 /* change to EAPD mode */
4303 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4304 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4309 * generic initialization of ADC, input mixers and output mixers
4311 static struct hda_verb alc882_auto_init_verbs[] = {
4313 * Unmute ADC0-2 and set the default input to mic-in
4315 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4317 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4318 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4319 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4320 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4322 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4324 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4327 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4335 * Set up output mixers (0x0c - 0x0f)
4337 /* set vol=0 to output mixers */
4338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4339 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4340 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4341 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4342 /* set up input amps for analog loopback */
4343 /* Amp Indices: DAC = 0, mixer = 1 */
4344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4352 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4353 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4355 /* FIXME: use matrix-type input source selection */
4356 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4357 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4376 /* capture mixer elements */
4377 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4378 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4379 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4380 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4381 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4384 /* The multiple "Capture Source" controls confuse alsamixer
4385 * So call somewhat different..
4386 * FIXME: the controls appear in the "playback" view!
4388 /* .name = "Capture Source", */
4389 .name = "Input Source",
4391 .info = alc882_mux_enum_info,
4392 .get = alc882_mux_enum_get,
4393 .put = alc882_mux_enum_put,
4398 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4399 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4400 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4401 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4402 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4403 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4404 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4407 /* The multiple "Capture Source" controls confuse alsamixer
4408 * So call somewhat different..
4409 * FIXME: the controls appear in the "playback" view!
4411 /* .name = "Capture Source", */
4412 .name = "Input Source",
4414 .info = alc882_mux_enum_info,
4415 .get = alc882_mux_enum_get,
4416 .put = alc882_mux_enum_put,
4421 /* pcm configuration: identiacal with ALC880 */
4422 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4423 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4424 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4425 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4428 * configuration and preset
4430 static struct hda_board_config alc882_cfg_tbl[] = {
4431 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4432 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4433 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4434 .config = ALC882_6ST_DIG }, /* MSI */
4435 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4436 .config = ALC882_6ST_DIG }, /* Foxconn */
4437 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4438 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
4439 { .modelname = "arima", .config = ALC882_ARIMA },
4440 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4441 .config = ALC882_ARIMA }, /* Arima W820Di1 */
4442 { .modelname = "auto", .config = ALC882_AUTO },
4446 static struct alc_config_preset alc882_presets[] = {
4447 [ALC882_3ST_DIG] = {
4448 .mixers = { alc882_base_mixer },
4449 .init_verbs = { alc882_init_verbs },
4450 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4451 .dac_nids = alc882_dac_nids,
4452 .dig_out_nid = ALC882_DIGOUT_NID,
4453 .dig_in_nid = ALC882_DIGIN_NID,
4454 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4455 .channel_mode = alc882_ch_modes,
4457 .input_mux = &alc882_capture_source,
4459 [ALC882_6ST_DIG] = {
4460 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4461 .init_verbs = { alc882_init_verbs },
4462 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4463 .dac_nids = alc882_dac_nids,
4464 .dig_out_nid = ALC882_DIGOUT_NID,
4465 .dig_in_nid = ALC882_DIGIN_NID,
4466 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4467 .channel_mode = alc882_sixstack_modes,
4468 .input_mux = &alc882_capture_source,
4471 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4472 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4473 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4474 .dac_nids = alc882_dac_nids,
4475 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4476 .channel_mode = alc882_sixstack_modes,
4477 .input_mux = &alc882_capture_source,
4483 * BIOS auto configuration
4485 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4486 hda_nid_t nid, int pin_type,
4490 struct alc_spec *spec = codec->spec;
4493 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4496 idx = spec->multiout.dac_nids[dac_idx] - 2;
4498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4499 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4500 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4504 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4506 struct alc_spec *spec = codec->spec;
4509 for (i = 0; i <= HDA_SIDE; i++) {
4510 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4512 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4516 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4518 struct alc_spec *spec = codec->spec;
4521 pin = spec->autocfg.hp_pin;
4522 if (pin) /* connect to front */
4523 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4526 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4527 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4529 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4531 struct alc_spec *spec = codec->spec;
4534 for (i = 0; i < AUTO_PIN_LAST; i++) {
4535 hda_nid_t nid = spec->autocfg.input_pins[i];
4536 if (alc882_is_input_pin(nid)) {
4537 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4538 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4539 if (nid != ALC882_PIN_CD_NID)
4540 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4546 /* almost identical with ALC880 parser... */
4547 static int alc882_parse_auto_config(struct hda_codec *codec)
4549 struct alc_spec *spec = codec->spec;
4550 int err = alc880_parse_auto_config(codec);
4555 /* hack - override the init verbs */
4556 spec->init_verbs[0] = alc882_auto_init_verbs;
4560 /* additional initialization for auto-configuration model */
4561 static void alc882_auto_init(struct hda_codec *codec)
4563 alc882_auto_init_multi_out(codec);
4564 alc882_auto_init_hp_out(codec);
4565 alc882_auto_init_analog_input(codec);
4568 static int patch_alc882(struct hda_codec *codec)
4570 struct alc_spec *spec;
4571 int err, board_config;
4573 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4579 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4581 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4582 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4583 "trying auto-probe from BIOS...\n");
4584 board_config = ALC882_AUTO;
4587 if (board_config == ALC882_AUTO) {
4588 /* automatic parse from the BIOS config */
4589 err = alc882_parse_auto_config(codec);
4595 "hda_codec: Cannot set up configuration "
4596 "from BIOS. Using base mode...\n");
4597 board_config = ALC882_3ST_DIG;
4601 if (board_config != ALC882_AUTO)
4602 setup_preset(spec, &alc882_presets[board_config]);
4604 spec->stream_name_analog = "ALC882 Analog";
4605 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4606 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4608 spec->stream_name_digital = "ALC882 Digital";
4609 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4610 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4612 if (! spec->adc_nids && spec->input_mux) {
4613 /* check whether NID 0x07 is valid */
4614 unsigned int wcap = get_wcaps(codec, 0x07);
4615 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4616 if (wcap != AC_WID_AUD_IN) {
4617 spec->adc_nids = alc882_adc_nids_alt;
4618 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4619 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4622 spec->adc_nids = alc882_adc_nids;
4623 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4624 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4629 codec->patch_ops = alc_patch_ops;
4630 if (board_config == ALC882_AUTO)
4631 spec->init_hook = alc882_auto_init;
4639 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4640 * configuration. Each pin widget can choose any input DACs and a mixer.
4641 * Each ADC is connected from a mixer of all inputs. This makes possible
4642 * 6-channel independent captures.
4644 * In addition, an independent DAC for the multi-playback (not used in this
4647 #define ALC883_DIGOUT_NID 0x06
4648 #define ALC883_DIGIN_NID 0x0a
4650 static hda_nid_t alc883_dac_nids[4] = {
4651 /* front, rear, clfe, rear_surr */
4652 0x02, 0x04, 0x03, 0x05
4655 static hda_nid_t alc883_adc_nids[2] = {
4660 /* FIXME: should be a matrix-type input source selection */
4662 static struct hda_input_mux alc883_capture_source = {
4666 { "Front Mic", 0x1 },
4671 #define alc883_mux_enum_info alc_mux_enum_info
4672 #define alc883_mux_enum_get alc_mux_enum_get
4674 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4675 struct snd_ctl_elem_value *ucontrol)
4677 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4678 struct alc_spec *spec = codec->spec;
4679 const struct hda_input_mux *imux = spec->input_mux;
4680 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4681 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4682 hda_nid_t nid = capture_mixers[adc_idx];
4683 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4684 unsigned int i, idx;
4686 idx = ucontrol->value.enumerated.item[0];
4687 if (idx >= imux->num_items)
4688 idx = imux->num_items - 1;
4689 if (*cur_val == idx && ! codec->in_resume)
4691 for (i = 0; i < imux->num_items; i++) {
4692 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4693 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4694 v | (imux->items[i].index << 8));
4702 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4709 static struct hda_verb alc883_3ST_ch2_init[] = {
4710 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4711 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4712 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4713 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4720 static struct hda_verb alc883_3ST_ch6_init[] = {
4721 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4722 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4723 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4724 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4725 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4726 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4730 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4731 { 2, alc883_3ST_ch2_init },
4732 { 6, alc883_3ST_ch6_init },
4738 static struct hda_verb alc883_sixstack_ch6_init[] = {
4739 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4740 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4741 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4742 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4749 static struct hda_verb alc883_sixstack_ch8_init[] = {
4750 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4751 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4752 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4753 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4757 static struct hda_channel_mode alc883_sixstack_modes[2] = {
4758 { 6, alc883_sixstack_ch6_init },
4759 { 8, alc883_sixstack_ch8_init },
4762 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4763 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4766 static struct snd_kcontrol_new alc883_base_mixer[] = {
4767 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4768 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4769 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4770 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4771 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4772 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4773 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4774 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4775 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4776 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4778 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4779 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4780 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4781 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4784 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4786 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4787 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4788 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4789 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4790 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4791 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4794 /* .name = "Capture Source", */
4795 .name = "Input Source",
4797 .info = alc883_mux_enum_info,
4798 .get = alc883_mux_enum_get,
4799 .put = alc883_mux_enum_put,
4804 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4814 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4815 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4816 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4817 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4818 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4819 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4820 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4821 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4824 /* .name = "Capture Source", */
4825 .name = "Input Source",
4827 .info = alc883_mux_enum_info,
4828 .get = alc883_mux_enum_get,
4829 .put = alc883_mux_enum_put,
4834 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4836 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4837 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4838 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4839 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4840 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4841 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4842 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4846 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4847 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4850 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4851 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4852 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4853 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4854 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4855 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4856 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4857 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4859 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4860 /* .name = "Capture Source", */
4861 .name = "Input Source",
4863 .info = alc883_mux_enum_info,
4864 .get = alc883_mux_enum_get,
4865 .put = alc883_mux_enum_put,
4870 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4873 .name = "Channel Mode",
4874 .info = alc_ch_mode_info,
4875 .get = alc_ch_mode_get,
4876 .put = alc_ch_mode_put,
4881 static struct hda_verb alc883_init_verbs[] = {
4882 /* ADC1: mute amp left and right */
4883 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4884 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4885 /* ADC2: mute amp left and right */
4886 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4887 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4888 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4911 /* Front Pin: output 0 (0x0c) */
4912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4914 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4915 /* Rear Pin: output 1 (0x0d) */
4916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4919 /* CLFE Pin: output 2 (0x0e) */
4920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4922 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4923 /* Side Pin: output 3 (0x0f) */
4924 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4926 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4927 /* Mic (rear) pin: input vref at 80% */
4928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4930 /* Front Mic pin: input vref at 80% */
4931 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4932 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4933 /* Line In pin: input */
4934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4936 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4938 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4939 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4940 /* CD pin widget for input */
4941 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4943 /* FIXME: use matrix-type input source selection */
4944 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4959 * generic initialization of ADC, input mixers and output mixers
4961 static struct hda_verb alc883_auto_init_verbs[] = {
4963 * Unmute ADC0-2 and set the default input to mic-in
4965 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4966 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4967 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4968 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4970 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4972 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4975 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4983 * Set up output mixers (0x0c - 0x0f)
4985 /* set vol=0 to output mixers */
4986 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4987 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4988 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4990 /* set up input amps for analog loopback */
4991 /* Amp Indices: DAC = 0, mixer = 1 */
4992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4996 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4998 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5000 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5001 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5003 /* FIXME: use matrix-type input source selection */
5004 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5009 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5010 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5015 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5021 /* capture mixer elements */
5022 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5023 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5024 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5025 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5026 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5029 /* The multiple "Capture Source" controls confuse alsamixer
5030 * So call somewhat different..
5031 * FIXME: the controls appear in the "playback" view!
5033 /* .name = "Capture Source", */
5034 .name = "Input Source",
5036 .info = alc882_mux_enum_info,
5037 .get = alc882_mux_enum_get,
5038 .put = alc882_mux_enum_put,
5043 /* pcm configuration: identiacal with ALC880 */
5044 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5045 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5046 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5047 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5050 * configuration and preset
5052 static struct hda_board_config alc883_cfg_tbl[] = {
5053 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5054 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5055 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5056 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5057 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5058 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5059 .config = ALC883_3ST_6ch },
5060 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5061 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5062 .config = ALC883_6ST_DIG }, /* MSI */
5063 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5064 .config = ALC883_6ST_DIG }, /* Foxconn */
5065 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5066 { .modelname = "auto", .config = ALC883_AUTO },
5070 static struct alc_config_preset alc883_presets[] = {
5071 [ALC883_3ST_2ch_DIG] = {
5072 .mixers = { alc883_3ST_2ch_mixer },
5073 .init_verbs = { alc883_init_verbs },
5074 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5075 .dac_nids = alc883_dac_nids,
5076 .dig_out_nid = ALC883_DIGOUT_NID,
5077 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5078 .adc_nids = alc883_adc_nids,
5079 .dig_in_nid = ALC883_DIGIN_NID,
5080 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5081 .channel_mode = alc883_3ST_2ch_modes,
5082 .input_mux = &alc883_capture_source,
5084 [ALC883_3ST_6ch_DIG] = {
5085 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5086 .init_verbs = { alc883_init_verbs },
5087 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5088 .dac_nids = alc883_dac_nids,
5089 .dig_out_nid = ALC883_DIGOUT_NID,
5090 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5091 .adc_nids = alc883_adc_nids,
5092 .dig_in_nid = ALC883_DIGIN_NID,
5093 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5094 .channel_mode = alc883_3ST_6ch_modes,
5096 .input_mux = &alc883_capture_source,
5098 [ALC883_3ST_6ch] = {
5099 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5100 .init_verbs = { alc883_init_verbs },
5101 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5102 .dac_nids = alc883_dac_nids,
5103 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5104 .adc_nids = alc883_adc_nids,
5105 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5106 .channel_mode = alc883_3ST_6ch_modes,
5108 .input_mux = &alc883_capture_source,
5110 [ALC883_6ST_DIG] = {
5111 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5112 .init_verbs = { alc883_init_verbs },
5113 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5114 .dac_nids = alc883_dac_nids,
5115 .dig_out_nid = ALC883_DIGOUT_NID,
5116 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5117 .adc_nids = alc883_adc_nids,
5118 .dig_in_nid = ALC883_DIGIN_NID,
5119 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5120 .channel_mode = alc883_sixstack_modes,
5121 .input_mux = &alc883_capture_source,
5123 [ALC888_DEMO_BOARD] = {
5124 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5125 .init_verbs = { alc883_init_verbs },
5126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5127 .dac_nids = alc883_dac_nids,
5128 .dig_out_nid = ALC883_DIGOUT_NID,
5129 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5130 .adc_nids = alc883_adc_nids,
5131 .dig_in_nid = ALC883_DIGIN_NID,
5132 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5133 .channel_mode = alc883_sixstack_modes,
5134 .input_mux = &alc883_capture_source,
5140 * BIOS auto configuration
5142 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5143 hda_nid_t nid, int pin_type,
5147 struct alc_spec *spec = codec->spec;
5150 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5153 idx = spec->multiout.dac_nids[dac_idx] - 2;
5155 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5157 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5159 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5163 static void alc883_auto_init_multi_out(struct hda_codec *codec)
5165 struct alc_spec *spec = codec->spec;
5168 for (i = 0; i <= HDA_SIDE; i++) {
5169 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5171 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5175 static void alc883_auto_init_hp_out(struct hda_codec *codec)
5177 struct alc_spec *spec = codec->spec;
5180 pin = spec->autocfg.hp_pin;
5181 if (pin) /* connect to front */
5183 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5186 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5187 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5189 static void alc883_auto_init_analog_input(struct hda_codec *codec)
5191 struct alc_spec *spec = codec->spec;
5194 for (i = 0; i < AUTO_PIN_LAST; i++) {
5195 hda_nid_t nid = spec->autocfg.input_pins[i];
5196 if (alc883_is_input_pin(nid)) {
5197 snd_hda_codec_write(codec, nid, 0,
5198 AC_VERB_SET_PIN_WIDGET_CONTROL,
5199 (i <= AUTO_PIN_FRONT_MIC ?
5200 PIN_VREF80 : PIN_IN));
5201 if (nid != ALC883_PIN_CD_NID)
5202 snd_hda_codec_write(codec, nid, 0,
5203 AC_VERB_SET_AMP_GAIN_MUTE,
5209 /* almost identical with ALC880 parser... */
5210 static int alc883_parse_auto_config(struct hda_codec *codec)
5212 struct alc_spec *spec = codec->spec;
5213 int err = alc880_parse_auto_config(codec);
5218 /* hack - override the init verbs */
5219 spec->init_verbs[0] = alc883_auto_init_verbs;
5220 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5225 /* additional initialization for auto-configuration model */
5226 static void alc883_auto_init(struct hda_codec *codec)
5228 alc883_auto_init_multi_out(codec);
5229 alc883_auto_init_hp_out(codec);
5230 alc883_auto_init_analog_input(codec);
5233 static int patch_alc883(struct hda_codec *codec)
5235 struct alc_spec *spec;
5236 int err, board_config;
5238 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5244 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5245 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5246 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5247 "trying auto-probe from BIOS...\n");
5248 board_config = ALC883_AUTO;
5251 if (board_config == ALC883_AUTO) {
5252 /* automatic parse from the BIOS config */
5253 err = alc883_parse_auto_config(codec);
5259 "hda_codec: Cannot set up configuration "
5260 "from BIOS. Using base mode...\n");
5261 board_config = ALC883_3ST_2ch_DIG;
5265 if (board_config != ALC883_AUTO)
5266 setup_preset(spec, &alc883_presets[board_config]);
5268 spec->stream_name_analog = "ALC883 Analog";
5269 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5270 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5272 spec->stream_name_digital = "ALC883 Digital";
5273 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5274 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5276 if (! spec->adc_nids && spec->input_mux) {
5277 spec->adc_nids = alc883_adc_nids;
5278 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5281 codec->patch_ops = alc_patch_ops;
5282 if (board_config == ALC883_AUTO)
5283 spec->init_hook = alc883_auto_init;
5292 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5293 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
5295 #define alc262_dac_nids alc260_dac_nids
5296 #define alc262_adc_nids alc882_adc_nids
5297 #define alc262_adc_nids_alt alc882_adc_nids_alt
5299 #define alc262_modes alc260_modes
5300 #define alc262_capture_source alc882_capture_source
5302 static struct snd_kcontrol_new alc262_base_mixer[] = {
5303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5304 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5305 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5306 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5307 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5308 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5311 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5312 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5313 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5314 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5315 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5316 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5317 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5318 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5322 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5324 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5326 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5327 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5331 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5332 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5335 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5336 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5337 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5338 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5339 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5340 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5344 #define alc262_capture_mixer alc882_capture_mixer
5345 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
5348 * generic initialization of ADC, input mixers and output mixers
5350 static struct hda_verb alc262_init_verbs[] = {
5352 * Unmute ADC0-2 and set the default input to mic-in
5354 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5356 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5358 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5361 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5363 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5366 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5374 * Set up output mixers (0x0c - 0x0e)
5376 /* set vol=0 to output mixers */
5377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5380 /* set up input amps for analog loopback */
5381 /* Amp Indices: DAC = 0, mixer = 1 */
5382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5391 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5392 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5393 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5394 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5396 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5397 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5398 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5399 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5400 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5402 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5403 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5405 /* FIXME: use matrix-type input source selection */
5406 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5407 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5428 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5431 #define ALC_HP_EVENT 0x37
5433 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5434 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5439 static struct hda_input_mux alc262_fujitsu_capture_source = {
5447 static struct hda_input_mux alc262_HP_capture_source = {
5451 { "Front Mic", 0x3 },
5458 /* mute/unmute internal speaker according to the hp jack and mute state */
5459 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5461 struct alc_spec *spec = codec->spec;
5464 if (force || ! spec->sense_updated) {
5465 unsigned int present;
5466 /* need to execute and sync at first */
5467 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5468 present = snd_hda_codec_read(codec, 0x14, 0,
5469 AC_VERB_GET_PIN_SENSE, 0);
5470 spec->jack_present = (present & 0x80000000) != 0;
5471 spec->sense_updated = 1;
5473 if (spec->jack_present) {
5474 /* mute internal speaker */
5475 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5477 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5480 /* unmute internal speaker if necessary */
5481 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5482 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5484 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5485 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5490 /* unsolicited event for HP jack sensing */
5491 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5494 if ((res >> 26) != ALC_HP_EVENT)
5496 alc262_fujitsu_automute(codec, 1);
5499 /* bind volumes of both NID 0x0c and 0x0d */
5500 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5501 struct snd_ctl_elem_value *ucontrol)
5503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5504 long *valp = ucontrol->value.integer.value;
5507 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5508 0x7f, valp[0] & 0x7f);
5509 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5510 0x7f, valp[1] & 0x7f);
5511 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5512 0x7f, valp[0] & 0x7f);
5513 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5514 0x7f, valp[1] & 0x7f);
5518 /* bind hp and internal speaker mute (with plug check) */
5519 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5520 struct snd_ctl_elem_value *ucontrol)
5522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5523 long *valp = ucontrol->value.integer.value;
5526 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5527 0x80, valp[0] ? 0 : 0x80);
5528 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5529 0x80, valp[1] ? 0 : 0x80);
5530 if (change || codec->in_resume)
5531 alc262_fujitsu_automute(codec, codec->in_resume);
5535 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5538 .name = "Master Playback Volume",
5539 .info = snd_hda_mixer_amp_volume_info,
5540 .get = snd_hda_mixer_amp_volume_get,
5541 .put = alc262_fujitsu_master_vol_put,
5542 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5545 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5546 .name = "Master Playback Switch",
5547 .info = snd_hda_mixer_amp_switch_info,
5548 .get = snd_hda_mixer_amp_switch_get,
5549 .put = alc262_fujitsu_master_sw_put,
5550 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5552 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5553 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5554 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5560 /* additional init verbs for Benq laptops */
5561 static struct hda_verb alc262_EAPD_verbs[] = {
5562 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5563 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5567 /* add playback controls from the parsed DAC table */
5568 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5573 spec->multiout.num_dacs = 1; /* only use one dac */
5574 spec->multiout.dac_nids = spec->private_dac_nids;
5575 spec->multiout.dac_nids[0] = 2;
5577 nid = cfg->line_out_pins[0];
5579 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5580 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5582 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5583 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5587 nid = cfg->speaker_pins[0];
5590 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5591 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5593 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5594 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5597 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5598 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5604 /* spec->multiout.hp_nid = 2; */
5606 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5607 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5609 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5610 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5613 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5614 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5621 /* identical with ALC880 */
5622 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5625 * generic initialization of ADC, input mixers and output mixers
5627 static struct hda_verb alc262_volume_init_verbs[] = {
5629 * Unmute ADC0-2 and set the default input to mic-in
5631 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5633 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5635 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5638 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5640 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5643 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5651 * Set up output mixers (0x0c - 0x0f)
5653 /* set vol=0 to output mixers */
5654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5658 /* set up input amps for analog loopback */
5659 /* Amp Indices: DAC = 0, mixer = 1 */
5660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5663 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5665 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5667 /* FIXME: use matrix-type input source selection */
5668 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5669 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5688 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5690 * Unmute ADC0-2 and set the default input to mic-in
5692 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5694 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5695 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5696 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5697 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5699 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5701 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5704 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5714 * Set up output mixers (0x0c - 0x0e)
5716 /* set vol=0 to output mixers */
5717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5721 /* set up input amps for analog loopback */
5722 /* Amp Indices: DAC = 0, mixer = 1 */
5723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5730 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5734 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5737 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5740 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5742 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5744 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5747 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5748 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5750 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5751 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5754 /* FIXME: use matrix-type input source selection */
5755 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5756 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5775 /* pcm configuration: identiacal with ALC880 */
5776 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
5777 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
5778 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
5779 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
5782 * BIOS auto configuration
5784 static int alc262_parse_auto_config(struct hda_codec *codec)
5786 struct alc_spec *spec = codec->spec;
5788 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5790 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5791 alc262_ignore)) < 0)
5793 if (! spec->autocfg.line_outs)
5794 return 0; /* can't find valid BIOS pin config */
5795 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5796 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5799 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5801 if (spec->autocfg.dig_out_pin)
5802 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5803 if (spec->autocfg.dig_in_pin)
5804 spec->dig_in_nid = ALC262_DIGIN_NID;
5806 if (spec->kctl_alloc)
5807 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5809 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
5810 spec->num_mux_defs = 1;
5811 spec->input_mux = &spec->private_imux;
5816 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
5817 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
5818 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
5821 /* init callback for auto-configuration model -- overriding the default init */
5822 static void alc262_auto_init(struct hda_codec *codec)
5824 alc262_auto_init_multi_out(codec);
5825 alc262_auto_init_hp_out(codec);
5826 alc262_auto_init_analog_input(codec);
5830 * configuration and preset
5832 static struct hda_board_config alc262_cfg_tbl[] = {
5833 { .modelname = "basic", .config = ALC262_BASIC },
5834 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
5835 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5836 .config = ALC262_FUJITSU },
5837 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
5838 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5839 .config = ALC262_HP_BPC }, /* xw4400 */
5840 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5841 .config = ALC262_HP_BPC }, /* xw6400 */
5842 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5843 .config = ALC262_HP_BPC }, /* xw8400 */
5844 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5845 .config = ALC262_HP_BPC }, /* xw9400 */
5846 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5847 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5848 .config = ALC262_BENQ_ED8 },
5849 { .modelname = "auto", .config = ALC262_AUTO },
5853 static struct alc_config_preset alc262_presets[] = {
5855 .mixers = { alc262_base_mixer },
5856 .init_verbs = { alc262_init_verbs },
5857 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5858 .dac_nids = alc262_dac_nids,
5860 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5861 .channel_mode = alc262_modes,
5862 .input_mux = &alc262_capture_source,
5864 [ALC262_FUJITSU] = {
5865 .mixers = { alc262_fujitsu_mixer },
5866 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5867 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5868 .dac_nids = alc262_dac_nids,
5870 .dig_out_nid = ALC262_DIGOUT_NID,
5871 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5872 .channel_mode = alc262_modes,
5873 .input_mux = &alc262_fujitsu_capture_source,
5874 .unsol_event = alc262_fujitsu_unsol_event,
5877 .mixers = { alc262_HP_BPC_mixer },
5878 .init_verbs = { alc262_HP_BPC_init_verbs },
5879 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5880 .dac_nids = alc262_dac_nids,
5882 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5883 .channel_mode = alc262_modes,
5884 .input_mux = &alc262_HP_capture_source,
5886 [ALC262_BENQ_ED8] = {
5887 .mixers = { alc262_base_mixer },
5888 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5889 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5890 .dac_nids = alc262_dac_nids,
5892 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5893 .channel_mode = alc262_modes,
5894 .input_mux = &alc262_capture_source,
5898 static int patch_alc262(struct hda_codec *codec)
5900 struct alc_spec *spec;
5904 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5910 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5913 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5914 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5915 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5916 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5920 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
5922 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
5923 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5924 "trying auto-probe from BIOS...\n");
5925 board_config = ALC262_AUTO;
5928 if (board_config == ALC262_AUTO) {
5929 /* automatic parse from the BIOS config */
5930 err = alc262_parse_auto_config(codec);
5936 "hda_codec: Cannot set up configuration "
5937 "from BIOS. Using base mode...\n");
5938 board_config = ALC262_BASIC;
5942 if (board_config != ALC262_AUTO)
5943 setup_preset(spec, &alc262_presets[board_config]);
5945 spec->stream_name_analog = "ALC262 Analog";
5946 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5947 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5949 spec->stream_name_digital = "ALC262 Digital";
5950 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5951 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5953 if (! spec->adc_nids && spec->input_mux) {
5954 /* check whether NID 0x07 is valid */
5955 unsigned int wcap = get_wcaps(codec, 0x07);
5957 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5958 if (wcap != AC_WID_AUD_IN) {
5959 spec->adc_nids = alc262_adc_nids_alt;
5960 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5961 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5964 spec->adc_nids = alc262_adc_nids;
5965 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5966 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5971 codec->patch_ops = alc_patch_ops;
5972 if (board_config == ALC262_AUTO)
5973 spec->init_hook = alc262_auto_init;
5979 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5983 * set the path ways for 2 channel output
5984 * need to set the codec line out and mic 1 pin widgets to inputs
5986 static struct hda_verb alc861_threestack_ch2_init[] = {
5987 /* set pin widget 1Ah (line in) for input */
5988 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5989 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5990 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5992 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5994 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
5995 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6001 * need to set the codec line out and mic 1 pin widgets to outputs
6003 static struct hda_verb alc861_threestack_ch6_init[] = {
6004 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6005 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6006 /* set pin widget 18h (mic1) for output (CLFE)*/
6007 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6009 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6010 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6012 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6014 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6015 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6020 static struct hda_channel_mode alc861_threestack_modes[2] = {
6021 { 2, alc861_threestack_ch2_init },
6022 { 6, alc861_threestack_ch6_init },
6027 static struct snd_kcontrol_new alc861_base_mixer[] = {
6028 /* output mixer control */
6029 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6031 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6032 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6033 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6035 /*Input mixer control */
6036 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6037 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6038 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6039 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6040 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6041 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6043 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6044 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6045 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6047 /* Capture mixer control */
6048 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6049 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6052 .name = "Capture Source",
6054 .info = alc_mux_enum_info,
6055 .get = alc_mux_enum_get,
6056 .put = alc_mux_enum_put,
6061 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6062 /* output mixer control */
6063 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6065 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6066 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6067 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6069 /* Input mixer control */
6070 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6071 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6072 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6073 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6074 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6075 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6077 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6078 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6081 /* Capture mixer control */
6082 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6083 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6086 .name = "Capture Source",
6088 .info = alc_mux_enum_info,
6089 .get = alc_mux_enum_get,
6090 .put = alc_mux_enum_put,
6093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6094 .name = "Channel Mode",
6095 .info = alc_ch_mode_info,
6096 .get = alc_ch_mode_get,
6097 .put = alc_ch_mode_put,
6098 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6104 * generic initialization of ADC, input mixers and output mixers
6106 static struct hda_verb alc861_base_init_verbs[] = {
6108 * Unmute ADC0 and set the default input to mic-in
6110 /* port-A for surround (rear panel) */
6111 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6112 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6113 /* port-B for mic-in (rear panel) with vref */
6114 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6115 /* port-C for line-in (rear panel) */
6116 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6117 /* port-D for Front */
6118 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6119 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6120 /* port-E for HP out (front panel) */
6121 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6122 /* route front PCM to HP */
6123 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6124 /* port-F for mic-in (front panel) with vref */
6125 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6126 /* port-G for CLFE (rear panel) */
6127 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6128 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6129 /* port-H for side (rear panel) */
6130 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6131 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6133 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6134 /* route front mic to ADC1*/
6135 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6136 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6138 /* Unmute DAC0~3 & spdif out*/
6139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6141 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6142 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6145 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6146 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6147 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6148 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6149 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6151 /* Unmute Stereo Mixer 15 */
6152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6157 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6158 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6159 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6162 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6165 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6166 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6171 static struct hda_verb alc861_threestack_init_verbs[] = {
6173 * Unmute ADC0 and set the default input to mic-in
6175 /* port-A for surround (rear panel) */
6176 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6177 /* port-B for mic-in (rear panel) with vref */
6178 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6179 /* port-C for line-in (rear panel) */
6180 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6181 /* port-D for Front */
6182 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6183 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6184 /* port-E for HP out (front panel) */
6185 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6186 /* route front PCM to HP */
6187 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6188 /* port-F for mic-in (front panel) with vref */
6189 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6190 /* port-G for CLFE (rear panel) */
6191 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6192 /* port-H for side (rear panel) */
6193 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6195 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6196 /* route front mic to ADC1*/
6197 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6199 /* Unmute DAC0~3 & spdif out*/
6200 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6201 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6202 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6203 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6204 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6206 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6207 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6208 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6209 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6210 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6212 /* Unmute Stereo Mixer 15 */
6213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6218 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6219 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6220 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6221 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6222 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6223 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6224 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6225 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6227 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6231 * generic initialization of ADC, input mixers and output mixers
6233 static struct hda_verb alc861_auto_init_verbs[] = {
6235 * Unmute ADC0 and set the default input to mic-in
6237 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6238 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6240 /* Unmute DAC0~3 & spdif out*/
6241 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6242 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6243 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6244 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6247 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6248 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6249 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6250 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6251 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6253 /* Unmute Stereo Mixer 15 */
6254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6260 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6262 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6266 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6275 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6277 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6282 /* pcm configuration: identiacal with ALC880 */
6283 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
6284 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
6285 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
6286 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
6289 #define ALC861_DIGOUT_NID 0x07
6291 static struct hda_channel_mode alc861_8ch_modes[1] = {
6295 static hda_nid_t alc861_dac_nids[4] = {
6296 /* front, surround, clfe, side */
6297 0x03, 0x06, 0x05, 0x04
6300 static hda_nid_t alc660_dac_nids[3] = {
6301 /* front, clfe, surround */
6305 static hda_nid_t alc861_adc_nids[1] = {
6310 static struct hda_input_mux alc861_capture_source = {
6314 { "Front Mic", 0x3 },
6321 /* fill in the dac_nids table from the parsed pin configuration */
6322 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6327 spec->multiout.dac_nids = spec->private_dac_nids;
6328 for (i = 0; i < cfg->line_outs; i++) {
6329 nid = cfg->line_out_pins[i];
6331 if (i >= ARRAY_SIZE(alc861_dac_nids))
6333 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6336 spec->multiout.num_dacs = cfg->line_outs;
6340 /* add playback controls from the parsed DAC table */
6341 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6342 const struct auto_pin_cfg *cfg)
6345 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6349 for (i = 0; i < cfg->line_outs; i++) {
6350 nid = spec->multiout.dac_nids[i];
6355 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6356 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6358 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6359 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6362 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6363 if (nid == alc861_dac_nids[idx])
6365 sprintf(name, "%s Playback Switch", chname[idx]);
6366 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6367 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6374 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6382 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6384 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6385 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6387 spec->multiout.hp_nid = nid;
6392 /* create playback/capture controls for input pins */
6393 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6395 struct hda_input_mux *imux = &spec->private_imux;
6396 int i, err, idx, idx1;
6398 for (i = 0; i < AUTO_PIN_LAST; i++) {
6399 switch(cfg->input_pins[i]) {
6424 err = new_analog_input(spec, cfg->input_pins[i],
6425 auto_pin_cfg_labels[i], idx, 0x15);
6429 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
6430 imux->items[imux->num_items].index = idx1;
6436 static struct snd_kcontrol_new alc861_capture_mixer[] = {
6437 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6438 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6442 /* The multiple "Capture Source" controls confuse alsamixer
6443 * So call somewhat different..
6444 *FIXME: the controls appear in the "playback" view!
6446 /* .name = "Capture Source", */
6447 .name = "Input Source",
6449 .info = alc_mux_enum_info,
6450 .get = alc_mux_enum_get,
6451 .put = alc_mux_enum_put,
6456 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6457 int pin_type, int dac_idx)
6461 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6462 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6466 static void alc861_auto_init_multi_out(struct hda_codec *codec)
6468 struct alc_spec *spec = codec->spec;
6471 for (i = 0; i < spec->autocfg.line_outs; i++) {
6472 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6474 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6478 static void alc861_auto_init_hp_out(struct hda_codec *codec)
6480 struct alc_spec *spec = codec->spec;
6483 pin = spec->autocfg.hp_pin;
6484 if (pin) /* connect to front */
6485 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6488 static void alc861_auto_init_analog_input(struct hda_codec *codec)
6490 struct alc_spec *spec = codec->spec;
6493 for (i = 0; i < AUTO_PIN_LAST; i++) {
6494 hda_nid_t nid = spec->autocfg.input_pins[i];
6495 if ((nid>=0x0c) && (nid <=0x11)) {
6496 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6497 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6502 /* parse the BIOS configuration and set up the alc_spec */
6503 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6504 static int alc861_parse_auto_config(struct hda_codec *codec)
6506 struct alc_spec *spec = codec->spec;
6508 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6510 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6511 alc861_ignore)) < 0)
6513 if (! spec->autocfg.line_outs)
6514 return 0; /* can't find valid BIOS pin config */
6516 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6517 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6518 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6519 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6522 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6524 if (spec->autocfg.dig_out_pin)
6525 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6527 if (spec->kctl_alloc)
6528 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6530 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6532 spec->num_mux_defs = 1;
6533 spec->input_mux = &spec->private_imux;
6535 spec->adc_nids = alc861_adc_nids;
6536 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6537 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6543 /* additional initialization for auto-configuration model */
6544 static void alc861_auto_init(struct hda_codec *codec)
6546 alc861_auto_init_multi_out(codec);
6547 alc861_auto_init_hp_out(codec);
6548 alc861_auto_init_analog_input(codec);
6553 * configuration and preset
6555 static struct hda_board_config alc861_cfg_tbl[] = {
6556 { .modelname = "3stack", .config = ALC861_3ST },
6557 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6558 .config = ALC861_3ST },
6559 { .modelname = "3stack-660", .config = ALC660_3ST },
6560 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6561 .config = ALC660_3ST },
6562 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6563 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
6564 { .modelname = "auto", .config = ALC861_AUTO },
6568 static struct alc_config_preset alc861_presets[] = {
6570 .mixers = { alc861_3ST_mixer },
6571 .init_verbs = { alc861_threestack_init_verbs },
6572 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6573 .dac_nids = alc861_dac_nids,
6574 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6575 .channel_mode = alc861_threestack_modes,
6577 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6578 .adc_nids = alc861_adc_nids,
6579 .input_mux = &alc861_capture_source,
6581 [ALC861_3ST_DIG] = {
6582 .mixers = { alc861_base_mixer },
6583 .init_verbs = { alc861_threestack_init_verbs },
6584 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6585 .dac_nids = alc861_dac_nids,
6586 .dig_out_nid = ALC861_DIGOUT_NID,
6587 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6588 .channel_mode = alc861_threestack_modes,
6590 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6591 .adc_nids = alc861_adc_nids,
6592 .input_mux = &alc861_capture_source,
6594 [ALC861_6ST_DIG] = {
6595 .mixers = { alc861_base_mixer },
6596 .init_verbs = { alc861_base_init_verbs },
6597 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6598 .dac_nids = alc861_dac_nids,
6599 .dig_out_nid = ALC861_DIGOUT_NID,
6600 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6601 .channel_mode = alc861_8ch_modes,
6602 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6603 .adc_nids = alc861_adc_nids,
6604 .input_mux = &alc861_capture_source,
6607 .mixers = { alc861_3ST_mixer },
6608 .init_verbs = { alc861_threestack_init_verbs },
6609 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6610 .dac_nids = alc660_dac_nids,
6611 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6612 .channel_mode = alc861_threestack_modes,
6614 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6615 .adc_nids = alc861_adc_nids,
6616 .input_mux = &alc861_capture_source,
6621 static int patch_alc861(struct hda_codec *codec)
6623 struct alc_spec *spec;
6627 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6633 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
6635 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
6636 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6637 "trying auto-probe from BIOS...\n");
6638 board_config = ALC861_AUTO;
6641 if (board_config == ALC861_AUTO) {
6642 /* automatic parse from the BIOS config */
6643 err = alc861_parse_auto_config(codec);
6649 "hda_codec: Cannot set up configuration "
6650 "from BIOS. Using base mode...\n");
6651 board_config = ALC861_3ST_DIG;
6655 if (board_config != ALC861_AUTO)
6656 setup_preset(spec, &alc861_presets[board_config]);
6658 spec->stream_name_analog = "ALC861 Analog";
6659 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6660 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6662 spec->stream_name_digital = "ALC861 Digital";
6663 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6664 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6666 codec->patch_ops = alc_patch_ops;
6667 if (board_config == ALC861_AUTO)
6668 spec->init_hook = alc861_auto_init;
6676 struct hda_codec_preset snd_hda_preset_realtek[] = {
6677 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6678 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6679 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6680 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6681 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
6682 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6683 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6684 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6685 .patch = patch_alc861 },
6686 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6687 .patch = patch_alc861 },