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 */
92 ALC262_MODEL_LAST /* last tag */
123 ALC883_TARGA_2ch_DIG,
132 #define GPIO_MASK 0x03
135 /* codec parameterization */
136 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
137 unsigned int num_mixers;
139 const struct hda_verb *init_verbs[5]; /* initialization verbs
143 unsigned int num_init_verbs;
145 char *stream_name_analog; /* analog PCM stream */
146 struct hda_pcm_stream *stream_analog_playback;
147 struct hda_pcm_stream *stream_analog_capture;
149 char *stream_name_digital; /* digital PCM stream */
150 struct hda_pcm_stream *stream_digital_playback;
151 struct hda_pcm_stream *stream_digital_capture;
154 struct hda_multi_out multiout; /* playback set-up
155 * max_channels, dacs must be set
156 * dig_out_nid and hp_nid are optional
160 unsigned int num_adc_nids;
162 hda_nid_t dig_in_nid; /* digital-in NID; optional */
165 unsigned int num_mux_defs;
166 const struct hda_input_mux *input_mux;
167 unsigned int cur_mux[3];
170 const struct hda_channel_mode *channel_mode;
171 int num_channel_mode;
174 /* PCM information */
175 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
177 /* dynamic controls, init_verbs and input_mux */
178 struct auto_pin_cfg autocfg;
179 unsigned int num_kctl_alloc, num_kctl_used;
180 struct snd_kcontrol_new *kctl_alloc;
181 struct hda_input_mux private_imux;
182 hda_nid_t private_dac_nids[5];
185 void (*init_hook)(struct hda_codec *codec);
186 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
188 /* for pin sensing */
189 unsigned int sense_updated: 1;
190 unsigned int jack_present: 1;
194 * configuration template - to be copied to the spec instance
196 struct alc_config_preset {
197 struct snd_kcontrol_new *mixers[5]; /* should be identical size
200 const struct hda_verb *init_verbs[5];
201 unsigned int num_dacs;
203 hda_nid_t dig_out_nid; /* optional */
204 hda_nid_t hp_nid; /* optional */
205 unsigned int num_adc_nids;
207 hda_nid_t dig_in_nid;
208 unsigned int num_channel_mode;
209 const struct hda_channel_mode *channel_mode;
211 unsigned int num_mux_defs;
212 const struct hda_input_mux *input_mux;
213 void (*unsol_event)(struct hda_codec *, unsigned int);
214 void (*init_hook)(struct hda_codec *);
221 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
222 struct snd_ctl_elem_info *uinfo)
224 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
225 struct alc_spec *spec = codec->spec;
226 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
227 if (mux_idx >= spec->num_mux_defs)
229 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
232 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
233 struct snd_ctl_elem_value *ucontrol)
235 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
236 struct alc_spec *spec = codec->spec;
237 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
239 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
243 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
244 struct snd_ctl_elem_value *ucontrol)
246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
247 struct alc_spec *spec = codec->spec;
248 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
249 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
250 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
251 spec->adc_nids[adc_idx],
252 &spec->cur_mux[adc_idx]);
257 * channel mode setting
259 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
260 struct snd_ctl_elem_info *uinfo)
262 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
263 struct alc_spec *spec = codec->spec;
264 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
265 spec->num_channel_mode);
268 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
269 struct snd_ctl_elem_value *ucontrol)
271 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
272 struct alc_spec *spec = codec->spec;
273 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
274 spec->num_channel_mode,
275 spec->multiout.max_channels);
278 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
279 struct snd_ctl_elem_value *ucontrol)
281 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
282 struct alc_spec *spec = codec->spec;
283 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
284 spec->num_channel_mode,
285 &spec->multiout.max_channels);
286 if (err >= 0 && spec->need_dac_fix)
287 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
292 * Control the mode of pin widget settings via the mixer. "pc" is used
293 * instead of "%" to avoid consequences of accidently treating the % as
294 * being part of a format specifier. Maximum allowed length of a value is
295 * 63 characters plus NULL terminator.
297 * Note: some retasking pin complexes seem to ignore requests for input
298 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
299 * are requested. Therefore order this list so that this behaviour will not
300 * cause problems when mixer clients move through the enum sequentially.
301 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
304 static char *alc_pin_mode_names[] = {
305 "Mic 50pc bias", "Mic 80pc bias",
306 "Line in", "Line out", "Headphone out",
308 static unsigned char alc_pin_mode_values[] = {
309 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
311 /* The control can present all 5 options, or it can limit the options based
312 * in the pin being assumed to be exclusively an input or an output pin. In
313 * addition, "input" pins may or may not process the mic bias option
314 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
315 * accept requests for bias as of chip versions up to March 2006) and/or
316 * wiring in the computer.
318 #define ALC_PIN_DIR_IN 0x00
319 #define ALC_PIN_DIR_OUT 0x01
320 #define ALC_PIN_DIR_INOUT 0x02
321 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
322 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
324 /* Info about the pin modes supported by the different pin direction modes.
325 * For each direction the minimum and maximum values are given.
327 static signed char alc_pin_mode_dir_info[5][2] = {
328 { 0, 2 }, /* ALC_PIN_DIR_IN */
329 { 3, 4 }, /* ALC_PIN_DIR_OUT */
330 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
331 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
332 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
334 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
335 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
336 #define alc_pin_mode_n_items(_dir) \
337 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
339 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
340 struct snd_ctl_elem_info *uinfo)
342 unsigned int item_num = uinfo->value.enumerated.item;
343 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
345 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
347 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
349 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
350 item_num = alc_pin_mode_min(dir);
351 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
355 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_value *ucontrol)
359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 hda_nid_t nid = kcontrol->private_value & 0xffff;
361 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
362 long *valp = ucontrol->value.integer.value;
363 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
364 AC_VERB_GET_PIN_WIDGET_CONTROL,
367 /* Find enumerated value for current pinctl setting */
368 i = alc_pin_mode_min(dir);
369 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
371 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
375 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_value *ucontrol)
379 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
380 hda_nid_t nid = kcontrol->private_value & 0xffff;
381 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
382 long val = *ucontrol->value.integer.value;
383 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
384 AC_VERB_GET_PIN_WIDGET_CONTROL,
387 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
388 val = alc_pin_mode_min(dir);
390 change = pinctl != alc_pin_mode_values[val];
392 /* Set pin mode to that requested */
393 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
394 alc_pin_mode_values[val]);
396 /* Also enable the retasking pin's input/output as required
397 * for the requested pin mode. Enum values of 2 or less are
400 * Dynamically switching the input/output buffers probably
401 * reduces noise slightly (particularly on input) so we'll
402 * do it. However, having both input and output buffers
403 * enabled simultaneously doesn't seem to be problematic if
404 * this turns out to be necessary in the future.
407 snd_hda_codec_write(codec, nid, 0,
408 AC_VERB_SET_AMP_GAIN_MUTE,
410 snd_hda_codec_write(codec, nid, 0,
411 AC_VERB_SET_AMP_GAIN_MUTE,
414 snd_hda_codec_write(codec, nid, 0,
415 AC_VERB_SET_AMP_GAIN_MUTE,
417 snd_hda_codec_write(codec, nid, 0,
418 AC_VERB_SET_AMP_GAIN_MUTE,
425 #define ALC_PIN_MODE(xname, nid, dir) \
426 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
427 .info = alc_pin_mode_info, \
428 .get = alc_pin_mode_get, \
429 .put = alc_pin_mode_put, \
430 .private_value = nid | (dir<<16) }
432 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
433 * together using a mask with more than one bit set. This control is
434 * currently used only by the ALC260 test model. At this stage they are not
435 * needed for any "production" models.
437 #ifdef CONFIG_SND_DEBUG
438 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
439 struct snd_ctl_elem_info *uinfo)
441 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
443 uinfo->value.integer.min = 0;
444 uinfo->value.integer.max = 1;
447 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_value *ucontrol)
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 hda_nid_t nid = kcontrol->private_value & 0xffff;
452 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
453 long *valp = ucontrol->value.integer.value;
454 unsigned int val = snd_hda_codec_read(codec, nid, 0,
455 AC_VERB_GET_GPIO_DATA, 0x00);
457 *valp = (val & mask) != 0;
460 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_value *ucontrol)
464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
465 hda_nid_t nid = kcontrol->private_value & 0xffff;
466 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
467 long val = *ucontrol->value.integer.value;
468 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
469 AC_VERB_GET_GPIO_DATA,
472 /* Set/unset the masked GPIO bit(s) as needed */
473 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
478 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
482 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
483 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
484 .info = alc_gpio_data_info, \
485 .get = alc_gpio_data_get, \
486 .put = alc_gpio_data_put, \
487 .private_value = nid | (mask<<16) }
488 #endif /* CONFIG_SND_DEBUG */
490 /* A switch control to allow the enabling of the digital IO pins on the
491 * ALC260. This is incredibly simplistic; the intention of this control is
492 * to provide something in the test model allowing digital outputs to be
493 * identified if present. If models are found which can utilise these
494 * outputs a more complete mixer control can be devised for those models if
497 #ifdef CONFIG_SND_DEBUG
498 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
499 struct snd_ctl_elem_info *uinfo)
501 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
503 uinfo->value.integer.min = 0;
504 uinfo->value.integer.max = 1;
507 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol)
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 hda_nid_t nid = kcontrol->private_value & 0xffff;
512 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
513 long *valp = ucontrol->value.integer.value;
514 unsigned int val = snd_hda_codec_read(codec, nid, 0,
515 AC_VERB_GET_DIGI_CONVERT, 0x00);
517 *valp = (val & mask) != 0;
520 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_value *ucontrol)
524 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
525 hda_nid_t nid = kcontrol->private_value & 0xffff;
526 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
527 long val = *ucontrol->value.integer.value;
528 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
529 AC_VERB_GET_DIGI_CONVERT,
532 /* Set/unset the masked control bit(s) as needed */
533 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
538 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
543 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
544 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
545 .info = alc_spdif_ctrl_info, \
546 .get = alc_spdif_ctrl_get, \
547 .put = alc_spdif_ctrl_put, \
548 .private_value = nid | (mask<<16) }
549 #endif /* CONFIG_SND_DEBUG */
552 * set up from the preset table
554 static void setup_preset(struct alc_spec *spec,
555 const struct alc_config_preset *preset)
559 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
560 spec->mixers[spec->num_mixers++] = preset->mixers[i];
561 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
563 spec->init_verbs[spec->num_init_verbs++] =
564 preset->init_verbs[i];
566 spec->channel_mode = preset->channel_mode;
567 spec->num_channel_mode = preset->num_channel_mode;
568 spec->need_dac_fix = preset->need_dac_fix;
570 spec->multiout.max_channels = spec->channel_mode[0].channels;
572 spec->multiout.num_dacs = preset->num_dacs;
573 spec->multiout.dac_nids = preset->dac_nids;
574 spec->multiout.dig_out_nid = preset->dig_out_nid;
575 spec->multiout.hp_nid = preset->hp_nid;
577 spec->num_mux_defs = preset->num_mux_defs;
578 if (! spec->num_mux_defs)
579 spec->num_mux_defs = 1;
580 spec->input_mux = preset->input_mux;
582 spec->num_adc_nids = preset->num_adc_nids;
583 spec->adc_nids = preset->adc_nids;
584 spec->dig_in_nid = preset->dig_in_nid;
586 spec->unsol_event = preset->unsol_event;
587 spec->init_hook = preset->init_hook;
591 * ALC880 3-stack model
593 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
594 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
595 * F-Mic = 0x1b, HP = 0x19
598 static hda_nid_t alc880_dac_nids[4] = {
599 /* front, rear, clfe, rear_surr */
600 0x02, 0x05, 0x04, 0x03
603 static hda_nid_t alc880_adc_nids[3] = {
608 /* The datasheet says the node 0x07 is connected from inputs,
609 * but it shows zero connection in the real implementation on some devices.
610 * Note: this is a 915GAV bug, fixed on 915GLV
612 static hda_nid_t alc880_adc_nids_alt[2] = {
617 #define ALC880_DIGOUT_NID 0x06
618 #define ALC880_DIGIN_NID 0x0a
620 static struct hda_input_mux alc880_capture_source = {
624 { "Front Mic", 0x3 },
630 /* channel source setting (2/6 channel selection for 3-stack) */
632 static struct hda_verb alc880_threestack_ch2_init[] = {
633 /* set line-in to input, mute it */
634 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
635 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
636 /* set mic-in to input vref 80%, mute it */
637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
643 static struct hda_verb alc880_threestack_ch6_init[] = {
644 /* set line-in to output, unmute it */
645 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
646 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
647 /* set mic-in to output, unmute it */
648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
653 static struct hda_channel_mode alc880_threestack_modes[2] = {
654 { 2, alc880_threestack_ch2_init },
655 { 6, alc880_threestack_ch6_init },
658 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
659 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
660 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
662 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
663 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
664 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
665 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
666 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
667 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
668 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
673 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
674 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
675 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
676 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
680 .name = "Channel Mode",
681 .info = alc_ch_mode_info,
682 .get = alc_ch_mode_get,
683 .put = alc_ch_mode_put,
688 /* capture mixer elements */
689 static struct snd_kcontrol_new alc880_capture_mixer[] = {
690 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
691 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
692 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
693 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
694 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
695 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
698 /* The multiple "Capture Source" controls confuse alsamixer
699 * So call somewhat different..
700 * FIXME: the controls appear in the "playback" view!
702 /* .name = "Capture Source", */
703 .name = "Input Source",
705 .info = alc_mux_enum_info,
706 .get = alc_mux_enum_get,
707 .put = alc_mux_enum_put,
712 /* capture mixer elements (in case NID 0x07 not available) */
713 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
714 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
715 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
716 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
717 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
720 /* The multiple "Capture Source" controls confuse alsamixer
721 * So call somewhat different..
722 * FIXME: the controls appear in the "playback" view!
724 /* .name = "Capture Source", */
725 .name = "Input Source",
727 .info = alc_mux_enum_info,
728 .get = alc_mux_enum_get,
729 .put = alc_mux_enum_put,
737 * ALC880 5-stack model
739 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
741 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
742 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
745 /* additional mixers to alc880_three_stack_mixer */
746 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
747 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
748 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
752 /* channel source setting (6/8 channel selection for 5-stack) */
754 static struct hda_verb alc880_fivestack_ch6_init[] = {
755 /* set line-in to input, mute it */
756 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
757 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
762 static struct hda_verb alc880_fivestack_ch8_init[] = {
763 /* set line-in to output, unmute it */
764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
769 static struct hda_channel_mode alc880_fivestack_modes[2] = {
770 { 6, alc880_fivestack_ch6_init },
771 { 8, alc880_fivestack_ch8_init },
776 * ALC880 6-stack model
778 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
780 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
781 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
784 static hda_nid_t alc880_6st_dac_nids[4] = {
785 /* front, rear, clfe, rear_surr */
786 0x02, 0x03, 0x04, 0x05
789 static struct hda_input_mux alc880_6stack_capture_source = {
793 { "Front Mic", 0x1 },
799 /* fixed 8-channels */
800 static struct hda_channel_mode alc880_sixstack_modes[1] = {
804 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
807 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
808 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
809 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
810 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
811 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
812 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
813 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
814 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
821 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
822 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
823 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
824 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
826 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
827 .name = "Channel Mode",
828 .info = alc_ch_mode_info,
829 .get = alc_ch_mode_get,
830 .put = alc_ch_mode_put,
839 * W810 has rear IO for:
842 * Center/LFE (DAC 04)
845 * The system also has a pair of internal speakers, and a headphone jack.
846 * These are both connected to Line2 on the codec, hence to DAC 02.
848 * There is a variable resistor to control the speaker or headphone
849 * volume. This is a hardware-only device without a software API.
851 * Plugging headphones in will disable the internal speakers. This is
852 * implemented in hardware, not via the driver using jack sense. In
853 * a similar fashion, plugging into the rear socket marked "front" will
854 * disable both the speakers and headphones.
856 * For input, there's a microphone jack, and an "audio in" jack.
857 * These may not do anything useful with this driver yet, because I
858 * haven't setup any initialization verbs for these yet...
861 static hda_nid_t alc880_w810_dac_nids[3] = {
862 /* front, rear/surround, clfe */
866 /* fixed 6 channels */
867 static struct hda_channel_mode alc880_w810_modes[1] = {
871 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
872 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
873 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
874 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
875 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
876 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
877 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
878 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
879 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
880 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
889 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
890 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
894 static hda_nid_t alc880_z71v_dac_nids[1] = {
897 #define ALC880_Z71V_HP_DAC 0x03
899 /* fixed 2 channels */
900 static struct hda_channel_mode alc880_2_jack_modes[1] = {
904 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
906 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
908 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
909 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
910 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
921 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
922 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
925 static hda_nid_t alc880_f1734_dac_nids[1] = {
928 #define ALC880_F1734_HP_DAC 0x02
930 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
931 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
932 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
933 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
934 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
935 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
936 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
947 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
948 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
949 * Mic = 0x18, Line = 0x1a
952 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
953 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
955 static struct snd_kcontrol_new alc880_asus_mixer[] = {
956 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
957 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
958 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
959 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
960 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
961 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
962 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
963 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
964 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
965 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
966 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
967 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
968 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
972 .name = "Channel Mode",
973 .info = alc_ch_mode_info,
974 .get = alc_ch_mode_get,
975 .put = alc_ch_mode_put,
982 * ALC880 ASUS W1V model
984 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
985 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
986 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
989 /* additional mixers to alc880_asus_mixer */
990 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
991 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
992 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
996 /* additional mixers to alc880_asus_mixer */
997 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
998 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
999 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1004 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1006 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1009 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1012 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1013 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1016 /* The multiple "Capture Source" controls confuse alsamixer
1017 * So call somewhat different..
1018 * FIXME: the controls appear in the "playback" view!
1020 /* .name = "Capture Source", */
1021 .name = "Input Source",
1023 .info = alc_mux_enum_info,
1024 .get = alc_mux_enum_get,
1025 .put = alc_mux_enum_put,
1031 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1032 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1033 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1034 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1035 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1036 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1038 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1039 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1040 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1041 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1045 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1046 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1047 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1048 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1049 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1052 .name = "Channel Mode",
1053 .info = alc_ch_mode_info,
1054 .get = alc_ch_mode_get,
1055 .put = alc_ch_mode_put,
1060 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1061 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1062 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1063 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1064 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1065 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1066 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1071 * build control elements
1073 static int alc_build_controls(struct hda_codec *codec)
1075 struct alc_spec *spec = codec->spec;
1079 for (i = 0; i < spec->num_mixers; i++) {
1080 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1085 if (spec->multiout.dig_out_nid) {
1086 err = snd_hda_create_spdif_out_ctls(codec,
1087 spec->multiout.dig_out_nid);
1091 if (spec->dig_in_nid) {
1092 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1101 * initialize the codec volumes, etc
1105 * generic initialization of ADC, input mixers and output mixers
1107 static struct hda_verb alc880_volume_init_verbs[] = {
1109 * Unmute ADC0-2 and set the default input to mic-in
1111 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1113 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1115 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1118 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1120 * Note: PASD motherboards uses the Line In 2 as the input for front
1123 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1131 * Set up output mixers (0x0c - 0x0f)
1133 /* set vol=0 to output mixers */
1134 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1137 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1138 /* set up input amps for analog loopback */
1139 /* Amp Indices: DAC = 0, mixer = 1 */
1140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1143 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1153 * 3-stack pin configuration:
1154 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1156 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1158 * preset connection lists of input pins
1159 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1161 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1162 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1163 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1166 * Set pin mode and muting
1168 /* set front pin widgets 0x14 for output */
1169 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1170 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1171 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1173 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1174 /* Mic2 (as headphone out) for HP output */
1175 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1176 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1177 /* Line In pin widget for input */
1178 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1179 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1180 /* Line2 (as front mic) pin widget for input and vref at 80% */
1181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1182 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1183 /* CD pin widget for input */
1184 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1190 * 5-stack pin configuration:
1191 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1192 * line-in/side = 0x1a, f-mic = 0x1b
1194 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1196 * preset connection lists of input pins
1197 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1199 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1200 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1203 * Set pin mode and muting
1205 /* set pin widgets 0x14-0x17 for output */
1206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1207 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1208 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1209 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1210 /* unmute pins for output (no gain on this amp) */
1211 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1213 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1214 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1216 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1217 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1218 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1219 /* Mic2 (as headphone out) for HP output */
1220 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1221 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1222 /* Line In pin widget for input */
1223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1224 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1225 /* Line2 (as front mic) pin widget for input and vref at 80% */
1226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1228 /* CD pin widget for input */
1229 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1235 * W810 pin configuration:
1236 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1238 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1239 /* hphone/speaker input selector: front DAC */
1240 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1243 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1245 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1246 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1247 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1256 * Z71V pin configuration:
1257 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1259 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1266 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1267 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1268 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1274 * 6-stack pin configuration:
1275 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1276 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1278 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1279 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1285 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1286 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1288 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1292 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1293 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1294 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1296 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1297 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1298 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1304 * Uniwill pin configuration:
1305 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1308 static struct hda_verb alc880_uniwill_init_verbs[] = {
1309 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1312 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1314 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1315 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1316 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1317 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1318 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1322 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1324 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1326 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1327 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1328 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1329 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1330 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1331 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1332 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1333 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1334 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1336 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1337 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1344 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1346 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1347 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1353 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1354 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1358 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1359 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1360 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1363 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1364 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1365 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1366 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1367 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1369 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1370 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1375 /* toggle speaker-output according to the hp-jack state */
1376 static void alc880_uniwill_automute(struct hda_codec *codec)
1378 unsigned int present;
1380 present = snd_hda_codec_read(codec, 0x14, 0,
1381 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1382 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1383 0x80, present ? 0x80 : 0);
1384 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1385 0x80, present ? 0x80 : 0);
1386 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1387 0x80, present ? 0x80 : 0);
1388 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1389 0x80, present ? 0x80 : 0);
1391 present = snd_hda_codec_read(codec, 0x18, 0,
1392 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1393 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1394 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
1397 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1400 /* Looks like the unsol event is incompatible with the standard
1401 * definition. 4bit tag is placed at 28 bit!
1403 if ((res >> 28) == ALC880_HP_EVENT ||
1404 (res >> 28) == ALC880_MIC_EVENT)
1405 alc880_uniwill_automute(codec);
1408 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1410 unsigned int present;
1412 present = snd_hda_codec_read(codec, 0x14, 0,
1413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1415 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1416 0x80, present ? 0x80 : 0);
1417 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1418 0x80, present ? 0x80 : 0);
1421 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1423 unsigned int present;
1425 present = snd_hda_codec_read(codec, 0x21, 0,
1426 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
1428 snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
1430 snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
1433 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
1435 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
1439 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1442 /* Looks like the unsol event is incompatible with the standard
1443 * definition. 4bit tag is placed at 28 bit!
1445 if ((res >> 28) == ALC880_HP_EVENT)
1446 alc880_uniwill_p53_hp_automute(codec);
1447 if ((res >> 28) == ALC880_DCVOL_EVENT)
1448 alc880_uniwill_p53_dcvol_automute(codec);
1453 * F1734 pin configuration:
1454 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1456 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1457 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1458 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1459 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1460 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1469 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1471 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1472 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1474 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1475 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1482 * ASUS pin configuration:
1483 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1485 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1486 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1487 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1488 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1489 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1495 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1503 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1506 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1508 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1513 /* Enable GPIO mask and set output */
1514 static struct hda_verb alc880_gpio1_init_verbs[] = {
1515 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1516 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1517 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1522 /* Enable GPIO mask and set output */
1523 static struct hda_verb alc880_gpio2_init_verbs[] = {
1524 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1525 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1526 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1531 /* Clevo m520g init */
1532 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1533 /* headphone output */
1534 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1537 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1540 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1542 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1543 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1544 /* Mic1 (rear panel) */
1545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1547 /* Mic2 (front panel) */
1548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1549 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1551 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1553 /* change to EAPD mode */
1554 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1555 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1560 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1561 /* change to EAPD mode */
1562 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1563 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1565 /* Headphone output */
1566 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1568 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1569 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1571 /* Line In pin widget for input */
1572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1573 /* CD pin widget for input */
1574 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1575 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1576 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1578 /* change to EAPD mode */
1579 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1580 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1586 * LG m1 express dual
1589 * Rear Line-In/Out (blue): 0x14
1590 * Build-in Mic-In: 0x15
1592 * HP-Out (green): 0x1b
1593 * Mic-In/Out (red): 0x19
1597 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1598 static hda_nid_t alc880_lg_dac_nids[3] = {
1602 /* seems analog CD is not working */
1603 static struct hda_input_mux alc880_lg_capture_source = {
1608 { "Internal Mic", 0x6 },
1612 /* 2,4,6 channel modes */
1613 static struct hda_verb alc880_lg_ch2_init[] = {
1614 /* set line-in and mic-in to input */
1615 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1616 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1620 static struct hda_verb alc880_lg_ch4_init[] = {
1621 /* set line-in to out and mic-in to input */
1622 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1623 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1627 static struct hda_verb alc880_lg_ch6_init[] = {
1628 /* set line-in and mic-in to output */
1629 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1630 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1634 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1635 { 2, alc880_lg_ch2_init },
1636 { 4, alc880_lg_ch4_init },
1637 { 6, alc880_lg_ch6_init },
1640 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1641 /* FIXME: it's not really "master" but front channels */
1642 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1643 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1644 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1645 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1646 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1647 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1648 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1649 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1651 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1653 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1654 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1655 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1658 .name = "Channel Mode",
1659 .info = alc_ch_mode_info,
1660 .get = alc_ch_mode_get,
1661 .put = alc_ch_mode_put,
1666 static struct hda_verb alc880_lg_init_verbs[] = {
1667 /* set capture source to mic-in */
1668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1669 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1670 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1671 /* mute all amp mixer inputs */
1672 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1673 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1675 /* line-in to input */
1676 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1677 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1682 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1683 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1684 /* mic-in to input */
1685 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1689 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1690 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1691 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1693 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1697 /* toggle speaker-output according to the hp-jack state */
1698 static void alc880_lg_automute(struct hda_codec *codec)
1700 unsigned int present;
1702 present = snd_hda_codec_read(codec, 0x1b, 0,
1703 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1704 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1705 0x80, present ? 0x80 : 0);
1706 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1707 0x80, present ? 0x80 : 0);
1710 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1712 /* Looks like the unsol event is incompatible with the standard
1713 * definition. 4bit tag is placed at 28 bit!
1715 if ((res >> 28) == 0x01)
1716 alc880_lg_automute(codec);
1725 * Built-in Mic-In: 0x19 (?)
1730 /* seems analog CD is not working */
1731 static struct hda_input_mux alc880_lg_lw_capture_source = {
1735 { "Internal Mic", 0x1 },
1739 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1740 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1741 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1744 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1745 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1749 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1750 /* set capture source to mic-in */
1751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1752 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1753 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1759 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1762 /* mic-in to input */
1763 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1766 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1769 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1773 /* toggle speaker-output according to the hp-jack state */
1774 static void alc880_lg_lw_automute(struct hda_codec *codec)
1776 unsigned int present;
1778 present = snd_hda_codec_read(codec, 0x1b, 0,
1779 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1780 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1781 0x80, present ? 0x80 : 0);
1782 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1783 0x80, present ? 0x80 : 0);
1786 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1788 /* Looks like the unsol event is incompatible with the standard
1789 * definition. 4bit tag is placed at 28 bit!
1791 if ((res >> 28) == 0x01)
1792 alc880_lg_lw_automute(codec);
1799 static int alc_init(struct hda_codec *codec)
1801 struct alc_spec *spec = codec->spec;
1804 for (i = 0; i < spec->num_init_verbs; i++)
1805 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1807 if (spec->init_hook)
1808 spec->init_hook(codec);
1813 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1815 struct alc_spec *spec = codec->spec;
1817 if (spec->unsol_event)
1818 spec->unsol_event(codec, res);
1825 static int alc_resume(struct hda_codec *codec)
1827 struct alc_spec *spec = codec->spec;
1831 for (i = 0; i < spec->num_mixers; i++)
1832 snd_hda_resume_ctls(codec, spec->mixers[i]);
1833 if (spec->multiout.dig_out_nid)
1834 snd_hda_resume_spdif_out(codec);
1835 if (spec->dig_in_nid)
1836 snd_hda_resume_spdif_in(codec);
1843 * Analog playback callbacks
1845 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1846 struct hda_codec *codec,
1847 struct snd_pcm_substream *substream)
1849 struct alc_spec *spec = codec->spec;
1850 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1853 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1854 struct hda_codec *codec,
1855 unsigned int stream_tag,
1856 unsigned int format,
1857 struct snd_pcm_substream *substream)
1859 struct alc_spec *spec = codec->spec;
1860 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1861 stream_tag, format, substream);
1864 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1865 struct hda_codec *codec,
1866 struct snd_pcm_substream *substream)
1868 struct alc_spec *spec = codec->spec;
1869 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1875 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1876 struct hda_codec *codec,
1877 struct snd_pcm_substream *substream)
1879 struct alc_spec *spec = codec->spec;
1880 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1883 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1884 struct hda_codec *codec,
1885 struct snd_pcm_substream *substream)
1887 struct alc_spec *spec = codec->spec;
1888 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1894 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1895 struct hda_codec *codec,
1896 unsigned int stream_tag,
1897 unsigned int format,
1898 struct snd_pcm_substream *substream)
1900 struct alc_spec *spec = codec->spec;
1902 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1903 stream_tag, 0, format);
1907 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1908 struct hda_codec *codec,
1909 struct snd_pcm_substream *substream)
1911 struct alc_spec *spec = codec->spec;
1913 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1921 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1925 /* NID is set in alc_build_pcms */
1927 .open = alc880_playback_pcm_open,
1928 .prepare = alc880_playback_pcm_prepare,
1929 .cleanup = alc880_playback_pcm_cleanup
1933 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1937 /* NID is set in alc_build_pcms */
1939 .prepare = alc880_capture_pcm_prepare,
1940 .cleanup = alc880_capture_pcm_cleanup
1944 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1948 /* NID is set in alc_build_pcms */
1950 .open = alc880_dig_playback_pcm_open,
1951 .close = alc880_dig_playback_pcm_close
1955 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1959 /* NID is set in alc_build_pcms */
1962 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1963 static struct hda_pcm_stream alc_pcm_null_playback = {
1969 static int alc_build_pcms(struct hda_codec *codec)
1971 struct alc_spec *spec = codec->spec;
1972 struct hda_pcm *info = spec->pcm_rec;
1975 codec->num_pcms = 1;
1976 codec->pcm_info = info;
1978 info->name = spec->stream_name_analog;
1979 if (spec->stream_analog_playback) {
1980 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1981 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1982 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1984 if (spec->stream_analog_capture) {
1985 snd_assert(spec->adc_nids, return -EINVAL);
1986 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1987 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1990 if (spec->channel_mode) {
1991 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1992 for (i = 0; i < spec->num_channel_mode; i++) {
1993 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1994 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1999 /* SPDIF for stream index #1 */
2000 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2001 codec->num_pcms = 2;
2002 info = spec->pcm_rec + 1;
2003 info->name = spec->stream_name_digital;
2004 if (spec->multiout.dig_out_nid &&
2005 spec->stream_digital_playback) {
2006 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2007 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2009 if (spec->dig_in_nid &&
2010 spec->stream_digital_capture) {
2011 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2012 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2016 /* If the use of more than one ADC is requested for the current
2017 * model, configure a second analog capture-only PCM.
2019 /* Additional Analaog capture for index #2 */
2020 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2022 codec->num_pcms = 3;
2023 info = spec->pcm_rec + 2;
2024 info->name = spec->stream_name_analog;
2025 /* No playback stream for second PCM */
2026 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2027 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2028 if (spec->stream_analog_capture) {
2029 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2030 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2037 static void alc_free(struct hda_codec *codec)
2039 struct alc_spec *spec = codec->spec;
2045 if (spec->kctl_alloc) {
2046 for (i = 0; i < spec->num_kctl_used; i++)
2047 kfree(spec->kctl_alloc[i].name);
2048 kfree(spec->kctl_alloc);
2055 static struct hda_codec_ops alc_patch_ops = {
2056 .build_controls = alc_build_controls,
2057 .build_pcms = alc_build_pcms,
2060 .unsol_event = alc_unsol_event,
2062 .resume = alc_resume,
2068 * Test configuration for debugging
2070 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2073 #ifdef CONFIG_SND_DEBUG
2074 static hda_nid_t alc880_test_dac_nids[4] = {
2075 0x02, 0x03, 0x04, 0x05
2078 static struct hda_input_mux alc880_test_capture_source = {
2087 { "Surround", 0x6 },
2091 static struct hda_channel_mode alc880_test_modes[4] = {
2098 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2099 struct snd_ctl_elem_info *uinfo)
2101 static char *texts[] = {
2102 "N/A", "Line Out", "HP Out",
2103 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2105 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2107 uinfo->value.enumerated.items = 8;
2108 if (uinfo->value.enumerated.item >= 8)
2109 uinfo->value.enumerated.item = 7;
2110 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2114 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2115 struct snd_ctl_elem_value *ucontrol)
2117 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2118 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2119 unsigned int pin_ctl, item = 0;
2121 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2122 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2123 if (pin_ctl & AC_PINCTL_OUT_EN) {
2124 if (pin_ctl & AC_PINCTL_HP_EN)
2128 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2129 switch (pin_ctl & AC_PINCTL_VREFEN) {
2130 case AC_PINCTL_VREF_HIZ: item = 3; break;
2131 case AC_PINCTL_VREF_50: item = 4; break;
2132 case AC_PINCTL_VREF_GRD: item = 5; break;
2133 case AC_PINCTL_VREF_80: item = 6; break;
2134 case AC_PINCTL_VREF_100: item = 7; break;
2137 ucontrol->value.enumerated.item[0] = item;
2141 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2142 struct snd_ctl_elem_value *ucontrol)
2144 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2145 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2146 static unsigned int ctls[] = {
2147 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2148 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2149 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2150 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2151 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2152 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2154 unsigned int old_ctl, new_ctl;
2156 old_ctl = snd_hda_codec_read(codec, nid, 0,
2157 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2158 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2159 if (old_ctl != new_ctl) {
2160 snd_hda_codec_write(codec, nid, 0,
2161 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
2162 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2163 (ucontrol->value.enumerated.item[0] >= 3 ?
2170 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2171 struct snd_ctl_elem_info *uinfo)
2173 static char *texts[] = {
2174 "Front", "Surround", "CLFE", "Side"
2176 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2178 uinfo->value.enumerated.items = 4;
2179 if (uinfo->value.enumerated.item >= 4)
2180 uinfo->value.enumerated.item = 3;
2181 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2185 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2186 struct snd_ctl_elem_value *ucontrol)
2188 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2189 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2192 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2193 ucontrol->value.enumerated.item[0] = sel & 3;
2197 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2198 struct snd_ctl_elem_value *ucontrol)
2200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2201 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2204 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2205 if (ucontrol->value.enumerated.item[0] != sel) {
2206 sel = ucontrol->value.enumerated.item[0] & 3;
2207 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2213 #define PIN_CTL_TEST(xname,nid) { \
2214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2216 .info = alc_test_pin_ctl_info, \
2217 .get = alc_test_pin_ctl_get, \
2218 .put = alc_test_pin_ctl_put, \
2219 .private_value = nid \
2222 #define PIN_SRC_TEST(xname,nid) { \
2223 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2225 .info = alc_test_pin_src_info, \
2226 .get = alc_test_pin_src_get, \
2227 .put = alc_test_pin_src_put, \
2228 .private_value = nid \
2231 static struct snd_kcontrol_new alc880_test_mixer[] = {
2232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2233 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2234 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2235 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2236 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2237 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2238 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2239 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2240 PIN_CTL_TEST("Front Pin Mode", 0x14),
2241 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2242 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2243 PIN_CTL_TEST("Side Pin Mode", 0x17),
2244 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2245 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2246 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2247 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2248 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2249 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2250 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2251 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2252 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2253 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2254 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2255 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2256 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2257 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2258 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2259 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2263 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2264 .name = "Channel Mode",
2265 .info = alc_ch_mode_info,
2266 .get = alc_ch_mode_get,
2267 .put = alc_ch_mode_put,
2272 static struct hda_verb alc880_test_init_verbs[] = {
2273 /* Unmute inputs of 0x0c - 0x0f */
2274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2276 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2279 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2280 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2282 /* Vol output for 0x0c-0x0f */
2283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2286 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2287 /* Set output pins 0x14-0x17 */
2288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2291 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2292 /* Unmute output pins 0x14-0x17 */
2293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2295 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2296 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2297 /* Set input pins 0x18-0x1c */
2298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2300 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2301 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2302 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2303 /* Mute input pins 0x18-0x1b */
2304 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2305 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2307 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2310 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2311 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2312 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2313 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2314 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2315 /* Analog input/passthru */
2316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2328 static struct hda_board_config alc880_cfg_tbl[] = {
2329 /* Back 3 jack, front 2 jack */
2330 { .modelname = "3stack", .config = ALC880_3ST },
2331 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2332 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2333 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2334 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2335 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2336 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2337 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2338 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2339 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2340 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2341 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2342 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2343 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2344 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2345 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2346 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2347 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2348 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2349 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
2350 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
2351 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2352 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
2353 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2354 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2355 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2356 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2357 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2358 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2359 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2360 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2361 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2362 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2363 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2364 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2365 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2367 { .modelname = "tcl", .config = ALC880_TCL_S700 },
2368 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2370 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2371 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2372 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2373 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2375 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2376 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2377 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2378 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2381 { .modelname = "clevo", .config = ALC880_CLEVO },
2382 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2383 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2384 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2385 .config = ALC880_CLEVO }, /* Clevo m665n */
2387 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2388 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2389 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2390 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2392 /* Back 5 jack, front 2 jack */
2393 { .modelname = "5stack", .config = ALC880_5ST },
2394 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2395 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2396 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2397 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2398 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2400 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2401 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2402 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2403 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2404 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2405 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2406 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2407 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2408 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2409 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2410 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2411 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2412 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2413 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2414 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2415 /* note subvendor = 0 below */
2416 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2418 { .modelname = "w810", .config = ALC880_W810 },
2419 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2421 { .modelname = "z71v", .config = ALC880_Z71V },
2422 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2424 { .modelname = "6stack", .config = ALC880_6ST },
2425 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2426 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2427 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2428 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2430 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2431 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2432 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2433 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2434 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2435 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2436 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2437 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2438 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2439 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2440 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2441 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2443 { .modelname = "asus", .config = ALC880_ASUS },
2444 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2445 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2446 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2447 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2448 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2449 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2450 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
2451 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2452 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2453 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2454 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2455 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
2456 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2457 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
2458 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2459 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
2460 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2462 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2463 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2464 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9070, .config = ALC880_UNIWILL },
2465 { .pci_subvendor = 0x1734, .pci_subdevice = 0x10ac, .config = ALC880_UNIWILL },
2466 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9077, .config = ALC880_UNIWILL_P53 },
2468 { .modelname = "F1734", .config = ALC880_F1734 },
2469 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2470 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2472 { .modelname = "lg", .config = ALC880_LG },
2473 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2474 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
2476 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2477 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2478 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
2480 #ifdef CONFIG_SND_DEBUG
2481 { .modelname = "test", .config = ALC880_TEST },
2483 { .modelname = "auto", .config = ALC880_AUTO },
2489 * ALC880 codec presets
2491 static struct alc_config_preset alc880_presets[] = {
2493 .mixers = { alc880_three_stack_mixer },
2494 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2495 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2496 .dac_nids = alc880_dac_nids,
2497 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2498 .channel_mode = alc880_threestack_modes,
2500 .input_mux = &alc880_capture_source,
2502 [ALC880_3ST_DIG] = {
2503 .mixers = { alc880_three_stack_mixer },
2504 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2505 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2506 .dac_nids = alc880_dac_nids,
2507 .dig_out_nid = ALC880_DIGOUT_NID,
2508 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2509 .channel_mode = alc880_threestack_modes,
2511 .input_mux = &alc880_capture_source,
2513 [ALC880_TCL_S700] = {
2514 .mixers = { alc880_tcl_s700_mixer },
2515 .init_verbs = { alc880_volume_init_verbs,
2516 alc880_pin_tcl_S700_init_verbs,
2517 alc880_gpio2_init_verbs },
2518 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2519 .dac_nids = alc880_dac_nids,
2521 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2522 .channel_mode = alc880_2_jack_modes,
2523 .input_mux = &alc880_capture_source,
2526 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2527 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2528 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2529 .dac_nids = alc880_dac_nids,
2530 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2531 .channel_mode = alc880_fivestack_modes,
2532 .input_mux = &alc880_capture_source,
2534 [ALC880_5ST_DIG] = {
2535 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2536 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2537 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2538 .dac_nids = alc880_dac_nids,
2539 .dig_out_nid = ALC880_DIGOUT_NID,
2540 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2541 .channel_mode = alc880_fivestack_modes,
2542 .input_mux = &alc880_capture_source,
2545 .mixers = { alc880_six_stack_mixer },
2546 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2547 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2548 .dac_nids = alc880_6st_dac_nids,
2549 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2550 .channel_mode = alc880_sixstack_modes,
2551 .input_mux = &alc880_6stack_capture_source,
2553 [ALC880_6ST_DIG] = {
2554 .mixers = { alc880_six_stack_mixer },
2555 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2556 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2557 .dac_nids = alc880_6st_dac_nids,
2558 .dig_out_nid = ALC880_DIGOUT_NID,
2559 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2560 .channel_mode = alc880_sixstack_modes,
2561 .input_mux = &alc880_6stack_capture_source,
2564 .mixers = { alc880_w810_base_mixer },
2565 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2566 alc880_gpio2_init_verbs },
2567 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2568 .dac_nids = alc880_w810_dac_nids,
2569 .dig_out_nid = ALC880_DIGOUT_NID,
2570 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2571 .channel_mode = alc880_w810_modes,
2572 .input_mux = &alc880_capture_source,
2575 .mixers = { alc880_z71v_mixer },
2576 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2577 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2578 .dac_nids = alc880_z71v_dac_nids,
2579 .dig_out_nid = ALC880_DIGOUT_NID,
2581 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2582 .channel_mode = alc880_2_jack_modes,
2583 .input_mux = &alc880_capture_source,
2586 .mixers = { alc880_f1734_mixer },
2587 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2588 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2589 .dac_nids = alc880_f1734_dac_nids,
2591 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2592 .channel_mode = alc880_2_jack_modes,
2593 .input_mux = &alc880_capture_source,
2596 .mixers = { alc880_asus_mixer },
2597 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2598 alc880_gpio1_init_verbs },
2599 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2600 .dac_nids = alc880_asus_dac_nids,
2601 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2602 .channel_mode = alc880_asus_modes,
2604 .input_mux = &alc880_capture_source,
2606 [ALC880_ASUS_DIG] = {
2607 .mixers = { alc880_asus_mixer },
2608 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2609 alc880_gpio1_init_verbs },
2610 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2611 .dac_nids = alc880_asus_dac_nids,
2612 .dig_out_nid = ALC880_DIGOUT_NID,
2613 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2614 .channel_mode = alc880_asus_modes,
2616 .input_mux = &alc880_capture_source,
2618 [ALC880_ASUS_DIG2] = {
2619 .mixers = { alc880_asus_mixer },
2620 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2621 alc880_gpio2_init_verbs }, /* use GPIO2 */
2622 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2623 .dac_nids = alc880_asus_dac_nids,
2624 .dig_out_nid = ALC880_DIGOUT_NID,
2625 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2626 .channel_mode = alc880_asus_modes,
2628 .input_mux = &alc880_capture_source,
2630 [ALC880_ASUS_W1V] = {
2631 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2632 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2633 alc880_gpio1_init_verbs },
2634 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2635 .dac_nids = alc880_asus_dac_nids,
2636 .dig_out_nid = ALC880_DIGOUT_NID,
2637 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2638 .channel_mode = alc880_asus_modes,
2640 .input_mux = &alc880_capture_source,
2642 [ALC880_UNIWILL_DIG] = {
2643 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2644 .init_verbs = { alc880_volume_init_verbs,
2645 alc880_pin_asus_init_verbs },
2646 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2647 .dac_nids = alc880_asus_dac_nids,
2648 .dig_out_nid = ALC880_DIGOUT_NID,
2649 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2650 .channel_mode = alc880_asus_modes,
2652 .input_mux = &alc880_capture_source,
2654 [ALC880_UNIWILL] = {
2655 .mixers = { alc880_uniwill_mixer },
2656 .init_verbs = { alc880_volume_init_verbs,
2657 alc880_uniwill_init_verbs },
2658 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2659 .dac_nids = alc880_asus_dac_nids,
2660 .dig_out_nid = ALC880_DIGOUT_NID,
2661 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2662 .channel_mode = alc880_threestack_modes,
2664 .input_mux = &alc880_capture_source,
2665 .unsol_event = alc880_uniwill_unsol_event,
2666 .init_hook = alc880_uniwill_automute,
2668 [ALC880_UNIWILL_P53] = {
2669 .mixers = { alc880_uniwill_p53_mixer },
2670 .init_verbs = { alc880_volume_init_verbs,
2671 alc880_uniwill_p53_init_verbs },
2672 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2673 .dac_nids = alc880_asus_dac_nids,
2674 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2675 .channel_mode = alc880_w810_modes,
2676 .input_mux = &alc880_capture_source,
2677 .unsol_event = alc880_uniwill_p53_unsol_event,
2678 .init_hook = alc880_uniwill_p53_hp_automute,
2681 .mixers = { alc880_three_stack_mixer },
2682 .init_verbs = { alc880_volume_init_verbs,
2683 alc880_pin_clevo_init_verbs },
2684 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2685 .dac_nids = alc880_dac_nids,
2687 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2688 .channel_mode = alc880_threestack_modes,
2690 .input_mux = &alc880_capture_source,
2693 .mixers = { alc880_lg_mixer },
2694 .init_verbs = { alc880_volume_init_verbs,
2695 alc880_lg_init_verbs },
2696 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2697 .dac_nids = alc880_lg_dac_nids,
2698 .dig_out_nid = ALC880_DIGOUT_NID,
2699 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2700 .channel_mode = alc880_lg_ch_modes,
2702 .input_mux = &alc880_lg_capture_source,
2703 .unsol_event = alc880_lg_unsol_event,
2704 .init_hook = alc880_lg_automute,
2707 .mixers = { alc880_lg_lw_mixer },
2708 .init_verbs = { alc880_volume_init_verbs,
2709 alc880_lg_lw_init_verbs },
2711 .dac_nids = alc880_dac_nids,
2712 .dig_out_nid = ALC880_DIGOUT_NID,
2713 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2714 .channel_mode = alc880_2_jack_modes,
2715 .input_mux = &alc880_lg_lw_capture_source,
2716 .unsol_event = alc880_lg_lw_unsol_event,
2717 .init_hook = alc880_lg_lw_automute,
2719 #ifdef CONFIG_SND_DEBUG
2721 .mixers = { alc880_test_mixer },
2722 .init_verbs = { alc880_test_init_verbs },
2723 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2724 .dac_nids = alc880_test_dac_nids,
2725 .dig_out_nid = ALC880_DIGOUT_NID,
2726 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2727 .channel_mode = alc880_test_modes,
2728 .input_mux = &alc880_test_capture_source,
2734 * Automatic parse of I/O pins from the BIOS configuration
2737 #define NUM_CONTROL_ALLOC 32
2738 #define NUM_VERB_ALLOC 32
2742 ALC_CTL_WIDGET_MUTE,
2745 static struct snd_kcontrol_new alc880_control_templates[] = {
2746 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2747 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2748 HDA_BIND_MUTE(NULL, 0, 0, 0),
2751 /* add dynamic controls */
2752 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2754 struct snd_kcontrol_new *knew;
2756 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2757 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2759 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2762 if (spec->kctl_alloc) {
2763 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2764 kfree(spec->kctl_alloc);
2766 spec->kctl_alloc = knew;
2767 spec->num_kctl_alloc = num;
2770 knew = &spec->kctl_alloc[spec->num_kctl_used];
2771 *knew = alc880_control_templates[type];
2772 knew->name = kstrdup(name, GFP_KERNEL);
2775 knew->private_value = val;
2776 spec->num_kctl_used++;
2780 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2781 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2782 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2783 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2784 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2785 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2786 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2787 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2788 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2789 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2790 #define ALC880_PIN_CD_NID 0x1c
2792 /* fill in the dac_nids table from the parsed pin configuration */
2793 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2799 memset(assigned, 0, sizeof(assigned));
2800 spec->multiout.dac_nids = spec->private_dac_nids;
2802 /* check the pins hardwired to audio widget */
2803 for (i = 0; i < cfg->line_outs; i++) {
2804 nid = cfg->line_out_pins[i];
2805 if (alc880_is_fixed_pin(nid)) {
2806 int idx = alc880_fixed_pin_idx(nid);
2807 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2811 /* left pins can be connect to any audio widget */
2812 for (i = 0; i < cfg->line_outs; i++) {
2813 nid = cfg->line_out_pins[i];
2814 if (alc880_is_fixed_pin(nid))
2816 /* search for an empty channel */
2817 for (j = 0; j < cfg->line_outs; j++) {
2818 if (! assigned[j]) {
2819 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2825 spec->multiout.num_dacs = cfg->line_outs;
2829 /* add playback controls from the parsed DAC table */
2830 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2831 const struct auto_pin_cfg *cfg)
2834 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2838 for (i = 0; i < cfg->line_outs; i++) {
2839 if (! spec->multiout.dac_nids[i])
2841 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2844 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2845 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2847 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2848 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2850 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2851 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2853 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2854 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2857 sprintf(name, "%s Playback Volume", chname[i]);
2858 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2859 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2861 sprintf(name, "%s Playback Switch", chname[i]);
2862 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2863 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2870 /* add playback controls for speaker and HP outputs */
2871 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2881 if (alc880_is_fixed_pin(pin)) {
2882 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2883 /* specify the DAC as the extra output */
2884 if (! spec->multiout.hp_nid)
2885 spec->multiout.hp_nid = nid;
2887 spec->multiout.extra_out_nid[0] = nid;
2888 /* control HP volume/switch on the output mixer amp */
2889 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2890 sprintf(name, "%s Playback Volume", pfx);
2891 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2892 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2894 sprintf(name, "%s Playback Switch", pfx);
2895 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2896 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2898 } else if (alc880_is_multi_pin(pin)) {
2899 /* set manual connection */
2900 /* we have only a switch on HP-out PIN */
2901 sprintf(name, "%s Playback Switch", pfx);
2902 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2903 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2909 /* create input playback/capture controls for the given pin */
2910 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2911 int idx, hda_nid_t mix_nid)
2916 sprintf(name, "%s Playback Volume", ctlname);
2917 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2918 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2920 sprintf(name, "%s Playback Switch", ctlname);
2921 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2922 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2927 /* create playback/capture controls for input pins */
2928 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2929 const struct auto_pin_cfg *cfg)
2931 struct hda_input_mux *imux = &spec->private_imux;
2934 for (i = 0; i < AUTO_PIN_LAST; i++) {
2935 if (alc880_is_input_pin(cfg->input_pins[i])) {
2936 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2937 err = new_analog_input(spec, cfg->input_pins[i],
2938 auto_pin_cfg_labels[i],
2942 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2943 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2950 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2951 hda_nid_t nid, int pin_type,
2955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2956 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2957 /* need the manual connection? */
2958 if (alc880_is_multi_pin(nid)) {
2959 struct alc_spec *spec = codec->spec;
2960 int idx = alc880_multi_pin_idx(nid);
2961 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2962 AC_VERB_SET_CONNECT_SEL,
2963 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2967 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2969 struct alc_spec *spec = codec->spec;
2972 for (i = 0; i < spec->autocfg.line_outs; i++) {
2973 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2974 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2978 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2980 struct alc_spec *spec = codec->spec;
2983 pin = spec->autocfg.speaker_pins[0];
2984 if (pin) /* connect to front */
2985 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2986 pin = spec->autocfg.hp_pins[0];
2987 if (pin) /* connect to front */
2988 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2991 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2993 struct alc_spec *spec = codec->spec;
2996 for (i = 0; i < AUTO_PIN_LAST; i++) {
2997 hda_nid_t nid = spec->autocfg.input_pins[i];
2998 if (alc880_is_input_pin(nid)) {
2999 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3000 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3001 if (nid != ALC880_PIN_CD_NID)
3002 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3008 /* parse the BIOS configuration and set up the alc_spec */
3009 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
3010 static int alc880_parse_auto_config(struct hda_codec *codec)
3012 struct alc_spec *spec = codec->spec;
3014 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3016 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3017 alc880_ignore)) < 0)
3019 if (! spec->autocfg.line_outs)
3020 return 0; /* can't find valid BIOS pin config */
3022 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
3023 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
3024 (err = alc880_auto_create_extra_out(spec,
3025 spec->autocfg.speaker_pins[0],
3027 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3028 "Headphone")) < 0 ||
3029 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3032 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3034 if (spec->autocfg.dig_out_pin)
3035 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3036 if (spec->autocfg.dig_in_pin)
3037 spec->dig_in_nid = ALC880_DIGIN_NID;
3039 if (spec->kctl_alloc)
3040 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3042 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3044 spec->num_mux_defs = 1;
3045 spec->input_mux = &spec->private_imux;
3050 /* additional initialization for auto-configuration model */
3051 static void alc880_auto_init(struct hda_codec *codec)
3053 alc880_auto_init_multi_out(codec);
3054 alc880_auto_init_extra_out(codec);
3055 alc880_auto_init_analog_input(codec);
3059 * OK, here we have finally the patch for ALC880
3062 static int patch_alc880(struct hda_codec *codec)
3064 struct alc_spec *spec;
3068 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3074 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
3075 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
3076 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3077 "trying auto-probe from BIOS...\n");
3078 board_config = ALC880_AUTO;
3081 if (board_config == ALC880_AUTO) {
3082 /* automatic parse from the BIOS config */
3083 err = alc880_parse_auto_config(codec);
3089 "hda_codec: Cannot set up configuration "
3090 "from BIOS. Using 3-stack mode...\n");
3091 board_config = ALC880_3ST;
3095 if (board_config != ALC880_AUTO)
3096 setup_preset(spec, &alc880_presets[board_config]);
3098 spec->stream_name_analog = "ALC880 Analog";
3099 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3100 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3102 spec->stream_name_digital = "ALC880 Digital";
3103 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3104 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3106 if (! spec->adc_nids && spec->input_mux) {
3107 /* check whether NID 0x07 is valid */
3108 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3109 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3110 if (wcap != AC_WID_AUD_IN) {
3111 spec->adc_nids = alc880_adc_nids_alt;
3112 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3113 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
3116 spec->adc_nids = alc880_adc_nids;
3117 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3118 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3123 codec->patch_ops = alc_patch_ops;
3124 if (board_config == ALC880_AUTO)
3125 spec->init_hook = alc880_auto_init;
3135 static hda_nid_t alc260_dac_nids[1] = {
3140 static hda_nid_t alc260_adc_nids[1] = {
3145 static hda_nid_t alc260_adc_nids_alt[1] = {
3150 static hda_nid_t alc260_hp_adc_nids[2] = {
3155 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3156 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3158 static hda_nid_t alc260_dual_adc_nids[2] = {
3163 #define ALC260_DIGOUT_NID 0x03
3164 #define ALC260_DIGIN_NID 0x06
3166 static struct hda_input_mux alc260_capture_source = {
3170 { "Front Mic", 0x1 },
3176 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3177 * headphone jack and the internal CD lines since these are the only pins at
3178 * which audio can appear. For flexibility, also allow the option of
3179 * recording the mixer output on the second ADC (ADC0 doesn't have a
3180 * connection to the mixer output).
3182 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3186 { "Mic/Line", 0x0 },
3188 { "Headphone", 0x2 },
3194 { "Mic/Line", 0x0 },
3196 { "Headphone", 0x2 },
3203 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3204 * the Fujitsu S702x, but jacks are marked differently.
3206 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3213 { "Headphone", 0x5 },
3222 { "Headphone", 0x6 },
3228 * This is just place-holder, so there's something for alc_build_pcms to look
3229 * at when it calculates the maximum number of channels. ALC260 has no mixer
3230 * element which allows changing the channel mode, so the verb list is
3233 static struct hda_channel_mode alc260_modes[1] = {
3238 /* Mixer combinations
3240 * basic: base_output + input + pc_beep + capture
3241 * HP: base_output + input + capture_alt
3242 * HP_3013: hp_3013 + input + capture
3243 * fujitsu: fujitsu + capture
3244 * acer: acer + capture
3247 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3248 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3249 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3250 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3251 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3252 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3253 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3257 static struct snd_kcontrol_new alc260_input_mixer[] = {
3258 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3259 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3260 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3261 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3263 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3264 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3265 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3269 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3270 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3271 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3275 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3276 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3277 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3278 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3279 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3280 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3282 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3283 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3287 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3288 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3290 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3291 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3292 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3293 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3294 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3295 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3296 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3297 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3298 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3299 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3300 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3301 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3302 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3306 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3307 * versions of the ALC260 don't act on requests to enable mic bias from NID
3308 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3309 * datasheet doesn't mention this restriction. At this stage it's not clear
3310 * whether this behaviour is intentional or is a hardware bug in chip
3311 * revisions available in early 2006. Therefore for now allow the
3312 * "Headphone Jack Mode" control to span all choices, but if it turns out
3313 * that the lack of mic bias for this NID is intentional we could change the
3314 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3316 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3317 * don't appear to make the mic bias available from the "line" jack, even
3318 * though the NID used for this jack (0x14) can supply it. The theory is
3319 * that perhaps Acer have included blocking capacitors between the ALC260
3320 * and the output jack. If this turns out to be the case for all such
3321 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3322 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3324 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3325 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3326 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3327 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3328 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3329 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3331 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3332 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3333 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3334 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3335 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3336 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3337 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3341 /* capture mixer elements */
3342 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3343 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3344 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3345 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3346 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3349 /* The multiple "Capture Source" controls confuse alsamixer
3350 * So call somewhat different..
3351 * FIXME: the controls appear in the "playback" view!
3353 /* .name = "Capture Source", */
3354 .name = "Input Source",
3356 .info = alc_mux_enum_info,
3357 .get = alc_mux_enum_get,
3358 .put = alc_mux_enum_put,
3363 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3364 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3365 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3367 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3368 /* The multiple "Capture Source" controls confuse alsamixer
3369 * So call somewhat different..
3370 * FIXME: the controls appear in the "playback" view!
3372 /* .name = "Capture Source", */
3373 .name = "Input Source",
3375 .info = alc_mux_enum_info,
3376 .get = alc_mux_enum_get,
3377 .put = alc_mux_enum_put,
3383 * initialization verbs
3385 static struct hda_verb alc260_init_verbs[] = {
3386 /* Line In pin widget for input */
3387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3388 /* CD pin widget for input */
3389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3390 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3391 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3392 /* Mic2 (front panel) pin widget for input and vref at 80% */
3393 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3394 /* LINE-2 is used for line-out in rear */
3395 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3396 /* select line-out */
3397 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3399 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3401 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3403 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3404 /* mute capture amp left and right */
3405 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3406 /* set connection select to line in (default select for this ADC) */
3407 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3408 /* mute capture amp left and right */
3409 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3410 /* set connection select to line in (default select for this ADC) */
3411 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3412 /* set vol=0 Line-Out mixer amp left and right */
3413 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3414 /* unmute pin widget amp left and right (no gain on this amp) */
3415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3416 /* set vol=0 HP mixer amp left and right */
3417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3418 /* unmute pin widget amp left and right (no gain on this amp) */
3419 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3420 /* set vol=0 Mono mixer amp left and right */
3421 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3422 /* unmute pin widget amp left and right (no gain on this amp) */
3423 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3424 /* unmute LINE-2 out pin */
3425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3426 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3433 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3434 /* mute Front out path */
3435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3436 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3437 /* mute Headphone out path */
3438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3439 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3440 /* mute Mono out path */
3441 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3442 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3446 #if 0 /* should be identical with alc260_init_verbs? */
3447 static struct hda_verb alc260_hp_init_verbs[] = {
3448 /* Headphone and output */
3449 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3451 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3452 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3453 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3454 /* Mic2 (front panel) pin widget for input and vref at 80% */
3455 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3456 /* Line In pin widget for input */
3457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3458 /* Line-2 pin widget for output */
3459 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3460 /* CD pin widget for input */
3461 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3462 /* unmute amp left and right */
3463 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3464 /* set connection select to line in (default select for this ADC) */
3465 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3466 /* unmute Line-Out mixer amp left and right (volume = 0) */
3467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3468 /* mute pin widget amp left and right (no gain on this amp) */
3469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3470 /* unmute HP mixer amp left and right (volume = 0) */
3471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3472 /* mute pin widget amp left and right (no gain on this amp) */
3473 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3474 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3477 /* unmute Line In */
3478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3481 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3482 /* Unmute Front out path */
3483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3485 /* Unmute Headphone out path */
3486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3488 /* Unmute Mono out path */
3489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3495 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3496 /* Line out and output */
3497 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3499 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3500 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3501 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3502 /* Mic2 (front panel) pin widget for input and vref at 80% */
3503 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3504 /* Line In pin widget for input */
3505 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3506 /* Headphone pin widget for output */
3507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3508 /* CD pin widget for input */
3509 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3510 /* unmute amp left and right */
3511 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3512 /* set connection select to line in (default select for this ADC) */
3513 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3514 /* unmute Line-Out mixer amp left and right (volume = 0) */
3515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3516 /* mute pin widget amp left and right (no gain on this amp) */
3517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3518 /* unmute HP mixer amp left and right (volume = 0) */
3519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3520 /* mute pin widget amp left and right (no gain on this amp) */
3521 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3522 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3525 /* unmute Line In */
3526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3529 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3530 /* Unmute Front out path */
3531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3533 /* Unmute Headphone out path */
3534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3536 /* Unmute Mono out path */
3537 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3538 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3542 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3543 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3544 * audio = 0x16, internal speaker = 0x10.
3546 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3547 /* Disable all GPIOs */
3548 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3549 /* Internal speaker is connected to headphone pin */
3550 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3551 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3553 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3554 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3555 /* Ensure all other unused pins are disabled and muted. */
3556 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3557 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3558 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3559 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3560 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3561 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3562 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3565 /* Disable digital (SPDIF) pins */
3566 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3567 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3569 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3570 * when acting as an output.
3572 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3574 /* Start with output sum widgets muted and their output gains at min */
3575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3576 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3577 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3578 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3579 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3580 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3581 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3582 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3583 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3585 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3586 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3587 /* Unmute Line1 pin widget output buffer since it starts as an output.
3588 * If the pin mode is changed by the user the pin mode control will
3589 * take care of enabling the pin's input/output buffers as needed.
3590 * Therefore there's no need to enable the input buffer at this
3593 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3594 /* Unmute input buffer of pin widget used for Line-in (no equiv
3597 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3599 /* Mute capture amp left and right */
3600 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3601 /* Set ADC connection select to match default mixer setting - line
3604 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3606 /* Do the same for the second ADC: mute capture input amp and
3607 * set ADC connection to line in (on mic1 pin)
3609 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3610 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3612 /* Mute all inputs to mixer widget (even unconnected ones) */
3613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3620 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3625 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3626 * similar laptops (adapted from Fujitsu init verbs).
3628 static struct hda_verb alc260_acer_init_verbs[] = {
3629 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3630 * the headphone jack. Turn this on and rely on the standard mute
3631 * methods whenever the user wants to turn these outputs off.
3633 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3634 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3635 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3636 /* Internal speaker/Headphone jack is connected to Line-out pin */
3637 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3638 /* Internal microphone/Mic jack is connected to Mic1 pin */
3639 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3640 /* Line In jack is connected to Line1 pin */
3641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3642 /* Ensure all other unused pins are disabled and muted. */
3643 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3644 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3645 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3646 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3647 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3648 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3651 /* Disable digital (SPDIF) pins */
3652 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3653 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3655 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3656 * bus when acting as outputs.
3658 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3659 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3661 /* Start with output sum widgets muted and their output gains at min */
3662 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3665 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3666 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3668 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3669 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3672 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3673 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3674 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3675 * inputs. If the pin mode is changed by the user the pin mode control
3676 * will take care of enabling the pin's input/output buffers as needed.
3677 * Therefore there's no need to enable the input buffer at this
3680 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3683 /* Mute capture amp left and right */
3684 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3685 /* Set ADC connection select to match default mixer setting - mic
3688 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3690 /* Do similar with the second ADC: mute capture input amp and
3691 * set ADC connection to mic to match ALSA's default state.
3693 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3694 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3696 /* Mute all inputs to mixer widget (even unconnected ones) */
3697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3703 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3704 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3709 /* Test configuration for debugging, modelled after the ALC880 test
3712 #ifdef CONFIG_SND_DEBUG
3713 static hda_nid_t alc260_test_dac_nids[1] = {
3716 static hda_nid_t alc260_test_adc_nids[2] = {
3719 /* For testing the ALC260, each input MUX needs its own definition since
3720 * the signal assignments are different. This assumes that the first ADC
3723 static struct hda_input_mux alc260_test_capture_sources[2] = {
3727 { "MIC1 pin", 0x0 },
3728 { "MIC2 pin", 0x1 },
3729 { "LINE1 pin", 0x2 },
3730 { "LINE2 pin", 0x3 },
3732 { "LINE-OUT pin", 0x5 },
3733 { "HP-OUT pin", 0x6 },
3739 { "MIC1 pin", 0x0 },
3740 { "MIC2 pin", 0x1 },
3741 { "LINE1 pin", 0x2 },
3742 { "LINE2 pin", 0x3 },
3745 { "LINE-OUT pin", 0x6 },
3746 { "HP-OUT pin", 0x7 },
3750 static struct snd_kcontrol_new alc260_test_mixer[] = {
3751 /* Output driver widgets */
3752 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3753 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3754 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3755 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3756 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3757 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3759 /* Modes for retasking pin widgets
3760 * Note: the ALC260 doesn't seem to act on requests to enable mic
3761 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3762 * mention this restriction. At this stage it's not clear whether
3763 * this behaviour is intentional or is a hardware bug in chip
3764 * revisions available at least up until early 2006. Therefore for
3765 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3766 * choices, but if it turns out that the lack of mic bias for these
3767 * NIDs is intentional we could change their modes from
3768 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3770 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3771 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3772 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3773 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3774 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3775 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3777 /* Loopback mixer controls */
3778 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3779 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3780 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3781 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3782 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3783 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3784 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3785 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3786 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3787 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3788 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3789 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3790 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3791 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3792 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3793 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3795 /* Controls for GPIO pins, assuming they are configured as outputs */
3796 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3797 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3798 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3799 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3801 /* Switches to allow the digital IO pins to be enabled. The datasheet
3802 * is ambigious as to which NID is which; testing on laptops which
3803 * make this output available should provide clarification.
3805 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3806 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3810 static struct hda_verb alc260_test_init_verbs[] = {
3811 /* Enable all GPIOs as outputs with an initial value of 0 */
3812 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3813 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3814 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3816 /* Enable retasking pins as output, initially without power amp */
3817 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3818 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3821 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3822 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3824 /* Disable digital (SPDIF) pins initially, but users can enable
3825 * them via a mixer switch. In the case of SPDIF-out, this initverb
3826 * payload also sets the generation to 0, output to be in "consumer"
3827 * PCM format, copyright asserted, no pre-emphasis and no validity
3830 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3831 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3833 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3834 * OUT1 sum bus when acting as an output.
3836 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3837 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3838 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3839 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3841 /* Start with output sum widgets muted and their output gains at min */
3842 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3843 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3845 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3846 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3847 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3848 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3849 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3850 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3852 /* Unmute retasking pin widget output buffers since the default
3853 * state appears to be output. As the pin mode is changed by the
3854 * user the pin mode control will take care of enabling the pin's
3855 * input/output buffers as needed.
3857 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3860 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3861 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3862 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3863 /* Also unmute the mono-out pin widget */
3864 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3866 /* Mute capture amp left and right */
3867 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3868 /* Set ADC connection select to match default mixer setting (mic1
3871 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3873 /* Do the same for the second ADC: mute capture input amp and
3874 * set ADC connection to mic1 pin
3876 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3877 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3879 /* Mute all inputs to mixer widget (even unconnected ones) */
3880 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3881 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3882 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3893 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3899 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3905 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3906 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3909 * for BIOS auto-configuration
3912 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3916 unsigned long vol_val, sw_val;
3920 if (nid >= 0x0f && nid < 0x11) {
3921 nid_vol = nid - 0x7;
3922 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3923 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3924 } else if (nid == 0x11) {
3925 nid_vol = nid - 0x7;
3926 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3927 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3928 } else if (nid >= 0x12 && nid <= 0x15) {
3930 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3931 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3935 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3936 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3938 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3939 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3944 /* add playback controls from the parsed DAC table */
3945 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3946 const struct auto_pin_cfg *cfg)
3951 spec->multiout.num_dacs = 1;
3952 spec->multiout.dac_nids = spec->private_dac_nids;
3953 spec->multiout.dac_nids[0] = 0x02;
3955 nid = cfg->line_out_pins[0];
3957 err = alc260_add_playback_controls(spec, nid, "Front");
3962 nid = cfg->speaker_pins[0];
3964 err = alc260_add_playback_controls(spec, nid, "Speaker");
3969 nid = cfg->hp_pins[0];
3971 err = alc260_add_playback_controls(spec, nid, "Headphone");
3978 /* create playback/capture controls for input pins */
3979 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3980 const struct auto_pin_cfg *cfg)
3982 struct hda_input_mux *imux = &spec->private_imux;
3985 for (i = 0; i < AUTO_PIN_LAST; i++) {
3986 if (cfg->input_pins[i] >= 0x12) {
3987 idx = cfg->input_pins[i] - 0x12;
3988 err = new_analog_input(spec, cfg->input_pins[i],
3989 auto_pin_cfg_labels[i], idx, 0x07);
3992 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3993 imux->items[imux->num_items].index = idx;
3996 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3997 idx = cfg->input_pins[i] - 0x09;
3998 err = new_analog_input(spec, cfg->input_pins[i],
3999 auto_pin_cfg_labels[i], idx, 0x07);
4002 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
4003 imux->items[imux->num_items].index = idx;
4010 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4011 hda_nid_t nid, int pin_type,
4015 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4016 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4017 /* need the manual connection? */
4019 int idx = nid - 0x12;
4020 snd_hda_codec_write(codec, idx + 0x0b, 0,
4021 AC_VERB_SET_CONNECT_SEL, sel_idx);
4026 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4028 struct alc_spec *spec = codec->spec;
4031 nid = spec->autocfg.line_out_pins[0];
4033 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4035 nid = spec->autocfg.speaker_pins[0];
4037 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4039 nid = spec->autocfg.hp_pins[0];
4041 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4044 #define ALC260_PIN_CD_NID 0x16
4045 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4047 struct alc_spec *spec = codec->spec;
4050 for (i = 0; i < AUTO_PIN_LAST; i++) {
4051 hda_nid_t nid = spec->autocfg.input_pins[i];
4053 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4054 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4055 if (nid != ALC260_PIN_CD_NID)
4056 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4063 * generic initialization of ADC, input mixers and output mixers
4065 static struct hda_verb alc260_volume_init_verbs[] = {
4067 * Unmute ADC0-1 and set the default input to mic-in
4069 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4070 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4071 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4072 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4074 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4076 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4080 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4087 * Set up output mixers (0x08 - 0x0a)
4089 /* set vol=0 to output mixers */
4090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4092 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4093 /* set up input amps for analog loopback */
4094 /* Amp Indices: DAC = 0, mixer = 1 */
4095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4096 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4097 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4099 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4100 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4105 static int alc260_parse_auto_config(struct hda_codec *codec)
4107 struct alc_spec *spec = codec->spec;
4110 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4112 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4113 alc260_ignore)) < 0)
4115 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
4117 if (! spec->kctl_alloc)
4118 return 0; /* can't find valid BIOS pin config */
4119 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4122 spec->multiout.max_channels = 2;
4124 if (spec->autocfg.dig_out_pin)
4125 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4126 if (spec->kctl_alloc)
4127 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4129 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4131 spec->num_mux_defs = 1;
4132 spec->input_mux = &spec->private_imux;
4134 /* check whether NID 0x04 is valid */
4135 wcap = get_wcaps(codec, 0x04);
4136 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4137 if (wcap != AC_WID_AUD_IN) {
4138 spec->adc_nids = alc260_adc_nids_alt;
4139 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4140 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4142 spec->adc_nids = alc260_adc_nids;
4143 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4144 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4151 /* additional initialization for auto-configuration model */
4152 static void alc260_auto_init(struct hda_codec *codec)
4154 alc260_auto_init_multi_out(codec);
4155 alc260_auto_init_analog_input(codec);
4159 * ALC260 configurations
4161 static struct hda_board_config alc260_cfg_tbl[] = {
4162 { .modelname = "basic", .config = ALC260_BASIC },
4163 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
4164 .config = ALC260_BASIC }, /* Sony VAIO */
4165 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
4166 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
4167 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
4168 .config = ALC260_BASIC }, /* Sony VAIO */
4169 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
4170 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
4171 { .modelname = "hp", .config = ALC260_HP },
4172 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
4173 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
4174 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
4175 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
4176 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
4177 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
4178 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
4179 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
4180 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
4181 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
4182 { .modelname = "acer", .config = ALC260_ACER },
4183 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
4184 #ifdef CONFIG_SND_DEBUG
4185 { .modelname = "test", .config = ALC260_TEST },
4187 { .modelname = "auto", .config = ALC260_AUTO },
4191 static struct alc_config_preset alc260_presets[] = {
4193 .mixers = { alc260_base_output_mixer,
4195 alc260_pc_beep_mixer,
4196 alc260_capture_mixer },
4197 .init_verbs = { alc260_init_verbs },
4198 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4199 .dac_nids = alc260_dac_nids,
4200 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4201 .adc_nids = alc260_adc_nids,
4202 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4203 .channel_mode = alc260_modes,
4204 .input_mux = &alc260_capture_source,
4207 .mixers = { alc260_base_output_mixer,
4209 alc260_capture_alt_mixer },
4210 .init_verbs = { alc260_init_verbs },
4211 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4212 .dac_nids = alc260_dac_nids,
4213 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4214 .adc_nids = alc260_hp_adc_nids,
4215 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4216 .channel_mode = alc260_modes,
4217 .input_mux = &alc260_capture_source,
4219 [ALC260_HP_3013] = {
4220 .mixers = { alc260_hp_3013_mixer,
4222 alc260_capture_alt_mixer },
4223 .init_verbs = { alc260_hp_3013_init_verbs },
4224 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4225 .dac_nids = alc260_dac_nids,
4226 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4227 .adc_nids = alc260_hp_adc_nids,
4228 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4229 .channel_mode = alc260_modes,
4230 .input_mux = &alc260_capture_source,
4232 [ALC260_FUJITSU_S702X] = {
4233 .mixers = { alc260_fujitsu_mixer,
4234 alc260_capture_mixer },
4235 .init_verbs = { alc260_fujitsu_init_verbs },
4236 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4237 .dac_nids = alc260_dac_nids,
4238 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4239 .adc_nids = alc260_dual_adc_nids,
4240 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4241 .channel_mode = alc260_modes,
4242 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4243 .input_mux = alc260_fujitsu_capture_sources,
4246 .mixers = { alc260_acer_mixer,
4247 alc260_capture_mixer },
4248 .init_verbs = { alc260_acer_init_verbs },
4249 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4250 .dac_nids = alc260_dac_nids,
4251 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4252 .adc_nids = alc260_dual_adc_nids,
4253 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4254 .channel_mode = alc260_modes,
4255 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4256 .input_mux = alc260_acer_capture_sources,
4258 #ifdef CONFIG_SND_DEBUG
4260 .mixers = { alc260_test_mixer,
4261 alc260_capture_mixer },
4262 .init_verbs = { alc260_test_init_verbs },
4263 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4264 .dac_nids = alc260_test_dac_nids,
4265 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4266 .adc_nids = alc260_test_adc_nids,
4267 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4268 .channel_mode = alc260_modes,
4269 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4270 .input_mux = alc260_test_capture_sources,
4275 static int patch_alc260(struct hda_codec *codec)
4277 struct alc_spec *spec;
4278 int err, board_config;
4280 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4286 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4287 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
4288 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4289 "trying auto-probe from BIOS...\n");
4290 board_config = ALC260_AUTO;
4293 if (board_config == ALC260_AUTO) {
4294 /* automatic parse from the BIOS config */
4295 err = alc260_parse_auto_config(codec);
4301 "hda_codec: Cannot set up configuration "
4302 "from BIOS. Using base mode...\n");
4303 board_config = ALC260_BASIC;
4307 if (board_config != ALC260_AUTO)
4308 setup_preset(spec, &alc260_presets[board_config]);
4310 spec->stream_name_analog = "ALC260 Analog";
4311 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4312 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4314 spec->stream_name_digital = "ALC260 Digital";
4315 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4316 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4318 codec->patch_ops = alc_patch_ops;
4319 if (board_config == ALC260_AUTO)
4320 spec->init_hook = alc260_auto_init;
4329 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4330 * configuration. Each pin widget can choose any input DACs and a mixer.
4331 * Each ADC is connected from a mixer of all inputs. This makes possible
4332 * 6-channel independent captures.
4334 * In addition, an independent DAC for the multi-playback (not used in this
4337 #define ALC882_DIGOUT_NID 0x06
4338 #define ALC882_DIGIN_NID 0x0a
4340 static struct hda_channel_mode alc882_ch_modes[1] = {
4344 static hda_nid_t alc882_dac_nids[4] = {
4345 /* front, rear, clfe, rear_surr */
4346 0x02, 0x03, 0x04, 0x05
4349 /* identical with ALC880 */
4350 #define alc882_adc_nids alc880_adc_nids
4351 #define alc882_adc_nids_alt alc880_adc_nids_alt
4354 /* FIXME: should be a matrix-type input source selection */
4356 static struct hda_input_mux alc882_capture_source = {
4360 { "Front Mic", 0x1 },
4365 #define alc882_mux_enum_info alc_mux_enum_info
4366 #define alc882_mux_enum_get alc_mux_enum_get
4368 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4371 struct alc_spec *spec = codec->spec;
4372 const struct hda_input_mux *imux = spec->input_mux;
4373 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4374 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4375 hda_nid_t nid = capture_mixers[adc_idx];
4376 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4377 unsigned int i, idx;
4379 idx = ucontrol->value.enumerated.item[0];
4380 if (idx >= imux->num_items)
4381 idx = imux->num_items - 1;
4382 if (*cur_val == idx && ! codec->in_resume)
4384 for (i = 0; i < imux->num_items; i++) {
4385 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4386 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4387 v | (imux->items[i].index << 8));
4396 static struct hda_verb alc882_sixstack_ch6_init[] = {
4397 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4398 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4399 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4400 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4407 static struct hda_verb alc882_sixstack_ch8_init[] = {
4408 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4409 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4410 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4411 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4415 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4416 { 6, alc882_sixstack_ch6_init },
4417 { 8, alc882_sixstack_ch8_init },
4420 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4421 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4423 static struct snd_kcontrol_new alc882_base_mixer[] = {
4424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4425 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4426 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4427 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4428 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4429 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4430 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4431 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4432 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4433 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4434 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4437 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4438 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4441 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4442 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4443 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4444 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4448 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4450 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4451 .name = "Channel Mode",
4452 .info = alc_ch_mode_info,
4453 .get = alc_ch_mode_get,
4454 .put = alc_ch_mode_put,
4459 static struct hda_verb alc882_init_verbs[] = {
4460 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4461 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4473 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4474 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4475 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4477 /* Front Pin: output 0 (0x0c) */
4478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4480 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4481 /* Rear Pin: output 1 (0x0d) */
4482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4485 /* CLFE Pin: output 2 (0x0e) */
4486 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4487 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4488 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4489 /* Side Pin: output 3 (0x0f) */
4490 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4491 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4492 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4493 /* Mic (rear) pin: input vref at 80% */
4494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4496 /* Front Mic pin: input vref at 80% */
4497 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4498 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4499 /* Line In pin: input */
4500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4502 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4503 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4504 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4505 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4506 /* CD pin widget for input */
4507 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4509 /* FIXME: use matrix-type input source selection */
4510 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4511 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4512 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4513 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4514 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4515 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4517 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4518 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4519 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4520 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4522 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4523 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4526 /* ADC1: mute amp left and right */
4527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4528 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4529 /* ADC2: mute amp left and right */
4530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4531 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4532 /* ADC3: mute amp left and right */
4533 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4534 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4539 static struct hda_verb alc882_eapd_verbs[] = {
4540 /* change to EAPD mode */
4541 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4542 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
4547 * generic initialization of ADC, input mixers and output mixers
4549 static struct hda_verb alc882_auto_init_verbs[] = {
4551 * Unmute ADC0-2 and set the default input to mic-in
4553 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4555 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4556 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4557 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4560 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4562 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4565 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4573 * Set up output mixers (0x0c - 0x0f)
4575 /* set vol=0 to output mixers */
4576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4577 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4578 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4580 /* set up input amps for analog loopback */
4581 /* Amp Indices: DAC = 0, mixer = 1 */
4582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4588 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4590 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4591 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4593 /* FIXME: use matrix-type input source selection */
4594 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4595 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4598 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4599 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4614 /* capture mixer elements */
4615 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4616 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4617 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4618 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4619 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4622 /* The multiple "Capture Source" controls confuse alsamixer
4623 * So call somewhat different..
4624 * FIXME: the controls appear in the "playback" view!
4626 /* .name = "Capture Source", */
4627 .name = "Input Source",
4629 .info = alc882_mux_enum_info,
4630 .get = alc882_mux_enum_get,
4631 .put = alc882_mux_enum_put,
4636 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4637 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4638 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4639 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4640 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4641 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4642 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4644 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4645 /* The multiple "Capture Source" controls confuse alsamixer
4646 * So call somewhat different..
4647 * FIXME: the controls appear in the "playback" view!
4649 /* .name = "Capture Source", */
4650 .name = "Input Source",
4652 .info = alc882_mux_enum_info,
4653 .get = alc882_mux_enum_get,
4654 .put = alc882_mux_enum_put,
4659 /* pcm configuration: identiacal with ALC880 */
4660 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4661 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4662 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4663 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4666 * configuration and preset
4668 static struct hda_board_config alc882_cfg_tbl[] = {
4669 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4670 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4671 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4672 .config = ALC882_6ST_DIG }, /* MSI */
4673 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4674 .config = ALC882_6ST_DIG }, /* Foxconn */
4675 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4676 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
4677 { .modelname = "arima", .config = ALC882_ARIMA },
4678 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4679 .config = ALC882_ARIMA }, /* Arima W820Di1 */
4680 { .modelname = "auto", .config = ALC882_AUTO },
4684 static struct alc_config_preset alc882_presets[] = {
4685 [ALC882_3ST_DIG] = {
4686 .mixers = { alc882_base_mixer },
4687 .init_verbs = { alc882_init_verbs },
4688 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4689 .dac_nids = alc882_dac_nids,
4690 .dig_out_nid = ALC882_DIGOUT_NID,
4691 .dig_in_nid = ALC882_DIGIN_NID,
4692 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4693 .channel_mode = alc882_ch_modes,
4695 .input_mux = &alc882_capture_source,
4697 [ALC882_6ST_DIG] = {
4698 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4699 .init_verbs = { alc882_init_verbs },
4700 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4701 .dac_nids = alc882_dac_nids,
4702 .dig_out_nid = ALC882_DIGOUT_NID,
4703 .dig_in_nid = ALC882_DIGIN_NID,
4704 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4705 .channel_mode = alc882_sixstack_modes,
4706 .input_mux = &alc882_capture_source,
4709 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4710 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4711 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4712 .dac_nids = alc882_dac_nids,
4713 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4714 .channel_mode = alc882_sixstack_modes,
4715 .input_mux = &alc882_capture_source,
4721 * BIOS auto configuration
4723 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4724 hda_nid_t nid, int pin_type,
4728 struct alc_spec *spec = codec->spec;
4731 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4734 idx = spec->multiout.dac_nids[dac_idx] - 2;
4736 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4737 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4738 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4742 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4744 struct alc_spec *spec = codec->spec;
4747 for (i = 0; i <= HDA_SIDE; i++) {
4748 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4750 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4754 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4756 struct alc_spec *spec = codec->spec;
4759 pin = spec->autocfg.hp_pins[0];
4760 if (pin) /* connect to front */
4761 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4764 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4765 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4767 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4769 struct alc_spec *spec = codec->spec;
4772 for (i = 0; i < AUTO_PIN_LAST; i++) {
4773 hda_nid_t nid = spec->autocfg.input_pins[i];
4774 if (alc882_is_input_pin(nid)) {
4775 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4776 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4777 if (nid != ALC882_PIN_CD_NID)
4778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4784 /* almost identical with ALC880 parser... */
4785 static int alc882_parse_auto_config(struct hda_codec *codec)
4787 struct alc_spec *spec = codec->spec;
4788 int err = alc880_parse_auto_config(codec);
4793 /* hack - override the init verbs */
4794 spec->init_verbs[0] = alc882_auto_init_verbs;
4798 /* additional initialization for auto-configuration model */
4799 static void alc882_auto_init(struct hda_codec *codec)
4801 alc882_auto_init_multi_out(codec);
4802 alc882_auto_init_hp_out(codec);
4803 alc882_auto_init_analog_input(codec);
4806 static int patch_alc882(struct hda_codec *codec)
4808 struct alc_spec *spec;
4809 int err, board_config;
4811 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4817 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4819 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4820 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4821 "trying auto-probe from BIOS...\n");
4822 board_config = ALC882_AUTO;
4825 if (board_config == ALC882_AUTO) {
4826 /* automatic parse from the BIOS config */
4827 err = alc882_parse_auto_config(codec);
4833 "hda_codec: Cannot set up configuration "
4834 "from BIOS. Using base mode...\n");
4835 board_config = ALC882_3ST_DIG;
4839 if (board_config != ALC882_AUTO)
4840 setup_preset(spec, &alc882_presets[board_config]);
4842 spec->stream_name_analog = "ALC882 Analog";
4843 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4844 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4846 spec->stream_name_digital = "ALC882 Digital";
4847 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4848 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4850 if (! spec->adc_nids && spec->input_mux) {
4851 /* check whether NID 0x07 is valid */
4852 unsigned int wcap = get_wcaps(codec, 0x07);
4853 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4854 if (wcap != AC_WID_AUD_IN) {
4855 spec->adc_nids = alc882_adc_nids_alt;
4856 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4857 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4860 spec->adc_nids = alc882_adc_nids;
4861 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4862 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4867 codec->patch_ops = alc_patch_ops;
4868 if (board_config == ALC882_AUTO)
4869 spec->init_hook = alc882_auto_init;
4877 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4878 * configuration. Each pin widget can choose any input DACs and a mixer.
4879 * Each ADC is connected from a mixer of all inputs. This makes possible
4880 * 6-channel independent captures.
4882 * In addition, an independent DAC for the multi-playback (not used in this
4885 #define ALC883_DIGOUT_NID 0x06
4886 #define ALC883_DIGIN_NID 0x0a
4888 static hda_nid_t alc883_dac_nids[4] = {
4889 /* front, rear, clfe, rear_surr */
4890 0x02, 0x04, 0x03, 0x05
4893 static hda_nid_t alc883_adc_nids[2] = {
4898 /* FIXME: should be a matrix-type input source selection */
4900 static struct hda_input_mux alc883_capture_source = {
4904 { "Front Mic", 0x1 },
4909 #define alc883_mux_enum_info alc_mux_enum_info
4910 #define alc883_mux_enum_get alc_mux_enum_get
4912 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4913 struct snd_ctl_elem_value *ucontrol)
4915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4916 struct alc_spec *spec = codec->spec;
4917 const struct hda_input_mux *imux = spec->input_mux;
4918 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4919 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4920 hda_nid_t nid = capture_mixers[adc_idx];
4921 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4922 unsigned int i, idx;
4924 idx = ucontrol->value.enumerated.item[0];
4925 if (idx >= imux->num_items)
4926 idx = imux->num_items - 1;
4927 if (*cur_val == idx && ! codec->in_resume)
4929 for (i = 0; i < imux->num_items; i++) {
4930 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4931 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4932 v | (imux->items[i].index << 8));
4940 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4947 static struct hda_verb alc883_3ST_ch2_init[] = {
4948 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4949 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4950 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4951 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4958 static struct hda_verb alc883_3ST_ch6_init[] = {
4959 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4960 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4961 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4962 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4963 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4964 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4968 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4969 { 2, alc883_3ST_ch2_init },
4970 { 6, alc883_3ST_ch6_init },
4976 static struct hda_verb alc883_sixstack_ch6_init[] = {
4977 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4978 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4979 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4980 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4987 static struct hda_verb alc883_sixstack_ch8_init[] = {
4988 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4989 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4990 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4991 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4995 static struct hda_channel_mode alc883_sixstack_modes[2] = {
4996 { 6, alc883_sixstack_ch6_init },
4997 { 8, alc883_sixstack_ch8_init },
5000 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5001 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5004 static struct snd_kcontrol_new alc883_base_mixer[] = {
5005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5007 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5008 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5009 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5010 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5011 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5012 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5013 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5014 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5015 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5018 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5019 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5022 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5023 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5024 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5025 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5026 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5027 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5028 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5029 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5032 /* .name = "Capture Source", */
5033 .name = "Input Source",
5035 .info = alc883_mux_enum_info,
5036 .get = alc883_mux_enum_get,
5037 .put = alc883_mux_enum_put,
5042 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5043 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5044 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5045 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5048 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5049 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5052 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5053 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5054 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5055 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5056 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5057 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5058 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5059 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5061 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5062 /* .name = "Capture Source", */
5063 .name = "Input Source",
5065 .info = alc883_mux_enum_info,
5066 .get = alc883_mux_enum_get,
5067 .put = alc883_mux_enum_put,
5072 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5075 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5076 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5077 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5078 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5079 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5080 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5081 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5084 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5085 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5087 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5088 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5089 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5090 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5091 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5092 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5093 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5094 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5095 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5098 /* .name = "Capture Source", */
5099 .name = "Input Source",
5101 .info = alc883_mux_enum_info,
5102 .get = alc883_mux_enum_get,
5103 .put = alc883_mux_enum_put,
5108 static snd_kcontrol_new_t alc883_fivestack_mixer[] = {
5109 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5110 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5111 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5112 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5113 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5114 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5115 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
5116 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5117 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, 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),
5132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5133 /* .name = "Capture Source", */
5134 .name = "Input Source",
5136 .info = alc883_mux_enum_info,
5137 .get = alc883_mux_enum_get,
5138 .put = alc883_mux_enum_put,
5143 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5144 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5146 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5147 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5148 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5149 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5150 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5151 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5153 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5154 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5155 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5156 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5159 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5160 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5161 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5162 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5165 /* .name = "Capture Source", */
5166 .name = "Input Source",
5168 .info = alc883_mux_enum_info,
5169 .get = alc883_mux_enum_get,
5170 .put = alc883_mux_enum_put,
5175 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5178 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5179 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5180 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5183 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5184 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5185 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5186 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5189 /* .name = "Capture Source", */
5190 .name = "Input Source",
5192 .info = alc883_mux_enum_info,
5193 .get = alc883_mux_enum_get,
5194 .put = alc883_mux_enum_put,
5199 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5201 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5202 .name = "Channel Mode",
5203 .info = alc_ch_mode_info,
5204 .get = alc_ch_mode_get,
5205 .put = alc_ch_mode_put,
5210 static struct hda_verb alc883_init_verbs[] = {
5211 /* ADC1: mute amp left and right */
5212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5213 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5214 /* ADC2: mute amp left and right */
5215 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5216 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5217 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5230 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5240 /* Front Pin: output 0 (0x0c) */
5241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5243 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5244 /* Rear Pin: output 1 (0x0d) */
5245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5248 /* CLFE Pin: output 2 (0x0e) */
5249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5250 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5251 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5252 /* Side Pin: output 3 (0x0f) */
5253 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5254 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5255 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5256 /* Mic (rear) pin: input vref at 80% */
5257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5259 /* Front Mic pin: input vref at 80% */
5260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5262 /* Line In pin: input */
5263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5265 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5269 /* CD pin widget for input */
5270 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5272 /* FIXME: use matrix-type input source selection */
5273 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5280 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5281 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5287 static struct hda_verb alc883_tagra_verbs[] = {
5288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5292 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5294 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5295 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5296 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5298 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5299 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5300 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5301 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5306 /* toggle speaker-output according to the hp-jack state */
5307 static void alc883_tagra_automute(struct hda_codec *codec)
5309 unsigned int present;
5311 present = snd_hda_codec_read(codec, 0x14, 0,
5312 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5313 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5314 0x80, present ? 0x80 : 0);
5315 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5316 0x80, present ? 0x80 : 0);
5317 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
5320 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5322 if ((res >> 26) == ALC880_HP_EVENT)
5323 alc883_tagra_automute(codec);
5327 * generic initialization of ADC, input mixers and output mixers
5329 static struct hda_verb alc883_auto_init_verbs[] = {
5331 * Unmute ADC0-2 and set the default input to mic-in
5333 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5338 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5340 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5343 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
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)},
5351 * Set up output mixers (0x0c - 0x0f)
5353 /* set vol=0 to output mixers */
5354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5357 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5358 /* set up input amps for analog loopback */
5359 /* Amp Indices: DAC = 0, mixer = 1 */
5360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5362 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5363 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5366 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5368 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5369 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5371 /* FIXME: use matrix-type input source selection */
5372 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5377 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5383 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5389 /* capture mixer elements */
5390 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5391 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5392 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5393 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5394 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5396 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5397 /* The multiple "Capture Source" controls confuse alsamixer
5398 * So call somewhat different..
5399 * FIXME: the controls appear in the "playback" view!
5401 /* .name = "Capture Source", */
5402 .name = "Input Source",
5404 .info = alc882_mux_enum_info,
5405 .get = alc882_mux_enum_get,
5406 .put = alc882_mux_enum_put,
5411 /* pcm configuration: identiacal with ALC880 */
5412 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5413 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5414 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5415 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5418 * configuration and preset
5420 static struct hda_board_config alc883_cfg_tbl[] = {
5421 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5422 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5423 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5424 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5425 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5426 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5427 .config = ALC883_3ST_6ch },
5428 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
5429 .config = ALC883_3ST_6ch }, /* D102GGC */
5430 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5431 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5432 .config = ALC883_6ST_DIG }, /* MSI */
5433 { .pci_subvendor = 0x1462, .pci_subdevice = 0x7280,
5434 .config = ALC883_6ST_DIG }, /* MSI K9A Platinum (MS-7280) */
5435 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5436 .config = ALC883_6ST_DIG }, /* Foxconn */
5437 { .pci_subvendor = 0x1462, .pci_subdevice = 0x7187,
5438 .config = ALC883_6ST_DIG }, /* MSI */
5439 { .modelname = "targa-dig", .config = ALC883_TARGA_DIG },
5440 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
5441 .config = ALC883_TARGA_DIG }, /* MSI */
5442 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fcc,
5443 .config = ALC883_TARGA_DIG }, /* MSI */
5444 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc1,
5445 .config = ALC883_TARGA_DIG }, /* MSI */
5446 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc3,
5447 .config = ALC883_TARGA_DIG }, /* MSI */
5448 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
5449 .config = ALC883_TARGA_DIG }, /* MSI */
5450 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4319,
5451 .config = ALC883_TARGA_DIG }, /* MSI */
5452 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3ef9,
5453 .config = ALC883_TARGA_DIG }, /* MSI */
5454 { .pci_subvendor = 0x1462, .pci_subdevice = 0x4324,
5455 .config = ALC883_TARGA_DIG }, /* MSI */
5456 { .modelname = "targa-2ch-dig", .config = ALC883_TARGA_2ch_DIG },
5457 { .pci_subvendor = 0x1462, .pci_subdevice = 0x0579,
5458 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
5459 { .pci_subvendor = 0x1462, .pci_subdevice = 0xa422,
5460 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
5461 { .pci_subvendor = 0x1462, .pci_subdevice = 0x3b7f,
5462 .config = ALC883_TARGA_2ch_DIG }, /* MSI */
5463 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5464 { .modelname = "acer", .config = ALC883_ACER },
5465 { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
5466 .config = ALC883_ACER },
5467 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
5468 .config = ALC883_ACER },
5469 { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
5470 .config = ALC883_ACER },
5471 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
5472 .modelname = "medion", .config = ALC883_MEDION },
5473 { .modelname = "auto", .config = ALC883_AUTO },
5477 static struct alc_config_preset alc883_presets[] = {
5478 [ALC883_3ST_2ch_DIG] = {
5479 .mixers = { alc883_3ST_2ch_mixer },
5480 .init_verbs = { alc883_init_verbs },
5481 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5482 .dac_nids = alc883_dac_nids,
5483 .dig_out_nid = ALC883_DIGOUT_NID,
5484 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5485 .adc_nids = alc883_adc_nids,
5486 .dig_in_nid = ALC883_DIGIN_NID,
5487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5488 .channel_mode = alc883_3ST_2ch_modes,
5489 .input_mux = &alc883_capture_source,
5491 [ALC883_3ST_6ch_DIG] = {
5492 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5493 .init_verbs = { alc883_init_verbs },
5494 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5495 .dac_nids = alc883_dac_nids,
5496 .dig_out_nid = ALC883_DIGOUT_NID,
5497 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5498 .adc_nids = alc883_adc_nids,
5499 .dig_in_nid = ALC883_DIGIN_NID,
5500 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5501 .channel_mode = alc883_3ST_6ch_modes,
5503 .input_mux = &alc883_capture_source,
5505 [ALC883_3ST_6ch] = {
5506 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5507 .init_verbs = { alc883_init_verbs },
5508 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5509 .dac_nids = alc883_dac_nids,
5510 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5511 .adc_nids = alc883_adc_nids,
5512 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5513 .channel_mode = alc883_3ST_6ch_modes,
5515 .input_mux = &alc883_capture_source,
5517 [ALC883_6ST_DIG] = {
5518 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5519 .init_verbs = { alc883_init_verbs },
5520 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5521 .dac_nids = alc883_dac_nids,
5522 .dig_out_nid = ALC883_DIGOUT_NID,
5523 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5524 .adc_nids = alc883_adc_nids,
5525 .dig_in_nid = ALC883_DIGIN_NID,
5526 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5527 .channel_mode = alc883_sixstack_modes,
5528 .input_mux = &alc883_capture_source,
5530 [ALC883_TARGA_DIG] = {
5531 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
5532 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5533 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5534 .dac_nids = alc883_dac_nids,
5535 .dig_out_nid = ALC883_DIGOUT_NID,
5536 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5537 .adc_nids = alc883_adc_nids,
5538 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5539 .channel_mode = alc883_3ST_6ch_modes,
5541 .input_mux = &alc883_capture_source,
5542 .unsol_event = alc883_tagra_unsol_event,
5543 .init_hook = alc883_tagra_automute,
5545 [ALC883_TARGA_2ch_DIG] = {
5546 .mixers = { alc883_tagra_2ch_mixer},
5547 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
5548 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5549 .dac_nids = alc883_dac_nids,
5550 .dig_out_nid = ALC883_DIGOUT_NID,
5551 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5552 .adc_nids = alc883_adc_nids,
5553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5554 .channel_mode = alc883_3ST_2ch_modes,
5555 .input_mux = &alc883_capture_source,
5556 .unsol_event = alc883_tagra_unsol_event,
5557 .init_hook = alc883_tagra_automute,
5559 [ALC888_DEMO_BOARD] = {
5560 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5561 .init_verbs = { alc883_init_verbs },
5562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5563 .dac_nids = alc883_dac_nids,
5564 .dig_out_nid = ALC883_DIGOUT_NID,
5565 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5566 .adc_nids = alc883_adc_nids,
5567 .dig_in_nid = ALC883_DIGIN_NID,
5568 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5569 .channel_mode = alc883_sixstack_modes,
5570 .input_mux = &alc883_capture_source,
5573 .mixers = { alc883_base_mixer,
5574 alc883_chmode_mixer },
5575 /* On TravelMate laptops, GPIO 0 enables the internal speaker
5576 * and the headphone jack. Turn this on and rely on the
5577 * standard mute methods whenever the user wants to turn
5578 * these outputs off.
5580 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
5581 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5582 .dac_nids = alc883_dac_nids,
5583 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5584 .adc_nids = alc883_adc_nids,
5585 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5586 .channel_mode = alc883_3ST_2ch_modes,
5587 .input_mux = &alc883_capture_source,
5590 .mixers = { alc883_fivestack_mixer,
5591 alc883_chmode_mixer },
5592 .init_verbs = { alc883_init_verbs,
5593 alc882_eapd_verbs },
5594 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5595 .dac_nids = alc883_dac_nids,
5596 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5597 .adc_nids = alc883_adc_nids,
5598 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5599 .channel_mode = alc883_sixstack_modes,
5600 .input_mux = &alc883_capture_source,
5607 * BIOS auto configuration
5609 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5610 hda_nid_t nid, int pin_type,
5614 struct alc_spec *spec = codec->spec;
5617 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5620 idx = spec->multiout.dac_nids[dac_idx] - 2;
5622 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5626 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5630 static void alc883_auto_init_multi_out(struct hda_codec *codec)
5632 struct alc_spec *spec = codec->spec;
5635 for (i = 0; i <= HDA_SIDE; i++) {
5636 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5638 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5642 static void alc883_auto_init_hp_out(struct hda_codec *codec)
5644 struct alc_spec *spec = codec->spec;
5647 pin = spec->autocfg.hp_pins[0];
5648 if (pin) /* connect to front */
5650 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5653 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5654 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5656 static void alc883_auto_init_analog_input(struct hda_codec *codec)
5658 struct alc_spec *spec = codec->spec;
5661 for (i = 0; i < AUTO_PIN_LAST; i++) {
5662 hda_nid_t nid = spec->autocfg.input_pins[i];
5663 if (alc883_is_input_pin(nid)) {
5664 snd_hda_codec_write(codec, nid, 0,
5665 AC_VERB_SET_PIN_WIDGET_CONTROL,
5666 (i <= AUTO_PIN_FRONT_MIC ?
5667 PIN_VREF80 : PIN_IN));
5668 if (nid != ALC883_PIN_CD_NID)
5669 snd_hda_codec_write(codec, nid, 0,
5670 AC_VERB_SET_AMP_GAIN_MUTE,
5676 /* almost identical with ALC880 parser... */
5677 static int alc883_parse_auto_config(struct hda_codec *codec)
5679 struct alc_spec *spec = codec->spec;
5680 int err = alc880_parse_auto_config(codec);
5685 /* hack - override the init verbs */
5686 spec->init_verbs[0] = alc883_auto_init_verbs;
5687 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5692 /* additional initialization for auto-configuration model */
5693 static void alc883_auto_init(struct hda_codec *codec)
5695 alc883_auto_init_multi_out(codec);
5696 alc883_auto_init_hp_out(codec);
5697 alc883_auto_init_analog_input(codec);
5700 static int patch_alc883(struct hda_codec *codec)
5702 struct alc_spec *spec;
5703 int err, board_config;
5705 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5711 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5712 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5713 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5714 "trying auto-probe from BIOS...\n");
5715 board_config = ALC883_AUTO;
5718 if (board_config == ALC883_AUTO) {
5719 /* automatic parse from the BIOS config */
5720 err = alc883_parse_auto_config(codec);
5726 "hda_codec: Cannot set up configuration "
5727 "from BIOS. Using base mode...\n");
5728 board_config = ALC883_3ST_2ch_DIG;
5732 if (board_config != ALC883_AUTO)
5733 setup_preset(spec, &alc883_presets[board_config]);
5735 spec->stream_name_analog = "ALC883 Analog";
5736 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5737 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5739 spec->stream_name_digital = "ALC883 Digital";
5740 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5741 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5743 if (! spec->adc_nids && spec->input_mux) {
5744 spec->adc_nids = alc883_adc_nids;
5745 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5748 codec->patch_ops = alc_patch_ops;
5749 if (board_config == ALC883_AUTO)
5750 spec->init_hook = alc883_auto_init;
5759 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5760 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
5762 #define alc262_dac_nids alc260_dac_nids
5763 #define alc262_adc_nids alc882_adc_nids
5764 #define alc262_adc_nids_alt alc882_adc_nids_alt
5766 #define alc262_modes alc260_modes
5767 #define alc262_capture_source alc882_capture_source
5769 static struct snd_kcontrol_new alc262_base_mixer[] = {
5770 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5771 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5772 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5773 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5774 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5775 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5776 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5780 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5781 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5782 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5784 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5785 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5789 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
5790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5791 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5792 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5793 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5794 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5795 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5800 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5801 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5802 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
5803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5807 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5808 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5809 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5811 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5812 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5816 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5822 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5823 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5824 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5825 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5829 #define alc262_capture_mixer alc882_capture_mixer
5830 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
5833 * generic initialization of ADC, input mixers and output mixers
5835 static struct hda_verb alc262_init_verbs[] = {
5837 * Unmute ADC0-2 and set the default input to mic-in
5839 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5841 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5842 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5843 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5844 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5846 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5848 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5851 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5859 * Set up output mixers (0x0c - 0x0e)
5861 /* set vol=0 to output mixers */
5862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5863 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5864 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5865 /* set up input amps for analog loopback */
5866 /* Amp Indices: DAC = 0, mixer = 1 */
5867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5868 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5872 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5875 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5877 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5878 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5879 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5881 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5884 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5887 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5888 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5890 /* FIXME: use matrix-type input source selection */
5891 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5892 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5893 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5894 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5895 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5896 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5898 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5899 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5900 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5911 static struct hda_verb alc262_hippo_unsol_verbs[] = {
5912 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5913 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5917 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
5918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5919 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5920 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5922 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5923 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5927 /* mute/unmute internal speaker according to the hp jack and mute state */
5928 static void alc262_hippo_automute(struct hda_codec *codec, int force)
5930 struct alc_spec *spec = codec->spec;
5933 if (force || ! spec->sense_updated) {
5934 unsigned int present;
5935 /* need to execute and sync at first */
5936 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
5937 present = snd_hda_codec_read(codec, 0x15, 0,
5938 AC_VERB_GET_PIN_SENSE, 0);
5939 spec->jack_present = (present & 0x80000000) != 0;
5940 spec->sense_updated = 1;
5942 if (spec->jack_present) {
5943 /* mute internal speaker */
5944 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5946 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5949 /* unmute internal speaker if necessary */
5950 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
5951 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5953 mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
5954 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5959 /* unsolicited event for HP jack sensing */
5960 static void alc262_hippo_unsol_event(struct hda_codec *codec,
5963 if ((res >> 26) != ALC880_HP_EVENT)
5965 alc262_hippo_automute(codec, 1);
5968 static void alc262_hippo1_automute(struct hda_codec *codec, int force)
5970 struct alc_spec *spec = codec->spec;
5973 if (force || ! spec->sense_updated) {
5974 unsigned int present;
5975 /* need to execute and sync at first */
5976 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
5977 present = snd_hda_codec_read(codec, 0x1b, 0,
5978 AC_VERB_GET_PIN_SENSE, 0);
5979 spec->jack_present = (present & 0x80000000) != 0;
5980 spec->sense_updated = 1;
5982 if (spec->jack_present) {
5983 /* mute internal speaker */
5984 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5986 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5989 /* unmute internal speaker if necessary */
5990 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
5991 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5993 mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
5994 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5999 /* unsolicited event for HP jack sensing */
6000 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
6003 if ((res >> 26) != ALC880_HP_EVENT)
6005 alc262_hippo1_automute(codec, 1);
6010 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
6013 #define ALC_HP_EVENT 0x37
6015 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
6016 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
6017 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6021 static struct hda_input_mux alc262_fujitsu_capture_source = {
6029 static struct hda_input_mux alc262_HP_capture_source = {
6033 { "Front Mic", 0x3 },
6040 /* mute/unmute internal speaker according to the hp jack and mute state */
6041 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6043 struct alc_spec *spec = codec->spec;
6046 if (force || ! spec->sense_updated) {
6047 unsigned int present;
6048 /* need to execute and sync at first */
6049 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
6050 present = snd_hda_codec_read(codec, 0x14, 0,
6051 AC_VERB_GET_PIN_SENSE, 0);
6052 spec->jack_present = (present & 0x80000000) != 0;
6053 spec->sense_updated = 1;
6055 if (spec->jack_present) {
6056 /* mute internal speaker */
6057 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6059 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6062 /* unmute internal speaker if necessary */
6063 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
6064 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
6066 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
6067 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
6072 /* unsolicited event for HP jack sensing */
6073 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
6076 if ((res >> 26) != ALC_HP_EVENT)
6078 alc262_fujitsu_automute(codec, 1);
6081 /* bind volumes of both NID 0x0c and 0x0d */
6082 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
6083 struct snd_ctl_elem_value *ucontrol)
6085 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6086 long *valp = ucontrol->value.integer.value;
6089 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
6090 0x7f, valp[0] & 0x7f);
6091 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
6092 0x7f, valp[1] & 0x7f);
6093 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
6094 0x7f, valp[0] & 0x7f);
6095 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
6096 0x7f, valp[1] & 0x7f);
6100 /* bind hp and internal speaker mute (with plug check) */
6101 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
6102 struct snd_ctl_elem_value *ucontrol)
6104 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6105 long *valp = ucontrol->value.integer.value;
6108 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
6109 0x80, valp[0] ? 0 : 0x80);
6110 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
6111 0x80, valp[1] ? 0 : 0x80);
6112 if (change || codec->in_resume)
6113 alc262_fujitsu_automute(codec, codec->in_resume);
6117 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
6119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6120 .name = "Master Playback Volume",
6121 .info = snd_hda_mixer_amp_volume_info,
6122 .get = snd_hda_mixer_amp_volume_get,
6123 .put = alc262_fujitsu_master_vol_put,
6124 .tlv = { .c = snd_hda_mixer_amp_tlv },
6125 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
6128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6129 .name = "Master Playback Switch",
6130 .info = snd_hda_mixer_amp_switch_info,
6131 .get = snd_hda_mixer_amp_switch_get,
6132 .put = alc262_fujitsu_master_sw_put,
6133 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
6135 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6136 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6138 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6139 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6143 /* additional init verbs for Benq laptops */
6144 static struct hda_verb alc262_EAPD_verbs[] = {
6145 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6146 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6150 /* add playback controls from the parsed DAC table */
6151 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6156 spec->multiout.num_dacs = 1; /* only use one dac */
6157 spec->multiout.dac_nids = spec->private_dac_nids;
6158 spec->multiout.dac_nids[0] = 2;
6160 nid = cfg->line_out_pins[0];
6162 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
6163 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
6165 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
6166 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6170 nid = cfg->speaker_pins[0];
6173 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
6174 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6176 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6177 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6180 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
6181 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6185 nid = cfg->hp_pins[0];
6187 /* spec->multiout.hp_nid = 2; */
6189 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
6190 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
6192 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6193 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6196 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6197 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6204 /* identical with ALC880 */
6205 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
6208 * generic initialization of ADC, input mixers and output mixers
6210 static struct hda_verb alc262_volume_init_verbs[] = {
6212 * Unmute ADC0-2 and set the default input to mic-in
6214 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6216 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6217 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6218 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6219 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6221 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6223 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6226 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6234 * Set up output mixers (0x0c - 0x0f)
6236 /* set vol=0 to output mixers */
6237 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6238 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6239 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6241 /* set up input amps for analog loopback */
6242 /* Amp Indices: DAC = 0, mixer = 1 */
6243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6247 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6250 /* FIXME: use matrix-type input source selection */
6251 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6252 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6258 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6271 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6273 * Unmute ADC0-2 and set the default input to mic-in
6275 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6277 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6279 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6282 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6284 * Note: PASD motherboards uses the Line In 2 as the input for front panel
6287 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
6294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
6297 * Set up output mixers (0x0c - 0x0e)
6299 /* set vol=0 to output mixers */
6300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6301 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6304 /* set up input amps for analog loopback */
6305 /* Amp Indices: DAC = 0, mixer = 1 */
6306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6313 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6315 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6318 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6320 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6321 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6325 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6326 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6327 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6330 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6331 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
6333 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6334 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
6337 /* FIXME: use matrix-type input source selection */
6338 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6339 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
6352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
6353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
6358 /* pcm configuration: identiacal with ALC880 */
6359 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
6360 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
6361 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
6362 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
6365 * BIOS auto configuration
6367 static int alc262_parse_auto_config(struct hda_codec *codec)
6369 struct alc_spec *spec = codec->spec;
6371 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6373 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6374 alc262_ignore)) < 0)
6376 if (! spec->autocfg.line_outs)
6377 return 0; /* can't find valid BIOS pin config */
6378 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6379 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6382 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6384 if (spec->autocfg.dig_out_pin)
6385 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
6386 if (spec->autocfg.dig_in_pin)
6387 spec->dig_in_nid = ALC262_DIGIN_NID;
6389 if (spec->kctl_alloc)
6390 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6392 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
6393 spec->num_mux_defs = 1;
6394 spec->input_mux = &spec->private_imux;
6399 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
6400 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
6401 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
6404 /* init callback for auto-configuration model -- overriding the default init */
6405 static void alc262_auto_init(struct hda_codec *codec)
6407 alc262_auto_init_multi_out(codec);
6408 alc262_auto_init_hp_out(codec);
6409 alc262_auto_init_analog_input(codec);
6413 * configuration and preset
6415 static struct hda_board_config alc262_cfg_tbl[] = {
6416 { .modelname = "basic", .config = ALC262_BASIC },
6417 { .modelname = "hippo",
6418 .pci_subvendor =0x1002, .pci_subdevice = 0x437b,
6419 .config = ALC262_HIPPO},
6420 { .modelname = "hippo_1",
6421 .pci_subvendor =0x17ff, .pci_subdevice = 0x058f,
6422 .config = ALC262_HIPPO_1},
6423 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
6424 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
6425 .config = ALC262_FUJITSU },
6426 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
6427 { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
6428 .config = ALC262_HP_BPC }, /* xw4400 */
6429 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801,
6430 .config = ALC262_HP_BPC }, /* q965 */
6431 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
6432 .config = ALC262_HP_BPC }, /* xw6400 */
6433 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
6434 .config = ALC262_HP_BPC }, /* xw8400 */
6435 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
6436 .config = ALC262_HP_BPC }, /* xw9400 */
6437 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
6438 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
6439 .config = ALC262_BENQ_ED8 },
6440 { .modelname = "auto", .config = ALC262_AUTO },
6444 static struct alc_config_preset alc262_presets[] = {
6446 .mixers = { alc262_base_mixer },
6447 .init_verbs = { alc262_init_verbs },
6448 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6449 .dac_nids = alc262_dac_nids,
6451 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6452 .channel_mode = alc262_modes,
6453 .input_mux = &alc262_capture_source,
6456 .mixers = { alc262_base_mixer },
6457 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
6458 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6459 .dac_nids = alc262_dac_nids,
6461 .dig_out_nid = ALC262_DIGOUT_NID,
6462 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6463 .channel_mode = alc262_modes,
6464 .input_mux = &alc262_capture_source,
6465 .unsol_event = alc262_hippo_unsol_event,
6467 [ALC262_HIPPO_1] = {
6468 .mixers = { alc262_hippo1_mixer },
6469 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
6470 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6471 .dac_nids = alc262_dac_nids,
6473 .dig_out_nid = ALC262_DIGOUT_NID,
6474 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6475 .channel_mode = alc262_modes,
6476 .input_mux = &alc262_capture_source,
6477 .unsol_event = alc262_hippo1_unsol_event,
6479 [ALC262_FUJITSU] = {
6480 .mixers = { alc262_fujitsu_mixer },
6481 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
6482 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6483 .dac_nids = alc262_dac_nids,
6485 .dig_out_nid = ALC262_DIGOUT_NID,
6486 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6487 .channel_mode = alc262_modes,
6488 .input_mux = &alc262_fujitsu_capture_source,
6489 .unsol_event = alc262_fujitsu_unsol_event,
6492 .mixers = { alc262_HP_BPC_mixer },
6493 .init_verbs = { alc262_HP_BPC_init_verbs },
6494 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6495 .dac_nids = alc262_dac_nids,
6497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6498 .channel_mode = alc262_modes,
6499 .input_mux = &alc262_HP_capture_source,
6501 [ALC262_BENQ_ED8] = {
6502 .mixers = { alc262_base_mixer },
6503 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
6504 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
6505 .dac_nids = alc262_dac_nids,
6507 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6508 .channel_mode = alc262_modes,
6509 .input_mux = &alc262_capture_source,
6513 static int patch_alc262(struct hda_codec *codec)
6515 struct alc_spec *spec;
6519 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6525 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
6528 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6529 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
6530 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
6531 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
6535 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
6537 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
6538 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
6539 "trying auto-probe from BIOS...\n");
6540 board_config = ALC262_AUTO;
6543 if (board_config == ALC262_AUTO) {
6544 /* automatic parse from the BIOS config */
6545 err = alc262_parse_auto_config(codec);
6551 "hda_codec: Cannot set up configuration "
6552 "from BIOS. Using base mode...\n");
6553 board_config = ALC262_BASIC;
6557 if (board_config != ALC262_AUTO)
6558 setup_preset(spec, &alc262_presets[board_config]);
6560 spec->stream_name_analog = "ALC262 Analog";
6561 spec->stream_analog_playback = &alc262_pcm_analog_playback;
6562 spec->stream_analog_capture = &alc262_pcm_analog_capture;
6564 spec->stream_name_digital = "ALC262 Digital";
6565 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6566 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6568 if (! spec->adc_nids && spec->input_mux) {
6569 /* check whether NID 0x07 is valid */
6570 unsigned int wcap = get_wcaps(codec, 0x07);
6572 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
6573 if (wcap != AC_WID_AUD_IN) {
6574 spec->adc_nids = alc262_adc_nids_alt;
6575 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6576 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
6579 spec->adc_nids = alc262_adc_nids;
6580 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
6581 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
6586 codec->patch_ops = alc_patch_ops;
6587 if (board_config == ALC262_AUTO)
6588 spec->init_hook = alc262_auto_init;
6594 * ALC861 channel source setting (2/6 channel selection for 3-stack)
6598 * set the path ways for 2 channel output
6599 * need to set the codec line out and mic 1 pin widgets to inputs
6601 static struct hda_verb alc861_threestack_ch2_init[] = {
6602 /* set pin widget 1Ah (line in) for input */
6603 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6604 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
6605 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6607 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6609 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6616 * need to set the codec line out and mic 1 pin widgets to outputs
6618 static struct hda_verb alc861_threestack_ch6_init[] = {
6619 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6620 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6621 /* set pin widget 18h (mic1) for output (CLFE)*/
6622 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6624 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6625 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6627 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6629 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6635 static struct hda_channel_mode alc861_threestack_modes[2] = {
6636 { 2, alc861_threestack_ch2_init },
6637 { 6, alc861_threestack_ch6_init },
6639 /* Set mic1 as input and unmute the mixer */
6640 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6641 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6642 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6645 /* Set mic1 as output and mute mixer */
6646 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6647 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6652 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6653 { 2, alc861_uniwill_m31_ch2_init },
6654 { 4, alc861_uniwill_m31_ch4_init },
6659 static struct snd_kcontrol_new alc861_base_mixer[] = {
6660 /* output mixer control */
6661 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6662 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6663 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6664 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6665 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6667 /*Input mixer control */
6668 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6669 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6670 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6671 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6672 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6673 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6675 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6679 /* Capture mixer control */
6680 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6681 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6684 .name = "Capture Source",
6686 .info = alc_mux_enum_info,
6687 .get = alc_mux_enum_get,
6688 .put = alc_mux_enum_put,
6693 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6694 /* output mixer control */
6695 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6696 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6697 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6698 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6699 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6701 /* Input mixer control */
6702 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6703 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6704 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6705 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6706 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6707 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6709 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6713 /* Capture mixer control */
6714 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6715 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6718 .name = "Capture Source",
6720 .info = alc_mux_enum_info,
6721 .get = alc_mux_enum_get,
6722 .put = alc_mux_enum_put,
6725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6726 .name = "Channel Mode",
6727 .info = alc_ch_mode_info,
6728 .get = alc_ch_mode_get,
6729 .put = alc_ch_mode_put,
6730 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6735 static snd_kcontrol_new_t alc861_toshiba_mixer[] = {
6736 /* output mixer control */
6737 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6739 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6741 /*Capture mixer control */
6742 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6743 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6745 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6746 .name = "Capture Source",
6748 .info = alc_mux_enum_info,
6749 .get = alc_mux_enum_get,
6750 .put = alc_mux_enum_put,
6756 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6757 /* output mixer control */
6758 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6759 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6760 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6761 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6762 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6764 /* Input mixer control */
6765 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6766 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6767 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6768 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6769 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6770 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6772 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6773 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6776 /* Capture mixer control */
6777 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6778 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6781 .name = "Capture Source",
6783 .info = alc_mux_enum_info,
6784 .get = alc_mux_enum_get,
6785 .put = alc_mux_enum_put,
6788 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6789 .name = "Channel Mode",
6790 .info = alc_ch_mode_info,
6791 .get = alc_ch_mode_get,
6792 .put = alc_ch_mode_put,
6793 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6799 * generic initialization of ADC, input mixers and output mixers
6801 static struct hda_verb alc861_base_init_verbs[] = {
6803 * Unmute ADC0 and set the default input to mic-in
6805 /* port-A for surround (rear panel) */
6806 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6807 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6808 /* port-B for mic-in (rear panel) with vref */
6809 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6810 /* port-C for line-in (rear panel) */
6811 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6812 /* port-D for Front */
6813 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6814 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6815 /* port-E for HP out (front panel) */
6816 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6817 /* route front PCM to HP */
6818 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6819 /* port-F for mic-in (front panel) with vref */
6820 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6821 /* port-G for CLFE (rear panel) */
6822 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6823 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6824 /* port-H for side (rear panel) */
6825 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6826 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6828 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6829 /* route front mic to ADC1*/
6830 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6833 /* Unmute DAC0~3 & spdif out*/
6834 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6835 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6836 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6837 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6838 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6840 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6841 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6842 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6843 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6844 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6846 /* Unmute Stereo Mixer 15 */
6847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6853 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6855 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6857 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6859 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6861 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6866 static struct hda_verb alc861_threestack_init_verbs[] = {
6868 * Unmute ADC0 and set the default input to mic-in
6870 /* port-A for surround (rear panel) */
6871 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6872 /* port-B for mic-in (rear panel) with vref */
6873 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6874 /* port-C for line-in (rear panel) */
6875 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6876 /* port-D for Front */
6877 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6878 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6879 /* port-E for HP out (front panel) */
6880 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6881 /* route front PCM to HP */
6882 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6883 /* port-F for mic-in (front panel) with vref */
6884 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6885 /* port-G for CLFE (rear panel) */
6886 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6887 /* port-H for side (rear panel) */
6888 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6890 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6891 /* route front mic to ADC1*/
6892 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6894 /* Unmute DAC0~3 & spdif out*/
6895 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6898 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6901 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6902 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6903 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6904 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6905 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6907 /* Unmute Stereo Mixer 15 */
6908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6909 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6921 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6926 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
6928 * Unmute ADC0 and set the default input to mic-in
6930 /* port-A for surround (rear panel) */
6931 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6932 /* port-B for mic-in (rear panel) with vref */
6933 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6934 /* port-C for line-in (rear panel) */
6935 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6936 /* port-D for Front */
6937 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6938 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6939 /* port-E for HP out (front panel) */
6940 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
6941 /* route front PCM to HP */
6942 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6943 /* port-F for mic-in (front panel) with vref */
6944 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6945 /* port-G for CLFE (rear panel) */
6946 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6947 /* port-H for side (rear panel) */
6948 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6950 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6951 /* route front mic to ADC1*/
6952 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6953 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6954 /* Unmute DAC0~3 & spdif out*/
6955 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6956 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6957 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6958 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6961 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6962 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6963 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6964 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6965 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6967 /* Unmute Stereo Mixer 15 */
6968 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6973 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6974 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6975 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6976 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6977 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6978 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6979 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6980 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6981 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6982 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6987 * generic initialization of ADC, input mixers and output mixers
6989 static struct hda_verb alc861_auto_init_verbs[] = {
6991 * Unmute ADC0 and set the default input to mic-in
6993 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6994 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6996 /* Unmute DAC0~3 & spdif out*/
6997 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6998 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6999 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7000 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7003 /* Unmute Mixer 14 (mic) 1c (Line in)*/
7004 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7005 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7006 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7007 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7009 /* Unmute Stereo Mixer 15 */
7010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
7015 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7017 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7018 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7019 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7020 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7021 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7022 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7025 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7026 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7027 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7028 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7030 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7031 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7033 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
7038 static struct hda_verb alc861_toshiba_init_verbs[] = {
7039 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7044 /* toggle speaker-output according to the hp-jack state */
7045 static void alc861_toshiba_automute(struct hda_codec *codec)
7047 unsigned int present;
7049 present = snd_hda_codec_read(codec, 0x0f, 0,
7050 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7051 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
7052 0x80, present ? 0x80 : 0);
7053 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
7054 0x80, present ? 0x80 : 0);
7055 snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
7056 0x80, present ? 0 : 0x80);
7057 snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
7058 0x80, present ? 0 : 0x80);
7061 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7064 /* Looks like the unsol event is incompatible with the standard
7065 * definition. 6bit tag is placed at 26 bit!
7067 if ((res >> 26) == ALC880_HP_EVENT)
7068 alc861_toshiba_automute(codec);
7071 /* pcm configuration: identiacal with ALC880 */
7072 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
7073 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
7074 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
7075 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
7078 #define ALC861_DIGOUT_NID 0x07
7080 static struct hda_channel_mode alc861_8ch_modes[1] = {
7084 static hda_nid_t alc861_dac_nids[4] = {
7085 /* front, surround, clfe, side */
7086 0x03, 0x06, 0x05, 0x04
7089 static hda_nid_t alc660_dac_nids[3] = {
7090 /* front, clfe, surround */
7094 static hda_nid_t alc861_adc_nids[1] = {
7099 static struct hda_input_mux alc861_capture_source = {
7103 { "Front Mic", 0x3 },
7110 /* fill in the dac_nids table from the parsed pin configuration */
7111 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7116 spec->multiout.dac_nids = spec->private_dac_nids;
7117 for (i = 0; i < cfg->line_outs; i++) {
7118 nid = cfg->line_out_pins[i];
7120 if (i >= ARRAY_SIZE(alc861_dac_nids))
7122 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
7125 spec->multiout.num_dacs = cfg->line_outs;
7129 /* add playback controls from the parsed DAC table */
7130 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7131 const struct auto_pin_cfg *cfg)
7134 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
7138 for (i = 0; i < cfg->line_outs; i++) {
7139 nid = spec->multiout.dac_nids[i];
7144 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
7145 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
7147 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
7148 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
7151 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
7152 if (nid == alc861_dac_nids[idx])
7154 sprintf(name, "%s Playback Switch", chname[idx]);
7155 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7156 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7163 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7171 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7173 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
7174 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
7176 spec->multiout.hp_nid = nid;
7181 /* create playback/capture controls for input pins */
7182 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
7184 struct hda_input_mux *imux = &spec->private_imux;
7185 int i, err, idx, idx1;
7187 for (i = 0; i < AUTO_PIN_LAST; i++) {
7188 switch(cfg->input_pins[i]) {
7213 err = new_analog_input(spec, cfg->input_pins[i],
7214 auto_pin_cfg_labels[i], idx, 0x15);
7218 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7219 imux->items[imux->num_items].index = idx1;
7225 static struct snd_kcontrol_new alc861_capture_mixer[] = {
7226 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7227 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7231 /* The multiple "Capture Source" controls confuse alsamixer
7232 * So call somewhat different..
7233 *FIXME: the controls appear in the "playback" view!
7235 /* .name = "Capture Source", */
7236 .name = "Input Source",
7238 .info = alc_mux_enum_info,
7239 .get = alc_mux_enum_get,
7240 .put = alc_mux_enum_put,
7245 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
7246 int pin_type, int dac_idx)
7250 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
7251 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
7255 static void alc861_auto_init_multi_out(struct hda_codec *codec)
7257 struct alc_spec *spec = codec->spec;
7260 for (i = 0; i < spec->autocfg.line_outs; i++) {
7261 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7263 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
7267 static void alc861_auto_init_hp_out(struct hda_codec *codec)
7269 struct alc_spec *spec = codec->spec;
7272 pin = spec->autocfg.hp_pins[0];
7273 if (pin) /* connect to front */
7274 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
7277 static void alc861_auto_init_analog_input(struct hda_codec *codec)
7279 struct alc_spec *spec = codec->spec;
7282 for (i = 0; i < AUTO_PIN_LAST; i++) {
7283 hda_nid_t nid = spec->autocfg.input_pins[i];
7284 if ((nid>=0x0c) && (nid <=0x11)) {
7285 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7286 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
7291 /* parse the BIOS configuration and set up the alc_spec */
7292 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
7293 static int alc861_parse_auto_config(struct hda_codec *codec)
7295 struct alc_spec *spec = codec->spec;
7297 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7299 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7300 alc861_ignore)) < 0)
7302 if (! spec->autocfg.line_outs)
7303 return 0; /* can't find valid BIOS pin config */
7305 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
7306 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
7307 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
7308 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
7311 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7313 if (spec->autocfg.dig_out_pin)
7314 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
7316 if (spec->kctl_alloc)
7317 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7319 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
7321 spec->num_mux_defs = 1;
7322 spec->input_mux = &spec->private_imux;
7324 spec->adc_nids = alc861_adc_nids;
7325 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
7326 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
7332 /* additional initialization for auto-configuration model */
7333 static void alc861_auto_init(struct hda_codec *codec)
7335 alc861_auto_init_multi_out(codec);
7336 alc861_auto_init_hp_out(codec);
7337 alc861_auto_init_analog_input(codec);
7342 * configuration and preset
7344 static struct hda_board_config alc861_cfg_tbl[] = {
7345 { .modelname = "3stack", .config = ALC861_3ST },
7346 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
7347 .config = ALC861_3ST },
7348 { .modelname = "3stack-660", .config = ALC660_3ST },
7349 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
7350 .config = ALC660_3ST },
7351 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
7352 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
7353 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
7354 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
7355 .config = ALC861_UNIWILL_M31 },
7356 { .modelname = "toshiba", .config = ALC861_TOSHIBA },
7357 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1338,
7358 .config = ALC861_TOSHIBA },
7359 { .pci_subvendor = 0x1179, .pci_subdevice = 0xff10,
7360 .config = ALC861_TOSHIBA },
7361 { .modelname = "auto", .config = ALC861_AUTO },
7365 static struct alc_config_preset alc861_presets[] = {
7367 .mixers = { alc861_3ST_mixer },
7368 .init_verbs = { alc861_threestack_init_verbs },
7369 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7370 .dac_nids = alc861_dac_nids,
7371 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7372 .channel_mode = alc861_threestack_modes,
7374 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7375 .adc_nids = alc861_adc_nids,
7376 .input_mux = &alc861_capture_source,
7378 [ALC861_3ST_DIG] = {
7379 .mixers = { alc861_base_mixer },
7380 .init_verbs = { alc861_threestack_init_verbs },
7381 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7382 .dac_nids = alc861_dac_nids,
7383 .dig_out_nid = ALC861_DIGOUT_NID,
7384 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7385 .channel_mode = alc861_threestack_modes,
7387 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7388 .adc_nids = alc861_adc_nids,
7389 .input_mux = &alc861_capture_source,
7391 [ALC861_6ST_DIG] = {
7392 .mixers = { alc861_base_mixer },
7393 .init_verbs = { alc861_base_init_verbs },
7394 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7395 .dac_nids = alc861_dac_nids,
7396 .dig_out_nid = ALC861_DIGOUT_NID,
7397 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
7398 .channel_mode = alc861_8ch_modes,
7399 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7400 .adc_nids = alc861_adc_nids,
7401 .input_mux = &alc861_capture_source,
7404 .mixers = { alc861_3ST_mixer },
7405 .init_verbs = { alc861_threestack_init_verbs },
7406 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
7407 .dac_nids = alc660_dac_nids,
7408 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
7409 .channel_mode = alc861_threestack_modes,
7411 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7412 .adc_nids = alc861_adc_nids,
7413 .input_mux = &alc861_capture_source,
7415 [ALC861_UNIWILL_M31] = {
7416 .mixers = { alc861_uniwill_m31_mixer },
7417 .init_verbs = { alc861_uniwill_m31_init_verbs },
7418 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7419 .dac_nids = alc861_dac_nids,
7420 .dig_out_nid = ALC861_DIGOUT_NID,
7421 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
7422 .channel_mode = alc861_uniwill_m31_modes,
7424 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7425 .adc_nids = alc861_adc_nids,
7426 .input_mux = &alc861_capture_source,
7428 [ALC861_TOSHIBA] = {
7429 .mixers = { alc861_toshiba_mixer },
7430 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
7431 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7432 .dac_nids = alc861_dac_nids,
7433 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7434 .channel_mode = alc883_3ST_2ch_modes,
7435 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
7436 .adc_nids = alc861_adc_nids,
7437 .input_mux = &alc861_capture_source,
7438 .unsol_event = alc861_toshiba_unsol_event,
7439 .init_hook = alc861_toshiba_automute,
7444 static int patch_alc861(struct hda_codec *codec)
7446 struct alc_spec *spec;
7450 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
7456 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
7458 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
7459 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
7460 "trying auto-probe from BIOS...\n");
7461 board_config = ALC861_AUTO;
7464 if (board_config == ALC861_AUTO) {
7465 /* automatic parse from the BIOS config */
7466 err = alc861_parse_auto_config(codec);
7472 "hda_codec: Cannot set up configuration "
7473 "from BIOS. Using base mode...\n");
7474 board_config = ALC861_3ST_DIG;
7478 if (board_config != ALC861_AUTO)
7479 setup_preset(spec, &alc861_presets[board_config]);
7481 spec->stream_name_analog = "ALC861 Analog";
7482 spec->stream_analog_playback = &alc861_pcm_analog_playback;
7483 spec->stream_analog_capture = &alc861_pcm_analog_capture;
7485 spec->stream_name_digital = "ALC861 Digital";
7486 spec->stream_digital_playback = &alc861_pcm_digital_playback;
7487 spec->stream_digital_capture = &alc861_pcm_digital_capture;
7489 codec->patch_ops = alc_patch_ops;
7490 if (board_config == ALC861_AUTO)
7491 spec->init_hook = alc861_auto_init;
7499 struct hda_codec_preset snd_hda_preset_realtek[] = {
7500 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
7501 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
7502 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
7503 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
7504 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
7505 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
7506 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
7507 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
7508 .patch = patch_alc861 },
7509 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
7510 .patch = patch_alc861 },
7511 { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },