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"
35 #define ALC880_FRONT_EVENT 0x01
36 #define ALC880_DCVOL_EVENT 0x02
37 #define ALC880_HP_EVENT 0x04
38 #define ALC880_MIC_EVENT 0x08
40 /* ALC880 board config type */
63 #ifdef CONFIG_SND_DEBUG
67 ALC880_MODEL_LAST /* last tag */
79 #ifdef CONFIG_SND_DEBUG
83 ALC260_MODEL_LAST /* last tag */
93 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
97 ALC262_MODEL_LAST /* last tag */
114 /* ALC861-VD models */
152 ALC883_TARGA_2ch_DIG,
157 ALC883_LENOVO_101E_2ch,
163 #define GPIO_MASK 0x03
166 /* codec parameterization */
167 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
168 unsigned int num_mixers;
170 const struct hda_verb *init_verbs[5]; /* initialization verbs
174 unsigned int num_init_verbs;
176 char *stream_name_analog; /* analog PCM stream */
177 struct hda_pcm_stream *stream_analog_playback;
178 struct hda_pcm_stream *stream_analog_capture;
180 char *stream_name_digital; /* digital PCM stream */
181 struct hda_pcm_stream *stream_digital_playback;
182 struct hda_pcm_stream *stream_digital_capture;
185 struct hda_multi_out multiout; /* playback set-up
186 * max_channels, dacs must be set
187 * dig_out_nid and hp_nid are optional
191 unsigned int num_adc_nids;
193 hda_nid_t dig_in_nid; /* digital-in NID; optional */
196 unsigned int num_mux_defs;
197 const struct hda_input_mux *input_mux;
198 unsigned int cur_mux[3];
201 const struct hda_channel_mode *channel_mode;
202 int num_channel_mode;
205 /* PCM information */
206 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
208 /* dynamic controls, init_verbs and input_mux */
209 struct auto_pin_cfg autocfg;
210 unsigned int num_kctl_alloc, num_kctl_used;
211 struct snd_kcontrol_new *kctl_alloc;
212 struct hda_input_mux private_imux;
213 hda_nid_t private_dac_nids[5];
216 void (*init_hook)(struct hda_codec *codec);
217 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
219 /* for pin sensing */
220 unsigned int sense_updated: 1;
221 unsigned int jack_present: 1;
225 * configuration template - to be copied to the spec instance
227 struct alc_config_preset {
228 struct snd_kcontrol_new *mixers[5]; /* should be identical size
231 const struct hda_verb *init_verbs[5];
232 unsigned int num_dacs;
234 hda_nid_t dig_out_nid; /* optional */
235 hda_nid_t hp_nid; /* optional */
236 unsigned int num_adc_nids;
238 hda_nid_t dig_in_nid;
239 unsigned int num_channel_mode;
240 const struct hda_channel_mode *channel_mode;
242 unsigned int num_mux_defs;
243 const struct hda_input_mux *input_mux;
244 void (*unsol_event)(struct hda_codec *, unsigned int);
245 void (*init_hook)(struct hda_codec *);
252 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
253 struct snd_ctl_elem_info *uinfo)
255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
256 struct alc_spec *spec = codec->spec;
257 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
258 if (mux_idx >= spec->num_mux_defs)
260 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
263 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
264 struct snd_ctl_elem_value *ucontrol)
266 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
267 struct alc_spec *spec = codec->spec;
268 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
270 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
274 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
275 struct snd_ctl_elem_value *ucontrol)
277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
278 struct alc_spec *spec = codec->spec;
279 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
280 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
281 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
282 spec->adc_nids[adc_idx],
283 &spec->cur_mux[adc_idx]);
288 * channel mode setting
290 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
291 struct snd_ctl_elem_info *uinfo)
293 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
294 struct alc_spec *spec = codec->spec;
295 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
296 spec->num_channel_mode);
299 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
300 struct snd_ctl_elem_value *ucontrol)
302 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
303 struct alc_spec *spec = codec->spec;
304 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
305 spec->num_channel_mode,
306 spec->multiout.max_channels);
309 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
310 struct snd_ctl_elem_value *ucontrol)
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 struct alc_spec *spec = codec->spec;
314 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
315 spec->num_channel_mode,
316 &spec->multiout.max_channels);
317 if (err >= 0 && spec->need_dac_fix)
318 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
323 * Control the mode of pin widget settings via the mixer. "pc" is used
324 * instead of "%" to avoid consequences of accidently treating the % as
325 * being part of a format specifier. Maximum allowed length of a value is
326 * 63 characters plus NULL terminator.
328 * Note: some retasking pin complexes seem to ignore requests for input
329 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
330 * are requested. Therefore order this list so that this behaviour will not
331 * cause problems when mixer clients move through the enum sequentially.
332 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
335 static char *alc_pin_mode_names[] = {
336 "Mic 50pc bias", "Mic 80pc bias",
337 "Line in", "Line out", "Headphone out",
339 static unsigned char alc_pin_mode_values[] = {
340 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
342 /* The control can present all 5 options, or it can limit the options based
343 * in the pin being assumed to be exclusively an input or an output pin. In
344 * addition, "input" pins may or may not process the mic bias option
345 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
346 * accept requests for bias as of chip versions up to March 2006) and/or
347 * wiring in the computer.
349 #define ALC_PIN_DIR_IN 0x00
350 #define ALC_PIN_DIR_OUT 0x01
351 #define ALC_PIN_DIR_INOUT 0x02
352 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
353 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
355 /* Info about the pin modes supported by the different pin direction modes.
356 * For each direction the minimum and maximum values are given.
358 static signed char alc_pin_mode_dir_info[5][2] = {
359 { 0, 2 }, /* ALC_PIN_DIR_IN */
360 { 3, 4 }, /* ALC_PIN_DIR_OUT */
361 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
362 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
363 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
365 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
366 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
367 #define alc_pin_mode_n_items(_dir) \
368 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
370 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_info *uinfo)
373 unsigned int item_num = uinfo->value.enumerated.item;
374 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
376 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
378 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
380 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
381 item_num = alc_pin_mode_min(dir);
382 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
386 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
391 hda_nid_t nid = kcontrol->private_value & 0xffff;
392 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
393 long *valp = ucontrol->value.integer.value;
394 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
395 AC_VERB_GET_PIN_WIDGET_CONTROL,
398 /* Find enumerated value for current pinctl setting */
399 i = alc_pin_mode_min(dir);
400 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
402 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
406 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
411 hda_nid_t nid = kcontrol->private_value & 0xffff;
412 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
413 long val = *ucontrol->value.integer.value;
414 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
415 AC_VERB_GET_PIN_WIDGET_CONTROL,
418 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
419 val = alc_pin_mode_min(dir);
421 change = pinctl != alc_pin_mode_values[val];
423 /* Set pin mode to that requested */
424 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
425 alc_pin_mode_values[val]);
427 /* Also enable the retasking pin's input/output as required
428 * for the requested pin mode. Enum values of 2 or less are
431 * Dynamically switching the input/output buffers probably
432 * reduces noise slightly (particularly on input) so we'll
433 * do it. However, having both input and output buffers
434 * enabled simultaneously doesn't seem to be problematic if
435 * this turns out to be necessary in the future.
438 snd_hda_codec_write(codec, nid, 0,
439 AC_VERB_SET_AMP_GAIN_MUTE,
441 snd_hda_codec_write(codec, nid, 0,
442 AC_VERB_SET_AMP_GAIN_MUTE,
445 snd_hda_codec_write(codec, nid, 0,
446 AC_VERB_SET_AMP_GAIN_MUTE,
448 snd_hda_codec_write(codec, nid, 0,
449 AC_VERB_SET_AMP_GAIN_MUTE,
456 #define ALC_PIN_MODE(xname, nid, dir) \
457 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
458 .info = alc_pin_mode_info, \
459 .get = alc_pin_mode_get, \
460 .put = alc_pin_mode_put, \
461 .private_value = nid | (dir<<16) }
463 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
464 * together using a mask with more than one bit set. This control is
465 * currently used only by the ALC260 test model. At this stage they are not
466 * needed for any "production" models.
468 #ifdef CONFIG_SND_DEBUG
469 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_info *uinfo)
472 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
474 uinfo->value.integer.min = 0;
475 uinfo->value.integer.max = 1;
479 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 hda_nid_t nid = kcontrol->private_value & 0xffff;
484 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
485 long *valp = ucontrol->value.integer.value;
486 unsigned int val = snd_hda_codec_read(codec, nid, 0,
487 AC_VERB_GET_GPIO_DATA, 0x00);
489 *valp = (val & mask) != 0;
492 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
493 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 val = *ucontrol->value.integer.value;
500 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
501 AC_VERB_GET_GPIO_DATA,
504 /* Set/unset the masked GPIO bit(s) as needed */
505 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
510 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
514 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
515 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
516 .info = alc_gpio_data_info, \
517 .get = alc_gpio_data_get, \
518 .put = alc_gpio_data_put, \
519 .private_value = nid | (mask<<16) }
520 #endif /* CONFIG_SND_DEBUG */
522 /* A switch control to allow the enabling of the digital IO pins on the
523 * ALC260. This is incredibly simplistic; the intention of this control is
524 * to provide something in the test model allowing digital outputs to be
525 * identified if present. If models are found which can utilise these
526 * outputs a more complete mixer control can be devised for those models if
529 #ifdef CONFIG_SND_DEBUG
530 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
531 struct snd_ctl_elem_info *uinfo)
533 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
535 uinfo->value.integer.min = 0;
536 uinfo->value.integer.max = 1;
540 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
541 struct snd_ctl_elem_value *ucontrol)
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 hda_nid_t nid = kcontrol->private_value & 0xffff;
545 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
546 long *valp = ucontrol->value.integer.value;
547 unsigned int val = snd_hda_codec_read(codec, nid, 0,
548 AC_VERB_GET_DIGI_CONVERT, 0x00);
550 *valp = (val & mask) != 0;
553 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
554 struct snd_ctl_elem_value *ucontrol)
557 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
558 hda_nid_t nid = kcontrol->private_value & 0xffff;
559 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
560 long val = *ucontrol->value.integer.value;
561 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
562 AC_VERB_GET_DIGI_CONVERT,
565 /* Set/unset the masked control bit(s) as needed */
566 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
571 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
576 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
577 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
578 .info = alc_spdif_ctrl_info, \
579 .get = alc_spdif_ctrl_get, \
580 .put = alc_spdif_ctrl_put, \
581 .private_value = nid | (mask<<16) }
582 #endif /* CONFIG_SND_DEBUG */
585 * set up from the preset table
587 static void setup_preset(struct alc_spec *spec,
588 const struct alc_config_preset *preset)
592 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
593 spec->mixers[spec->num_mixers++] = preset->mixers[i];
594 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
596 spec->init_verbs[spec->num_init_verbs++] =
597 preset->init_verbs[i];
599 spec->channel_mode = preset->channel_mode;
600 spec->num_channel_mode = preset->num_channel_mode;
601 spec->need_dac_fix = preset->need_dac_fix;
603 spec->multiout.max_channels = spec->channel_mode[0].channels;
605 spec->multiout.num_dacs = preset->num_dacs;
606 spec->multiout.dac_nids = preset->dac_nids;
607 spec->multiout.dig_out_nid = preset->dig_out_nid;
608 spec->multiout.hp_nid = preset->hp_nid;
610 spec->num_mux_defs = preset->num_mux_defs;
611 if (!spec->num_mux_defs)
612 spec->num_mux_defs = 1;
613 spec->input_mux = preset->input_mux;
615 spec->num_adc_nids = preset->num_adc_nids;
616 spec->adc_nids = preset->adc_nids;
617 spec->dig_in_nid = preset->dig_in_nid;
619 spec->unsol_event = preset->unsol_event;
620 spec->init_hook = preset->init_hook;
623 /* Enable GPIO mask and set output */
624 static struct hda_verb alc_gpio1_init_verbs[] = {
625 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
626 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
627 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
631 static struct hda_verb alc_gpio2_init_verbs[] = {
632 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
633 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
634 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
638 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
639 * 31 ~ 16 : Manufacture ID
641 * 7 ~ 0 : Assembly ID
642 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
644 static void alc_subsystem_id(struct hda_codec *codec,
645 unsigned int porta, unsigned int porte,
648 unsigned int ass, tmp;
650 ass = codec->subsystem_id;
655 tmp = (ass & 0x38) >> 3; /* external Amp control */
658 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
661 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
665 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
667 tmp = (ass & 0x1800) >> 11;
669 case 0: port = porta; break;
670 case 1: port = porte; break;
671 case 2: port = portd; break;
674 snd_hda_codec_write(codec, port, 0,
675 AC_VERB_SET_EAPD_BTLENABLE,
678 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
679 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
680 (tmp == 5 ? 0x3040 : 0x3050));
686 * ALC880 3-stack model
688 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
689 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
690 * F-Mic = 0x1b, HP = 0x19
693 static hda_nid_t alc880_dac_nids[4] = {
694 /* front, rear, clfe, rear_surr */
695 0x02, 0x05, 0x04, 0x03
698 static hda_nid_t alc880_adc_nids[3] = {
703 /* The datasheet says the node 0x07 is connected from inputs,
704 * but it shows zero connection in the real implementation on some devices.
705 * Note: this is a 915GAV bug, fixed on 915GLV
707 static hda_nid_t alc880_adc_nids_alt[2] = {
712 #define ALC880_DIGOUT_NID 0x06
713 #define ALC880_DIGIN_NID 0x0a
715 static struct hda_input_mux alc880_capture_source = {
719 { "Front Mic", 0x3 },
725 /* channel source setting (2/6 channel selection for 3-stack) */
727 static struct hda_verb alc880_threestack_ch2_init[] = {
728 /* set line-in to input, mute it */
729 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
730 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
731 /* set mic-in to input vref 80%, mute it */
732 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
733 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
738 static struct hda_verb alc880_threestack_ch6_init[] = {
739 /* set line-in to output, unmute it */
740 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
741 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
742 /* set mic-in to output, unmute it */
743 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
744 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
748 static struct hda_channel_mode alc880_threestack_modes[2] = {
749 { 2, alc880_threestack_ch2_init },
750 { 6, alc880_threestack_ch6_init },
753 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
756 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
757 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
758 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
759 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
760 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
761 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
762 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
763 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
768 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
769 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
770 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
771 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
774 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
775 .name = "Channel Mode",
776 .info = alc_ch_mode_info,
777 .get = alc_ch_mode_get,
778 .put = alc_ch_mode_put,
783 /* capture mixer elements */
784 static struct snd_kcontrol_new alc880_capture_mixer[] = {
785 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
786 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
787 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
788 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
789 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
790 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
793 /* The multiple "Capture Source" controls confuse alsamixer
794 * So call somewhat different..
795 * FIXME: the controls appear in the "playback" view!
797 /* .name = "Capture Source", */
798 .name = "Input Source",
800 .info = alc_mux_enum_info,
801 .get = alc_mux_enum_get,
802 .put = alc_mux_enum_put,
807 /* capture mixer elements (in case NID 0x07 not available) */
808 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
809 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
810 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
811 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
812 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
815 /* The multiple "Capture Source" controls confuse alsamixer
816 * So call somewhat different..
817 * FIXME: the controls appear in the "playback" view!
819 /* .name = "Capture Source", */
820 .name = "Input Source",
822 .info = alc_mux_enum_info,
823 .get = alc_mux_enum_get,
824 .put = alc_mux_enum_put,
832 * ALC880 5-stack model
834 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
836 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
837 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
840 /* additional mixers to alc880_three_stack_mixer */
841 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
842 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
843 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
847 /* channel source setting (6/8 channel selection for 5-stack) */
849 static struct hda_verb alc880_fivestack_ch6_init[] = {
850 /* set line-in to input, mute it */
851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
857 static struct hda_verb alc880_fivestack_ch8_init[] = {
858 /* set line-in to output, unmute it */
859 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
860 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
864 static struct hda_channel_mode alc880_fivestack_modes[2] = {
865 { 6, alc880_fivestack_ch6_init },
866 { 8, alc880_fivestack_ch8_init },
871 * ALC880 6-stack model
873 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
875 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
876 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
879 static hda_nid_t alc880_6st_dac_nids[4] = {
880 /* front, rear, clfe, rear_surr */
881 0x02, 0x03, 0x04, 0x05
884 static struct hda_input_mux alc880_6stack_capture_source = {
888 { "Front Mic", 0x1 },
894 /* fixed 8-channels */
895 static struct hda_channel_mode alc880_sixstack_modes[1] = {
899 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
900 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
901 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
902 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
903 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
904 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
905 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
906 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
907 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
908 HDA_CODEC_VOLUME("Side Playback Volume&