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", 0x0f, 0x0, HDA_OUTPUT),
909 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
912 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
913 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
918 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
919 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
922 .name = "Channel Mode",
923 .info = alc_ch_mode_info,
924 .get = alc_ch_mode_get,
925 .put = alc_ch_mode_put,
934 * W810 has rear IO for:
937 * Center/LFE (DAC 04)
940 * The system also has a pair of internal speakers, and a headphone jack.
941 * These are both connected to Line2 on the codec, hence to DAC 02.
943 * There is a variable resistor to control the speaker or headphone
944 * volume. This is a hardware-only device without a software API.
946 * Plugging headphones in will disable the internal speakers. This is
947 * implemented in hardware, not via the driver using jack sense. In
948 * a similar fashion, plugging into the rear socket marked "front" will
949 * disable both the speakers and headphones.
951 * For input, there's a microphone jack, and an "audio in" jack.
952 * These may not do anything useful with this driver yet, because I
953 * haven't setup any initialization verbs for these yet...
956 static hda_nid_t alc880_w810_dac_nids[3] = {
957 /* front, rear/surround, clfe */
961 /* fixed 6 channels */
962 static struct hda_channel_mode alc880_w810_modes[1] = {
966 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
967 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
968 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
969 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
970 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
971 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
972 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
973 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
974 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
975 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
984 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
985 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
989 static hda_nid_t alc880_z71v_dac_nids[1] = {
992 #define ALC880_Z71V_HP_DAC 0x03
994 /* fixed 2 channels */
995 static struct hda_channel_mode alc880_2_jack_modes[1] = {
999 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1000 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1001 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1003 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1004 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1005 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1014 * ALC880 F1734 model
1016 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1017 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1020 static hda_nid_t alc880_f1734_dac_nids[1] = {
1023 #define ALC880_F1734_HP_DAC 0x02
1025 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1027 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1028 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1029 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1030 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1031 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1042 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1043 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1044 * Mic = 0x18, Line = 0x1a
1047 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1048 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1050 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1052 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1053 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1054 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1055 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1056 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1057 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1058 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1059 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1060 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1061 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1062 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1063 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1066 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1067 .name = "Channel Mode",
1068 .info = alc_ch_mode_info,
1069 .get = alc_ch_mode_get,
1070 .put = alc_ch_mode_put,
1077 * ALC880 ASUS W1V model
1079 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1080 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1081 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1084 /* additional mixers to alc880_asus_mixer */
1085 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1086 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1087 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1091 /* additional mixers to alc880_asus_mixer */
1092 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1093 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1094 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1099 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1103 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1104 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1105 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1107 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1108 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1111 /* The multiple "Capture Source" controls confuse alsamixer
1112 * So call somewhat different..
1113 * FIXME: the controls appear in the "playback" view!
1115 /* .name = "Capture Source", */
1116 .name = "Input Source",
1118 .info = alc_mux_enum_info,
1119 .get = alc_mux_enum_get,
1120 .put = alc_mux_enum_put,
1126 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1127 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1128 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1129 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1130 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1131 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1132 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1133 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1134 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1135 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1136 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1137 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1138 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1141 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1142 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1143 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1144 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1147 .name = "Channel Mode",
1148 .info = alc_ch_mode_info,
1149 .get = alc_ch_mode_get,
1150 .put = alc_ch_mode_put,
1155 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1156 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1157 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1158 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1159 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1160 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1161 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1162 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1163 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1164 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1165 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1169 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1170 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1171 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1172 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1173 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1175 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1180 * build control elements
1182 static int alc_build_controls(struct hda_codec *codec)
1184 struct alc_spec *spec = codec->spec;
1188 for (i = 0; i < spec->num_mixers; i++) {
1189 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1194 if (spec->multiout.dig_out_nid) {
1195 err = snd_hda_create_spdif_out_ctls(codec,
1196 spec->multiout.dig_out_nid);
1200 if (spec->dig_in_nid) {
1201 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1210 * initialize the codec volumes, etc
1214 * generic initialization of ADC, input mixers and output mixers
1216 static struct hda_verb alc880_volume_init_verbs[] = {
1218 * Unmute ADC0-2 and set the default input to mic-in
1220 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1222 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1224 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1227 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1229 * Note: PASD motherboards uses the Line In 2 as the input for front
1232 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1240 * Set up output mixers (0x0c - 0x0f)
1242 /* set vol=0 to output mixers */
1243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1246 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1247 /* set up input amps for analog loopback */
1248 /* Amp Indices: DAC = 0, mixer = 1 */
1249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1252 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1256 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1262 * 3-stack pin configuration:
1263 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1265 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1267 * preset connection lists of input pins
1268 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1270 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1271 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1272 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1275 * Set pin mode and muting
1277 /* set front pin widgets 0x14 for output */
1278 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1280 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1283 /* Mic2 (as headphone out) for HP output */
1284 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1285 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1286 /* Line In pin widget for input */
1287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1289 /* Line2 (as front mic) pin widget for input and vref at 80% */
1290 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1291 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1292 /* CD pin widget for input */
1293 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1299 * 5-stack pin configuration:
1300 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1301 * line-in/side = 0x1a, f-mic = 0x1b
1303 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1305 * preset connection lists of input pins
1306 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1308 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1309 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1312 * Set pin mode and muting
1314 /* set pin widgets 0x14-0x17 for output */
1315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1316 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1317 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1318 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1319 /* unmute pins for output (no gain on this amp) */
1320 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1322 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1323 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1325 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1326 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1327 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1328 /* Mic2 (as headphone out) for HP output */
1329 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1330 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1331 /* Line In pin widget for input */
1332 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1333 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1334 /* Line2 (as front mic) pin widget for input and vref at 80% */
1335 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1336 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1337 /* CD pin widget for input */
1338 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1344 * W810 pin configuration:
1345 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1347 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1348 /* hphone/speaker input selector: front DAC */
1349 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1356 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1365 * Z71V pin configuration:
1366 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1368 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1369 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1370 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1376 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1377 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1383 * 6-stack pin configuration:
1384 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1385 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1387 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1388 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1392 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1395 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1397 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1399 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1401 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1402 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1403 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1404 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1405 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1406 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1407 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1413 * Uniwill pin configuration:
1414 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1417 static struct hda_verb alc880_uniwill_init_verbs[] = {
1418 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1421 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1424 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1425 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1426 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1427 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1438 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1441 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1442 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1443 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1445 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1446 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1453 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1455 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1456 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1462 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1463 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1472 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1478 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1479 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1484 static struct hda_verb alc880_beep_init_verbs[] = {
1485 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1489 /* toggle speaker-output according to the hp-jack state */
1490 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1492 unsigned int present;
1495 present = snd_hda_codec_read(codec, 0x14, 0,
1496 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1497 bits = present ? 0x80 : 0;
1498 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1500 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1502 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1504 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1508 /* auto-toggle front mic */
1509 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1511 unsigned int present;
1514 present = snd_hda_codec_read(codec, 0x18, 0,
1515 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1516 bits = present ? 0x80 : 0;
1517 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1519 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1523 static void alc880_uniwill_automute(struct hda_codec *codec)
1525 alc880_uniwill_hp_automute(codec);
1526 alc880_uniwill_mic_automute(codec);
1529 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1532 /* Looks like the unsol event is incompatible with the standard
1533 * definition. 4bit tag is placed at 28 bit!
1535 switch (res >> 28) {
1536 case ALC880_HP_EVENT:
1537 alc880_uniwill_hp_automute(codec);
1539 case ALC880_MIC_EVENT:
1540 alc880_uniwill_mic_automute(codec);
1545 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1547 unsigned int present;
1550 present = snd_hda_codec_read(codec, 0x14, 0,
1551 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1552 bits = present ? 0x80 : 0;
1553 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1555 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1559 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1561 unsigned int present;
1563 present = snd_hda_codec_read(codec, 0x21, 0,
1564 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1566 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1568 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1571 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1573 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1577 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1580 /* Looks like the unsol event is incompatible with the standard
1581 * definition. 4bit tag is placed at 28 bit!
1583 if ((res >> 28) == ALC880_HP_EVENT)
1584 alc880_uniwill_p53_hp_automute(codec);
1585 if ((res >> 28) == ALC880_DCVOL_EVENT)
1586 alc880_uniwill_p53_dcvol_automute(codec);
1591 * F1734 pin configuration:
1592 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1594 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1595 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1596 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1597 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1598 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1601 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1609 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1610 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1612 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1613 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1620 * ASUS pin configuration:
1621 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1623 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1624 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1625 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1626 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1627 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1629 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1630 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1631 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1632 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1635 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1636 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1640 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1641 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1642 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1644 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1646 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1651 /* Enable GPIO mask and set output */
1652 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1653 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1655 /* Clevo m520g init */
1656 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1657 /* headphone output */
1658 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1664 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1666 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1667 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 /* Mic1 (rear panel) */
1669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1671 /* Mic2 (front panel) */
1672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1673 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1675 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1677 /* change to EAPD mode */
1678 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1679 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1684 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1685 /* change to EAPD mode */
1686 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1687 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1689 /* Headphone output */
1690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1695 /* Line In pin widget for input */
1696 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1697 /* CD pin widget for input */
1698 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1699 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1700 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1702 /* change to EAPD mode */
1703 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1704 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1710 * LG m1 express dual
1713 * Rear Line-In/Out (blue): 0x14
1714 * Build-in Mic-In: 0x15
1716 * HP-Out (green): 0x1b
1717 * Mic-In/Out (red): 0x19
1721 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1722 static hda_nid_t alc880_lg_dac_nids[3] = {
1726 /* seems analog CD is not working */
1727 static struct hda_input_mux alc880_lg_capture_source = {
1732 { "Internal Mic", 0x6 },
1736 /* 2,4,6 channel modes */
1737 static struct hda_verb alc880_lg_ch2_init[] = {
1738 /* set line-in and mic-in to input */
1739 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1740 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1744 static struct hda_verb alc880_lg_ch4_init[] = {
1745 /* set line-in to out and mic-in to input */
1746 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1747 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1751 static struct hda_verb alc880_lg_ch6_init[] = {
1752 /* set line-in and mic-in to output */
1753 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1754 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1758 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1759 { 2, alc880_lg_ch2_init },
1760 { 4, alc880_lg_ch4_init },
1761 { 6, alc880_lg_ch6_init },
1764 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1765 /* FIXME: it's not really "master" but front channels */
1766 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1767 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1771 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1773 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1775 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1776 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1777 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1779 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1782 .name = "Channel Mode",
1783 .info = alc_ch_mode_info,
1784 .get = alc_ch_mode_get,
1785 .put = alc_ch_mode_put,
1790 static struct hda_verb alc880_lg_init_verbs[] = {
1791 /* set capture source to mic-in */
1792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1794 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1795 /* mute all amp mixer inputs */
1796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1798 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1799 /* line-in to input */
1800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1804 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1806 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1807 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1808 /* mic-in to input */
1809 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1810 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1811 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1813 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1814 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1815 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1817 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1821 /* toggle speaker-output according to the hp-jack state */
1822 static void alc880_lg_automute(struct hda_codec *codec)
1824 unsigned int present;
1827 present = snd_hda_codec_read(codec, 0x1b, 0,
1828 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1829 bits = present ? 0x80 : 0;
1830 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1832 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1836 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1838 /* Looks like the unsol event is incompatible with the standard
1839 * definition. 4bit tag is placed at 28 bit!
1841 if ((res >> 28) == 0x01)
1842 alc880_lg_automute(codec);
1851 * Built-in Mic-In: 0x19 (?)
1856 /* seems analog CD is not working */
1857 static struct hda_input_mux alc880_lg_lw_capture_source = {
1861 { "Internal Mic", 0x1 },
1865 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1866 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1867 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1868 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1869 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1870 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1871 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1875 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1876 /* set capture source to mic-in */
1877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1885 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1887 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1888 /* mic-in to input */
1889 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1892 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1895 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1899 /* toggle speaker-output according to the hp-jack state */
1900 static void alc880_lg_lw_automute(struct hda_codec *codec)
1902 unsigned int present;
1905 present = snd_hda_codec_read(codec, 0x1b, 0,
1906 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1907 bits = present ? 0x80 : 0;
1908 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1910 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1914 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1916 /* Looks like the unsol event is incompatible with the standard
1917 * definition. 4bit tag is placed at 28 bit!
1919 if ((res >> 28) == 0x01)
1920 alc880_lg_lw_automute(codec);
1927 static int alc_init(struct hda_codec *codec)
1929 struct alc_spec *spec = codec->spec;
1932 for (i = 0; i < spec->num_init_verbs; i++)
1933 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1935 if (spec->init_hook)
1936 spec->init_hook(codec);
1941 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1943 struct alc_spec *spec = codec->spec;
1945 if (spec->unsol_event)
1946 spec->unsol_event(codec, res);
1953 static int alc_resume(struct hda_codec *codec)
1955 struct alc_spec *spec = codec->spec;
1959 for (i = 0; i < spec->num_mixers; i++)
1960 snd_hda_resume_ctls(codec, spec->mixers[i]);
1961 if (spec->multiout.dig_out_nid)
1962 snd_hda_resume_spdif_out(codec);
1963 if (spec->dig_in_nid)
1964 snd_hda_resume_spdif_in(codec);
1971 * Analog playback callbacks
1973 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1974 struct hda_codec *codec,
1975 struct snd_pcm_substream *substream)
1977 struct alc_spec *spec = codec->spec;
1978 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1981 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1982 struct hda_codec *codec,
1983 unsigned int stream_tag,
1984 unsigned int format,
1985 struct snd_pcm_substream *substream)
1987 struct alc_spec *spec = codec->spec;
1988 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1989 stream_tag, format, substream);
1992 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1993 struct hda_codec *codec,
1994 struct snd_pcm_substream *substream)
1996 struct alc_spec *spec = codec->spec;
1997 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2003 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2004 struct hda_codec *codec,
2005 struct snd_pcm_substream *substream)
2007 struct alc_spec *spec = codec->spec;
2008 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2011 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2012 struct hda_codec *codec,
2013 unsigned int stream_tag,
2014 unsigned int format,
2015 struct snd_pcm_substream *substream)
2017 struct alc_spec *spec = codec->spec;
2018 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2019 stream_tag, format, substream);
2022 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2023 struct hda_codec *codec,
2024 struct snd_pcm_substream *substream)
2026 struct alc_spec *spec = codec->spec;
2027 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2033 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2034 struct hda_codec *codec,
2035 unsigned int stream_tag,
2036 unsigned int format,
2037 struct snd_pcm_substream *substream)
2039 struct alc_spec *spec = codec->spec;
2041 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2042 stream_tag, 0, format);
2046 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2047 struct hda_codec *codec,
2048 struct snd_pcm_substream *substream)
2050 struct alc_spec *spec = codec->spec;
2052 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2060 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2064 /* NID is set in alc_build_pcms */
2066 .open = alc880_playback_pcm_open,
2067 .prepare = alc880_playback_pcm_prepare,
2068 .cleanup = alc880_playback_pcm_cleanup
2072 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2076 /* NID is set in alc_build_pcms */
2078 .prepare = alc880_capture_pcm_prepare,
2079 .cleanup = alc880_capture_pcm_cleanup
2083 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2087 /* NID is set in alc_build_pcms */
2089 .open = alc880_dig_playback_pcm_open,
2090 .close = alc880_dig_playback_pcm_close,
2091 .prepare = alc880_dig_playback_pcm_prepare
2095 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2099 /* NID is set in alc_build_pcms */
2102 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2103 static struct hda_pcm_stream alc_pcm_null_playback = {
2109 static int alc_build_pcms(struct hda_codec *codec)
2111 struct alc_spec *spec = codec->spec;
2112 struct hda_pcm *info = spec->pcm_rec;
2115 codec->num_pcms = 1;
2116 codec->pcm_info = info;
2118 info->name = spec->stream_name_analog;
2119 if (spec->stream_analog_playback) {
2120 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2121 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2122 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2124 if (spec->stream_analog_capture) {
2125 snd_assert(spec->adc_nids, return -EINVAL);
2126 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2127 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2130 if (spec->channel_mode) {
2131 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2132 for (i = 0; i < spec->num_channel_mode; i++) {
2133 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2134 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2139 /* SPDIF for stream index #1 */
2140 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2141 codec->num_pcms = 2;
2142 info = spec->pcm_rec + 1;
2143 info->name = spec->stream_name_digital;
2144 if (spec->multiout.dig_out_nid &&
2145 spec->stream_digital_playback) {
2146 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2147 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2149 if (spec->dig_in_nid &&
2150 spec->stream_digital_capture) {
2151 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2152 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2156 /* If the use of more than one ADC is requested for the current
2157 * model, configure a second analog capture-only PCM.
2159 /* Additional Analaog capture for index #2 */
2160 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2162 codec->num_pcms = 3;
2163 info = spec->pcm_rec + 2;
2164 info->name = spec->stream_name_analog;
2165 /* No playback stream for second PCM */
2166 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2167 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2168 if (spec->stream_analog_capture) {
2169 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2170 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2177 static void alc_free(struct hda_codec *codec)
2179 struct alc_spec *spec = codec->spec;
2185 if (spec->kctl_alloc) {
2186 for (i = 0; i < spec->num_kctl_used; i++)
2187 kfree(spec->kctl_alloc[i].name);
2188 kfree(spec->kctl_alloc);
2195 static struct hda_codec_ops alc_patch_ops = {
2196 .build_controls = alc_build_controls,
2197 .build_pcms = alc_build_pcms,
2200 .unsol_event = alc_unsol_event,
2202 .resume = alc_resume,
2208 * Test configuration for debugging
2210 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2213 #ifdef CONFIG_SND_DEBUG
2214 static hda_nid_t alc880_test_dac_nids[4] = {
2215 0x02, 0x03, 0x04, 0x05
2218 static struct hda_input_mux alc880_test_capture_source = {
2227 { "Surround", 0x6 },
2231 static struct hda_channel_mode alc880_test_modes[4] = {
2238 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2239 struct snd_ctl_elem_info *uinfo)
2241 static char *texts[] = {
2242 "N/A", "Line Out", "HP Out",
2243 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2245 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2247 uinfo->value.enumerated.items = 8;
2248 if (uinfo->value.enumerated.item >= 8)
2249 uinfo->value.enumerated.item = 7;
2250 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2254 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2255 struct snd_ctl_elem_value *ucontrol)
2257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2258 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2259 unsigned int pin_ctl, item = 0;
2261 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2262 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2263 if (pin_ctl & AC_PINCTL_OUT_EN) {
2264 if (pin_ctl & AC_PINCTL_HP_EN)
2268 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2269 switch (pin_ctl & AC_PINCTL_VREFEN) {
2270 case AC_PINCTL_VREF_HIZ: item = 3; break;
2271 case AC_PINCTL_VREF_50: item = 4; break;
2272 case AC_PINCTL_VREF_GRD: item = 5; break;
2273 case AC_PINCTL_VREF_80: item = 6; break;
2274 case AC_PINCTL_VREF_100: item = 7; break;
2277 ucontrol->value.enumerated.item[0] = item;
2281 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2282 struct snd_ctl_elem_value *ucontrol)
2284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2285 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2286 static unsigned int ctls[] = {
2287 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2288 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2289 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2290 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2291 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2292 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2294 unsigned int old_ctl, new_ctl;
2296 old_ctl = snd_hda_codec_read(codec, nid, 0,
2297 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2298 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2299 if (old_ctl != new_ctl) {
2300 snd_hda_codec_write(codec, nid, 0,
2301 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
2302 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2303 (ucontrol->value.enumerated.item[0] >= 3 ?
2310 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2311 struct snd_ctl_elem_info *uinfo)
2313 static char *texts[] = {
2314 "Front", "Surround", "CLFE", "Side"
2316 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2318 uinfo->value.enumerated.items = 4;
2319 if (uinfo->value.enumerated.item >= 4)
2320 uinfo->value.enumerated.item = 3;
2321 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2325 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2326 struct snd_ctl_elem_value *ucontrol)
2328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2329 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2332 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2333 ucontrol->value.enumerated.item[0] = sel & 3;
2337 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2338 struct snd_ctl_elem_value *ucontrol)
2340 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2341 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2344 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2345 if (ucontrol->value.enumerated.item[0] != sel) {
2346 sel = ucontrol->value.enumerated.item[0] & 3;
2347 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2353 #define PIN_CTL_TEST(xname,nid) { \
2354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2356 .info = alc_test_pin_ctl_info, \
2357 .get = alc_test_pin_ctl_get, \
2358 .put = alc_test_pin_ctl_put, \
2359 .private_value = nid \
2362 #define PIN_SRC_TEST(xname,nid) { \
2363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2365 .info = alc_test_pin_src_info, \
2366 .get = alc_test_pin_src_get, \
2367 .put = alc_test_pin_src_put, \
2368 .private_value = nid \
2371 static struct snd_kcontrol_new alc880_test_mixer[] = {
2372 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2373 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2374 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2375 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2376 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2377 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2378 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2379 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2380 PIN_CTL_TEST("Front Pin Mode", 0x14),
2381 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2382 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2383 PIN_CTL_TEST("Side Pin Mode", 0x17),
2384 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2385 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2386 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2387 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2388 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2389 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2390 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2391 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2392 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2393 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2394 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2395 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2396 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2397 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2398 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2399 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2400 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2401 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2404 .name = "Channel Mode",
2405 .info = alc_ch_mode_info,
2406 .get = alc_ch_mode_get,
2407 .put = alc_ch_mode_put,
2412 static struct hda_verb alc880_test_init_verbs[] = {
2413 /* Unmute inputs of 0x0c - 0x0f */
2414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2420 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2421 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2422 /* Vol output for 0x0c-0x0f */
2423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2425 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2426 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2427 /* Set output pins 0x14-0x17 */
2428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2430 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2431 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2432 /* Unmute output pins 0x14-0x17 */
2433 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2435 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2436 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2437 /* Set input pins 0x18-0x1c */
2438 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2439 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2443 /* Mute input pins 0x18-0x1b */
2444 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2446 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2447 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2450 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2452 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2453 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2454 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2455 /* Analog input/passthru */
2456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2460 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2468 static const char *alc880_models[ALC880_MODEL_LAST] = {
2469 [ALC880_3ST] = "3stack",
2470 [ALC880_TCL_S700] = "tcl",
2471 [ALC880_3ST_DIG] = "3stack-digout",
2472 [ALC880_CLEVO] = "clevo",
2473 [ALC880_5ST] = "5stack",
2474 [ALC880_5ST_DIG] = "5stack-digout",
2475 [ALC880_W810] = "w810",
2476 [ALC880_Z71V] = "z71v",
2477 [ALC880_6ST] = "6stack",
2478 [ALC880_6ST_DIG] = "6stack-digout",
2479 [ALC880_ASUS] = "asus",
2480 [ALC880_ASUS_W1V] = "asus-w1v",
2481 [ALC880_ASUS_DIG] = "asus-dig",
2482 [ALC880_ASUS_DIG2] = "asus-dig2",
2483 [ALC880_UNIWILL_DIG] = "uniwill",
2484 [ALC880_UNIWILL_P53] = "uniwill-p53",
2485 [ALC880_FUJITSU] = "fujitsu",
2486 [ALC880_F1734] = "F1734",
2488 [ALC880_LG_LW] = "lg-lw",
2489 #ifdef CONFIG_SND_DEBUG
2490 [ALC880_TEST] = "test",
2492 [ALC880_AUTO] = "auto",
2495 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2496 /* Broken BIOS configuration */
2497 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2498 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2500 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2501 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2502 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2503 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2504 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2505 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2506 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2507 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2508 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2510 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2511 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2513 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2514 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2515 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2516 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2517 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2518 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2519 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2520 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2521 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2522 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2523 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2524 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2525 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2526 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2527 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2529 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2530 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2531 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2532 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2533 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2534 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2535 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2536 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2537 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2538 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2539 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2540 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2541 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2542 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2543 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2544 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2545 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2546 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2548 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2549 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2550 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2551 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2553 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2554 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2555 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2556 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2558 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2559 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2560 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2561 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2563 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2564 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2565 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2566 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2567 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2568 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2569 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2570 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2571 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2572 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2573 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2579 * ALC880 codec presets
2581 static struct alc_config_preset alc880_presets[] = {
2583 .mixers = { alc880_three_stack_mixer },
2584 .init_verbs = { alc880_volume_init_verbs,
2585 alc880_pin_3stack_init_verbs },
2586 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2587 .dac_nids = alc880_dac_nids,
2588 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2589 .channel_mode = alc880_threestack_modes,
2591 .input_mux = &alc880_capture_source,
2593 [ALC880_3ST_DIG] = {
2594 .mixers = { alc880_three_stack_mixer },
2595 .init_verbs = { alc880_volume_init_verbs,
2596 alc880_pin_3stack_init_verbs },
2597 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2598 .dac_nids = alc880_dac_nids,
2599 .dig_out_nid = ALC880_DIGOUT_NID,
2600 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2601 .channel_mode = alc880_threestack_modes,
2603 .input_mux = &alc880_capture_source,
2605 [ALC880_TCL_S700] = {
2606 .mixers = { alc880_tcl_s700_mixer },
2607 .init_verbs = { alc880_volume_init_verbs,
2608 alc880_pin_tcl_S700_init_verbs,
2609 alc880_gpio2_init_verbs },
2610 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2611 .dac_nids = alc880_dac_nids,
2613 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2614 .channel_mode = alc880_2_jack_modes,
2615 .input_mux = &alc880_capture_source,
2618 .mixers = { alc880_three_stack_mixer,
2619 alc880_five_stack_mixer},
2620 .init_verbs = { alc880_volume_init_verbs,
2621 alc880_pin_5stack_init_verbs },
2622 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2623 .dac_nids = alc880_dac_nids,
2624 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2625 .channel_mode = alc880_fivestack_modes,
2626 .input_mux = &alc880_capture_source,
2628 [ALC880_5ST_DIG] = {
2629 .mixers = { alc880_three_stack_mixer,
2630 alc880_five_stack_mixer },
2631 .init_verbs = { alc880_volume_init_verbs,
2632 alc880_pin_5stack_init_verbs },
2633 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2634 .dac_nids = alc880_dac_nids,
2635 .dig_out_nid = ALC880_DIGOUT_NID,
2636 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2637 .channel_mode = alc880_fivestack_modes,
2638 .input_mux = &alc880_capture_source,
2641 .mixers = { alc880_six_stack_mixer },
2642 .init_verbs = { alc880_volume_init_verbs,
2643 alc880_pin_6stack_init_verbs },
2644 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2645 .dac_nids = alc880_6st_dac_nids,
2646 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2647 .channel_mode = alc880_sixstack_modes,
2648 .input_mux = &alc880_6stack_capture_source,
2650 [ALC880_6ST_DIG] = {
2651 .mixers = { alc880_six_stack_mixer },
2652 .init_verbs = { alc880_volume_init_verbs,
2653 alc880_pin_6stack_init_verbs },
2654 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2655 .dac_nids = alc880_6st_dac_nids,
2656 .dig_out_nid = ALC880_DIGOUT_NID,
2657 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2658 .channel_mode = alc880_sixstack_modes,
2659 .input_mux = &alc880_6stack_capture_source,
2662 .mixers = { alc880_w810_base_mixer },
2663 .init_verbs = { alc880_volume_init_verbs,
2664 alc880_pin_w810_init_verbs,
2665 alc880_gpio2_init_verbs },
2666 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2667 .dac_nids = alc880_w810_dac_nids,
2668 .dig_out_nid = ALC880_DIGOUT_NID,
2669 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2670 .channel_mode = alc880_w810_modes,
2671 .input_mux = &alc880_capture_source,
2674 .mixers = { alc880_z71v_mixer },
2675 .init_verbs = { alc880_volume_init_verbs,
2676 alc880_pin_z71v_init_verbs },
2677 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2678 .dac_nids = alc880_z71v_dac_nids,
2679 .dig_out_nid = ALC880_DIGOUT_NID,
2681 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2682 .channel_mode = alc880_2_jack_modes,
2683 .input_mux = &alc880_capture_source,
2686 .mixers = { alc880_f1734_mixer },
2687 .init_verbs = { alc880_volume_init_verbs,
2688 alc880_pin_f1734_init_verbs },
2689 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2690 .dac_nids = alc880_f1734_dac_nids,
2692 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2693 .channel_mode = alc880_2_jack_modes,
2694 .input_mux = &alc880_capture_source,
2697 .mixers = { alc880_asus_mixer },
2698 .init_verbs = { alc880_volume_init_verbs,
2699 alc880_pin_asus_init_verbs,
2700 alc880_gpio1_init_verbs },
2701 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2702 .dac_nids = alc880_asus_dac_nids,
2703 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2704 .channel_mode = alc880_asus_modes,
2706 .input_mux = &alc880_capture_source,
2708 [ALC880_ASUS_DIG] = {
2709 .mixers = { alc880_asus_mixer },
2710 .init_verbs = { alc880_volume_init_verbs,
2711 alc880_pin_asus_init_verbs,
2712 alc880_gpio1_init_verbs },
2713 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2714 .dac_nids = alc880_asus_dac_nids,
2715 .dig_out_nid = ALC880_DIGOUT_NID,
2716 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2717 .channel_mode = alc880_asus_modes,
2719 .input_mux = &alc880_capture_source,
2721 [ALC880_ASUS_DIG2] = {
2722 .mixers = { alc880_asus_mixer },
2723 .init_verbs = { alc880_volume_init_verbs,
2724 alc880_pin_asus_init_verbs,
2725 alc880_gpio2_init_verbs }, /* use GPIO2 */
2726 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2727 .dac_nids = alc880_asus_dac_nids,
2728 .dig_out_nid = ALC880_DIGOUT_NID,
2729 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2730 .channel_mode = alc880_asus_modes,
2732 .input_mux = &alc880_capture_source,
2734 [ALC880_ASUS_W1V] = {
2735 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2736 .init_verbs = { alc880_volume_init_verbs,
2737 alc880_pin_asus_init_verbs,
2738 alc880_gpio1_init_verbs },
2739 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2740 .dac_nids = alc880_asus_dac_nids,
2741 .dig_out_nid = ALC880_DIGOUT_NID,
2742 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2743 .channel_mode = alc880_asus_modes,
2745 .input_mux = &alc880_capture_source,
2747 [ALC880_UNIWILL_DIG] = {
2748 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2749 .init_verbs = { alc880_volume_init_verbs,
2750 alc880_pin_asus_init_verbs },
2751 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2752 .dac_nids = alc880_asus_dac_nids,
2753 .dig_out_nid = ALC880_DIGOUT_NID,
2754 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2755 .channel_mode = alc880_asus_modes,
2757 .input_mux = &alc880_capture_source,
2759 [ALC880_UNIWILL] = {
2760 .mixers = { alc880_uniwill_mixer },
2761 .init_verbs = { alc880_volume_init_verbs,
2762 alc880_uniwill_init_verbs },
2763 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2764 .dac_nids = alc880_asus_dac_nids,
2765 .dig_out_nid = ALC880_DIGOUT_NID,
2766 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2767 .channel_mode = alc880_threestack_modes,
2769 .input_mux = &alc880_capture_source,
2770 .unsol_event = alc880_uniwill_unsol_event,
2771 .init_hook = alc880_uniwill_automute,
2773 [ALC880_UNIWILL_P53] = {
2774 .mixers = { alc880_uniwill_p53_mixer },
2775 .init_verbs = { alc880_volume_init_verbs,
2776 alc880_uniwill_p53_init_verbs },
2777 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2778 .dac_nids = alc880_asus_dac_nids,
2779 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2780 .channel_mode = alc880_threestack_modes,
2781 .input_mux = &alc880_capture_source,
2782 .unsol_event = alc880_uniwill_p53_unsol_event,
2783 .init_hook = alc880_uniwill_p53_hp_automute,
2785 [ALC880_FUJITSU] = {
2786 .mixers = { alc880_fujitsu_mixer,
2787 alc880_pcbeep_mixer, },
2788 .init_verbs = { alc880_volume_init_verbs,
2789 alc880_uniwill_p53_init_verbs,
2790 alc880_beep_init_verbs },
2791 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2792 .dac_nids = alc880_dac_nids,
2793 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2794 .channel_mode = alc880_2_jack_modes,
2795 .input_mux = &alc880_capture_source,
2796 .unsol_event = alc880_uniwill_p53_unsol_event,
2797 .init_hook = alc880_uniwill_p53_hp_automute,
2800 .mixers = { alc880_three_stack_mixer },
2801 .init_verbs = { alc880_volume_init_verbs,
2802 alc880_pin_clevo_init_verbs },
2803 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2804 .dac_nids = alc880_dac_nids,
2806 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2807 .channel_mode = alc880_threestack_modes,
2809 .input_mux = &alc880_capture_source,
2812 .mixers = { alc880_lg_mixer },
2813 .init_verbs = { alc880_volume_init_verbs,
2814 alc880_lg_init_verbs },
2815 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2816 .dac_nids = alc880_lg_dac_nids,
2817 .dig_out_nid = ALC880_DIGOUT_NID,
2818 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2819 .channel_mode = alc880_lg_ch_modes,
2821 .input_mux = &alc880_lg_capture_source,
2822 .unsol_event = alc880_lg_unsol_event,
2823 .init_hook = alc880_lg_automute,
2826 .mixers = { alc880_lg_lw_mixer },
2827 .init_verbs = { alc880_volume_init_verbs,
2828 alc880_lg_lw_init_verbs },
2830 .dac_nids = alc880_dac_nids,
2831 .dig_out_nid = ALC880_DIGOUT_NID,
2832 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2833 .channel_mode = alc880_2_jack_modes,
2834 .input_mux = &alc880_lg_lw_capture_source,
2835 .unsol_event = alc880_lg_lw_unsol_event,
2836 .init_hook = alc880_lg_lw_automute,
2838 #ifdef CONFIG_SND_DEBUG
2840 .mixers = { alc880_test_mixer },
2841 .init_verbs = { alc880_test_init_verbs },
2842 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2843 .dac_nids = alc880_test_dac_nids,
2844 .dig_out_nid = ALC880_DIGOUT_NID,
2845 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2846 .channel_mode = alc880_test_modes,
2847 .input_mux = &alc880_test_capture_source,
2853 * Automatic parse of I/O pins from the BIOS configuration
2856 #define NUM_CONTROL_ALLOC 32
2857 #define NUM_VERB_ALLOC 32
2861 ALC_CTL_WIDGET_MUTE,
2864 static struct snd_kcontrol_new alc880_control_templates[] = {
2865 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2866 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2867 HDA_BIND_MUTE(NULL, 0, 0, 0),
2870 /* add dynamic controls */
2871 static int add_control(struct alc_spec *spec, int type, const char *name,
2874 struct snd_kcontrol_new *knew;
2876 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2877 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2879 /* array + terminator */
2880 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2883 if (spec->kctl_alloc) {
2884 memcpy(knew, spec->kctl_alloc,
2885 sizeof(*knew) * spec->num_kctl_alloc);
2886 kfree(spec->kctl_alloc);
2888 spec->kctl_alloc = knew;
2889 spec->num_kctl_alloc = num;
2892 knew = &spec->kctl_alloc[spec->num_kctl_used];
2893 *knew = alc880_control_templates[type];
2894 knew->name = kstrdup(name, GFP_KERNEL);
2897 knew->private_value = val;
2898 spec->num_kctl_used++;
2902 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2903 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2904 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2905 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2906 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2907 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2908 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2909 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2910 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2911 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2912 #define ALC880_PIN_CD_NID 0x1c
2914 /* fill in the dac_nids table from the parsed pin configuration */
2915 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2916 const struct auto_pin_cfg *cfg)
2922 memset(assigned, 0, sizeof(assigned));
2923 spec->multiout.dac_nids = spec->private_dac_nids;
2925 /* check the pins hardwired to audio widget */
2926 for (i = 0; i < cfg->line_outs; i++) {
2927 nid = cfg->line_out_pins[i];
2928 if (alc880_is_fixed_pin(nid)) {
2929 int idx = alc880_fixed_pin_idx(nid);
2930 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2934 /* left pins can be connect to any audio widget */
2935 for (i = 0; i < cfg->line_outs; i++) {
2936 nid = cfg->line_out_pins[i];
2937 if (alc880_is_fixed_pin(nid))
2939 /* search for an empty channel */
2940 for (j = 0; j < cfg->line_outs; j++) {
2942 spec->multiout.dac_nids[i] =
2943 alc880_idx_to_dac(j);
2949 spec->multiout.num_dacs = cfg->line_outs;
2953 /* add playback controls from the parsed DAC table */
2954 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2955 const struct auto_pin_cfg *cfg)
2958 static const char *chname[4] = {
2959 "Front", "Surround", NULL /*CLFE*/, "Side"
2964 for (i = 0; i < cfg->line_outs; i++) {
2965 if (!spec->multiout.dac_nids[i])
2967 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2970 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2971 "Center Playback Volume",
2972 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
2976 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2977 "LFE Playback Volume",
2978 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
2982 err = add_control(spec, ALC_CTL_BIND_MUTE,
2983 "Center Playback Switch",
2984 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
2988 err = add_control(spec, ALC_CTL_BIND_MUTE,
2989 "LFE Playback Switch",
2990 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
2995 sprintf(name, "%s Playback Volume", chname[i]);
2996 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2997 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3001 sprintf(name, "%s Playback Switch", chname[i]);
3002 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3003 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3012 /* add playback controls for speaker and HP outputs */
3013 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3023 if (alc880_is_fixed_pin(pin)) {
3024 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3025 /* specify the DAC as the extra output */
3026 if (!spec->multiout.hp_nid)
3027 spec->multiout.hp_nid = nid;
3029 spec->multiout.extra_out_nid[0] = nid;
3030 /* control HP volume/switch on the output mixer amp */
3031 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3032 sprintf(name, "%s Playback Volume", pfx);
3033 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3034 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3037 sprintf(name, "%s Playback Switch", pfx);
3038 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3039 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3042 } else if (alc880_is_multi_pin(pin)) {
3043 /* set manual connection */
3044 /* we have only a switch on HP-out PIN */
3045 sprintf(name, "%s Playback Switch", pfx);
3046 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3047 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3054 /* create input playback/capture controls for the given pin */
3055 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3056 const char *ctlname,
3057 int idx, hda_nid_t mix_nid)
3062 sprintf(name, "%s Playback Volume", ctlname);
3063 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3064 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3067 sprintf(name, "%s Playback Switch", ctlname);
3068 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3069 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3075 /* create playback/capture controls for input pins */
3076 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3077 const struct auto_pin_cfg *cfg)
3079 struct hda_input_mux *imux = &spec->private_imux;
3082 for (i = 0; i < AUTO_PIN_LAST; i++) {
3083 if (alc880_is_input_pin(cfg->input_pins[i])) {
3084 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3085 err = new_analog_input(spec, cfg->input_pins[i],
3086 auto_pin_cfg_labels[i],
3090 imux->items[imux->num_items].label =
3091 auto_pin_cfg_labels[i];
3092 imux->items[imux->num_items].index =
3093 alc880_input_pin_idx(cfg->input_pins[i]);
3100 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3101 hda_nid_t nid, int pin_type,
3105 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3107 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3109 /* need the manual connection? */
3110 if (alc880_is_multi_pin(nid)) {
3111 struct alc_spec *spec = codec->spec;
3112 int idx = alc880_multi_pin_idx(nid);
3113 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3114 AC_VERB_SET_CONNECT_SEL,
3115 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3119 static int get_pin_type(int line_out_type)
3121 if (line_out_type == AUTO_PIN_HP_OUT)
3127 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3129 struct alc_spec *spec = codec->spec;
3132 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3133 for (i = 0; i < spec->autocfg.line_outs; i++) {
3134 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3135 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3136 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3140 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3142 struct alc_spec *spec = codec->spec;
3145 pin = spec->autocfg.speaker_pins[0];
3146 if (pin) /* connect to front */
3147 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3148 pin = spec->autocfg.hp_pins[0];
3149 if (pin) /* connect to front */
3150 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3153 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3155 struct alc_spec *spec = codec->spec;
3158 for (i = 0; i < AUTO_PIN_LAST; i++) {
3159 hda_nid_t nid = spec->autocfg.input_pins[i];
3160 if (alc880_is_input_pin(nid)) {
3161 snd_hda_codec_write(codec, nid, 0,
3162 AC_VERB_SET_PIN_WIDGET_CONTROL,
3163 i <= AUTO_PIN_FRONT_MIC ?
3164 PIN_VREF80 : PIN_IN);
3165 if (nid != ALC880_PIN_CD_NID)
3166 snd_hda_codec_write(codec, nid, 0,
3167 AC_VERB_SET_AMP_GAIN_MUTE,
3173 /* parse the BIOS configuration and set up the alc_spec */
3174 /* return 1 if successful, 0 if the proper config is not found,
3175 * or a negative error code
3177 static int alc880_parse_auto_config(struct hda_codec *codec)
3179 struct alc_spec *spec = codec->spec;
3181 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3183 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3187 if (!spec->autocfg.line_outs)
3188 return 0; /* can't find valid BIOS pin config */
3190 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3193 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3196 err = alc880_auto_create_extra_out(spec,
3197 spec->autocfg.speaker_pins[0],
3201 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3205 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3209 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3211 if (spec->autocfg.dig_out_pin)
3212 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3213 if (spec->autocfg.dig_in_pin)
3214 spec->dig_in_nid = ALC880_DIGIN_NID;
3216 if (spec->kctl_alloc)
3217 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3219 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3221 spec->num_mux_defs = 1;
3222 spec->input_mux = &spec->private_imux;
3227 /* additional initialization for auto-configuration model */
3228 static void alc880_auto_init(struct hda_codec *codec)
3230 alc880_auto_init_multi_out(codec);
3231 alc880_auto_init_extra_out(codec);
3232 alc880_auto_init_analog_input(codec);
3236 * OK, here we have finally the patch for ALC880
3239 static int patch_alc880(struct hda_codec *codec)
3241 struct alc_spec *spec;
3245 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3251 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3254 if (board_config < 0) {
3255 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3256 "trying auto-probe from BIOS...\n");
3257 board_config = ALC880_AUTO;
3260 if (board_config == ALC880_AUTO) {
3261 /* automatic parse from the BIOS config */
3262 err = alc880_parse_auto_config(codec);
3268 "hda_codec: Cannot set up configuration "
3269 "from BIOS. Using 3-stack mode...\n");
3270 board_config = ALC880_3ST;
3274 if (board_config != ALC880_AUTO)
3275 setup_preset(spec, &alc880_presets[board_config]);
3277 spec->stream_name_analog = "ALC880 Analog";
3278 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3279 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3281 spec->stream_name_digital = "ALC880 Digital";
3282 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3283 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3285 if (!spec->adc_nids && spec->input_mux) {
3286 /* check whether NID 0x07 is valid */
3287 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3289 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3290 if (wcap != AC_WID_AUD_IN) {
3291 spec->adc_nids = alc880_adc_nids_alt;
3292 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3293 spec->mixers[spec->num_mixers] =
3294 alc880_capture_alt_mixer;
3297 spec->adc_nids = alc880_adc_nids;
3298 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3299 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3304 codec->patch_ops = alc_patch_ops;
3305 if (board_config == ALC880_AUTO)
3306 spec->init_hook = alc880_auto_init;
3316 static hda_nid_t alc260_dac_nids[1] = {
3321 static hda_nid_t alc260_adc_nids[1] = {
3326 static hda_nid_t alc260_adc_nids_alt[1] = {
3331 static hda_nid_t alc260_hp_adc_nids[2] = {
3336 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3337 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3339 static hda_nid_t alc260_dual_adc_nids[2] = {
3344 #define ALC260_DIGOUT_NID 0x03
3345 #define ALC260_DIGIN_NID 0x06
3347 static struct hda_input_mux alc260_capture_source = {
3351 { "Front Mic", 0x1 },
3357 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3358 * headphone jack and the internal CD lines since these are the only pins at
3359 * which audio can appear. For flexibility, also allow the option of
3360 * recording the mixer output on the second ADC (ADC0 doesn't have a
3361 * connection to the mixer output).
3363 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3367 { "Mic/Line", 0x0 },
3369 { "Headphone", 0x2 },
3375 { "Mic/Line", 0x0 },
3377 { "Headphone", 0x2 },
3384 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3385 * the Fujitsu S702x, but jacks are marked differently.
3387 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3394 { "Headphone", 0x5 },
3403 { "Headphone", 0x6 },
3409 * This is just place-holder, so there's something for alc_build_pcms to look
3410 * at when it calculates the maximum number of channels. ALC260 has no mixer
3411 * element which allows changing the channel mode, so the verb list is
3414 static struct hda_channel_mode alc260_modes[1] = {
3419 /* Mixer combinations
3421 * basic: base_output + input + pc_beep + capture
3422 * HP: base_output + input + capture_alt
3423 * HP_3013: hp_3013 + input + capture
3424 * fujitsu: fujitsu + capture
3425 * acer: acer + capture
3428 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3429 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3430 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3432 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3433 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3434 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3438 static struct snd_kcontrol_new alc260_input_mixer[] = {
3439 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3440 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3441 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3442 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3444 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3445 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3446 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3450 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3451 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3452 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3456 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3457 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3458 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3459 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3460 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3463 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3464 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3468 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3469 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3471 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3472 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3473 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3474 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3475 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3476 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3477 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3478 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3479 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3480 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3481 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3482 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3483 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3487 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3488 * versions of the ALC260 don't act on requests to enable mic bias from NID
3489 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3490 * datasheet doesn't mention this restriction. At this stage it's not clear
3491 * whether this behaviour is intentional or is a hardware bug in chip
3492 * revisions available in early 2006. Therefore for now allow the
3493 * "Headphone Jack Mode" control to span all choices, but if it turns out
3494 * that the lack of mic bias for this NID is intentional we could change the
3495 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3497 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3498 * don't appear to make the mic bias available from the "line" jack, even
3499 * though the NID used for this jack (0x14) can supply it. The theory is
3500 * that perhaps Acer have included blocking capacitors between the ALC260
3501 * and the output jack. If this turns out to be the case for all such
3502 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3503 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3505 * The C20x Tablet series have a mono internal speaker which is controlled
3506 * via the chip's Mono sum widget and pin complex, so include the necessary
3507 * controls for such models. On models without a "mono speaker" the control
3508 * won't do anything.
3510 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3511 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3512 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3513 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3514 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3516 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3518 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3519 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3521 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3522 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3523 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3524 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3525 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3526 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3527 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3531 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3532 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3534 static struct snd_kcontrol_new alc260_will_mixer[] = {
3535 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3536 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3538 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3539 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3540 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3541 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3542 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3543 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3544 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3545 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3546 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3550 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3551 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3553 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3554 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3555 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3557 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3558 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3559 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3560 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3561 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3562 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3563 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3567 /* capture mixer elements */
3568 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3569 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3570 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3571 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3572 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),