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 */
62 #ifdef CONFIG_SND_DEBUG
66 ALC880_MODEL_LAST /* last tag */
76 #ifdef CONFIG_SND_DEBUG
80 ALC260_MODEL_LAST /* last tag */
90 ALC262_HP_BPC_D7000_WL,
91 ALC262_HP_BPC_D7000_WF,
94 ALC262_MODEL_LAST /* last tag */
111 /* ALC861-VD models */
138 ALC883_TARGA_2ch_DIG,
148 #define GPIO_MASK 0x03
151 /* codec parameterization */
152 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
153 unsigned int num_mixers;
155 const struct hda_verb *init_verbs[5]; /* initialization verbs
159 unsigned int num_init_verbs;
161 char *stream_name_analog; /* analog PCM stream */
162 struct hda_pcm_stream *stream_analog_playback;
163 struct hda_pcm_stream *stream_analog_capture;
165 char *stream_name_digital; /* digital PCM stream */
166 struct hda_pcm_stream *stream_digital_playback;
167 struct hda_pcm_stream *stream_digital_capture;
170 struct hda_multi_out multiout; /* playback set-up
171 * max_channels, dacs must be set
172 * dig_out_nid and hp_nid are optional
176 unsigned int num_adc_nids;
178 hda_nid_t dig_in_nid; /* digital-in NID; optional */
181 unsigned int num_mux_defs;
182 const struct hda_input_mux *input_mux;
183 unsigned int cur_mux[3];
186 const struct hda_channel_mode *channel_mode;
187 int num_channel_mode;
190 /* PCM information */
191 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
193 /* dynamic controls, init_verbs and input_mux */
194 struct auto_pin_cfg autocfg;
195 unsigned int num_kctl_alloc, num_kctl_used;
196 struct snd_kcontrol_new *kctl_alloc;
197 struct hda_input_mux private_imux;
198 hda_nid_t private_dac_nids[5];
201 void (*init_hook)(struct hda_codec *codec);
202 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
204 /* for pin sensing */
205 unsigned int sense_updated: 1;
206 unsigned int jack_present: 1;
210 * configuration template - to be copied to the spec instance
212 struct alc_config_preset {
213 struct snd_kcontrol_new *mixers[5]; /* should be identical size
216 const struct hda_verb *init_verbs[5];
217 unsigned int num_dacs;
219 hda_nid_t dig_out_nid; /* optional */
220 hda_nid_t hp_nid; /* optional */
221 unsigned int num_adc_nids;
223 hda_nid_t dig_in_nid;
224 unsigned int num_channel_mode;
225 const struct hda_channel_mode *channel_mode;
227 unsigned int num_mux_defs;
228 const struct hda_input_mux *input_mux;
229 void (*unsol_event)(struct hda_codec *, unsigned int);
230 void (*init_hook)(struct hda_codec *);
237 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
238 struct snd_ctl_elem_info *uinfo)
240 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
241 struct alc_spec *spec = codec->spec;
242 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
243 if (mux_idx >= spec->num_mux_defs)
245 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
248 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
249 struct snd_ctl_elem_value *ucontrol)
251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
252 struct alc_spec *spec = codec->spec;
253 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
255 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
259 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
260 struct snd_ctl_elem_value *ucontrol)
262 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
263 struct alc_spec *spec = codec->spec;
264 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
265 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
266 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
267 spec->adc_nids[adc_idx],
268 &spec->cur_mux[adc_idx]);
273 * channel mode setting
275 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
276 struct snd_ctl_elem_info *uinfo)
278 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
279 struct alc_spec *spec = codec->spec;
280 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
281 spec->num_channel_mode);
284 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
285 struct snd_ctl_elem_value *ucontrol)
287 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
288 struct alc_spec *spec = codec->spec;
289 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
290 spec->num_channel_mode,
291 spec->multiout.max_channels);
294 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
295 struct snd_ctl_elem_value *ucontrol)
297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
298 struct alc_spec *spec = codec->spec;
299 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
300 spec->num_channel_mode,
301 &spec->multiout.max_channels);
302 if (err >= 0 && spec->need_dac_fix)
303 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
308 * Control the mode of pin widget settings via the mixer. "pc" is used
309 * instead of "%" to avoid consequences of accidently treating the % as
310 * being part of a format specifier. Maximum allowed length of a value is
311 * 63 characters plus NULL terminator.
313 * Note: some retasking pin complexes seem to ignore requests for input
314 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
315 * are requested. Therefore order this list so that this behaviour will not
316 * cause problems when mixer clients move through the enum sequentially.
317 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
320 static char *alc_pin_mode_names[] = {
321 "Mic 50pc bias", "Mic 80pc bias",
322 "Line in", "Line out", "Headphone out",
324 static unsigned char alc_pin_mode_values[] = {
325 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
327 /* The control can present all 5 options, or it can limit the options based
328 * in the pin being assumed to be exclusively an input or an output pin. In
329 * addition, "input" pins may or may not process the mic bias option
330 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
331 * accept requests for bias as of chip versions up to March 2006) and/or
332 * wiring in the computer.
334 #define ALC_PIN_DIR_IN 0x00
335 #define ALC_PIN_DIR_OUT 0x01
336 #define ALC_PIN_DIR_INOUT 0x02
337 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
338 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
340 /* Info about the pin modes supported by the different pin direction modes.
341 * For each direction the minimum and maximum values are given.
343 static signed char alc_pin_mode_dir_info[5][2] = {
344 { 0, 2 }, /* ALC_PIN_DIR_IN */
345 { 3, 4 }, /* ALC_PIN_DIR_OUT */
346 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
347 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
348 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
350 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
351 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
352 #define alc_pin_mode_n_items(_dir) \
353 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
355 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_info *uinfo)
358 unsigned int item_num = uinfo->value.enumerated.item;
359 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
361 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
363 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
365 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
366 item_num = alc_pin_mode_min(dir);
367 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
371 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
372 struct snd_ctl_elem_value *ucontrol)
375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
376 hda_nid_t nid = kcontrol->private_value & 0xffff;
377 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
378 long *valp = ucontrol->value.integer.value;
379 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
380 AC_VERB_GET_PIN_WIDGET_CONTROL,
383 /* Find enumerated value for current pinctl setting */
384 i = alc_pin_mode_min(dir);
385 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
387 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
391 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 hda_nid_t nid = kcontrol->private_value & 0xffff;
397 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
398 long val = *ucontrol->value.integer.value;
399 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
400 AC_VERB_GET_PIN_WIDGET_CONTROL,
403 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
404 val = alc_pin_mode_min(dir);
406 change = pinctl != alc_pin_mode_values[val];
408 /* Set pin mode to that requested */
409 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
410 alc_pin_mode_values[val]);
412 /* Also enable the retasking pin's input/output as required
413 * for the requested pin mode. Enum values of 2 or less are
416 * Dynamically switching the input/output buffers probably
417 * reduces noise slightly (particularly on input) so we'll
418 * do it. However, having both input and output buffers
419 * enabled simultaneously doesn't seem to be problematic if
420 * this turns out to be necessary in the future.
423 snd_hda_codec_write(codec, nid, 0,
424 AC_VERB_SET_AMP_GAIN_MUTE,
426 snd_hda_codec_write(codec, nid, 0,
427 AC_VERB_SET_AMP_GAIN_MUTE,
430 snd_hda_codec_write(codec, nid, 0,
431 AC_VERB_SET_AMP_GAIN_MUTE,
433 snd_hda_codec_write(codec, nid, 0,
434 AC_VERB_SET_AMP_GAIN_MUTE,
441 #define ALC_PIN_MODE(xname, nid, dir) \
442 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
443 .info = alc_pin_mode_info, \
444 .get = alc_pin_mode_get, \
445 .put = alc_pin_mode_put, \
446 .private_value = nid | (dir<<16) }
448 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
449 * together using a mask with more than one bit set. This control is
450 * currently used only by the ALC260 test model. At this stage they are not
451 * needed for any "production" models.
453 #ifdef CONFIG_SND_DEBUG
454 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
455 struct snd_ctl_elem_info *uinfo)
457 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
459 uinfo->value.integer.min = 0;
460 uinfo->value.integer.max = 1;
463 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
466 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
467 hda_nid_t nid = kcontrol->private_value & 0xffff;
468 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
469 long *valp = ucontrol->value.integer.value;
470 unsigned int val = snd_hda_codec_read(codec, nid, 0,
471 AC_VERB_GET_GPIO_DATA, 0x00);
473 *valp = (val & mask) != 0;
476 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
477 struct snd_ctl_elem_value *ucontrol)
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 hda_nid_t nid = kcontrol->private_value & 0xffff;
482 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
483 long val = *ucontrol->value.integer.value;
484 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
485 AC_VERB_GET_GPIO_DATA,
488 /* Set/unset the masked GPIO bit(s) as needed */
489 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
494 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
498 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
499 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
500 .info = alc_gpio_data_info, \
501 .get = alc_gpio_data_get, \
502 .put = alc_gpio_data_put, \
503 .private_value = nid | (mask<<16) }
504 #endif /* CONFIG_SND_DEBUG */
506 /* A switch control to allow the enabling of the digital IO pins on the
507 * ALC260. This is incredibly simplistic; the intention of this control is
508 * to provide something in the test model allowing digital outputs to be
509 * identified if present. If models are found which can utilise these
510 * outputs a more complete mixer control can be devised for those models if
513 #ifdef CONFIG_SND_DEBUG
514 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
517 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
519 uinfo->value.integer.min = 0;
520 uinfo->value.integer.max = 1;
523 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 hda_nid_t nid = kcontrol->private_value & 0xffff;
528 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
529 long *valp = ucontrol->value.integer.value;
530 unsigned int val = snd_hda_codec_read(codec, nid, 0,
531 AC_VERB_GET_DIGI_CONVERT, 0x00);
533 *valp = (val & mask) != 0;
536 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 hda_nid_t nid = kcontrol->private_value & 0xffff;
542 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
543 long val = *ucontrol->value.integer.value;
544 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
545 AC_VERB_GET_DIGI_CONVERT,
548 /* Set/unset the masked control bit(s) as needed */
549 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
554 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
559 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
560 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
561 .info = alc_spdif_ctrl_info, \
562 .get = alc_spdif_ctrl_get, \
563 .put = alc_spdif_ctrl_put, \
564 .private_value = nid | (mask<<16) }
565 #endif /* CONFIG_SND_DEBUG */
568 * set up from the preset table
570 static void setup_preset(struct alc_spec *spec,
571 const struct alc_config_preset *preset)
575 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
576 spec->mixers[spec->num_mixers++] = preset->mixers[i];
577 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
579 spec->init_verbs[spec->num_init_verbs++] =
580 preset->init_verbs[i];
582 spec->channel_mode = preset->channel_mode;
583 spec->num_channel_mode = preset->num_channel_mode;
584 spec->need_dac_fix = preset->need_dac_fix;
586 spec->multiout.max_channels = spec->channel_mode[0].channels;
588 spec->multiout.num_dacs = preset->num_dacs;
589 spec->multiout.dac_nids = preset->dac_nids;
590 spec->multiout.dig_out_nid = preset->dig_out_nid;
591 spec->multiout.hp_nid = preset->hp_nid;
593 spec->num_mux_defs = preset->num_mux_defs;
594 if (! spec->num_mux_defs)
595 spec->num_mux_defs = 1;
596 spec->input_mux = preset->input_mux;
598 spec->num_adc_nids = preset->num_adc_nids;
599 spec->adc_nids = preset->adc_nids;
600 spec->dig_in_nid = preset->dig_in_nid;
602 spec->unsol_event = preset->unsol_event;
603 spec->init_hook = preset->init_hook;
607 * ALC880 3-stack model
609 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
610 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
611 * F-Mic = 0x1b, HP = 0x19
614 static hda_nid_t alc880_dac_nids[4] = {
615 /* front, rear, clfe, rear_surr */
616 0x02, 0x05, 0x04, 0x03
619 static hda_nid_t alc880_adc_nids[3] = {
624 /* The datasheet says the node 0x07 is connected from inputs,
625 * but it shows zero connection in the real implementation on some devices.
626 * Note: this is a 915GAV bug, fixed on 915GLV
628 static hda_nid_t alc880_adc_nids_alt[2] = {
633 #define ALC880_DIGOUT_NID 0x06
634 #define ALC880_DIGIN_NID 0x0a
636 static struct hda_input_mux alc880_capture_source = {
640 { "Front Mic", 0x3 },
646 /* channel source setting (2/6 channel selection for 3-stack) */
648 static struct hda_verb alc880_threestack_ch2_init[] = {
649 /* set line-in to input, mute it */
650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
652 /* set mic-in to input vref 80%, mute it */
653 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
654 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
659 static struct hda_verb alc880_threestack_ch6_init[] = {
660 /* set line-in to output, unmute it */
661 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
662 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
663 /* set mic-in to output, unmute it */
664 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
665 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
669 static struct hda_channel_mode alc880_threestack_modes[2] = {
670 { 2, alc880_threestack_ch2_init },
671 { 6, alc880_threestack_ch6_init },
674 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
675 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
676 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
677 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
678 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
679 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
680 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
681 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
682 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
683 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
684 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
686 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
688 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
689 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
690 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
691 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
692 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
695 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
696 .name = "Channel Mode",
697 .info = alc_ch_mode_info,
698 .get = alc_ch_mode_get,
699 .put = alc_ch_mode_put,
704 /* capture mixer elements */
705 static struct snd_kcontrol_new alc880_capture_mixer[] = {
706 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
707 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
708 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
709 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
710 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
711 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
713 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
714 /* The multiple "Capture Source" controls confuse alsamixer
715 * So call somewhat different..
716 * FIXME: the controls appear in the "playback" view!
718 /* .name = "Capture Source", */
719 .name = "Input Source",
721 .info = alc_mux_enum_info,
722 .get = alc_mux_enum_get,
723 .put = alc_mux_enum_put,
728 /* capture mixer elements (in case NID 0x07 not available) */
729 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
730 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
731 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
732 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
733 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
735 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
736 /* The multiple "Capture Source" controls confuse alsamixer
737 * So call somewhat different..
738 * FIXME: the controls appear in the "playback" view!
740 /* .name = "Capture Source", */
741 .name = "Input Source",
743 .info = alc_mux_enum_info,
744 .get = alc_mux_enum_get,
745 .put = alc_mux_enum_put,
753 * ALC880 5-stack model
755 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
757 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
758 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
761 /* additional mixers to alc880_three_stack_mixer */
762 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
763 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
764 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
768 /* channel source setting (6/8 channel selection for 5-stack) */
770 static struct hda_verb alc880_fivestack_ch6_init[] = {
771 /* set line-in to input, mute it */
772 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
773 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
778 static struct hda_verb alc880_fivestack_ch8_init[] = {
779 /* set line-in to output, unmute it */
780 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
781 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
785 static struct hda_channel_mode alc880_fivestack_modes[2] = {
786 { 6, alc880_fivestack_ch6_init },
787 { 8, alc880_fivestack_ch8_init },
792 * ALC880 6-stack model
794 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
796 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
797 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
800 static hda_nid_t alc880_6st_dac_nids[4] = {
801 /* front, rear, clfe, rear_surr */
802 0x02, 0x03, 0x04, 0x05
805 static struct hda_input_mux alc880_6stack_capture_source = {
809 { "Front Mic", 0x1 },
815 /* fixed 8-channels */
816 static struct hda_channel_mode alc880_sixstack_modes[1] = {
820 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
821 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
822 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
823 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
824 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
825 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
826 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
827 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
828 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
829 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
830 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
838 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
839 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
840 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
843 .name = "Channel Mode",
844 .info = alc_ch_mode_info,
845 .get = alc_ch_mode_get,
846 .put = alc_ch_mode_put,
855 * W810 has rear IO for:
858 * Center/LFE (DAC 04)
861 * The system also has a pair of internal speakers, and a headphone jack.
862 * These are both connected to Line2 on the codec, hence to DAC 02.
864 * There is a variable resistor to control the speaker or headphone
865 * volume. This is a hardware-only device without a software API.
867 * Plugging headphones in will disable the internal speakers. This is
868 * implemented in hardware, not via the driver using jack sense. In
869 * a similar fashion, plugging into the rear socket marked "front" will
870 * disable both the speakers and headphones.
872 * For input, there's a microphone jack, and an "audio in" jack.
873 * These may not do anything useful with this driver yet, because I
874 * haven't setup any initialization verbs for these yet...
877 static hda_nid_t alc880_w810_dac_nids[3] = {
878 /* front, rear/surround, clfe */
882 /* fixed 6 channels */
883 static struct hda_channel_mode alc880_w810_modes[1] = {
887 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
888 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
889 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
890 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
891 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
892 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
893 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
894 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
895 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
896 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
905 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
906 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
910 static hda_nid_t alc880_z71v_dac_nids[1] = {
913 #define ALC880_Z71V_HP_DAC 0x03
915 /* fixed 2 channels */
916 static struct hda_channel_mode alc880_2_jack_modes[1] = {
920 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
921 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
922 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
923 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
924 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
925 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
926 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
937 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
938 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
941 static hda_nid_t alc880_f1734_dac_nids[1] = {
944 #define ALC880_F1734_HP_DAC 0x02
946 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
947 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
948 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
949 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
950 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
963 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
964 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
965 * Mic = 0x18, Line = 0x1a
968 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
969 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
971 static struct snd_kcontrol_new alc880_asus_mixer[] = {
972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
988 .name = "Channel Mode",
989 .info = alc_ch_mode_info,
990 .get = alc_ch_mode_get,
991 .put = alc_ch_mode_put,
998 * ALC880 ASUS W1V model
1000 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1001 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1002 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1005 /* additional mixers to alc880_asus_mixer */
1006 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1007 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1008 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1012 /* additional mixers to alc880_asus_mixer */
1013 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1014 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1015 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1020 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1021 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1024 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1025 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1026 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1027 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1032 /* The multiple "Capture Source" controls confuse alsamixer
1033 * So call somewhat different..
1034 * FIXME: the controls appear in the "playback" view!
1036 /* .name = "Capture Source", */
1037 .name = "Input Source",
1039 .info = alc_mux_enum_info,
1040 .get = alc_mux_enum_get,
1041 .put = alc_mux_enum_put,
1047 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1048 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1049 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1050 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1051 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1052 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1054 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1055 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1062 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1063 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1064 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1065 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1068 .name = "Channel Mode",
1069 .info = alc_ch_mode_info,
1070 .get = alc_ch_mode_get,
1071 .put = alc_ch_mode_put,
1076 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1077 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1078 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1079 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1080 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1087 * build control elements
1089 static int alc_build_controls(struct hda_codec *codec)
1091 struct alc_spec *spec = codec->spec;
1095 for (i = 0; i < spec->num_mixers; i++) {
1096 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1101 if (spec->multiout.dig_out_nid) {
1102 err = snd_hda_create_spdif_out_ctls(codec,
1103 spec->multiout.dig_out_nid);
1107 if (spec->dig_in_nid) {
1108 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1117 * initialize the codec volumes, etc
1121 * generic initialization of ADC, input mixers and output mixers
1123 static struct hda_verb alc880_volume_init_verbs[] = {
1125 * Unmute ADC0-2 and set the default input to mic-in
1127 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1129 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1130 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1131 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1134 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1136 * Note: PASD motherboards uses the Line In 2 as the input for front
1139 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1147 * Set up output mixers (0x0c - 0x0f)
1149 /* set vol=0 to output mixers */
1150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1151 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1152 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1153 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1154 /* set up input amps for analog loopback */
1155 /* Amp Indices: DAC = 0, mixer = 1 */
1156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1158 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1159 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1160 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1161 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1169 * 3-stack pin configuration:
1170 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1172 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1174 * preset connection lists of input pins
1175 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1177 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1178 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1179 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1182 * Set pin mode and muting
1184 /* set front pin widgets 0x14 for output */
1185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1187 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1188 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1189 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1190 /* Mic2 (as headphone out) for HP output */
1191 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1193 /* Line In pin widget for input */
1194 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1195 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1196 /* Line2 (as front mic) pin widget for input and vref at 80% */
1197 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1198 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1199 /* CD pin widget for input */
1200 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1206 * 5-stack pin configuration:
1207 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1208 * line-in/side = 0x1a, f-mic = 0x1b
1210 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1212 * preset connection lists of input pins
1213 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1215 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1216 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1219 * Set pin mode and muting
1221 /* set pin widgets 0x14-0x17 for output */
1222 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1225 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1226 /* unmute pins for output (no gain on this amp) */
1227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1228 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1229 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1230 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1232 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1233 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1234 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1235 /* Mic2 (as headphone out) for HP output */
1236 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1237 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1238 /* Line In pin widget for input */
1239 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1240 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1241 /* Line2 (as front mic) pin widget for input and vref at 80% */
1242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1244 /* CD pin widget for input */
1245 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1251 * W810 pin configuration:
1252 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1254 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1255 /* hphone/speaker input selector: front DAC */
1256 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1258 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1259 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1262 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1263 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1266 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1272 * Z71V pin configuration:
1273 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1275 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1277 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1282 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1284 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1290 * 6-stack pin configuration:
1291 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1292 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1294 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1295 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1298 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1301 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1303 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1307 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1308 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1310 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1311 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1312 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1313 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1314 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1320 * Uniwill pin configuration:
1321 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1324 static struct hda_verb alc880_uniwill_init_verbs[] = {
1325 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1329 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1331 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1332 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1333 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1334 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1337 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1340 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1342 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1343 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1344 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1345 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1346 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1347 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1348 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1349 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1350 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1352 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1353 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1360 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1362 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1363 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1366 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1370 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1380 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1381 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1382 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1383 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1385 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1386 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1391 /* toggle speaker-output according to the hp-jack state */
1392 static void alc880_uniwill_automute(struct hda_codec *codec)
1394 unsigned int present;
1396 present = snd_hda_codec_read(codec, 0x14, 0,
1397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1398 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1399 0x80, present ? 0x80 : 0);
1400 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1401 0x80, present ? 0x80 : 0);
1402 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1403 0x80, present ? 0x80 : 0);
1404 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1405 0x80, present ? 0x80 : 0);
1407 present = snd_hda_codec_read(codec, 0x18, 0,
1408 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1409 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1410 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
1413 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1416 /* Looks like the unsol event is incompatible with the standard
1417 * definition. 4bit tag is placed at 28 bit!
1419 if ((res >> 28) == ALC880_HP_EVENT ||
1420 (res >> 28) == ALC880_MIC_EVENT)
1421 alc880_uniwill_automute(codec);
1424 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1426 unsigned int present;
1428 present = snd_hda_codec_read(codec, 0x14, 0,
1429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1431 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1432 0x80, present ? 0x80 : 0);
1433 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1434 0x80, present ? 0x80 : 0);
1437 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1439 unsigned int present;
1441 present = snd_hda_codec_read(codec, 0x21, 0,
1442 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1444 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1446 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1449 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1451 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1455 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1458 /* Looks like the unsol event is incompatible with the standard
1459 * definition. 4bit tag is placed at 28 bit!
1461 if ((res >> 28) == ALC880_HP_EVENT)
1462 alc880_uniwill_p53_hp_automute(codec);
1463 if ((res >> 28) == ALC880_DCVOL_EVENT)
1464 alc880_uniwill_p53_dcvol_automute(codec);
1469 * F1734 pin configuration:
1470 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1472 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1473 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1474 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1475 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1476 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1483 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1484 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1487 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1498 * ASUS pin configuration:
1499 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1501 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1502 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1503 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1504 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1505 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1511 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1513 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1514 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1516 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1517 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1520 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1521 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1522 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1524 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1529 /* Enable GPIO mask and set output */
1530 static struct hda_verb alc880_gpio1_init_verbs[] = {
1531 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1532 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1533 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1538 /* Enable GPIO mask and set output */
1539 static struct hda_verb alc880_gpio2_init_verbs[] = {
1540 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1541 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1542 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1547 /* Clevo m520g init */
1548 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1549 /* headphone output */
1550 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1553 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1558 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1559 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1560 /* Mic1 (rear panel) */
1561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1563 /* Mic2 (front panel) */
1564 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1565 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1569 /* change to EAPD mode */
1570 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1571 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1576 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1577 /* change to EAPD mode */
1578 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1579 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1581 /* Headphone output */
1582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1584 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1585 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1587 /* Line In pin widget for input */
1588 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1589 /* CD pin widget for input */
1590 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1591 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1592 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1594 /* change to EAPD mode */
1595 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1596 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1602 * LG m1 express dual
1605 * Rear Line-In/Out (blue): 0x14
1606 * Build-in Mic-In: 0x15
1608 * HP-Out (green): 0x1b
1609 * Mic-In/Out (red): 0x19
1613 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1614 static hda_nid_t alc880_lg_dac_nids[3] = {
1618 /* seems analog CD is not working */
1619 static struct hda_input_mux alc880_lg_capture_source = {
1624 { "Internal Mic", 0x6 },
1628 /* 2,4,6 channel modes */
1629 static struct hda_verb alc880_lg_ch2_init[] = {
1630 /* set line-in and mic-in to input */
1631 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1632 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1636 static struct hda_verb alc880_lg_ch4_init[] = {
1637 /* set line-in to out and mic-in to input */
1638 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1639 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1643 static struct hda_verb alc880_lg_ch6_init[] = {
1644 /* set line-in and mic-in to output */
1645 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1646 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1650 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1651 { 2, alc880_lg_ch2_init },
1652 { 4, alc880_lg_ch4_init },
1653 { 6, alc880_lg_ch6_init },
1656 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1657 /* FIXME: it's not really "master" but front channels */
1658 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1659 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1660 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1661 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1662 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1663 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1664 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1665 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1670 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1671 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1674 .name = "Channel Mode",
1675 .info = alc_ch_mode_info,
1676 .get = alc_ch_mode_get,
1677 .put = alc_ch_mode_put,
1682 static struct hda_verb alc880_lg_init_verbs[] = {
1683 /* set capture source to mic-in */
1684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1685 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1687 /* mute all amp mixer inputs */
1688 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1689 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1690 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1691 /* line-in to input */
1692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1698 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1699 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1700 /* mic-in to input */
1701 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1702 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1703 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1706 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1707 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1713 /* toggle speaker-output according to the hp-jack state */
1714 static void alc880_lg_automute(struct hda_codec *codec)
1716 unsigned int present;
1718 present = snd_hda_codec_read(codec, 0x1b, 0,
1719 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1720 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1721 0x80, present ? 0x80 : 0);
1722 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1723 0x80, present ? 0x80 : 0);
1726 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1728 /* Looks like the unsol event is incompatible with the standard
1729 * definition. 4bit tag is placed at 28 bit!
1731 if ((res >> 28) == 0x01)
1732 alc880_lg_automute(codec);
1741 * Built-in Mic-In: 0x19 (?)
1746 /* seems analog CD is not working */
1747 static struct hda_input_mux alc880_lg_lw_capture_source = {
1751 { "Internal Mic", 0x1 },
1755 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1756 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1757 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1759 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1761 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1765 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1766 /* set capture source to mic-in */
1767 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1768 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1769 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1770 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1775 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1776 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1777 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1778 /* mic-in to input */
1779 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1785 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1789 /* toggle speaker-output according to the hp-jack state */
1790 static void alc880_lg_lw_automute(struct hda_codec *codec)
1792 unsigned int present;
1794 present = snd_hda_codec_read(codec, 0x1b, 0,
1795 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1796 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1797 0x80, present ? 0x80 : 0);
1798 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1799 0x80, present ? 0x80 : 0);
1802 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1804 /* Looks like the unsol event is incompatible with the standard
1805 * definition. 4bit tag is placed at 28 bit!
1807 if ((res >> 28) == 0x01)
1808 alc880_lg_lw_automute(codec);
1815 static int alc_init(struct hda_codec *codec)
1817 struct alc_spec *spec = codec->spec;
1820 for (i = 0; i < spec->num_init_verbs; i++)
1821 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1823 if (spec->init_hook)
1824 spec->init_hook(codec);
1829 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1831 struct alc_spec *spec = codec->spec;
1833 if (spec->unsol_event)
1834 spec->unsol_event(codec, res);
1841 static int alc_resume(struct hda_codec *codec)
1843 struct alc_spec *spec = codec->spec;
1847 for (i = 0; i < spec->num_mixers; i++)
1848 snd_hda_resume_ctls(codec, spec->mixers[i]);
1849 if (spec->multiout.dig_out_nid)
1850 snd_hda_resume_spdif_out(codec);
1851 if (spec->dig_in_nid)
1852 snd_hda_resume_spdif_in(codec);
1859 * Analog playback callbacks
1861 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1862 struct hda_codec *codec,
1863 struct snd_pcm_substream *substream)
1865 struct alc_spec *spec = codec->spec;
1866 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1869 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1870 struct hda_codec *codec,
1871 unsigned int stream_tag,
1872 unsigned int format,
1873 struct snd_pcm_substream *substream)
1875 struct alc_spec *spec = codec->spec;
1876 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1877 stream_tag, format, substream);
1880 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1881 struct hda_codec *codec,
1882 struct snd_pcm_substream *substream)
1884 struct alc_spec *spec = codec->spec;
1885 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1891 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1892 struct hda_codec *codec,
1893 struct snd_pcm_substream *substream)
1895 struct alc_spec *spec = codec->spec;
1896 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1899 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1900 struct hda_codec *codec,
1901 struct snd_pcm_substream *substream)
1903 struct alc_spec *spec = codec->spec;
1904 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1910 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1911 struct hda_codec *codec,
1912 unsigned int stream_tag,
1913 unsigned int format,
1914 struct snd_pcm_substream *substream)
1916 struct alc_spec *spec = codec->spec;
1918 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1919 stream_tag, 0, format);
1923 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1924 struct hda_codec *codec,
1925 struct snd_pcm_substream *substream)
1927 struct alc_spec *spec = codec->spec;
1929 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1937 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1941 /* NID is set in alc_build_pcms */
1943 .open = alc880_playback_pcm_open,
1944 .prepare = alc880_playback_pcm_prepare,
1945 .cleanup = alc880_playback_pcm_cleanup
1949 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1953 /* NID is set in alc_build_pcms */
1955 .prepare = alc880_capture_pcm_prepare,
1956 .cleanup = alc880_capture_pcm_cleanup
1960 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1964 /* NID is set in alc_build_pcms */
1966 .open = alc880_dig_playback_pcm_open,
1967 .close = alc880_dig_playback_pcm_close
1971 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1975 /* NID is set in alc_build_pcms */
1978 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1979 static struct hda_pcm_stream alc_pcm_null_playback = {
1985 static int alc_build_pcms(struct hda_codec *codec)
1987 struct alc_spec *spec = codec->spec;
1988 struct hda_pcm *info = spec->pcm_rec;
1991 codec->num_pcms = 1;
1992 codec->pcm_info = info;
1994 info->name = spec->stream_name_analog;
1995 if (spec->stream_analog_playback) {
1996 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1997 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1998 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2000 if (spec->stream_analog_capture) {
2001 snd_assert(spec->adc_nids, return -EINVAL);
2002 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2003 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2006 if (spec->channel_mode) {
2007 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2008 for (i = 0; i < spec->num_channel_mode; i++) {
2009 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2010 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2015 /* SPDIF for stream index #1 */
2016 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2017 codec->num_pcms = 2;
2018 info = spec->pcm_rec + 1;
2019 info->name = spec->stream_name_digital;
2020 if (spec->multiout.dig_out_nid &&
2021 spec->stream_digital_playback) {
2022 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2023 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2025 if (spec->dig_in_nid &&
2026 spec->stream_digital_capture) {
2027 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2028 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2032 /* If the use of more than one ADC is requested for the current
2033 * model, configure a second analog capture-only PCM.
2035 /* Additional Analaog capture for index #2 */
2036 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2038 codec->num_pcms = 3;
2039 info = spec->pcm_rec + 2;
2040 info->name = spec->stream_name_analog;
2041 /* No playback stream for second PCM */
2042 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2043 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2044 if (spec->stream_analog_capture) {
2045 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2046 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2053 static void alc_free(struct hda_codec *codec)
2055 struct alc_spec *spec = codec->spec;
2061 if (spec->kctl_alloc) {
2062 for (i = 0; i < spec->num_kctl_used; i++)
2063 kfree(spec->kctl_alloc[i].name);
2064 kfree(spec->kctl_alloc);
2071 static struct hda_codec_ops alc_patch_ops = {
2072 .build_controls = alc_build_controls,
2073 .build_pcms = alc_build_pcms,
2076 .unsol_event = alc_unsol_event,
2078 .resume = alc_resume,
2084 * Test configuration for debugging
2086 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2089 #ifdef CONFIG_SND_DEBUG
2090 static hda_nid_t alc880_test_dac_nids[4] = {
2091 0x02, 0x03, 0x04, 0x05
2094 static struct hda_input_mux alc880_test_capture_source = {
2103 { "Surround", 0x6 },
2107 static struct hda_channel_mode alc880_test_modes[4] = {
2114 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2115 struct snd_ctl_elem_info *uinfo)
2117 static char *texts[] = {
2118 "N/A", "Line Out", "HP Out",
2119 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2121 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2123 uinfo->value.enumerated.items = 8;
2124 if (uinfo->value.enumerated.item >= 8)
2125 uinfo->value.enumerated.item = 7;
2126 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2130 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2131 struct snd_ctl_elem_value *ucontrol)
2133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2134 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2135 unsigned int pin_ctl, item = 0;
2137 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2138 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2139 if (pin_ctl & AC_PINCTL_OUT_EN) {
2140 if (pin_ctl & AC_PINCTL_HP_EN)
2144 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2145 switch (pin_ctl & AC_PINCTL_VREFEN) {
2146 case AC_PINCTL_VREF_HIZ: item = 3; break;
2147 case AC_PINCTL_VREF_50: item = 4; break;
2148 case AC_PINCTL_VREF_GRD: item = 5; break;
2149 case AC_PINCTL_VREF_80: item = 6; break;
2150 case AC_PINCTL_VREF_100: item = 7; break;
2153 ucontrol->value.enumerated.item[0] = item;
2157 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2158 struct snd_ctl_elem_value *ucontrol)
2160 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2161 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2162 static unsigned int ctls[] = {
2163 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2164 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2165 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2166 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2167 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2168 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2170 unsigned int old_ctl, new_ctl;
2172 old_ctl = snd_hda_codec_read(codec, nid, 0,
2173 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2174 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2175 if (old_ctl != new_ctl) {
2176 snd_hda_codec_write(codec, nid, 0,
2177 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
2178 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2179 (ucontrol->value.enumerated.item[0] >= 3 ?
2186 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2187 struct snd_ctl_elem_info *uinfo)
2189 static char *texts[] = {
2190 "Front", "Surround", "CLFE", "Side"
2192 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2194 uinfo->value.enumerated.items = 4;
2195 if (uinfo->value.enumerated.item >= 4)
2196 uinfo->value.enumerated.item = 3;
2197 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2201 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2202 struct snd_ctl_elem_value *ucontrol)
2204 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2205 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2208 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2209 ucontrol->value.enumerated.item[0] = sel & 3;
2213 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2214 struct snd_ctl_elem_value *ucontrol)
2216 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2217 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2220 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2221 if (ucontrol->value.enumerated.item[0] != sel) {
2222 sel = ucontrol->value.enumerated.item[0] & 3;
2223 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2229 #define PIN_CTL_TEST(xname,nid) { \
2230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2232 .info = alc_test_pin_ctl_info, \
2233 .get = alc_test_pin_ctl_get, \
2234 .put = alc_test_pin_ctl_put, \
2235 .private_value = nid \
2238 #define PIN_SRC_TEST(xname,nid) { \
2239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2241 .info = alc_test_pin_src_info, \
2242 .get = alc_test_pin_src_get, \
2243 .put = alc_test_pin_src_put, \
2244 .private_value = nid \
2247 static struct snd_kcontrol_new alc880_test_mixer[] = {
2248 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2249 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2250 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2251 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2253 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2254 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2255 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2256 PIN_CTL_TEST("Front Pin Mode", 0x14),
2257 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2258 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2259 PIN_CTL_TEST("Side Pin Mode", 0x17),
2260 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2261 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2262 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2263 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2264 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2265 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2266 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2267 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2268 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2269 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2270 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2271 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2272 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2273 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2274 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2275 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2280 .name = "Channel Mode",
2281 .info = alc_ch_mode_info,
2282 .get = alc_ch_mode_get,
2283 .put = alc_ch_mode_put,
2288 static struct hda_verb alc880_test_init_verbs[] = {
2289 /* Unmute inputs of 0x0c - 0x0f */
2290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2292 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2293 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2295 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2296 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2297 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2298 /* Vol output for 0x0c-0x0f */
2299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2303 /* Set output pins 0x14-0x17 */
2304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2305 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2306 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2307 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2308 /* Unmute output pins 0x14-0x17 */
2309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2313 /* Set input pins 0x18-0x1c */
2314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2316 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2318 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2319 /* Mute input pins 0x18-0x1b */
2320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2321 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2322 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2323 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2326 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2327 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2328 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2329 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2330 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2331 /* Analog input/passthru */
2332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2344 static const char *alc880_models[ALC880_MODEL_LAST] = {
2345 [ALC880_3ST] = "3stack",
2346 [ALC880_TCL_S700] = "tcl",
2347 [ALC880_3ST_DIG] = "3stack-digout",
2348 [ALC880_CLEVO] = "clevo",
2349 [ALC880_5ST] = "5stack",
2350 [ALC880_5ST_DIG] = "5stack-digout",
2351 [ALC880_W810] = "w810",
2352 [ALC880_Z71V] = "z71v",
2353 [ALC880_6ST] = "6stack",
2354 [ALC880_6ST_DIG] = "6stack-digout",
2355 [ALC880_ASUS] = "asus",
2356 [ALC880_ASUS_W1V] = "asus-w1v",
2357 [ALC880_ASUS_DIG] = "asus-dig",
2358 [ALC880_ASUS_DIG2] = "asus-dig2",
2359 [ALC880_UNIWILL_DIG] = "uniwill",
2360 [ALC880_F1734] = "F1734",
2362 [ALC880_LG_LW] = "lg-lw",
2363 #ifdef CONFIG_SND_DEBUG
2364 [ALC880_TEST] = "test",
2366 [ALC880_AUTO] = "auto",
2369 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2370 /* Broken BIOS configuration */
2371 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2372 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2374 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2375 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2376 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2377 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2378 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2379 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2380 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2381 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2382 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2384 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2385 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2387 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2388 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2389 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2390 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2391 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2392 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2393 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2394 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2395 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2396 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2397 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2398 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2399 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2400 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2401 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2403 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2404 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2405 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2406 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2407 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2408 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2409 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2410 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2411 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2412 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2413 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2414 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2415 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2416 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2417 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2418 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2419 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2420 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2422 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2423 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2424 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2425 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2427 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2428 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2429 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2431 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2432 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2433 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2434 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2436 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2437 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2438 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2439 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2440 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2441 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2442 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2443 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2444 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2445 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2446 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2452 * ALC880 codec presets
2454 static struct alc_config_preset alc880_presets[] = {
2456 .mixers = { alc880_three_stack_mixer },
2457 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2458 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2459 .dac_nids = alc880_dac_nids,
2460 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2461 .channel_mode = alc880_threestack_modes,
2463 .input_mux = &alc880_capture_source,
2465 [ALC880_3ST_DIG] = {
2466 .mixers = { alc880_three_stack_mixer },
2467 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2468 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2469 .dac_nids = alc880_dac_nids,
2470 .dig_out_nid = ALC880_DIGOUT_NID,
2471 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2472 .channel_mode = alc880_threestack_modes,
2474 .input_mux = &alc880_capture_source,
2476 [ALC880_TCL_S700] = {
2477 .mixers = { alc880_tcl_s700_mixer },
2478 .init_verbs = { alc880_volume_init_verbs,
2479 alc880_pin_tcl_S700_init_verbs,
2480 alc880_gpio2_init_verbs },
2481 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2482 .dac_nids = alc880_dac_nids,
2484 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2485 .channel_mode = alc880_2_jack_modes,
2486 .input_mux = &alc880_capture_source,
2489 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2490 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2491 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2492 .dac_nids = alc880_dac_nids,
2493 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2494 .channel_mode = alc880_fivestack_modes,
2495 .input_mux = &alc880_capture_source,
2497 [ALC880_5ST_DIG] = {
2498 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2499 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2500 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2501 .dac_nids = alc880_dac_nids,
2502 .dig_out_nid = ALC880_DIGOUT_NID,
2503 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2504 .channel_mode = alc880_fivestack_modes,
2505 .input_mux = &alc880_capture_source,
2508 .mixers = { alc880_six_stack_mixer },
2509 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2510 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2511 .dac_nids = alc880_6st_dac_nids,
2512 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2513 .channel_mode = alc880_sixstack_modes,
2514 .input_mux = &alc880_6stack_capture_source,
2516 [ALC880_6ST_DIG] = {
2517 .mixers = { alc880_six_stack_mixer },
2518 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2519 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2520 .dac_nids = alc880_6st_dac_nids,
2521 .dig_out_nid = ALC880_DIGOUT_NID,
2522 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2523 .channel_mode = alc880_sixstack_modes,
2524 .input_mux = &alc880_6stack_capture_source,
2527 .mixers = { alc880_w810_base_mixer },
2528 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2529 alc880_gpio2_init_verbs },
2530 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2531 .dac_nids = alc880_w810_dac_nids,
2532 .dig_out_nid = ALC880_DIGOUT_NID,
2533 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2534 .channel_mode = alc880_w810_modes,
2535 .input_mux = &alc880_capture_source,
2538 .mixers = { alc880_z71v_mixer },
2539 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2540 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2541 .dac_nids = alc880_z71v_dac_nids,
2542 .dig_out_nid = ALC880_DIGOUT_NID,
2544 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2545 .channel_mode = alc880_2_jack_modes,
2546 .input_mux = &alc880_capture_source,
2549 .mixers = { alc880_f1734_mixer },
2550 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2551 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2552 .dac_nids = alc880_f1734_dac_nids,
2554 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2555 .channel_mode = alc880_2_jack_modes,
2556 .input_mux = &alc880_capture_source,
2559 .mixers = { alc880_asus_mixer },
2560 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2561 alc880_gpio1_init_verbs },
2562 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2563 .dac_nids = alc880_asus_dac_nids,
2564 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2565 .channel_mode = alc880_asus_modes,
2567 .input_mux = &alc880_capture_source,
2569 [ALC880_ASUS_DIG] = {
2570 .mixers = { alc880_asus_mixer },
2571 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2572 alc880_gpio1_init_verbs },
2573 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2574 .dac_nids = alc880_asus_dac_nids,
2575 .dig_out_nid = ALC880_DIGOUT_NID,
2576 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2577 .channel_mode = alc880_asus_modes,
2579 .input_mux = &alc880_capture_source,
2581 [ALC880_ASUS_DIG2] = {
2582 .mixers = { alc880_asus_mixer },
2583 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2584 alc880_gpio2_init_verbs }, /* use GPIO2 */
2585 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2586 .dac_nids = alc880_asus_dac_nids,
2587 .dig_out_nid = ALC880_DIGOUT_NID,
2588 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2589 .channel_mode = alc880_asus_modes,
2591 .input_mux = &alc880_capture_source,
2593 [ALC880_ASUS_W1V] = {
2594 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2595 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2596 alc880_gpio1_init_verbs },
2597 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2598 .dac_nids = alc880_asus_dac_nids,
2599 .dig_out_nid = ALC880_DIGOUT_NID,
2600 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2601 .channel_mode = alc880_asus_modes,
2603 .input_mux = &alc880_capture_source,
2605 [ALC880_UNIWILL_DIG] = {
2606 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2607 .init_verbs = { alc880_volume_init_verbs,
2608 alc880_pin_asus_init_verbs },
2609 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2610 .dac_nids = alc880_asus_dac_nids,
2611 .dig_out_nid = ALC880_DIGOUT_NID,
2612 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2613 .channel_mode = alc880_asus_modes,
2615 .input_mux = &alc880_capture_source,
2617 [ALC880_UNIWILL] = {
2618 .mixers = { alc880_uniwill_mixer },
2619 .init_verbs = { alc880_volume_init_verbs,
2620 alc880_uniwill_init_verbs },
2621 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2622 .dac_nids = alc880_asus_dac_nids,
2623 .dig_out_nid = ALC880_DIGOUT_NID,
2624 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2625 .channel_mode = alc880_threestack_modes,
2627 .input_mux = &alc880_capture_source,
2628 .unsol_event = alc880_uniwill_unsol_event,
2629 .init_hook = alc880_uniwill_automute,
2631 [ALC880_UNIWILL_P53] = {
2632 .mixers = { alc880_uniwill_p53_mixer },
2633 .init_verbs = { alc880_volume_init_verbs,
2634 alc880_uniwill_p53_init_verbs },
2635 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2636 .dac_nids = alc880_asus_dac_nids,
2637 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2638 .channel_mode = alc880_w810_modes,
2639 .input_mux = &alc880_capture_source,
2640 .unsol_event = alc880_uniwill_p53_unsol_event,
2641 .init_hook = alc880_uniwill_p53_hp_automute,
2644 .mixers = { alc880_three_stack_mixer },
2645 .init_verbs = { alc880_volume_init_verbs,
2646 alc880_pin_clevo_init_verbs },
2647 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2648 .dac_nids = alc880_dac_nids,
2650 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2651 .channel_mode = alc880_threestack_modes,
2653 .input_mux = &alc880_capture_source,
2656 .mixers = { alc880_lg_mixer },
2657 .init_verbs = { alc880_volume_init_verbs,
2658 alc880_lg_init_verbs },
2659 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2660 .dac_nids = alc880_lg_dac_nids,
2661 .dig_out_nid = ALC880_DIGOUT_NID,
2662 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2663 .channel_mode = alc880_lg_ch_modes,
2665 .input_mux = &alc880_lg_capture_source,
2666 .unsol_event = alc880_lg_unsol_event,
2667 .init_hook = alc880_lg_automute,
2670 .mixers = { alc880_lg_lw_mixer },
2671 .init_verbs = { alc880_volume_init_verbs,
2672 alc880_lg_lw_init_verbs },
2674 .dac_nids = alc880_dac_nids,
2675 .dig_out_nid = ALC880_DIGOUT_NID,
2676 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2677 .channel_mode = alc880_2_jack_modes,
2678 .input_mux = &alc880_lg_lw_capture_source,
2679 .unsol_event = alc880_lg_lw_unsol_event,
2680 .init_hook = alc880_lg_lw_automute,
2682 #ifdef CONFIG_SND_DEBUG
2684 .mixers = { alc880_test_mixer },
2685 .init_verbs = { alc880_test_init_verbs },
2686 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2687 .dac_nids = alc880_test_dac_nids,
2688 .dig_out_nid = ALC880_DIGOUT_NID,
2689 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2690 .channel_mode = alc880_test_modes,
2691 .input_mux = &alc880_test_capture_source,
2697 * Automatic parse of I/O pins from the BIOS configuration
2700 #define NUM_CONTROL_ALLOC 32
2701 #define NUM_VERB_ALLOC 32
2705 ALC_CTL_WIDGET_MUTE,
2708 static struct snd_kcontrol_new alc880_control_templates[] = {
2709 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2710 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2711 HDA_BIND_MUTE(NULL, 0, 0, 0),
2714 /* add dynamic controls */
2715 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2717 struct snd_kcontrol_new *knew;
2719 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2720 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2722 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2725 if (spec->kctl_alloc) {
2726 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2727 kfree(spec->kctl_alloc);
2729 spec->kctl_alloc = knew;
2730 spec->num_kctl_alloc = num;
2733 knew = &spec->kctl_alloc[spec->num_kctl_used];
2734 *knew = alc880_control_templates[type];
2735 knew->name = kstrdup(name, GFP_KERNEL);
2738 knew->private_value = val;
2739 spec->num_kctl_used++;
2743 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2744 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2745 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2746 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2747 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2748 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2749 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2750 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2751 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2752 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2753 #define ALC880_PIN_CD_NID 0x1c
2755 /* fill in the dac_nids table from the parsed pin configuration */
2756 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2762 memset(assigned, 0, sizeof(assigned));
2763 spec->multiout.dac_nids = spec->private_dac_nids;
2765 /* check the pins hardwired to audio widget */
2766 for (i = 0; i < cfg->line_outs; i++) {
2767 nid = cfg->line_out_pins[i];
2768 if (alc880_is_fixed_pin(nid)) {
2769 int idx = alc880_fixed_pin_idx(nid);
2770 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2774 /* left pins can be connect to any audio widget */
2775 for (i = 0; i < cfg->line_outs; i++) {
2776 nid = cfg->line_out_pins[i];
2777 if (alc880_is_fixed_pin(nid))
2779 /* search for an empty channel */
2780 for (j = 0; j < cfg->line_outs; j++) {
2781 if (! assigned[j]) {
2782 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2788 spec->multiout.num_dacs = cfg->line_outs;
2792 /* add playback controls from the parsed DAC table */
2793 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2794 const struct auto_pin_cfg *cfg)
2797 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2801 for (i = 0; i < cfg->line_outs; i++) {
2802 if (! spec->multiout.dac_nids[i])
2804 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2807 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2808 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2810 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2811 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2813 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2814 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2816 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2817 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2820 sprintf(name, "%s Playback Volume", chname[i]);
2821 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2822 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2824 sprintf(name, "%s Playback Switch", chname[i]);
2825 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2826 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2833 /* add playback controls for speaker and HP outputs */
2834 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2844 if (alc880_is_fixed_pin(pin)) {
2845 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2846 /* specify the DAC as the extra output */
2847 if (! spec->multiout.hp_nid)
2848 spec->multiout.hp_nid = nid;
2850 spec->multiout.extra_out_nid[0] = nid;
2851 /* control HP volume/switch on the output mixer amp */
2852 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2853 sprintf(name, "%s Playback Volume", pfx);
2854 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2855 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2857 sprintf(name, "%s Playback Switch", pfx);
2858 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2859 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2861 } else if (alc880_is_multi_pin(pin)) {
2862 /* set manual connection */
2863 /* we have only a switch on HP-out PIN */
2864 sprintf(name, "%s Playback Switch", pfx);
2865 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2866 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2872 /* create input playback/capture controls for the given pin */
2873 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2874 int idx, hda_nid_t mix_nid)
2879 sprintf(name, "%s Playback Volume", ctlname);
2880 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2881 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2883 sprintf(name, "%s Playback Switch", ctlname);
2884 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2885 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2890 /* create playback/capture controls for input pins */
2891 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2892 const struct auto_pin_cfg *cfg)
2894 struct hda_input_mux *imux = &spec->private_imux;
2897 for (i = 0; i < AUTO_PIN_LAST; i++) {
2898 if (alc880_is_input_pin(cfg->input_pins[i])) {
2899 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2900 err = new_analog_input(spec, cfg->input_pins[i],
2901 auto_pin_cfg_labels[i],
2905 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2906 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2913 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2914 hda_nid_t nid, int pin_type,
2918 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2919 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2920 /* need the manual connection? */
2921 if (alc880_is_multi_pin(nid)) {
2922 struct alc_spec *spec = codec->spec;
2923 int idx = alc880_multi_pin_idx(nid);
2924 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2925 AC_VERB_SET_CONNECT_SEL,
2926 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2930 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2932 struct alc_spec *spec = codec->spec;
2935 for (i = 0; i < spec->autocfg.line_outs; i++) {
2936 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2937 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2941 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2943 struct alc_spec *spec = codec->spec;
2946 pin = spec->autocfg.speaker_pins[0];
2947 if (pin) /* connect to front */
2948 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2949 pin = spec->autocfg.hp_pins[0];
2950 if (pin) /* connect to front */
2951 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2954 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2956 struct alc_spec *spec = codec->spec;
2959 for (i = 0; i < AUTO_PIN_LAST; i++) {
2960 hda_nid_t nid = spec->autocfg.input_pins[i];
2961 if (alc880_is_input_pin(nid)) {
2962 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2963 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2964 if (nid != ALC880_PIN_CD_NID)
2965 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2971 /* parse the BIOS configuration and set up the alc_spec */
2972 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2973 static int alc880_parse_auto_config(struct hda_codec *codec)
2975 struct alc_spec *spec = codec->spec;
2977 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2979 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2980 alc880_ignore)) < 0)
2982 if (! spec->autocfg.line_outs)
2983 return 0; /* can't find valid BIOS pin config */
2985 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2986 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2987 (err = alc880_auto_create_extra_out(spec,
2988 spec->autocfg.speaker_pins[0],
2990 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
2991 "Headphone")) < 0 ||
2992 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2995 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2997 if (spec->autocfg.dig_out_pin)
2998 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2999 if (spec->autocfg.dig_in_pin)
3000 spec->dig_in_nid = ALC880_DIGIN_NID;
3002 if (spec->kctl_alloc)
3003 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3005 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3007 spec->num_mux_defs = 1;
3008 spec->input_mux = &spec->private_imux;
3013 /* additional initialization for auto-configuration model */
3014 static void alc880_auto_init(struct hda_codec *codec)
3016 alc880_auto_init_multi_out(codec);
3017 alc880_auto_init_extra_out(codec);
3018 alc880_auto_init_analog_input(codec);
3022 * OK, here we have finally the patch for ALC880
3025 static int patch_alc880(struct hda_codec *codec)
3027 struct alc_spec *spec;
3031 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3037 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3040 if (board_config < 0) {
3041 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3042 "trying auto-probe from BIOS...\n");
3043 board_config = ALC880_AUTO;
3046 if (board_config == ALC880_AUTO) {
3047 /* automatic parse from the BIOS config */
3048 err = alc880_parse_auto_config(codec);
3054 "hda_codec: Cannot set up configuration "
3055 "from BIOS. Using 3-stack mode...\n");
3056 board_config = ALC880_3ST;
3060 if (board_config != ALC880_AUTO)
3061 setup_preset(spec, &alc880_presets[board_config]);
3063 spec->stream_name_analog = "ALC880 Analog";
3064 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3065 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3067 spec->stream_name_digital = "ALC880 Digital";
3068 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3069 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3071 if (! spec->adc_nids && spec->input_mux) {
3072 /* check whether NID 0x07 is valid */
3073 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3074 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3075 if (wcap != AC_WID_AUD_IN) {
3076 spec->adc_nids = alc880_adc_nids_alt;
3077 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3078 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
3081 spec->adc_nids = alc880_adc_nids;
3082 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3083 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3088 codec->patch_ops = alc_patch_ops;
3089 if (board_config == ALC880_AUTO)
3090 spec->init_hook = alc880_auto_init;
3100 static hda_nid_t alc260_dac_nids[1] = {
3105 static hda_nid_t alc260_adc_nids[1] = {
3110 static hda_nid_t alc260_adc_nids_alt[1] = {
3115 static hda_nid_t alc260_hp_adc_nids[2] = {
3120 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3121 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3123 static hda_nid_t alc260_dual_adc_nids[2] = {
3128 #define ALC260_DIGOUT_NID 0x03
3129 #define ALC260_DIGIN_NID 0x06
3131 static struct hda_input_mux alc260_capture_source = {
3135 { "Front Mic", 0x1 },
3141 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3142 * headphone jack and the internal CD lines since these are the only pins at
3143 * which audio can appear. For flexibility, also allow the option of
3144 * recording the mixer output on the second ADC (ADC0 doesn't have a
3145 * connection to the mixer output).
3147 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3151 { "Mic/Line", 0x0 },
3153 { "Headphone", 0x2 },
3159 { "Mic/Line", 0x0 },
3161 { "Headphone", 0x2 },
3168 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3169 * the Fujitsu S702x, but jacks are marked differently.
3171 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3178 { "Headphone", 0x5 },
3187 { "Headphone", 0x6 },
3193 * This is just place-holder, so there's something for alc_build_pcms to look
3194 * at when it calculates the maximum number of channels. ALC260 has no mixer
3195 * element which allows changing the channel mode, so the verb list is
3198 static struct hda_channel_mode alc260_modes[1] = {
3203 /* Mixer combinations
3205 * basic: base_output + input + pc_beep + capture
3206 * HP: base_output + input + capture_alt
3207 * HP_3013: hp_3013 + input + capture
3208 * fujitsu: fujitsu + capture
3209 * acer: acer + capture
3212 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3213 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3214 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3215 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3216 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3217 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3218 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3222 static struct snd_kcontrol_new alc260_input_mixer[] = {
3223 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3224 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3225 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3226 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3227 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3228 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3229 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3230 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3234 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3235 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3236 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3240 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3241 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3242 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3243 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3244 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3245 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3246 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3247 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3248 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3252 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3253 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3255 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3256 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3257 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3258 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3259 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3260 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3261 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3262 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3263 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3264 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3265 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3266 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3267 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3271 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3272 * versions of the ALC260 don't act on requests to enable mic bias from NID
3273 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3274 * datasheet doesn't mention this restriction. At this stage it's not clear
3275 * whether this behaviour is intentional or is a hardware bug in chip
3276 * revisions available in early 2006. Therefore for now allow the
3277 * "Headphone Jack Mode" control to span all choices, but if it turns out
3278 * that the lack of mic bias for this NID is intentional we could change the
3279 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3281 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3282 * don't appear to make the mic bias available from the "line" jack, even
3283 * though the NID used for this jack (0x14) can supply it. The theory is
3284 * that perhaps Acer have included blocking capacitors between the ALC260
3285 * and the output jack. If this turns out to be the case for all such
3286 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3287 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3289 * The C20x Tablet series have a mono internal speaker which is controlled
3290 * via the chip's Mono sum widget and pin complex, so include the necessary
3291 * controls for such models. On models without a "mono speaker" the control
3292 * won't do anything.
3294 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3295 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3296 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3297 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3298 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3300 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3302 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3303 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3305 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3306 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3307 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3308 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3309 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3310 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3311 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3315 /* capture mixer elements */
3316 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3317 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3318 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3319 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3320 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3322 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3323 /* The multiple "Capture Source" controls confuse alsamixer
3324 * So call somewhat different..
3325 * FIXME: the controls appear in the "playback" view!
3327 /* .name = "Capture Source", */
3328 .name = "Input Source",
3330 .info = alc_mux_enum_info,
3331 .get = alc_mux_enum_get,
3332 .put = alc_mux_enum_put,
3337 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3338 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3339 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3342 /* The multiple "Capture Source" controls confuse alsamixer
3343 * So call somewhat different..
3344 * FIXME: the controls appear in the "playback" view!
3346 /* .name = "Capture Source", */
3347 .name = "Input Source",
3349 .info = alc_mux_enum_info,
3350 .get = alc_mux_enum_get,
3351 .put = alc_mux_enum_put,
3357 * initialization verbs
3359 static struct hda_verb alc260_init_verbs[] = {
3360 /* Line In pin widget for input */
3361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3362 /* CD pin widget for input */
3363 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3364 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3365 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3366 /* Mic2 (front panel) pin widget for input and vref at 80% */
3367 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3368 /* LINE-2 is used for line-out in rear */
3369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3370 /* select line-out */
3371 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3373 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3375 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3377 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3378 /* mute capture amp left and right */
3379 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3380 /* set connection select to line in (default select for this ADC) */
3381 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3382 /* mute capture amp left and right */
3383 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3384 /* set connection select to line in (default select for this ADC) */
3385 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3386 /* set vol=0 Line-Out mixer amp left and right */
3387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3388 /* unmute pin widget amp left and right (no gain on this amp) */
3389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3390 /* set vol=0 HP mixer amp left and right */
3391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3392 /* unmute pin widget amp left and right (no gain on this amp) */
3393 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3394 /* set vol=0 Mono mixer amp left and right */
3395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3396 /* unmute pin widget amp left and right (no gain on this amp) */
3397 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3398 /* unmute LINE-2 out pin */
3399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3400 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3407 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3408 /* mute Front out path */
3409 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3411 /* mute Headphone out path */
3412 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3413 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3414 /* mute Mono out path */
3415 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3416 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3420 #if 0 /* should be identical with alc260_init_verbs? */
3421 static struct hda_verb alc260_hp_init_verbs[] = {
3422 /* Headphone and output */
3423 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3425 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3426 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3427 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3428 /* Mic2 (front panel) pin widget for input and vref at 80% */
3429 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3430 /* Line In pin widget for input */
3431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3432 /* Line-2 pin widget for output */
3433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3434 /* CD pin widget for input */
3435 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3436 /* unmute amp left and right */
3437 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3438 /* set connection select to line in (default select for this ADC) */
3439 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3440 /* unmute Line-Out mixer amp left and right (volume = 0) */
3441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3442 /* mute pin widget amp left and right (no gain on this amp) */
3443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3444 /* unmute HP mixer amp left and right (volume = 0) */
3445 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3446 /* mute pin widget amp left and right (no gain on this amp) */
3447 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3448 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3451 /* unmute Line In */
3452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3455 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3456 /* Unmute Front out path */
3457 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3459 /* Unmute Headphone out path */
3460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3462 /* Unmute Mono out path */
3463 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3464 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3469 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3470 /* Line out and output */
3471 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3473 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3474 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3475 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3476 /* Mic2 (front panel) pin widget for input and vref at 80% */
3477 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3478 /* Line In pin widget for input */
3479 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3480 /* Headphone pin widget for output */
3481 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3482 /* CD pin widget for input */
3483 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3484 /* unmute amp left and right */
3485 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3486 /* set connection select to line in (default select for this ADC) */
3487 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3488 /* unmute Line-Out mixer amp left and right (volume = 0) */
3489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3490 /* mute pin widget amp left and right (no gain on this amp) */
3491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3492 /* unmute HP mixer amp left and right (volume = 0) */
3493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3494 /* mute pin widget amp left and right (no gain on this amp) */
3495 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3496 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3499 /* unmute Line In */
3500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3503 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3504 /* Unmute Front out path */
3505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3507 /* Unmute Headphone out path */
3508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3510 /* Unmute Mono out path */
3511 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3512 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3516 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3517 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3518 * audio = 0x16, internal speaker = 0x10.
3520 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3521 /* Disable all GPIOs */
3522 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3523 /* Internal speaker is connected to headphone pin */
3524 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3525 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3527 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3528 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3529 /* Ensure all other unused pins are disabled and muted. */
3530 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3531 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3532 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3533 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3534 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3535 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3536 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3537 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3539 /* Disable digital (SPDIF) pins */
3540 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3541 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3543 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3544 * when acting as an output.
3546 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3548 /* Start with output sum widgets muted and their output gains at min */
3549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3553 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3555 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3556 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3557 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3559 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3560 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3561 /* Unmute Line1 pin widget output buffer since it starts as an output.
3562 * If the pin mode is changed by the user the pin mode control will
3563 * take care of enabling the pin's input/output buffers as needed.
3564 * Therefore there's no need to enable the input buffer at this
3567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3568 /* Unmute input buffer of pin widget used for Line-in (no equiv
3571 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3573 /* Mute capture amp left and right */
3574 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3575 /* Set ADC connection select to match default mixer setting - line
3578 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3580 /* Do the same for the second ADC: mute capture input amp and
3581 * set ADC connection to line in (on mic1 pin)
3583 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3584 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3586 /* Mute all inputs to mixer widget (even unconnected ones) */
3587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3593 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3599 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3600 * similar laptops (adapted from Fujitsu init verbs).
3602 static struct hda_verb alc260_acer_init_verbs[] = {
3603 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3604 * the headphone jack. Turn this on and rely on the standard mute
3605 * methods whenever the user wants to turn these outputs off.
3607 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3608 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3609 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3610 /* Internal speaker/Headphone jack is connected to Line-out pin */
3611 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3612 /* Internal microphone/Mic jack is connected to Mic1 pin */
3613 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3614 /* Line In jack is connected to Line1 pin */
3615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3616 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3617 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3618 /* Ensure all other unused pins are disabled and muted. */
3619 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3620 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3621 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3622 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3625 /* Disable digital (SPDIF) pins */
3626 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3627 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3629 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3630 * bus when acting as outputs.
3632 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3633 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3635 /* Start with output sum widgets muted and their output gains at min */
3636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3637 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3638 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3640 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3641 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3642 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3643 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3644 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3646 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3648 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3649 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3650 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3651 * inputs. If the pin mode is changed by the user the pin mode control
3652 * will take care of enabling the pin's input/output buffers as needed.
3653 * Therefore there's no need to enable the input buffer at this
3656 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3659 /* Mute capture amp left and right */
3660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3661 /* Set ADC connection select to match default mixer setting - mic
3664 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3666 /* Do similar with the second ADC: mute capture input amp and
3667 * set ADC connection to mic to match ALSA's default state.
3669 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3670 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3672 /* Mute all inputs to mixer widget (even unconnected ones) */
3673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3685 /* Test configuration for debugging, modelled after the ALC880 test
3688 #ifdef CONFIG_SND_DEBUG
3689 static hda_nid_t alc260_test_dac_nids[1] = {
3692 static hda_nid_t alc260_test_adc_nids[2] = {
3695 /* For testing the ALC260, each input MUX needs its own definition since
3696 * the signal assignments are different. This assumes that the first ADC
3699 static struct hda_input_mux alc260_test_capture_sources[2] = {
3703 { "MIC1 pin", 0x0 },
3704 { "MIC2 pin", 0x1 },
3705 { "LINE1 pin", 0x2 },
3706 { "LINE2 pin", 0x3 },
3708 { "LINE-OUT pin", 0x5 },
3709 { "HP-OUT pin", 0x6 },
3715 { "MIC1 pin", 0x0 },
3716 { "MIC2 pin", 0x1 },
3717 { "LINE1 pin", 0x2 },
3718 { "LINE2 pin", 0x3 },
3721 { "LINE-OUT pin", 0x6 },
3722 { "HP-OUT pin", 0x7 },
3726 static struct snd_kcontrol_new alc260_test_mixer[] = {
3727 /* Output driver widgets */
3728 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3729 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3730 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3731 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3732 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3733 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3735 /* Modes for retasking pin widgets
3736 * Note: the ALC260 doesn't seem to act on requests to enable mic
3737 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3738 * mention this restriction. At this stage it's not clear whether
3739 * this behaviour is intentional or is a hardware bug in chip
3740 * revisions available at least up until early 2006. Therefore for
3741 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3742 * choices, but if it turns out that the lack of mic bias for these
3743 * NIDs is intentional we could change their modes from
3744 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3746 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3747 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3748 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3749 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3750 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3751 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3753 /* Loopback mixer controls */
3754 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3755 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3756 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3757 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3758 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3759 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3760 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3761 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3762 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3763 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3764 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3765 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3766 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3767 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3768 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3769 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3771 /* Controls for GPIO pins, assuming they are configured as outputs */
3772 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3773 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3774 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3775 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3777 /* Switches to allow the digital IO pins to be enabled. The datasheet
3778 * is ambigious as to which NID is which; testing on laptops which
3779 * make this output available should provide clarification.
3781 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3782 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3786 static struct hda_verb alc260_test_init_verbs[] = {
3787 /* Enable all GPIOs as outputs with an initial value of 0 */
3788 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3789 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3790 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3792 /* Enable retasking pins as output, initially without power amp */
3793 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3794 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3796 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3797 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3798 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3800 /* Disable digital (SPDIF) pins initially, but users can enable
3801 * them via a mixer switch. In the case of SPDIF-out, this initverb
3802 * payload also sets the generation to 0, output to be in "consumer"
3803 * PCM format, copyright asserted, no pre-emphasis and no validity
3806 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3807 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3809 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3810 * OUT1 sum bus when acting as an output.
3812 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3813 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3814 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3815 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3817 /* Start with output sum widgets muted and their output gains at min */
3818 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3819 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3820 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3821 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3822 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3823 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3824 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3825 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3826 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3828 /* Unmute retasking pin widget output buffers since the default
3829 * state appears to be output. As the pin mode is changed by the
3830 * user the pin mode control will take care of enabling the pin's
3831 * input/output buffers as needed.
3833 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3834 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3835 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3837 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3838 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3839 /* Also unmute the mono-out pin widget */
3840 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3842 /* Mute capture amp left and right */
3843 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3844 /* Set ADC connection select to match default mixer setting (mic1
3847 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3849 /* Do the same for the second ADC: mute capture input amp and
3850 * set ADC connection to mic1 pin
3852 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3853 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3855 /* Mute all inputs to mixer widget (even unconnected ones) */
3856 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3859 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3862 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3863 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3869 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3875 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3881 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3882 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3885 * for BIOS auto-configuration
3888 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3892 unsigned long vol_val, sw_val;
3896 if (nid >= 0x0f && nid < 0x11) {
3897 nid_vol = nid - 0x7;
3898 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3899 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3900 } else if (nid == 0x11) {
3901 nid_vol = nid - 0x7;
3902 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3903 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3904 } else if (nid >= 0x12 && nid <= 0x15) {
3906 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3907 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3911 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3912 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3914 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3915 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3920 /* add playback controls from the parsed DAC table */
3921 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3922 const struct auto_pin_cfg *cfg)
3927 spec->multiout.num_dacs = 1;
3928 spec->multiout.dac_nids = spec->private_dac_nids;
3929 spec->multiout.dac_nids[0] = 0x02;
3931 nid = cfg->line_out_pins[0];
3933 err = alc260_add_playback_controls(spec, nid, "Front");
3938 nid = cfg->speaker_pins[0];
3940 err = alc260_add_playback_controls(spec, nid, "Speaker");
3945 nid = cfg->hp_pins[0];
3947 err = alc260_add_playback_controls(spec, nid, "Headphone");
3954 /* create playback/capture controls for input pins */
3955 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3956 const struct auto_pin_cfg *cfg)
3958 struct hda_input_mux *imux = &spec->private_imux;
3961 for (i = 0; i < AUTO_PIN_LAST; i++) {
3962 if (cfg->input_pins[i] >= 0x12) {
3963 idx = cfg->input_pins[i] - 0x12;
3964 err = new_analog_input(spec, cfg->input_pins[i],
3965 auto_pin_cfg_labels[i], idx, 0x07);
3968 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3969 imux->items[imux->num_items].index = idx;
3972 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3973 idx = cfg->input_pins[i] - 0x09;
3974 err = new_analog_input(spec, cfg->input_pins[i],
3975 auto_pin_cfg_labels[i], idx, 0x07);
3978 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3979 imux->items[imux->num_items].index = idx;
3986 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3987 hda_nid_t nid, int pin_type,
3991 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3992 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3993 /* need the manual connection? */
3995 int idx = nid - 0x12;
3996 snd_hda_codec_write(codec, idx + 0x0b, 0,
3997 AC_VERB_SET_CONNECT_SEL, sel_idx);
4002 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4004 struct alc_spec *spec = codec->spec;
4007 nid = spec->autocfg.line_out_pins[0];
4009 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4011 nid = spec->autocfg.speaker_pins[0];
4013 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4015 nid = spec->autocfg.hp_pins[0];
4017 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4020 #define ALC260_PIN_CD_NID 0x16
4021 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4023 struct alc_spec *spec = codec->spec;
4026 for (i = 0; i < AUTO_PIN_LAST; i++) {
4027 hda_nid_t nid = spec->autocfg.input_pins[i];
4029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4030 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4031 if (nid != ALC260_PIN_CD_NID)
4032 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4039 * generic initialization of ADC, input mixers and output mixers
4041 static struct hda_verb alc260_volume_init_verbs[] = {
4043 * Unmute ADC0-1 and set the default input to mic-in
4045 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4046 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4047 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4048 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4050 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4052 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4055 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4063 * Set up output mixers (0x08 - 0x0a)
4065 /* set vol=0 to output mixers */
4066 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4068 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4069 /* set up input amps for analog loopback */
4070 /* Amp Indices: DAC = 0, mixer = 1 */
4071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4075 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4076 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4081 static int alc260_parse_auto_config(struct hda_codec *codec)
4083 struct alc_spec *spec = codec->spec;
4086 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4088 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4089 alc260_ignore)) < 0)
4091 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
4093 if (! spec->kctl_alloc)
4094 return 0; /* can't find valid BIOS pin config */
4095 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4098 spec->multiout.max_channels = 2;
4100 if (spec->autocfg.dig_out_pin)
4101 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4102 if (spec->kctl_alloc)
4103 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4105 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4107 spec->num_mux_defs = 1;
4108 spec->input_mux = &spec->private_imux;
4110 /* check whether NID 0x04 is valid */
4111 wcap = get_wcaps(codec, 0x04);
4112 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4113 if (wcap != AC_WID_AUD_IN) {
4114 spec->adc_nids = alc260_adc_nids_alt;
4115 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4116 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4118 spec->adc_nids = alc260_adc_nids;
4119 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4120 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4127 /* additional initialization for auto-configuration model */
4128 static void alc260_auto_init(struct hda_codec *codec)
4130 alc260_auto_init_multi_out(codec);
4131 alc260_auto_init_analog_input(codec);
4135 * ALC260 configurations
4137 static const char *alc260_models[ALC260_MODEL_LAST] = {
4138 [ALC260_BASIC] = "basic",
4140 [ALC260_HP_3013] = "hp-3013",
4141 [ALC260_FUJITSU_S702X] = "fujitsu",
4142 [ALC260_ACER] = "acer",
4143 #ifdef CONFIG_SND_DEBUG
4144 [ALC260_TEST] = "test",
4146 [ALC260_AUTO] = "auto",
4149 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4150 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4151 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4152 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4153 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4154 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4155 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4156 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4157 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4158 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4159 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4160 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4161 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4162 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4163 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4167 static struct alc_config_preset alc260_presets[] = {
4169 .mixers = { alc260_base_output_mixer,
4171 alc260_pc_beep_mixer,
4172 alc260_capture_mixer },
4173 .init_verbs = { alc260_init_verbs },
4174 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4175 .dac_nids = alc260_dac_nids,
4176 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4177 .adc_nids = alc260_adc_nids,
4178 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4179 .channel_mode = alc260_modes,
4180 .input_mux = &alc260_capture_source,
4183 .mixers = { alc260_base_output_mixer,
4185 alc260_capture_alt_mixer },
4186 .init_verbs = { alc260_init_verbs },
4187 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4188 .dac_nids = alc260_dac_nids,
4189 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4190 .adc_nids = alc260_hp_adc_nids,
4191 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4192 .channel_mode = alc260_modes,
4193 .input_mux = &alc260_capture_source,
4195 [ALC260_HP_3013] = {
4196 .mixers = { alc260_hp_3013_mixer,
4198 alc260_capture_alt_mixer },
4199 .init_verbs = { alc260_hp_3013_init_verbs },
4200 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4201 .dac_nids = alc260_dac_nids,
4202 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4203 .adc_nids = alc260_hp_adc_nids,
4204 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4205 .channel_mode = alc260_modes,
4206 .input_mux = &alc260_capture_source,
4208 [ALC260_FUJITSU_S702X] = {
4209 .mixers = { alc260_fujitsu_mixer,
4210 alc260_capture_mixer },
4211 .init_verbs = { alc260_fujitsu_init_verbs },
4212 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4213 .dac_nids = alc260_dac_nids,
4214 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4215 .adc_nids = alc260_dual_adc_nids,
4216 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4217 .channel_mode = alc260_modes,
4218 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4219 .input_mux = alc260_fujitsu_capture_sources,
4222 .mixers = { alc260_acer_mixer,
4223 alc260_capture_mixer },
4224 .init_verbs = { alc260_acer_init_verbs },
4225 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4226 .dac_nids = alc260_dac_nids,
4227 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4228 .adc_nids = alc260_dual_adc_nids,
4229 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4230 .channel_mode = alc260_modes,
4231 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4232 .input_mux = alc260_acer_capture_sources,
4234 #ifdef CONFIG_SND_DEBUG
4236 .mixers = { alc260_test_mixer,
4237 alc260_capture_mixer },
4238 .init_verbs = { alc260_test_init_verbs },
4239 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4240 .dac_nids = alc260_test_dac_nids,
4241 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4242 .adc_nids = alc260_test_adc_nids,
4243 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4244 .channel_mode = alc260_modes,
4245 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4246 .input_mux = alc260_test_capture_sources,
4251 static int patch_alc260(struct hda_codec *codec)
4253 struct alc_spec *spec;
4254 int err, board_config;
4256 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4262 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4265 if (board_config < 0) {
4266 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4267 "trying auto-probe from BIOS...\n");
4268 board_config = ALC260_AUTO;
4271 if (board_config == ALC260_AUTO) {
4272 /* automatic parse from the BIOS config */
4273 err = alc260_parse_auto_config(codec);
4279 "hda_codec: Cannot set up configuration "
4280 "from BIOS. Using base mode...\n");
4281 board_config = ALC260_BASIC;
4285 if (board_config != ALC260_AUTO)
4286 setup_preset(spec, &alc260_presets[board_config]);
4288 spec->stream_name_analog = "ALC260 Analog";
4289 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4290 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4292 spec->stream_name_digital = "ALC260 Digital";
4293 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4294 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4296 codec->patch_ops = alc_patch_ops;
4297 if (board_config == ALC260_AUTO)
4298 spec->init_hook = alc260_auto_init;
4307 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4308 * configuration. Each pin widget can choose any input DACs and a mixer.
4309 * Each ADC is connected from a mixer of all inputs. This makes possible
4310 * 6-channel independent captures.
4312 * In addition, an independent DAC for the multi-playback (not used in this
4315 #define ALC882_DIGOUT_NID 0x06
4316 #define ALC882_DIGIN_NID 0x0a
4318 static struct hda_channel_mode alc882_ch_modes[1] = {
4322 static hda_nid_t alc882_dac_nids[4] = {
4323 /* front, rear, clfe, rear_surr */
4324 0x02, 0x03, 0x04, 0x05
4327 /* identical with ALC880 */
4328 #define alc882_adc_nids alc880_adc_nids
4329 #define alc882_adc_nids_alt alc880_adc_nids_alt
4332 /* FIXME: should be a matrix-type input source selection */
4334 static struct hda_input_mux alc882_capture_source = {
4338 { "Front Mic", 0x1 },
4343 #define alc882_mux_enum_info alc_mux_enum_info
4344 #define alc882_mux_enum_get alc_mux_enum_get
4346 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4348 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4349 struct alc_spec *spec = codec->spec;
4350 const struct hda_input_mux *imux = spec->input_mux;
4351 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4352 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4353 hda_nid_t nid = capture_mixers[adc_idx];
4354 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4355 unsigned int i, idx;
4357 idx = ucontrol->value.enumerated.item[0];
4358 if (idx >= imux->num_items)
4359 idx = imux->num_items - 1;
4360 if (*cur_val == idx && ! codec->in_resume)
4362 for (i = 0; i < imux->num_items; i++) {
4363 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4364 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4365 v | (imux->items[i].index << 8));
4374 static struct hda_verb alc882_sixstack_ch6_init[] = {
4375 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4376 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4377 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4378 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4385 static struct hda_verb alc882_sixstack_ch8_init[] = {
4386 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4387 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4388 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4389 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4393 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4394 { 6, alc882_sixstack_ch6_init },
4395 { 8, alc882_sixstack_ch8_init },
4398 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4399 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4401 static struct snd_kcontrol_new alc882_base_mixer[] = {
4402 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4403 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4404 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4405 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4406 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4407 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4408 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4409 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4410 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4411 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4412 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4413 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4414 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4415 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4416 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4417 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4418 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4420 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4421 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4422 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4423 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4424 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4428 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4431 .name = "Channel Mode",
4432 .info = alc_ch_mode_info,
4433 .get = alc_ch_mode_get,
4434 .put = alc_ch_mode_put,
4439 static struct hda_verb alc882_init_verbs[] = {
4440 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4442 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4443 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4446 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4447 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4449 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4450 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4451 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4453 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4454 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4455 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4457 /* Front Pin: output 0 (0x0c) */
4458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4460 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4461 /* Rear Pin: output 1 (0x0d) */
4462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4465 /* CLFE Pin: output 2 (0x0e) */
4466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4467 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4468 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4469 /* Side Pin: output 3 (0x0f) */
4470 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4472 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4473 /* Mic (rear) pin: input vref at 80% */
4474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4475 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4476 /* Front Mic pin: input vref at 80% */
4477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4478 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4479 /* Line In pin: input */
4480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4482 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4483 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4484 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4485 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4486 /* CD pin widget for input */
4487 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4489 /* FIXME: use matrix-type input source selection */
4490 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4491 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4492 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4497 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4502 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4506 /* ADC1: mute amp left and right */
4507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4508 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4509 /* ADC2: mute amp left and right */
4510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4511 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4512 /* ADC3: mute amp left and right */
4513 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4514 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4519 static struct hda_verb alc882_eapd_verbs[] = {
4520 /* change to EAPD mode */
4521 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4522 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4527 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
4528 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4529 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
4531 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
4532 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
4533 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
4534 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
4538 static struct hda_verb alc882_macpro_init_verbs[] = {
4539 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4543 /* Front Pin: output 0 (0x0c) */
4544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4545 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
4547 /* Front Mic pin: input vref at 80% */
4548 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4550 /* Speaker: output */
4551 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4553 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
4554 /* Headphone output (output 0 - 0x0c) */
4555 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4556 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4557 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
4559 /* FIXME: use matrix-type input source selection */
4560 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4561 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4564 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4576 /* ADC1: mute amp left and right */
4577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4578 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4579 /* ADC2: mute amp left and right */
4580 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4581 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4582 /* ADC3: mute amp left and right */
4583 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4584 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4588 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4590 unsigned int gpiostate, gpiomask, gpiodir;
4592 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4593 AC_VERB_GET_GPIO_DATA, 0);
4596 gpiostate |= (1 << pin);
4598 gpiostate &= ~(1 << pin);
4600 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4601 AC_VERB_GET_GPIO_MASK, 0);
4602 gpiomask |= (1 << pin);
4604 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4605 AC_VERB_GET_GPIO_DIRECTION, 0);
4606 gpiodir |= (1 << pin);
4609 snd_hda_codec_write(codec, codec->afg, 0,
4610 AC_VERB_SET_GPIO_MASK, gpiomask);
4611 snd_hda_codec_write(codec, codec->afg, 0,
4612 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
4616 snd_hda_codec_write(codec, codec->afg, 0,
4617 AC_VERB_SET_GPIO_DATA, gpiostate);
4621 * generic initialization of ADC, input mixers and output mixers
4623 static struct hda_verb alc882_auto_init_verbs[] = {
4625 * Unmute ADC0-2 and set the default input to mic-in
4627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4634 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4636 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4647 * Set up output mixers (0x0c - 0x0f)
4649 /* set vol=0 to output mixers */
4650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4652 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4653 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4654 /* set up input amps for analog loopback */
4655 /* Amp Indices: DAC = 0, mixer = 1 */
4656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4659 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4662 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4663 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4664 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4665 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4667 /* FIXME: use matrix-type input source selection */
4668 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4669 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4688 /* capture mixer elements */
4689 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4690 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4691 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4692 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4693 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4695 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4696 /* The multiple "Capture Source" controls confuse alsamixer
4697 * So call somewhat different..
4698 * FIXME: the controls appear in the "playback" view!
4700 /* .name = "Capture Source", */
4701 .name = "Input Source",
4703 .info = alc882_mux_enum_info,
4704 .get = alc882_mux_enum_get,
4705 .put = alc882_mux_enum_put,
4710 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4711 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4712 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4713 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4714 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4715 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4716 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4719 /* The multiple "Capture Source" controls confuse alsamixer
4720 * So call somewhat different..
4721 * FIXME: the controls appear in the "playback" view!
4723 /* .name = "Capture Source", */
4724 .name = "Input Source",
4726 .info = alc882_mux_enum_info,
4727 .get = alc882_mux_enum_get,
4728 .put = alc882_mux_enum_put,
4733 /* pcm configuration: identiacal with ALC880 */
4734 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4735 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4736 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4737 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4740 * configuration and preset
4742 static const char *alc882_models[ALC882_MODEL_LAST] = {
4743 [ALC882_3ST_DIG] = "3stack-dig",
4744 [ALC882_6ST_DIG] = "6stack-dig",
4745 [ALC882_ARIMA] = "arima",
4746 [ALC885_MACPRO] = "macpro",
4747 [ALC882_AUTO] = "auto",
4750 static struct snd_pci_quirk alc882_cfg_tbl[] = {
4751 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
4752 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
4753 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
4754 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
4755 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
4759 static struct alc_config_preset alc882_presets[] = {
4760 [ALC882_3ST_DIG] = {
4761 .mixers = { alc882_base_mixer },
4762 .init_verbs = { alc882_init_verbs },
4763 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4764 .dac_nids = alc882_dac_nids,
4765 .dig_out_nid = ALC882_DIGOUT_NID,
4766 .dig_in_nid = ALC882_DIGIN_NID,
4767 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4768 .channel_mode = alc882_ch_modes,
4770 .input_mux = &alc882_capture_source,
4772 [ALC882_6ST_DIG] = {
4773 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4774 .init_verbs = { alc882_init_verbs },
4775 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4776 .dac_nids = alc882_dac_nids,
4777 .dig_out_nid = ALC882_DIGOUT_NID,
4778 .dig_in_nid = ALC882_DIGIN_NID,
4779 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4780 .channel_mode = alc882_sixstack_modes,
4781 .input_mux = &alc882_capture_source,
4784 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4785 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4786 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4787 .dac_nids = alc882_dac_nids,
4788 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4789 .channel_mode = alc882_sixstack_modes,
4790 .input_mux = &alc882_capture_source,
4793 .mixers = { alc882_macpro_mixer },
4794 .init_verbs = { alc882_macpro_init_verbs },
4795 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4796 .dac_nids = alc882_dac_nids,
4797 .dig_out_nid = ALC882_DIGOUT_NID,
4798 .dig_in_nid = ALC882_DIGIN_NID,
4799 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4800 .channel_mode = alc882_ch_modes,
4801 .input_mux = &alc882_capture_source,
4807 * BIOS auto configuration
4809 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4810 hda_nid_t nid, int pin_type,
4814 struct alc_spec *spec = codec->spec;
4817 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4820 idx = spec->multiout.dac_nids[dac_idx] - 2;
4822 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4823 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4824 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4828 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4830 struct alc_spec *spec = codec->spec;
4833 for (i = 0; i <= HDA_SIDE; i++) {
4834 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4836 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4840 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4842 struct alc_spec *spec = codec->spec;
4845 pin = spec->autocfg.hp_pins[0];
4846 if (pin) /* connect to front */
4847 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4850 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4851 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4853 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4855 struct alc_spec *spec = codec->spec;
4858 for (i = 0; i < AUTO_PIN_LAST; i++) {
4859 hda_nid_t nid = spec->autocfg.input_pins[i];
4860 if (alc882_is_input_pin(nid)) {
4861 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4862 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4863 if (nid != ALC882_PIN_CD_NID)
4864 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4870 /* almost identical with ALC880 parser... */
4871 static int alc882_parse_auto_config(struct hda_codec *codec)
4873 struct alc_spec *spec = codec->spec;
4874 int err = alc880_parse_auto_config(codec);
4879 /* hack - override the init verbs */
4880 spec->init_verbs[0] = alc882_auto_init_verbs;
4884 /* additional initialization for auto-configuration model */
4885 static void alc882_auto_init(struct hda_codec *codec)
4887 alc882_auto_init_multi_out(codec);
4888 alc882_auto_init_hp_out(codec);
4889 alc882_auto_init_analog_input(codec);
4892 static int patch_alc882(struct hda_codec *codec)
4894 struct alc_spec *spec;
4895 int err, board_config;
4897 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4903 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
4907 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4908 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4909 "trying auto-probe from BIOS...\n");
4910 board_config = ALC882_AUTO;
4913 if (board_config == ALC882_AUTO) {
4914 /* automatic parse from the BIOS config */
4915 err = alc882_parse_auto_config(codec);
4921 "hda_codec: Cannot set up configuration "
4922 "from BIOS. Using base mode...\n");
4923 board_config = ALC882_3ST_DIG;
4927 if (board_config != ALC882_AUTO)
4928 setup_preset(spec, &alc882_presets[board_config]);
4930 if (board_config == ALC885_MACPRO) {
4931 alc882_gpio_mute(codec, 0, 0);
4932 alc882_gpio_mute(codec, 1, 0);
4935 spec->stream_name_analog = "ALC882 Analog";
4936 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4937 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4939 spec->stream_name_digital = "ALC882 Digital";
4940 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4941 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4943 if (! spec->adc_nids && spec->input_mux) {
4944 /* check whether NID 0x07 is valid */
4945 unsigned int wcap = get_wcaps(codec, 0x07);
4946 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4947 if (wcap != AC_WID_AUD_IN) {
4948 spec->adc_nids = alc882_adc_nids_alt;
4949 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4950 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4953 spec->adc_nids = alc882_adc_nids;
4954 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4955 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4960 codec->patch_ops = alc_patch_ops;
4961 if (board_config == ALC882_AUTO)
4962 spec->init_hook = alc882_auto_init;
4970 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4971 * configuration. Each pin widget can choose any input DACs and a mixer.
4972 * Each ADC is connected from a mixer of all inputs. This makes possible
4973 * 6-channel independent captures.
4975 * In addition, an independent DAC for the multi-playback (not used in this
4978 #define ALC883_DIGOUT_NID 0x06
4979 #define ALC883_DIGIN_NID 0x0a
4981 static hda_nid_t alc883_dac_nids[4] = {
4982 /* front, rear, clfe, rear_surr */
4983 0x02, 0x04, 0x03, 0x05
4986 static hda_nid_t alc883_adc_nids[2] = {
4991 /* FIXME: should be a matrix-type input source selection */
4993 static struct hda_input_mux alc883_capture_source = {
4997 { "Front Mic", 0x1 },
5002 #define alc883_mux_enum_info alc_mux_enum_info
5003 #define alc883_mux_enum_get alc_mux_enum_get
5005 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5006 struct snd_ctl_elem_value *ucontrol)
5008 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5009 struct alc_spec *spec = codec->spec;
5010 const struct hda_input_mux *imux = spec->input_mux;
5011 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5012 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5013 hda_nid_t nid = capture_mixers[adc_idx];
5014 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5015 unsigned int i, idx;
5017 idx = ucontrol->value.enumerated.item[0];
5018 if (idx >= imux->num_items)
5019 idx = imux->num_items - 1;
5020 if (*cur_val == idx && ! codec->in_resume)
5022 for (i = 0; i < imux->num_items; i++) {
5023 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
5024 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5025 v | (imux->items[i].index << 8));
5033 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5040 static struct hda_verb alc883_3ST_ch2_init[] = {
5041 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5042 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5043 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5044 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5051 static struct hda_verb alc883_3ST_ch6_init[] = {
5052 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5053 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5054 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5055 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5056 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5057 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5061 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5062 { 2, alc883_3ST_ch2_init },
5063 { 6, alc883_3ST_ch6_init },
5069 static struct hda_verb alc883_sixstack_ch6_init[] = {
5070 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5071 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5072 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5073 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5080 static struct hda_verb alc883_sixstack_ch8_init[] = {
5081 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5082 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5083 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5084 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5088 static struct hda_channel_mode alc883_sixstack_modes[2] = {
5089 { 6, alc883_sixstack_ch6_init },
5090 { 8, alc883_sixstack_ch8_init },
5093 static struct hda_verb alc883_medion_eapd_verbs[] = {
5094 /* eanable EAPD on medion laptop */
5095 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5096 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5100 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5101 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5104 static struct snd_kcontrol_new alc883_base_mixer[] = {
5105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5106 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5107 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5108 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5109 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5110 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5111 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5112 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5113 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5114 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5123 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5124 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5126 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5127 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5128 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5129 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5130 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5131 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5134 /* .name = "Capture Source", */
5135 .name = "Input Source",
5137 .info = alc883_mux_enum_info,
5138 .get = alc883_mux_enum_get,
5139 .put = alc883_mux_enum_put,
5144 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5146 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5148 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5149 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5150 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5151 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5153 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5155 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5156 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5157 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5158 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5159 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5162 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5163 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5166 /* .name = "Capture Source", */
5167 .name = "Input Source",
5169 .info = alc883_mux_enum_info,
5170 .get = alc883_mux_enum_get,
5171 .put = alc883_mux_enum_put,
5176 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5178 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5180 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5182 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5183 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5184 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5186 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5187 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5188 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5189 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5192 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5193 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5194 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5195 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5196 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5197 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5198 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5199 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5200 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5201 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5204 /* .name = "Capture Source", */
5205 .name = "Input Source",
5207 .info = alc883_mux_enum_info,
5208 .get = alc883_mux_enum_get,
5209 .put = alc883_mux_enum_put,
5214 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
5215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5216 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5217 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5218 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5219 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5220 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5221 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5222 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5223 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5224 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5225 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5231 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5232 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5233 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5234 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5235 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5236 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5237 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5241 /* .name = "Capture Source", */
5242 .name = "Input Source",
5244 .info = alc883_mux_enum_info,
5245 .get = alc883_mux_enum_get,
5246 .put = alc883_mux_enum_put,
5251 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5253 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5254 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5255 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5256 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5257 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5258 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5259 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5260 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5261 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5262 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5263 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5264 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5265 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5266 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5268 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5269 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5270 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5271 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5273 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5274 /* .name = "Capture Source", */
5275 .name = "Input Source",
5277 .info = alc883_mux_enum_info,
5278 .get = alc883_mux_enum_get,
5279 .put = alc883_mux_enum_put,
5284 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5285 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5286 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5287 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5288 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5289 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5290 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5291 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5293 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5294 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5295 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5296 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5298 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5299 /* .name = "Capture Source", */
5300 .name = "Input Source",
5302 .info = alc883_mux_enum_info,
5303 .get = alc883_mux_enum_get,
5304 .put = alc883_mux_enum_put,
5309 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5312 .name = "Channel Mode",
5313 .info = alc_ch_mode_info,
5314 .get = alc_ch_mode_get,
5315 .put = alc_ch_mode_put,
5320 static struct hda_verb alc883_init_verbs[] = {
5321 /* ADC1: mute amp left and right */
5322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5323 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5324 /* ADC2: mute amp left and right */
5325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5326 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5327 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5328 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5337 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5338 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5340 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5341 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5342 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5347 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5348 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5350 /* Front Pin: output 0 (0x0c) */
5351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5353 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5354 /* Rear Pin: output 1 (0x0d) */
5355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5356 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5357 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5358 /* CLFE Pin: output 2 (0x0e) */
5359 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5360 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5361 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5362 /* Side Pin: output 3 (0x0f) */
5363 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5364 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5365 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5366 /* Mic (rear) pin: input vref at 80% */
5367 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5369 /* Front Mic pin: input vref at 80% */
5370 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5372 /* Line In pin: input */
5373 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5375 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5376 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5377 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5378 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5379 /* CD pin widget for input */
5380 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5382 /* FIXME: use matrix-type input source selection */
5383 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5397 static struct hda_verb alc883_tagra_verbs[] = {
5398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5402 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5404 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5405 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5406 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5408 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5409 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5410 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5411 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5416 /* toggle speaker-output according to the hp-jack state */
5417 static void alc883_tagra_automute(struct hda_codec *codec)
5419 unsigned int present;
5421 present = snd_hda_codec_read(codec, 0x14, 0,
5422 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5423 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5424 0x80, present ? 0x80 : 0);
5425 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5426 0x80, present ? 0x80 : 0);
5427 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5430 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5432 if ((res >> 26) == ALC880_HP_EVENT)
5433 alc883_tagra_automute(codec);
5437 * generic initialization of ADC, input mixers and output mixers
5439 static struct hda_verb alc883_auto_init_verbs[] = {
5441 * Unmute ADC0-2 and set the default input to mic-in
5443 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5445 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5448 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5450 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5453 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5454 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5455 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5456 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5457 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5461 * Set up output mixers (0x0c - 0x0f)
5463 /* set vol=0 to output mixers */
5464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5466 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5467 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5468 /* set up input amps for analog loopback */
5469 /* Amp Indices: DAC = 0, mixer = 1 */
5470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5472 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5473 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5478 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5479 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5481 /* FIXME: use matrix-type input source selection */
5482 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5487 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5493 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5494 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5499 /* capture mixer elements */
5500 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5501 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5502 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5503 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5504 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5507 /* The multiple "Capture Source" controls confuse alsamixer
5508 * So call somewhat different..
5509 * FIXME: the controls appear in the "playback" view!
5511 /* .name = "Capture Source", */
5512 .name = "Input Source",
5514 .info = alc882_mux_enum_info,
5515 .get = alc882_mux_enum_get,
5516 .put = alc882_mux_enum_put,
5521 /* pcm configuration: identiacal with ALC880 */
5522 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5523 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5524 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5525 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5528 * configuration and preset
5530 static const char *alc883_models[ALC883_MODEL_LAST] = {
5531 [ALC883_3ST_2ch_DIG] = "3stack-dig",
5532 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
5533 [ALC883_3ST_6ch] = "3stack-6ch",
5534 [ALC883_6ST_DIG] = "6stack-dig",
5535 [ALC883_TARGA_DIG] = "targa-dig",
5536 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
5537 [ALC888_DEMO_BOARD] = "6stack-dig-demo",
5538 [ALC883_ACER] = "acer",
5539 [ALC883_MEDION] = "medion",
5540 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
5541 [ALC883_AUTO] = "auto",
5544 static struct snd_pci_quirk alc883_cfg_tbl[] = {
5545 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
5546 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5547 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5548 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
5549 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5550 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
5551 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
5552 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
5553 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
5554 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
5555 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
5556 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
5557 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
5558 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
5559 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
5560 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
5561 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
5562 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
5563 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5564 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5565 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
5569 static struct alc_config_preset alc883_presets[] = {
5570 [ALC883_3ST_2ch_DIG] = {
5571 .mixers = { alc883_3ST_2ch_mixer },
5572 .init_verbs = { alc883_init_verbs },
5573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5574 .dac_nids = alc883_dac_nids,
5575 .dig_out_nid = ALC883_DIGOUT_NID,
5576 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5577 .adc_nids = alc883_adc_nids,
5578 .dig_in_nid = ALC883_DIGIN_NID,
5579 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5580 .channel_mode = alc883_3ST_2ch_modes,
5581 .input_mux = &alc883_capture_source,
5583 [ALC883_3ST_6ch_DIG] = {
5584 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5585 .init_verbs = { alc883_init_verbs },
5586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5587 .dac_nids = alc883_dac_nids,
5588 .dig_out_nid = ALC883_DIGOUT_NID,
5589 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5590 .adc_nids = alc883_adc_nids,
5591 .dig_in_nid = ALC883_DIGIN_NID,
5592 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5593 .channel_mode = alc883_3ST_6ch_modes,
5595 .input_mux = &alc883_capture_source,
5597 [ALC883_3ST_6ch] = {
5598 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5599 .init_verbs = { alc883_init_verbs },
5600 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5601 .dac_nids = alc883_dac_nids,
5602 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5603 .adc_nids = alc883_adc_nids,
5604 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5605 .channel_mode = alc883_3ST_6ch_modes,
5607 .input_mux = &alc883_capture_source,
5609 [ALC883_6ST_DIG] = {
5610 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5611 .init_verbs = { alc883_init_verbs },
5612 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5613 .dac_nids = alc883_dac_nids,
5614 .dig_out_nid = ALC883_DIGOUT_NID,
5615 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5616 .adc_nids = alc883_adc_nids,
5617 .dig_in_nid = ALC883_DIGIN_NID,
5618 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5619 .channel_mode = alc883_sixstack_modes,
5620 .input_mux = &alc883_capture_source,
5622 [ALC883_TARGA_DIG] = {
5623 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
5624 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5625 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5626 .dac_nids = alc883_dac_nids,
5627 .dig_out_nid = ALC883_DIGOUT_NID,
5628 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5629 .adc_nids = alc883_adc_nids,
5630 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5631 .channel_mode = alc883_3ST_6ch_modes,
5633 .input_mux = &alc883_capture_source,
5634 .unsol_event = alc883_tagra_unsol_event,
5635 .init_hook = alc883_tagra_automute,
5637 [ALC883_TARGA_2ch_DIG] = {
5638 .mixers = { alc883_tagra_2ch_mixer},
5639 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5640 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5641 .dac_nids = alc883_dac_nids,
5642 .dig_out_nid = ALC883_DIGOUT_NID,
5643 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5644 .adc_nids = alc883_adc_nids,
5645 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5646 .channel_mode = alc883_3ST_2ch_modes,
5647 .input_mux = &alc883_capture_source,
5648 .unsol_event = alc883_tagra_unsol_event,
5649 .init_hook = alc883_tagra_automute,
5651 [ALC888_DEMO_BOARD] = {
5652 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5653 .init_verbs = { alc883_init_verbs },
5654 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5655 .dac_nids = alc883_dac_nids,
5656 .dig_out_nid = ALC883_DIGOUT_NID,
5657 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5658 .adc_nids = alc883_adc_nids,
5659 .dig_in_nid = ALC883_DIGIN_NID,
5660 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5661 .channel_mode = alc883_sixstack_modes,
5662 .input_mux = &alc883_capture_source,
5665 .mixers = { alc883_base_mixer,
5666 alc883_chmode_mixer },
5667 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5668 * and the headphone jack. Turn this on and rely on the
5669 * standard mute methods whenever the user wants to turn
5670 * these outputs off.
5672 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5673 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5674 .dac_nids = alc883_dac_nids,
5675 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5676 .adc_nids = alc883_adc_nids,
5677 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5678 .channel_mode = alc883_3ST_2ch_modes,
5679 .input_mux = &alc883_capture_source,
5682 .mixers = { alc883_fivestack_mixer,
5683 alc883_chmode_mixer },
5684 .init_verbs = { alc883_init_verbs,
5685 alc883_medion_eapd_verbs },
5686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5687 .dac_nids = alc883_dac_nids,
5688 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5689 .adc_nids = alc883_adc_nids,
5690 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5691 .channel_mode = alc883_sixstack_modes,
5692 .input_mux = &alc883_capture_source,
5694 [ALC883_LAPTOP_EAPD] = {
5695 .mixers = { alc883_base_mixer,
5696 alc883_chmode_mixer },
5697 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
5698 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5699 .dac_nids = alc883_dac_nids,
5700 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5701 .adc_nids = alc883_adc_nids,
5702 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5703 .channel_mode = alc883_3ST_2ch_modes,
5704 .input_mux = &alc883_capture_source,
5710 * BIOS auto configuration
5712 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5713 hda_nid_t nid, int pin_type,
5717 struct alc_spec *spec = codec->spec;
5720 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5723 idx = spec->multiout.dac_nids[dac_idx] - 2;
5725 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5727 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5729 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5733 static void alc883_auto_init_multi_out(struct hda_codec *codec)
5735 struct alc_spec *spec = codec->spec;
5738 for (i = 0; i <= HDA_SIDE; i++) {
5739 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5741 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5745 static void alc883_auto_init_hp_out(struct hda_codec *codec)
5747 struct alc_spec *spec = codec->spec;
5750 pin = spec->autocfg.hp_pins[0];
5751 if (pin) /* connect to front */
5753 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5756 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5757 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5759 static void alc883_auto_init_analog_input(struct hda_codec *codec)
5761 struct alc_spec *spec = codec->spec;
5764 for (i = 0; i < AUTO_PIN_LAST; i++) {
5765 hda_nid_t nid = spec->autocfg.input_pins[i];
5766 if (alc883_is_input_pin(nid)) {
5767 snd_hda_codec_write(codec, nid, 0,
5768 AC_VERB_SET_PIN_WIDGET_CONTROL,
5769 (i <= AUTO_PIN_FRONT_MIC ?
5770 PIN_VREF80 : PIN_IN));
5771 if (nid != ALC883_PIN_CD_NID)
5772 snd_hda_codec_write(codec, nid, 0,
5773 AC_VERB_SET_AMP_GAIN_MUTE,
5779 /* almost identical with ALC880 parser... */
5780 static int alc883_parse_auto_config(struct hda_codec *codec)
5782 struct alc_spec *spec = codec->spec;
5783 int err = alc880_parse_auto_config(codec);
5788 /* hack - override the init verbs */
5789 spec->init_verbs[0] = alc883_auto_init_verbs;
5790 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5795 /* additional initialization for auto-configuration model */
5796 static void alc883_auto_init(struct hda_codec *codec)
5798 alc883_auto_init_multi_out(codec);
5799 alc883_auto_init_hp_out(codec);
5800 alc883_auto_init_analog_input(codec);
5803 static int patch_alc883(struct hda_codec *codec)
5805 struct alc_spec *spec;
5806 int err, board_config;
5808 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5814 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
5817 if (board_config < 0) {
5818 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5819 "trying auto-probe from BIOS...\n");
5820 board_config = ALC883_AUTO;
5823 if (board_config == ALC883_AUTO) {
5824 /* automatic parse from the BIOS config */
5825 err = alc883_parse_auto_config(codec);
5831 "hda_codec: Cannot set up configuration "
5832 "from BIOS. Using base mode...\n");
5833 board_config = ALC883_3ST_2ch_DIG;
5837 if (board_config != ALC883_AUTO)
5838 setup_preset(spec, &alc883_presets[board_config]);
5840 spec->stream_name_analog = "ALC883 Analog";
5841 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5842 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5844 spec->stream_name_digital = "ALC883 Digital";
5845 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5846 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5848 if (! spec->adc_nids && spec->input_mux) {
5849 spec->adc_nids = alc883_adc_nids;
5850 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5853 codec->patch_ops = alc_patch_ops;
5854 if (board_config == ALC883_AUTO)
5855 spec->init_hook = alc883_auto_init;
5864 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5865 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
5867 #define alc262_dac_nids alc260_dac_nids
5868 #define alc262_adc_nids alc882_adc_nids
5869 #define alc262_adc_nids_alt alc882_adc_nids_alt
5871 #define alc262_modes alc260_modes
5872 #define alc262_capture_source alc882_capture_source
5874 static struct snd_kcontrol_new alc262_base_mixer[] = {
5875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5876 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5877 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5878 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5883 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5884 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5885 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5886 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5887 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5889 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5890 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5894 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
5895 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5896 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5897 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5898 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5899 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5900 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5903 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5904 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5905 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5906 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5907 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
5908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5912 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5913 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5914 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5915 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5916 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5917 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5921 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5922 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5923 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5924 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5925 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5926 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5927 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5928 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5929 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5930 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5934 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
5935 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5936 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5937 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5938 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5939 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5940 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5941 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
5942 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
5943 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5944 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5947 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5948 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5952 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
5953 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5954 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5958 #define alc262_capture_mixer alc882_capture_mixer
5959 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
5962 * generic initialization of ADC, input mixers and output mixers
5964 static struct hda_verb alc262_init_verbs[] = {
5966 * Unmute ADC0-2 and set the default input to mic-in
5968 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5970 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5971 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5972 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5975 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5977 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5980 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5988 * Set up output mixers (0x0c - 0x0e)
5990 /* set vol=0 to output mixers */
5991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5992 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5994 /* set up input amps for analog loopback */
5995 /* Amp Indices: DAC = 0, mixer = 1 */
5996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6003 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6005 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6007 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6008 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6012 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6013 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6016 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6019 /* FIXME: use matrix-type input source selection */
6020 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6021 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6022 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6023 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6027 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6028 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6029 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6032 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6040 static struct hda_verb alc262_hippo_unsol_verbs[] = {
6041 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6042 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6046 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
6047 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6048 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6049 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6051 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6056 /* mute/unmute internal speaker according to the hp jack and mute state */
6057 static void alc262_hippo_automute(struct hda_codec *codec, int force)
6059 struct alc_spec *spec = codec->spec;
6062 if (force || ! spec->sense_updated) {
6063 unsigned int present;
6064 /* need to execute and sync at first */
6065 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
6066 present = snd_hda_codec_read(codec, 0x15, 0,
6067 AC_VERB_GET_PIN_SENSE, 0);
6068 spec->jack_present = (present & 0x80000000) != 0;
6069 spec->sense_updated = 1;
6071 if (spec->jack_present) {
6072 /* mute internal speaker */
6073 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6075 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6078 /* unmute internal speaker if necessary */
6079 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
6080 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6082 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
6083 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6088 /* unsolicited event for HP jack sensing */
6089 static void alc262_hippo_unsol_event(struct hda_codec *codec,
6092 if ((res >> 26) != ALC880_HP_EVENT)
6094 alc262_hippo_automute(codec, 1);
6097 static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6099 struct alc_spec *spec = codec->spec;
6102 if (force || ! spec->sense_updated) {
6103 unsigned int present;
6104 /* need to execute and sync at first */
6105 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
6106 present = snd_hda_codec_read(codec, 0x1b, 0,
6107 AC_VERB_GET_PIN_SENSE, 0);
6108 spec->jack_present = (present & 0x80000000) != 0;
6109 spec->sense_updated = 1;
6111 if (spec->jack_present) {
6112 /* mute internal speaker */
6113 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6115 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6118 /* unmute internal speaker if necessary */
6119 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
6120 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6122 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
6123 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6128 /* unsolicited event for HP jack sensing */
6129 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
6132 if ((res >> 26) != ALC880_HP_EVENT)
6134 alc262_hippo1_automute(codec, 1);
6139 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
6142 #define ALC_HP_EVENT 0x37
6144 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
6145 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
6146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6150 static struct hda_input_mux alc262_fujitsu_capture_source = {
6158 static struct hda_input_mux alc262_HP_capture_source = {
6162 { "Front Mic", 0x3 },
6169 /* mute/unmute internal speaker according to the hp jack and mute state */
6170 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6172 struct alc_spec *spec = codec->spec;
6175 if (force || ! spec->sense_updated) {
6176 unsigned int present;
6177 /* need to execute and sync at first */
6178 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
6179 present = snd_hda_codec_read(codec, 0x14, 0,
6180 AC_VERB_GET_PIN_SENSE, 0);
6181 spec->jack_present = (present & 0x80000000) != 0;
6182 spec->sense_updated = 1;
6184 if (spec->jack_present) {
6185 /* mute internal speaker */
6186 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6188 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6191 /* unmute internal speaker if necessary */
6192 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
6193 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6195 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
6196 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6201 /* unsolicited event for HP jack sensing */
6202 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
6205 if ((res >> 26) != ALC_HP_EVENT)
6207 alc262_fujitsu_automute(codec, 1);
6210 /* bind volumes of both NID 0x0c and 0x0d */
6211 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
6212 struct snd_ctl_elem_value *ucontrol)
6214 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6215 long *valp = ucontrol->value.integer.value;
6218 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
6219 0x7f, valp[0] & 0x7f);
6220 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
6221 0x7f, valp[1] & 0x7f);
6222 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
6223 0x7f, valp[0] & 0x7f);
6224 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
6225 0x7f, valp[1] & 0x7f);
6229 /* bind hp and internal speaker mute (with plug check) */
6230 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
6231 struct snd_ctl_elem_value *ucontrol)
6233 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6234 long *valp = ucontrol->value.integer.value;
6237 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6238 0x80, valp[0] ? 0 : 0x80);
6239 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6240 0x80, valp[1] ? 0 : 0x80);
6241 if (change || codec->in_resume)
6242 alc262_fujitsu_automute(codec, codec->in_resume);
6246 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
6248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6249 .name = "Master Playback Volume",
6250 .info = snd_hda_mixer_amp_volume_info,
6251 .get = snd_hda_mixer_amp_volume_get,
6252 .put = alc262_fujitsu_master_vol_put,
6253 .tlv = { .c = snd_hda_mixer_amp_tlv },
6254 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
6257 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6258 .name = "Master Playback Switch",
6259 .info = snd_hda_mixer_amp_switch_info,
6260 .get = snd_hda_mixer_amp_switch_get,
6261 .put = alc262_fujitsu_master_sw_put,
6262 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
6264 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6265 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6266 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6272 /* additional init verbs for Benq laptops */
6273 static struct hda_verb alc262_EAPD_verbs[] = {
6274 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6275 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6279 /* add playback controls from the parsed DAC table */
6280 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6285 spec->multiout.num_dacs = 1; /* only use one dac */
6286 spec->multiout.dac_nids = spec->private_dac_nids;
6287 spec->multiout.dac_nids[0] = 2;
6289 nid = cfg->line_out_pins[0];
6291 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
6292 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
6294 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
6295 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6299 nid = cfg->speaker_pins[0];
6302 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
6303 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6305 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6306 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6309 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6310 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6314 nid = cfg->hp_pins[0];
6316 /* spec->multiout.hp_nid = 2; */
6318 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
6319 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6321 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6322 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6325 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6326 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6333 /* identical with ALC880 */
6334 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
6337 * generic initialization of ADC, input mixers and output mixers
6339 static struct hda_verb alc262_volume_init_verbs[] = {
6341 * Unmute ADC0-2 and set the default input to mic-in
6343 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6345 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6346 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6347 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6348 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6350 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6352 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6355 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6363 * Set up output mixers (0x0c - 0x0f)
6365 /* set vol=0 to output mixers */
6366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6370 /* set up input amps for analog loopback */
6371 /* Amp Indices: DAC = 0, mixer = 1 */
6372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6379 /* FIXME: use matrix-type input source selection */
6380 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6381 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6382 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6383 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6400 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6402 * Unmute ADC0-2 and set the default input to mic-in
6404 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6406 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6408 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6411 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6413 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6416 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6421 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6422 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6423 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6426 * Set up output mixers (0x0c - 0x0e)
6428 /* set vol=0 to output mixers */
6429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6431 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6433 /* set up input amps for analog loopback */
6434 /* Amp Indices: DAC = 0, mixer = 1 */
6435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6442 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6444 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6446 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6449 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6450 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6452 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6453 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6455 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6456 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6461 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6462 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6463 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6466 /* FIXME: use matrix-type input source selection */
6467 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6468 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6469 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6487 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
6489 * Unmute ADC0-2 and set the default input to mic-in
6491 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6495 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6498 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6500 * Note: PASD motherboards uses the Line In 2 as the input for front
6503 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
6513 * Set up output mixers (0x0c - 0x0e)
6515 /* set vol=0 to output mixers */
6516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6520 /* set up input amps for analog loopback */
6521 /* Amp Indices: DAC = 0, mixer = 1 */
6522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
6531 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
6532 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
6533 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
6534 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
6535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
6536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
6538 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6539 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6541 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6542 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6544 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
6545 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6548 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6549 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6551 /* FIXME: use matrix-type input source selection */
6552 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6553 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6554 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
6555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
6556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
6557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
6558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
6559 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
6560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
6562 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6567 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
6568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
6570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6575 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
6576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
6581 /* pcm configuration: identiacal with ALC880 */
6582 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
6583 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
6584 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
6585 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
6588 * BIOS auto configuration
6590 static int alc262_parse_auto_config(struct hda_codec *codec)
6592 struct alc_spec *spec = codec->spec;
6594 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6596 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6597 alc262_ignore)) < 0)
6599 if (! spec->autocfg.line_outs)
6600 return 0; /* can't find valid BIOS pin config */
6601 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6602 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6605 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6607 if (spec->autocfg.dig_out_pin)
6608 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
6609 if (spec->autocfg.dig_in_pin)
6610 spec->dig_in_nid = ALC262_DIGIN_NID;
6612 if (spec->kctl_alloc)
6613 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6615 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
6616 spec->num_mux_defs = 1;
6617 spec->input_mux = &spec->private_imux;
6622 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
6623 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
6624 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
6627 /* init callback for auto-configuration model -- overriding the default init */
6628 static void alc262_auto_init(struct hda_codec *codec)
6630 alc262_auto_init_multi_out(codec);
6631 alc262_auto_init_hp_out(codec);
6632 alc262_auto_init_analog_input(codec);
6636 * configuration and preset
6638 static const char *alc262_models[ALC262_MODEL_LAST] = {
6639 [ALC262_BASIC] = "basic",
6640 [ALC262_HIPPO] = "hippo",
6641 [ALC262_HIPPO_1] = "hippo_1",
6642 [ALC262_FUJITSU] = "fujitsu",
6643 [ALC262_HP_BPC] = "hp-bpc",
6644 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
6645 [ALC262_BENQ_ED8] = "benq",
6646 [ALC262_AUTO] = "auto",
6649 static struct snd_pci_quirk alc262_cfg_tbl[] = {
6650 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
6651 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
6652 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
6653 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
6654 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
6655 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
6656 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
6657 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
6658 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
6659 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
6660 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
6661 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
6662 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
6663 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
6664 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
6665 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
6666 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
6670 static struct alc_config_preset alc262_presets[] = {
6672 .mixers = { alc262_base_mixer },
6673 .init_verbs = { alc262_init_verbs },
6674 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6675 .dac_nids = alc262_dac_nids,
6677 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6678 .channel_mode = alc262_modes,
6679 .input_mux = &alc262_capture_source,
6682 .mixers = { alc262_base_mixer },
6683 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
6684 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6685 .dac_nids = alc262_dac_nids,
6687 .dig_out_nid = ALC262_DIGOUT_NID,
6688 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6689 .channel_mode = alc262_modes,
6690 .input_mux = &alc262_capture_source,
6691 .unsol_event = alc262_hippo_unsol_event,
6693 [ALC262_HIPPO_1] = {
6694 .mixers = { alc262_hippo1_mixer },
6695 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
6696 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6697 .dac_nids = alc262_dac_nids,
6699 .dig_out_nid = ALC262_DIGOUT_NID,
6700 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6701 .channel_mode = alc262_modes,
6702 .input_mux = &alc262_capture_source,
6703 .unsol_event = alc262_hippo1_unsol_event,
6705 [ALC262_FUJITSU] = {
6706 .mixers = { alc262_fujitsu_mixer },
6707 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
6708 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6709 .dac_nids = alc262_dac_nids,
6711 .dig_out_nid = ALC262_DIGOUT_NID,
6712 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6713 .channel_mode = alc262_modes,
6714 .input_mux = &alc262_fujitsu_capture_source,
6715 .unsol_event = alc262_fujitsu_unsol_event,
6718 .mixers = { alc262_HP_BPC_mixer },
6719 .init_verbs = { alc262_HP_BPC_init_verbs },
6720 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6721 .dac_nids = alc262_dac_nids,
6723 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6724 .channel_mode = alc262_modes,
6725 .input_mux = &alc262_HP_capture_source,
6727 [ALC262_HP_BPC_D7000_WF] = {
6728 .mixers = { alc262_HP_BPC_WildWest_mixer },
6729 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
6730 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6731 .dac_nids = alc262_dac_nids,
6733 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6734 .channel_mode = alc262_modes,
6735 .input_mux = &alc262_HP_capture_source,
6737 [ALC262_HP_BPC_D7000_WL] = {
6738 .mixers = { alc262_HP_BPC_WildWest_mixer,
6739 alc262_HP_BPC_WildWest_option_mixer },
6740 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
6741 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6742 .dac_nids = alc262_dac_nids,
6744 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6745 .channel_mode = alc262_modes,
6746 .input_mux = &alc262_HP_capture_source,
6748 [ALC262_BENQ_ED8] = {
6749 .mixers = { alc262_base_mixer },
6750 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
6751 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6752 .dac_nids = alc262_dac_nids,
6754 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6755 .channel_mode = alc262_modes,
6756 .input_mux = &alc262_capture_source,
6760 static int patch_alc262(struct hda_codec *codec)
6762 struct alc_spec *spec;
6766 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6772 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
6775 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6776 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
6777 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6778 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
6782 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
6786 if (board_config < 0) {
6787 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
6788 "trying auto-probe from BIOS...\n");
6789 board_config = ALC262_AUTO;
6792 if (board_config == ALC262_AUTO) {
6793 /* automatic parse from the BIOS config */
6794 err = alc262_parse_auto_config(codec);
6800 "hda_codec: Cannot set up configuration "
6801 "from BIOS. Using base mode...\n");
6802 board_config = ALC262_BASIC;
6806 if (board_config != ALC262_AUTO)
6807 setup_preset(spec, &alc262_presets[board_config]);
6809 spec->stream_name_analog = "ALC262 Analog";
6810 spec->stream_analog_playback = &alc262_pcm_analog_playback;
6811 spec->stream_analog_capture = &alc262_pcm_analog_capture;
6813 spec->stream_name_digital = "ALC262 Digital";
6814 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6815 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6817 if (! spec->adc_nids && spec->input_mux) {
6818 /* check whether NID 0x07 is valid */
6819 unsigned int wcap = get_wcaps(codec, 0x07);
6821 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
6822 if (wcap != AC_WID_AUD_IN) {
6823 spec->adc_nids = alc262_adc_nids_alt;
6824 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6825 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
6828 spec->adc_nids = alc262_adc_nids;
6829 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
6830 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
6835 codec->patch_ops = alc_patch_ops;
6836 if (board_config == ALC262_AUTO)
6837 spec->init_hook = alc262_auto_init;
6843 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6847 * set the path ways for 2 channel output
6848 * need to set the codec line out and mic 1 pin widgets to inputs
6850 static struct hda_verb alc861_threestack_ch2_init[] = {
6851 /* set pin widget 1Ah (line in) for input */
6852 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6853 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6854 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6856 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6858 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6859 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6865 * need to set the codec line out and mic 1 pin widgets to outputs
6867 static struct hda_verb alc861_threestack_ch6_init[] = {
6868 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6869 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6870 /* set pin widget 18h (mic1) for output (CLFE)*/
6871 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6873 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6874 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6876 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6878 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6879 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6884 static struct hda_channel_mode alc861_threestack_modes[2] = {
6885 { 2, alc861_threestack_ch2_init },
6886 { 6, alc861_threestack_ch6_init },
6888 /* Set mic1 as input and unmute the mixer */
6889 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6890 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6891 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6894 /* Set mic1 as output and mute mixer */
6895 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6896 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6897 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6901 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6902 { 2, alc861_uniwill_m31_ch2_init },
6903 { 4, alc861_uniwill_m31_ch4_init },
6906 /* Set mic1 and line-in as input and unmute the mixer */
6907 static struct hda_verb alc861_asus_ch2_init[] = {
6908 /* set pin widget 1Ah (line in) for input */
6909 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6910 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6911 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6913 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6915 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6916 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6920 /* Set mic1 nad line-in as output and mute mixer */
6921 static struct hda_verb alc861_asus_ch6_init[] = {
6922 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6923 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6924 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6925 /* set pin widget 18h (mic1) for output (CLFE)*/
6926 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6927 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
6928 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6929 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6931 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6933 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6934 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6939 static struct hda_channel_mode alc861_asus_modes[2] = {
6940 { 2, alc861_asus_ch2_init },
6941 { 6, alc861_asus_ch6_init },
6946 static struct snd_kcontrol_new alc861_base_mixer[] = {
6947 /* output mixer control */
6948 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6949 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6950 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6951 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6952 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6954 /*Input mixer control */
6955 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6956 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6957 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6958 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6959 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6960 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6962 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6966 /* Capture mixer control */
6967 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6968 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6971 .name = "Capture Source",
6973 .info = alc_mux_enum_info,
6974 .get = alc_mux_enum_get,
6975 .put = alc_mux_enum_put,
6980 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6981 /* output mixer control */
6982 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6983 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6984 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6985 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6986 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6988 /* Input mixer control */
6989 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6990 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6991 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6992 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6994 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6996 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7000 /* Capture mixer control */
7001 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7002 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7005 .name = "Capture Source",
7007 .info = alc_mux_enum_info,
7008 .get = alc_mux_enum_get,
7009 .put = alc_mux_enum_put,
7012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7013 .name = "Channel Mode",
7014 .info = alc_ch_mode_info,
7015 .get = alc_ch_mode_get,
7016 .put = alc_ch_mode_put,
7017 .private_value = ARRAY_SIZE(alc861_threestack_modes),
7022 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
7023 /* output mixer control */
7024 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7026 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7028 /*Capture mixer control */
7029 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7030 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7033 .name = "Capture Source",
7035 .info = alc_mux_enum_info,
7036 .get = alc_mux_enum_get,
7037 .put = alc_mux_enum_put,
7043 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7044 /* output mixer control */
7045 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7046 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7047 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7048 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7049 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
7051 /* Input mixer control */
7052 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7053 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
7054 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7055 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7056 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7057 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7059 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7060 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7061 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7063 /* Capture mixer control */
7064 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7065 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7068 .name = "Capture Source",
7070 .info = alc_mux_enum_info,
7071 .get = alc_mux_enum_get,
7072 .put = alc_mux_enum_put,
7075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7076 .name = "Channel Mode",
7077 .info = alc_ch_mode_info,
7078 .get = alc_ch_mode_get,
7079 .put = alc_ch_mode_put,
7080 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
7085 static struct snd_kcontrol_new alc861_asus_mixer[] = {
7086 /* output mixer control */
7087 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
7088 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
7093 /* Input mixer control */
7094 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
7095 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7096 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7097 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7098 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
7099 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
7100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7101 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
7105 /* Capture mixer control */
7106 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7107 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7110 .name = "Capture Source",
7112 .info = alc_mux_enum_info,
7113 .get = alc_mux_enum_get,
7114 .put = alc_mux_enum_put,
7117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7118 .name = "Channel Mode",
7119 .info = alc_ch_mode_info,
7120 .get = alc_ch_mode_get,
7121 .put = alc_ch_mode_put,
7122 .private_value = ARRAY_SIZE(alc861_asus_modes),
7127 /* additional mixer */
7128 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
7129 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
7130 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
7131 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
7132 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
7137 * generic initialization of ADC, input mixers and output mixers
7139 static struct hda_verb alc861_base_init_verbs[] = {
7141 * Unmute ADC0 and set the default input to mic-in
7143 /* port-A for surround (rear panel) */
7144 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7145 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
7146 /* port-B for mic-in (rear panel) with vref */
7147 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7148 /* port-C for line-in (rear panel) */
7149 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7150 /* port-D for Front */
7151 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7152 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7153 /* port-E for HP out (front panel) */
7154 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7155 /* route front PCM to HP */
7156 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7157 /* port-F for mic-in (front panel) with vref */
7158 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7159 /* port-G for CLFE (rear panel) */
7160 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7161 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7162 /* port-H for side (rear panel) */
7163 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7164 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
7166 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7167 /* route front mic to ADC1*/
7168 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7169 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7171 /* Unmute DAC0~3 & spdif out*/
7172 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7173 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7174 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7175 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7178 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7179 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7180 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7181 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7182 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7184 /* Unmute Stereo Mixer 15 */
7185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7190 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7191 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7192 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7193 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7194 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7195 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7197 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7198 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7204 static struct hda_verb alc861_threestack_init_verbs[] = {
7206 * Unmute ADC0 and set the default input to mic-in
7208 /* port-A for surround (rear panel) */
7209 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7210 /* port-B for mic-in (rear panel) with vref */
7211 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7212 /* port-C for line-in (rear panel) */
7213 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7214 /* port-D for Front */
7215 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7216 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7217 /* port-E for HP out (front panel) */
7218 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
7219 /* route front PCM to HP */
7220 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7221 /* port-F for mic-in (front panel) with vref */
7222 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7223 /* port-G for CLFE (rear panel) */
7224 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7225 /* port-H for side (rear panel) */
7226 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7228 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7229 /* route front mic to ADC1*/
7230 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7231 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7232 /* Unmute DAC0~3 & spdif out*/
7233 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7235 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7236 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7239 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7240 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7241 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7242 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7243 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7245 /* Unmute Stereo Mixer 15 */
7246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7251 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7252 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7253 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7254 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7255 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7258 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7259 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7260 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7264 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7266 * Unmute ADC0 and set the default input to mic-in
7268 /* port-A for surround (rear panel) */
7269 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7270 /* port-B for mic-in (rear panel) with vref */
7271 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7272 /* port-C for line-in (rear panel) */
7273 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7274 /* port-D for Front */
7275 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7276 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7277 /* port-E for HP out (front panel) */
7278 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
7279 /* route front PCM to HP */
7280 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7281 /* port-F for mic-in (front panel) with vref */
7282 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7283 /* port-G for CLFE (rear panel) */
7284 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7285 /* port-H for side (rear panel) */
7286 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7288 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7289 /* route front mic to ADC1*/
7290 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7292 /* Unmute DAC0~3 & spdif out*/
7293 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7294 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7295 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7296 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7299 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7300 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7301 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7302 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7303 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7305 /* Unmute Stereo Mixer 15 */
7306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
7311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
7320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7324 static struct hda_verb alc861_asus_init_verbs[] = {
7326 * Unmute ADC0 and set the default input to mic-in
7328 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
7329 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7330 /* route front PCM to HP */
7331 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
7332 /* port-B for mic-in (rear panel) with vref */
7333 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7334 /* port-C for line-in (rear panel) */
7335 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7336 /* port-D for Front */
7337 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7338 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7339 /* port-E for HP out (front panel) */
7340 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
7341 /* route front PCM to HP */
7342 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7343 /* port-F for mic-in (front panel) with vref */
7344 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7345 /* port-G for CLFE (rear panel) */
7346 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7347 /* port-H for side (rear panel) */
7348 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7350 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
7351 /* route front mic to ADC1*/
7352 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7354 /* Unmute DAC0~3 & spdif out*/
7355 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7356 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7357 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7358 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7360 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7361 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7362 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7363 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7364 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7366 /* Unmute Stereo Mixer 15 */
7367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
7372 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7373 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7374 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7375 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7378 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7379 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
7381 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7385 /* additional init verbs for ASUS laptops */
7386 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
7387 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
7388 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
7393 * generic initialization of ADC, input mixers and output mixers
7395 static struct hda_verb alc861_auto_init_verbs[] = {
7397 * Unmute ADC0 and set the default input to mic-in
7399 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7400 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7402 /* Unmute DAC0~3 & spdif out*/
7403 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7404 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7405 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7406 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7409 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7410 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7411 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7412 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7413 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7415 /* Unmute Stereo Mixer 15 */
7416 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7417 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
7421 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7422 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7423 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7424 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7425 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7426 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7427 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7430 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7431 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7432 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7433 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7434 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7435 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7436 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7437 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7439 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
7444 static struct hda_verb alc861_toshiba_init_verbs[] = {
7445 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7450 /* toggle speaker-output according to the hp-jack state */
7451 static void alc861_toshiba_automute(struct hda_codec *codec)
7453 unsigned int present;
7455 present = snd_hda_codec_read(codec, 0x0f, 0,
7456 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7457 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
7458 0x80, present ? 0x80 : 0);
7459 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
7460 0x80, present ? 0x80 : 0);
7461 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
7462 0x80, present ? 0 : 0x80);
7463 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
7464 0x80, present ? 0 : 0x80);
7467 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7470 /* Looks like the unsol event is incompatible with the standard
7471 * definition. 6bit tag is placed at 26 bit!
7473 if ((res >> 26) == ALC880_HP_EVENT)
7474 alc861_toshiba_automute(codec);
7477 /* pcm configuration: identiacal with ALC880 */
7478 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
7479 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
7480 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
7481 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
7484 #define ALC861_DIGOUT_NID 0x07
7486 static struct hda_channel_mode alc861_8ch_modes[1] = {
7490 static hda_nid_t alc861_dac_nids[4] = {
7491 /* front, surround, clfe, side */
7492 0x03, 0x06, 0x05, 0x04
7495 static hda_nid_t alc660_dac_nids[3] = {
7496 /* front, clfe, surround */
7500 static hda_nid_t alc861_adc_nids[1] = {
7505 static struct hda_input_mux alc861_capture_source = {
7509 { "Front Mic", 0x3 },
7516 /* fill in the dac_nids table from the parsed pin configuration */
7517 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7522 spec->multiout.dac_nids = spec->private_dac_nids;
7523 for (i = 0; i < cfg->line_outs; i++) {
7524 nid = cfg->line_out_pins[i];
7526 if (i >= ARRAY_SIZE(alc861_dac_nids))
7528 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
7531 spec->multiout.num_dacs = cfg->line_outs;
7535 /* add playback controls from the parsed DAC table */
7536 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7537 const struct auto_pin_cfg *cfg)
7540 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
7544 for (i = 0; i < cfg->line_outs; i++) {
7545 nid = spec->multiout.dac_nids[i];
7550 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
7551 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
7553 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
7554 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
7557 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
7558 if (nid == alc861_dac_nids[idx])
7560 sprintf(name, "%s Playback Switch", chname[idx]);
7561 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7562 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7569 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7577 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7579 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
7580 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7582 spec->multiout.hp_nid = nid;
7587 /* create playback/capture controls for input pins */
7588 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7590 struct hda_input_mux *imux = &spec->private_imux;
7591 int i, err, idx, idx1;
7593 for (i = 0; i < AUTO_PIN_LAST; i++) {
7594 switch(cfg->input_pins[i]) {
7619 err = new_analog_input(spec, cfg->input_pins[i],
7620 auto_pin_cfg_labels[i], idx, 0x15);
7624 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7625 imux->items[imux->num_items].index = idx1;
7631 static struct snd_kcontrol_new alc861_capture_mixer[] = {
7632 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7633 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7637 /* The multiple "Capture Source" controls confuse alsamixer
7638 * So call somewhat different..
7639 *FIXME: the controls appear in the "playback" view!
7641 /* .name = "Capture Source", */
7642 .name = "Input Source",
7644 .info = alc_mux_enum_info,
7645 .get = alc_mux_enum_get,
7646 .put = alc_mux_enum_put,
7651 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
7652 int pin_type, int dac_idx)
7656 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
7657 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
7661 static void alc861_auto_init_multi_out(struct hda_codec *codec)
7663 struct alc_spec *spec = codec->spec;
7666 for (i = 0; i < spec->autocfg.line_outs; i++) {
7667 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7669 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
7673 static void alc861_auto_init_hp_out(struct hda_codec *codec)
7675 struct alc_spec *spec = codec->spec;
7678 pin = spec->autocfg.hp_pins[0];
7679 if (pin) /* connect to front */
7680 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
7683 static void alc861_auto_init_analog_input(struct hda_codec *codec)
7685 struct alc_spec *spec = codec->spec;
7688 for (i = 0; i < AUTO_PIN_LAST; i++) {
7689 hda_nid_t nid = spec->autocfg.input_pins[i];
7690 if ((nid>=0x0c) && (nid <=0x11)) {
7691 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7692 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
7697 /* parse the BIOS configuration and set up the alc_spec */
7698 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
7699 static int alc861_parse_auto_config(struct hda_codec *codec)
7701 struct alc_spec *spec = codec->spec;
7703 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7705 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7706 alc861_ignore)) < 0)
7708 if (! spec->autocfg.line_outs)
7709 return 0; /* can't find valid BIOS pin config */
7711 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
7712 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
7713 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
7714 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
7717 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7719 if (spec->autocfg.dig_out_pin)
7720 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
7722 if (spec->kctl_alloc)
7723 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7725 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
7727 spec->num_mux_defs = 1;
7728 spec->input_mux = &spec->private_imux;
7730 spec->adc_nids = alc861_adc_nids;
7731 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
7732 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
7738 /* additional initialization for auto-configuration model */
7739 static void alc861_auto_init(struct hda_codec *codec)
7741 alc861_auto_init_multi_out(codec);
7742 alc861_auto_init_hp_out(codec);
7743 alc861_auto_init_analog_input(codec);
7748 * configuration and preset
7750 static const char *alc861_models[ALC861_MODEL_LAST] = {
7751 [ALC861_3ST] = "3stack",
7752 [ALC660_3ST] = "3stack-660",
7753 [ALC861_3ST_DIG] = "3stack-dig",
7754 [ALC861_6ST_DIG] = "6stack-dig",
7755 [ALC861_UNIWILL_M31] = "uniwill-m31",
7756 [ALC861_TOSHIBA] = "toshiba",
7757 [ALC861_ASUS] = "asus",
7758 [ALC861_ASUS_LAPTOP] = "asus-laptop",
7759 [ALC861_AUTO] = "auto",
7762 static struct snd_pci_quirk alc861_cfg_tbl[] = {
7763 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
7764 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7765 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7766 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
7767 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
7768 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
7769 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
7770 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
7771 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
7772 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
7776 static struct alc_config_preset alc861_presets[] = {
7778 .mixers = { alc861_3ST_mixer },
7779 .init_verbs = { alc861_threestack_init_verbs },
7780 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7781 .dac_nids = alc861_dac_nids,
7782 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7783 .channel_mode = alc861_threestack_modes,
7785 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7786 .adc_nids = alc861_adc_nids,
7787 .input_mux = &alc861_capture_source,
7789 [ALC861_3ST_DIG] = {
7790 .mixers = { alc861_base_mixer },
7791 .init_verbs = { alc861_threestack_init_verbs },
7792 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7793 .dac_nids = alc861_dac_nids,
7794 .dig_out_nid = ALC861_DIGOUT_NID,
7795 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7796 .channel_mode = alc861_threestack_modes,
7798 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7799 .adc_nids = alc861_adc_nids,
7800 .input_mux = &alc861_capture_source,
7802 [ALC861_6ST_DIG] = {
7803 .mixers = { alc861_base_mixer },
7804 .init_verbs = { alc861_base_init_verbs },
7805 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7806 .dac_nids = alc861_dac_nids,
7807 .dig_out_nid = ALC861_DIGOUT_NID,
7808 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
7809 .channel_mode = alc861_8ch_modes,
7810 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7811 .adc_nids = alc861_adc_nids,
7812 .input_mux = &alc861_capture_source,
7815 .mixers = { alc861_3ST_mixer },
7816 .init_verbs = { alc861_threestack_init_verbs },
7817 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
7818 .dac_nids = alc660_dac_nids,
7819 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7820 .channel_mode = alc861_threestack_modes,
7822 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7823 .adc_nids = alc861_adc_nids,
7824 .input_mux = &alc861_capture_source,
7826 [ALC861_UNIWILL_M31] = {
7827 .mixers = { alc861_uniwill_m31_mixer },
7828 .init_verbs = { alc861_uniwill_m31_init_verbs },
7829 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7830 .dac_nids = alc861_dac_nids,
7831 .dig_out_nid = ALC861_DIGOUT_NID,
7832 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
7833 .channel_mode = alc861_uniwill_m31_modes,
7835 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7836 .adc_nids = alc861_adc_nids,
7837 .input_mux = &alc861_capture_source,
7839 [ALC861_TOSHIBA] = {
7840 .mixers = { alc861_toshiba_mixer },
7841 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
7842 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7843 .dac_nids = alc861_dac_nids,
7844 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7845 .channel_mode = alc883_3ST_2ch_modes,
7846 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7847 .adc_nids = alc861_adc_nids,
7848 .input_mux = &alc861_capture_source,
7849 .unsol_event = alc861_toshiba_unsol_event,
7850 .init_hook = alc861_toshiba_automute,
7853 .mixers = { alc861_asus_mixer },
7854 .init_verbs = { alc861_asus_init_verbs },
7855 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7856 .dac_nids = alc861_dac_nids,
7857 .dig_out_nid = ALC861_DIGOUT_NID,
7858 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
7859 .channel_mode = alc861_asus_modes,
7862 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7863 .adc_nids = alc861_adc_nids,
7864 .input_mux = &alc861_capture_source,
7866 [ALC861_ASUS_LAPTOP] = {
7867 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
7868 .init_verbs = { alc861_asus_init_verbs,
7869 alc861_asus_laptop_init_verbs },
7870 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7871 .dac_nids = alc861_dac_nids,
7872 .dig_out_nid = ALC861_DIGOUT_NID,
7873 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7874 .channel_mode = alc883_3ST_2ch_modes,
7876 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7877 .adc_nids = alc861_adc_nids,
7878 .input_mux = &alc861_capture_source,
7883 static int patch_alc861(struct hda_codec *codec)
7885 struct alc_spec *spec;
7889 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7895 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
7899 if (board_config < 0) {
7900 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
7901 "trying auto-probe from BIOS...\n");
7902 board_config = ALC861_AUTO;
7905 if (board_config == ALC861_AUTO) {
7906 /* automatic parse from the BIOS config */
7907 err = alc861_parse_auto_config(codec);
7913 "hda_codec: Cannot set up configuration "
7914 "from BIOS. Using base mode...\n");
7915 board_config = ALC861_3ST_DIG;
7919 if (board_config != ALC861_AUTO)
7920 setup_preset(spec, &alc861_presets[board_config]);
7922 spec->stream_name_analog = "ALC861 Analog";
7923 spec->stream_analog_playback = &alc861_pcm_analog_playback;
7924 spec->stream_analog_capture = &alc861_pcm_analog_capture;
7926 spec->stream_name_digital = "ALC861 Digital";
7927 spec->stream_digital_playback = &alc861_pcm_digital_playback;
7928 spec->stream_digital_capture = &alc861_pcm_digital_capture;
7930 codec->patch_ops = alc_patch_ops;
7931 if (board_config == ALC861_AUTO)
7932 spec->init_hook = alc861_auto_init;
7942 * In addition, an independent DAC
7944 #define ALC861VD_DIGOUT_NID 0x06
7946 static hda_nid_t alc861vd_dac_nids[4] = {
7947 /* front, surr, clfe, side surr */
7948 0x02, 0x03, 0x04, 0x05
7951 /* dac_nids for ALC660vd are in a different order - according to
7953 * This should probably tesult in a different mixer for 6stack models
7954 * of ALC660vd codecs, but for now there is only 3stack mixer
7955 * - and it is the same as in 861vd.
7956 * adc_nids in ALC660vd are (is) the same as in 861vd
7958 static hda_nid_t alc660vd_dac_nids[3] = {
7959 /* front, rear, clfe, rear_surr */
7963 static hda_nid_t alc861vd_adc_nids[1] = {
7969 /* FIXME: should be a matrix-type input source selection */
7970 static struct hda_input_mux alc861vd_capture_source = {
7974 { "Front Mic", 0x1 },
7980 #define alc861vd_mux_enum_info alc_mux_enum_info
7981 #define alc861vd_mux_enum_get alc_mux_enum_get
7983 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
7984 struct snd_ctl_elem_value *ucontrol)
7986 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7987 struct alc_spec *spec = codec->spec;
7988 const struct hda_input_mux *imux = spec->input_mux;
7989 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
7990 static hda_nid_t capture_mixers[1] = { 0x22 };
7991 hda_nid_t nid = capture_mixers[adc_idx];
7992 unsigned int *cur_val = &spec->cur_mux[adc_idx];
7993 unsigned int i, idx;
7995 idx = ucontrol->value.enumerated.item[0];
7996 if (idx >= imux->num_items)
7997 idx = imux->num_items - 1;
7998 if (*cur_val == idx && ! codec->in_resume)
8000 for (i = 0; i < imux->num_items; i++) {
8001 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
8002 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8003 v | (imux->items[i].index << 8));
8012 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
8019 static struct hda_verb alc861vd_6stack_ch6_init[] = {
8020 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
8021 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8022 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8023 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8030 static struct hda_verb alc861vd_6stack_ch8_init[] = {
8031 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8032 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8033 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8034 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8038 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
8039 { 6, alc861vd_6stack_ch6_init },
8040 { 8, alc861vd_6stack_ch8_init },
8043 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
8045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8046 .name = "Channel Mode",
8047 .info = alc_ch_mode_info,
8048 .get = alc_ch_mode_get,
8049 .put = alc_ch_mode_put,
8054 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
8055 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
8056 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
8059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8060 /* The multiple "Capture Source" controls confuse alsamixer
8061 * So call somewhat different..
8062 *FIXME: the controls appear in the "playback" view!
8064 /* .name = "Capture Source", */
8065 .name = "Input Source",
8067 .info = alc861vd_mux_enum_info,
8068 .get = alc861vd_mux_enum_get,
8069 .put = alc861vd_mux_enum_put,
8074 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
8075 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
8077 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
8078 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
8079 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8081 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
8082 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8084 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
8086 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
8088 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8089 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8091 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
8092 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8100 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8107 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8108 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8110 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
8111 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
8116 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
8117 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
8118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8126 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8127 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8128 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8130 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8131 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8134 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8136 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
8137 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
8143 * generic initialization of ADC, input mixers and output mixers
8145 static struct hda_verb alc861vd_volume_init_verbs[] = {
8147 * Unmute ADC0 and set the default input to mic-in
8149 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8150 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8152 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
8153 * the analog-loopback mixer widget
8155 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8162 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
8163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
8165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
8166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
8169 * Set up output mixers (0x02 - 0x05)
8171 /* set vol=0 to output mixers */
8172 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8173 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8174 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8175 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8177 /* set up input amps for analog loopback */
8178 /* Amp Indices: DAC = 0, mixer = 1 */
8179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8182 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8184 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8185 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8192 * 3-stack pin configuration:
8193 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
8195 static struct hda_verb alc861vd_3stack_init_verbs[] = {
8197 * Set pin mode and muting
8199 /* set front pin widgets 0x14 for output */
8200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8202 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8204 /* Mic (rear) pin: input vref at 80% */
8205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8206 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8207 /* Front Mic pin: input vref at 80% */
8208 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8209 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8210 /* Line In pin: input */
8211 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8212 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8213 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8215 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8216 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8217 /* CD pin widget for input */
8218 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8224 * 6-stack pin configuration:
8226 static struct hda_verb alc861vd_6stack_init_verbs[] = {
8228 * Set pin mode and muting
8230 /* set front pin widgets 0x14 for output */
8231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8233 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8235 /* Rear Pin: output 1 (0x0d) */
8236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8239 /* CLFE Pin: output 2 (0x0e) */
8240 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8242 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8243 /* Side Pin: output 3 (0x0f) */
8244 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8246 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8248 /* Mic (rear) pin: input vref at 80% */
8249 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8251 /* Front Mic pin: input vref at 80% */
8252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8254 /* Line In pin: input */
8255 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8257 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8258 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8260 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8261 /* CD pin widget for input */
8262 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8267 /* pcm configuration: identiacal with ALC880 */
8268 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
8269 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
8270 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
8271 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
8274 * configuration and preset
8276 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
8277 [ALC660VD_3ST] = "3stack-660",
8278 [ALC861VD_3ST] = "3stack",
8279 [ALC861VD_3ST_DIG] = "3stack-digout",
8280 [ALC861VD_6ST_DIG] = "6stack-digout",
8281 [ALC861VD_AUTO] = "auto",
8284 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
8285 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
8286 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
8287 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
8289 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST),
8293 static struct alc_config_preset alc861vd_presets[] = {
8295 .mixers = { alc861vd_3st_mixer },
8296 .init_verbs = { alc861vd_volume_init_verbs,
8297 alc861vd_3stack_init_verbs },
8298 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
8299 .dac_nids = alc660vd_dac_nids,
8300 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
8301 .adc_nids = alc861vd_adc_nids,
8302 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
8303 .channel_mode = alc861vd_3stack_2ch_modes,
8304 .input_mux = &alc861vd_capture_source,
8307 .mixers = { alc861vd_3st_mixer },
8308 .init_verbs = { alc861vd_volume_init_verbs,
8309 alc861vd_3stack_init_verbs },
8310 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
8311 .dac_nids = alc861vd_dac_nids,
8312 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
8313 .channel_mode = alc861vd_3stack_2ch_modes,
8314 .input_mux = &alc861vd_capture_source,
8316 [ALC861VD_3ST_DIG] = {
8317 .mixers = { alc861vd_3st_mixer },
8318 .init_verbs = { alc861vd_volume_init_verbs,
8319 alc861vd_3stack_init_verbs },
8320 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
8321 .dac_nids = alc861vd_dac_nids,
8322 .dig_out_nid = ALC861VD_DIGOUT_NID,
8323 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
8324 .channel_mode = alc861vd_3stack_2ch_modes,
8325 .input_mux = &alc861vd_capture_source,
8327 [ALC861VD_6ST_DIG] = {
8328 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
8329 .init_verbs = { alc861vd_volume_init_verbs,
8330 alc861vd_6stack_init_verbs },
8331 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
8332 .dac_nids = alc861vd_dac_nids,
8333 .dig_out_nid = ALC861VD_DIGOUT_NID,
8334 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
8335 .channel_mode = alc861vd_6stack_modes,
8336 .input_mux = &alc861vd_capture_source,
8341 * BIOS auto configuration
8343 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
8344 hda_nid_t nid, int pin_type, int dac_idx)
8347 snd_hda_codec_write(codec, nid, 0,
8348 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
8349 snd_hda_codec_write(codec, nid, 0,
8350 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
8353 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
8355 struct alc_spec *spec = codec->spec;
8358 for (i = 0; i <= HDA_SIDE; i++) {
8359 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8361 alc861vd_auto_set_output_and_unmute(codec, nid,
8367 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
8369 struct alc_spec *spec = codec->spec;
8372 pin = spec->autocfg.hp_pins[0];
8373 if (pin) /* connect to front and use dac 0 */
8374 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
8377 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
8378 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
8380 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
8382 struct alc_spec *spec = codec->spec;
8385 for (i = 0; i < AUTO_PIN_LAST; i++) {
8386 hda_nid_t nid = spec->autocfg.input_pins[i];
8387 if (alc861vd_is_input_pin(nid)) {
8388 snd_hda_codec_write(codec, nid, 0,
8389 AC_VERB_SET_PIN_WIDGET_CONTROL,
8390 i <= AUTO_PIN_FRONT_MIC ?
8391 PIN_VREF80 : PIN_IN);
8392 if (nid != ALC861VD_PIN_CD_NID)
8393 snd_hda_codec_write(codec, nid, 0,
8394 AC_VERB_SET_AMP_GAIN_MUTE,
8400 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
8401 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
8403 /* add playback controls from the parsed DAC table */
8404 /* Based on ALC880 version. But ALC861VD has separate,
8405 * different NIDs for mute/unmute switch and volume control */
8406 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8407 const struct auto_pin_cfg *cfg)
8410 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
8411 hda_nid_t nid_v, nid_s;
8414 for (i = 0; i < cfg->line_outs; i++) {
8415 if (! spec->multiout.dac_nids[i])
8417 nid_v = alc861vd_idx_to_mixer_vol(
8419 spec->multiout.dac_nids[i]));
8420 nid_s = alc861vd_idx_to_mixer_switch(
8422 spec->multiout.dac_nids[i]));
8426 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
8427 "Center Playback Volume",
8428 HDA_COMPOSE_AMP_VAL(nid_v, 1,
8429 0, HDA_OUTPUT))) < 0)
8431 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL,
8432 "LFE Playback Volume",
8433 HDA_COMPOSE_AMP_VAL(nid_v, 2,
8434 0, HDA_OUTPUT))) < 0)
8436 if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
8437 "Center Playback Switch",
8438 HDA_COMPOSE_AMP_VAL(nid_s, 1,
8439 2, HDA_INPUT))) < 0)
8441 if ((err = add_control(spec, ALC_CTL_BIND_MUTE,
8442 "LFE Playback Switch",
8443 HDA_COMPOSE_AMP_VAL(nid_s, 2,
8444 2, HDA_INPUT))) < 0)
8447 sprintf(name, "%s Playback Volume", chname[i]);
8448 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8449 HDA_COMPOSE_AMP_VAL(nid_v, 3,
8450 0, HDA_OUTPUT))) < 0)
8452 sprintf(name, "%s Playback Switch", chname[i]);
8453 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8454 HDA_COMPOSE_AMP_VAL(nid_v, 3,
8455 2, HDA_INPUT))) < 0)
8462 /* add playback controls for speaker and HP outputs */
8463 /* Based on ALC880 version. But ALC861VD has separate,
8464 * different NIDs for mute/unmute switch and volume control */
8465 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8466 hda_nid_t pin, const char *pfx)
8468 hda_nid_t nid_v, nid_s;
8475 if (alc880_is_fixed_pin(pin)) {
8476 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
8477 /* specify the DAC as the extra output */
8478 if (! spec->multiout.hp_nid)
8479 spec->multiout.hp_nid = nid_v;
8481 spec->multiout.extra_out_nid[0] = nid_v;
8482 /* control HP volume/switch on the output mixer amp */
8483 nid_v = alc861vd_idx_to_mixer_vol(
8484 alc880_fixed_pin_idx(pin));
8485 nid_s = alc861vd_idx_to_mixer_switch(
8486 alc880_fixed_pin_idx(pin));
8488 sprintf(name, "%s Playback Volume", pfx);
8489 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8490 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
8493 sprintf(name, "%s Playback Switch", pfx);
8494 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8495 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
8498 } else if (alc880_is_multi_pin(pin)) {
8499 /* set manual connection */
8500 /* we have only a switch on HP-out PIN */
8501 sprintf(name, "%s Playback Switch", pfx);
8502 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8503 HDA_COMPOSE_AMP_VAL(pin, 3, 0,
8510 /* parse the BIOS configuration and set up the alc_spec
8511 * return 1 if successful, 0 if the proper config is not found,
8512 * or a negative error code
8513 * Based on ALC880 version - had to change it to override
8514 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
8515 static int alc861vd_parse_auto_config(struct hda_codec *codec)
8517 struct alc_spec *spec = codec->spec;
8519 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8521 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8522 alc861vd_ignore)) < 0)
8524 if (! spec->autocfg.line_outs)
8525 return 0; /* can't find valid BIOS pin config */
8527 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
8528 (err = alc861vd_auto_create_multi_out_ctls(spec,
8529 &spec->autocfg)) < 0 ||
8530 (err = alc861vd_auto_create_extra_out(spec,
8531 spec->autocfg.speaker_pins[0], "Speaker")) < 0 ||
8532 (err = alc861vd_auto_create_extra_out(spec,
8533 spec->autocfg.hp_pins[0], "Headphone")) < 0 ||
8534 (err = alc880_auto_create_analog_input_ctls(spec,
8535 &spec->autocfg)) < 0)
8538 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8540 if (spec->autocfg.dig_out_pin)
8541 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
8543 if (spec->kctl_alloc)
8544 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8546 spec->init_verbs[spec->num_init_verbs++]
8547 = alc861vd_volume_init_verbs;
8549 spec->num_mux_defs = 1;
8550 spec->input_mux = &spec->private_imux;
8555 /* additional initialization for auto-configuration model */
8556 static void alc861vd_auto_init(struct hda_codec *codec)
8558 alc861vd_auto_init_multi_out(codec);
8559 alc861vd_auto_init_hp_out(codec);
8560 alc861vd_auto_init_analog_input(codec);
8563 static int patch_alc861vd(struct hda_codec *codec)
8565 struct alc_spec *spec;
8566 int err, board_config;
8568 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8574 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
8578 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
8579 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
8580 "ALC861VD, trying auto-probe from BIOS...\n");
8581 board_config = ALC861VD_AUTO;
8584 if (board_config == ALC861VD_AUTO) {
8585 /* automatic parse from the BIOS config */
8586 err = alc861vd_parse_auto_config(codec);
8592 "hda_codec: Cannot set up configuration "
8593 "from BIOS. Using base mode...\n");
8594 board_config = ALC861VD_3ST;
8598 if (board_config != ALC861VD_AUTO)
8599 setup_preset(spec, &alc861vd_presets[board_config]);
8601 spec->stream_name_analog = "ALC861VD Analog";
8602 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
8603 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
8605 spec->stream_name_digital = "ALC861VD Digital";
8606 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
8607 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
8609 spec->adc_nids = alc861vd_adc_nids;
8610 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
8612 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
8615 codec->patch_ops = alc_patch_ops;
8617 if (board_config == ALC861VD_AUTO)
8618 spec->init_hook = alc861vd_auto_init;
8626 struct hda_codec_preset snd_hda_preset_realtek[] = {
8627 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
8628 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
8629 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
8630 .patch = patch_alc861 },
8631 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
8632 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
8633 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
8634 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
8635 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
8636 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
8637 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
8638 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },