2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sound/driver.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include "hda_codec.h"
33 #include "hda_local.h"
36 /* ALC880 board config type */
56 #ifdef CONFIG_SND_DEBUG
60 ALC880_MODEL_LAST /* last tag */
70 #ifdef CONFIG_SND_DEBUG
74 ALC260_MODEL_LAST /* last tag */
84 ALC262_MODEL_LAST /* last tag */
118 #define GPIO_MASK 0x03
121 /* codec parameterization */
122 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
123 unsigned int num_mixers;
125 const struct hda_verb *init_verbs[5]; /* initialization verbs
129 unsigned int num_init_verbs;
131 char *stream_name_analog; /* analog PCM stream */
132 struct hda_pcm_stream *stream_analog_playback;
133 struct hda_pcm_stream *stream_analog_capture;
135 char *stream_name_digital; /* digital PCM stream */
136 struct hda_pcm_stream *stream_digital_playback;
137 struct hda_pcm_stream *stream_digital_capture;
140 struct hda_multi_out multiout; /* playback set-up
141 * max_channels, dacs must be set
142 * dig_out_nid and hp_nid are optional
146 unsigned int num_adc_nids;
148 hda_nid_t dig_in_nid; /* digital-in NID; optional */
151 unsigned int num_mux_defs;
152 const struct hda_input_mux *input_mux;
153 unsigned int cur_mux[3];
156 const struct hda_channel_mode *channel_mode;
157 int num_channel_mode;
160 /* PCM information */
161 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
163 /* dynamic controls, init_verbs and input_mux */
164 struct auto_pin_cfg autocfg;
165 unsigned int num_kctl_alloc, num_kctl_used;
166 struct snd_kcontrol_new *kctl_alloc;
167 struct hda_input_mux private_imux;
168 hda_nid_t private_dac_nids[5];
171 void (*init_hook)(struct hda_codec *codec);
172 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
174 /* for pin sensing */
175 unsigned int sense_updated: 1;
176 unsigned int jack_present: 1;
180 * configuration template - to be copied to the spec instance
182 struct alc_config_preset {
183 struct snd_kcontrol_new *mixers[5]; /* should be identical size
186 const struct hda_verb *init_verbs[5];
187 unsigned int num_dacs;
189 hda_nid_t dig_out_nid; /* optional */
190 hda_nid_t hp_nid; /* optional */
191 unsigned int num_adc_nids;
193 hda_nid_t dig_in_nid;
194 unsigned int num_channel_mode;
195 const struct hda_channel_mode *channel_mode;
197 unsigned int num_mux_defs;
198 const struct hda_input_mux *input_mux;
199 void (*unsol_event)(struct hda_codec *, unsigned int);
200 void (*init_hook)(struct hda_codec *);
207 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
208 struct snd_ctl_elem_info *uinfo)
210 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
211 struct alc_spec *spec = codec->spec;
212 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
213 if (mux_idx >= spec->num_mux_defs)
215 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
218 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
219 struct snd_ctl_elem_value *ucontrol)
221 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
222 struct alc_spec *spec = codec->spec;
223 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
225 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
229 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_value *ucontrol)
232 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
233 struct alc_spec *spec = codec->spec;
234 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
235 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
236 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
237 spec->adc_nids[adc_idx],
238 &spec->cur_mux[adc_idx]);
243 * channel mode setting
245 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
246 struct snd_ctl_elem_info *uinfo)
248 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
249 struct alc_spec *spec = codec->spec;
250 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
251 spec->num_channel_mode);
254 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
255 struct snd_ctl_elem_value *ucontrol)
257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
258 struct alc_spec *spec = codec->spec;
259 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
260 spec->num_channel_mode,
261 spec->multiout.max_channels);
264 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
265 struct snd_ctl_elem_value *ucontrol)
267 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
268 struct alc_spec *spec = codec->spec;
269 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
270 spec->num_channel_mode,
271 &spec->multiout.max_channels);
272 if (! err && spec->need_dac_fix)
273 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
278 * Control the mode of pin widget settings via the mixer. "pc" is used
279 * instead of "%" to avoid consequences of accidently treating the % as
280 * being part of a format specifier. Maximum allowed length of a value is
281 * 63 characters plus NULL terminator.
283 * Note: some retasking pin complexes seem to ignore requests for input
284 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
285 * are requested. Therefore order this list so that this behaviour will not
286 * cause problems when mixer clients move through the enum sequentially.
287 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
290 static char *alc_pin_mode_names[] = {
291 "Mic 50pc bias", "Mic 80pc bias",
292 "Line in", "Line out", "Headphone out",
294 static unsigned char alc_pin_mode_values[] = {
295 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
297 /* The control can present all 5 options, or it can limit the options based
298 * in the pin being assumed to be exclusively an input or an output pin. In
299 * addition, "input" pins may or may not process the mic bias option
300 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
301 * accept requests for bias as of chip versions up to March 2006) and/or
302 * wiring in the computer.
304 #define ALC_PIN_DIR_IN 0x00
305 #define ALC_PIN_DIR_OUT 0x01
306 #define ALC_PIN_DIR_INOUT 0x02
307 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
308 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
310 /* Info about the pin modes supported by the different pin direction modes.
311 * For each direction the minimum and maximum values are given.
313 static signed char alc_pin_mode_dir_info[5][2] = {
314 { 0, 2 }, /* ALC_PIN_DIR_IN */
315 { 3, 4 }, /* ALC_PIN_DIR_OUT */
316 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
317 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
318 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
320 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
321 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
322 #define alc_pin_mode_n_items(_dir) \
323 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
325 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_info *uinfo)
328 unsigned int item_num = uinfo->value.enumerated.item;
329 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
331 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
333 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
335 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
336 item_num = alc_pin_mode_min(dir);
337 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
341 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
342 struct snd_ctl_elem_value *ucontrol)
345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
346 hda_nid_t nid = kcontrol->private_value & 0xffff;
347 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
348 long *valp = ucontrol->value.integer.value;
349 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
350 AC_VERB_GET_PIN_WIDGET_CONTROL,
353 /* Find enumerated value for current pinctl setting */
354 i = alc_pin_mode_min(dir);
355 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
357 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
361 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
362 struct snd_ctl_elem_value *ucontrol)
365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
366 hda_nid_t nid = kcontrol->private_value & 0xffff;
367 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
368 long val = *ucontrol->value.integer.value;
369 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
370 AC_VERB_GET_PIN_WIDGET_CONTROL,
373 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
374 val = alc_pin_mode_min(dir);
376 change = pinctl != alc_pin_mode_values[val];
378 /* Set pin mode to that requested */
379 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
380 alc_pin_mode_values[val]);
382 /* Also enable the retasking pin's input/output as required
383 * for the requested pin mode. Enum values of 2 or less are
386 * Dynamically switching the input/output buffers probably
387 * reduces noise slightly (particularly on input) so we'll
388 * do it. However, having both input and output buffers
389 * enabled simultaneously doesn't seem to be problematic if
390 * this turns out to be necessary in the future.
393 snd_hda_codec_write(codec, nid, 0,
394 AC_VERB_SET_AMP_GAIN_MUTE,
396 snd_hda_codec_write(codec, nid, 0,
397 AC_VERB_SET_AMP_GAIN_MUTE,
400 snd_hda_codec_write(codec, nid, 0,
401 AC_VERB_SET_AMP_GAIN_MUTE,
403 snd_hda_codec_write(codec, nid, 0,
404 AC_VERB_SET_AMP_GAIN_MUTE,
411 #define ALC_PIN_MODE(xname, nid, dir) \
412 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
413 .info = alc_pin_mode_info, \
414 .get = alc_pin_mode_get, \
415 .put = alc_pin_mode_put, \
416 .private_value = nid | (dir<<16) }
418 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
419 * together using a mask with more than one bit set. This control is
420 * currently used only by the ALC260 test model. At this stage they are not
421 * needed for any "production" models.
423 #ifdef CONFIG_SND_DEBUG
424 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_info *uinfo)
427 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
429 uinfo->value.integer.min = 0;
430 uinfo->value.integer.max = 1;
433 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
434 struct snd_ctl_elem_value *ucontrol)
436 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
437 hda_nid_t nid = kcontrol->private_value & 0xffff;
438 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
439 long *valp = ucontrol->value.integer.value;
440 unsigned int val = snd_hda_codec_read(codec, nid, 0,
441 AC_VERB_GET_GPIO_DATA, 0x00);
443 *valp = (val & mask) != 0;
446 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_value *ucontrol)
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 hda_nid_t nid = kcontrol->private_value & 0xffff;
452 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
453 long val = *ucontrol->value.integer.value;
454 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
455 AC_VERB_GET_GPIO_DATA,
458 /* Set/unset the masked GPIO bit(s) as needed */
459 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
464 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
468 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
469 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
470 .info = alc_gpio_data_info, \
471 .get = alc_gpio_data_get, \
472 .put = alc_gpio_data_put, \
473 .private_value = nid | (mask<<16) }
474 #endif /* CONFIG_SND_DEBUG */
476 /* A switch control to allow the enabling of the digital IO pins on the
477 * ALC260. This is incredibly simplistic; the intention of this control is
478 * to provide something in the test model allowing digital outputs to be
479 * identified if present. If models are found which can utilise these
480 * outputs a more complete mixer control can be devised for those models if
483 #ifdef CONFIG_SND_DEBUG
484 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_info *uinfo)
487 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
489 uinfo->value.integer.min = 0;
490 uinfo->value.integer.max = 1;
493 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
494 struct snd_ctl_elem_value *ucontrol)
496 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
497 hda_nid_t nid = kcontrol->private_value & 0xffff;
498 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
499 long *valp = ucontrol->value.integer.value;
500 unsigned int val = snd_hda_codec_read(codec, nid, 0,
501 AC_VERB_GET_DIGI_CONVERT, 0x00);
503 *valp = (val & mask) != 0;
506 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
507 struct snd_ctl_elem_value *ucontrol)
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 hda_nid_t nid = kcontrol->private_value & 0xffff;
512 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
513 long val = *ucontrol->value.integer.value;
514 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
515 AC_VERB_GET_DIGI_CONVERT,
518 /* Set/unset the masked control bit(s) as needed */
519 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
524 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
529 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
530 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
531 .info = alc_spdif_ctrl_info, \
532 .get = alc_spdif_ctrl_get, \
533 .put = alc_spdif_ctrl_put, \
534 .private_value = nid | (mask<<16) }
535 #endif /* CONFIG_SND_DEBUG */
538 * set up from the preset table
540 static void setup_preset(struct alc_spec *spec,
541 const struct alc_config_preset *preset)
545 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
546 spec->mixers[spec->num_mixers++] = preset->mixers[i];
547 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
549 spec->init_verbs[spec->num_init_verbs++] =
550 preset->init_verbs[i];
552 spec->channel_mode = preset->channel_mode;
553 spec->num_channel_mode = preset->num_channel_mode;
554 spec->need_dac_fix = preset->need_dac_fix;
556 spec->multiout.max_channels = spec->channel_mode[0].channels;
558 spec->multiout.num_dacs = preset->num_dacs;
559 spec->multiout.dac_nids = preset->dac_nids;
560 spec->multiout.dig_out_nid = preset->dig_out_nid;
561 spec->multiout.hp_nid = preset->hp_nid;
563 spec->num_mux_defs = preset->num_mux_defs;
564 if (! spec->num_mux_defs)
565 spec->num_mux_defs = 1;
566 spec->input_mux = preset->input_mux;
568 spec->num_adc_nids = preset->num_adc_nids;
569 spec->adc_nids = preset->adc_nids;
570 spec->dig_in_nid = preset->dig_in_nid;
572 spec->unsol_event = preset->unsol_event;
573 spec->init_hook = preset->init_hook;
577 * ALC880 3-stack model
579 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
580 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
581 * F-Mic = 0x1b, HP = 0x19
584 static hda_nid_t alc880_dac_nids[4] = {
585 /* front, rear, clfe, rear_surr */
586 0x02, 0x05, 0x04, 0x03
589 static hda_nid_t alc880_adc_nids[3] = {
594 /* The datasheet says the node 0x07 is connected from inputs,
595 * but it shows zero connection in the real implementation on some devices.
596 * Note: this is a 915GAV bug, fixed on 915GLV
598 static hda_nid_t alc880_adc_nids_alt[2] = {
603 #define ALC880_DIGOUT_NID 0x06
604 #define ALC880_DIGIN_NID 0x0a
606 static struct hda_input_mux alc880_capture_source = {
610 { "Front Mic", 0x3 },
616 /* channel source setting (2/6 channel selection for 3-stack) */
618 static struct hda_verb alc880_threestack_ch2_init[] = {
619 /* set line-in to input, mute it */
620 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
621 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
622 /* set mic-in to input vref 80%, mute it */
623 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
624 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
629 static struct hda_verb alc880_threestack_ch6_init[] = {
630 /* set line-in to output, unmute it */
631 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
632 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
633 /* set mic-in to output, unmute it */
634 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
635 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
639 static struct hda_channel_mode alc880_threestack_modes[2] = {
640 { 2, alc880_threestack_ch2_init },
641 { 6, alc880_threestack_ch6_init },
644 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
645 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
646 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
647 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
648 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
649 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
650 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
651 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
652 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
653 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
654 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
656 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
659 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
661 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
662 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
666 .name = "Channel Mode",
667 .info = alc_ch_mode_info,
668 .get = alc_ch_mode_get,
669 .put = alc_ch_mode_put,
674 /* capture mixer elements */
675 static struct snd_kcontrol_new alc880_capture_mixer[] = {
676 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
677 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
678 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
679 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
680 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
681 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
684 /* The multiple "Capture Source" controls confuse alsamixer
685 * So call somewhat different..
686 * FIXME: the controls appear in the "playback" view!
688 /* .name = "Capture Source", */
689 .name = "Input Source",
691 .info = alc_mux_enum_info,
692 .get = alc_mux_enum_get,
693 .put = alc_mux_enum_put,
698 /* capture mixer elements (in case NID 0x07 not available) */
699 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
700 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
701 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
702 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
703 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
706 /* The multiple "Capture Source" controls confuse alsamixer
707 * So call somewhat different..
708 * FIXME: the controls appear in the "playback" view!
710 /* .name = "Capture Source", */
711 .name = "Input Source",
713 .info = alc_mux_enum_info,
714 .get = alc_mux_enum_get,
715 .put = alc_mux_enum_put,
723 * ALC880 5-stack model
725 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
727 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
728 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
731 /* additional mixers to alc880_three_stack_mixer */
732 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
733 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
734 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
738 /* channel source setting (6/8 channel selection for 5-stack) */
740 static struct hda_verb alc880_fivestack_ch6_init[] = {
741 /* set line-in to input, mute it */
742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
748 static struct hda_verb alc880_fivestack_ch8_init[] = {
749 /* set line-in to output, unmute it */
750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
755 static struct hda_channel_mode alc880_fivestack_modes[2] = {
756 { 6, alc880_fivestack_ch6_init },
757 { 8, alc880_fivestack_ch8_init },
762 * ALC880 6-stack model
764 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
766 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
767 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
770 static hda_nid_t alc880_6st_dac_nids[4] = {
771 /* front, rear, clfe, rear_surr */
772 0x02, 0x03, 0x04, 0x05
775 static struct hda_input_mux alc880_6stack_capture_source = {
779 { "Front Mic", 0x1 },
785 /* fixed 8-channels */
786 static struct hda_channel_mode alc880_sixstack_modes[1] = {
790 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
796 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
797 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
798 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
799 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
800 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
802 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
803 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
804 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
807 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
808 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
809 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
810 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
813 .name = "Channel Mode",
814 .info = alc_ch_mode_info,
815 .get = alc_ch_mode_get,
816 .put = alc_ch_mode_put,
825 * W810 has rear IO for:
828 * Center/LFE (DAC 04)
831 * The system also has a pair of internal speakers, and a headphone jack.
832 * These are both connected to Line2 on the codec, hence to DAC 02.
834 * There is a variable resistor to control the speaker or headphone
835 * volume. This is a hardware-only device without a software API.
837 * Plugging headphones in will disable the internal speakers. This is
838 * implemented in hardware, not via the driver using jack sense. In
839 * a similar fashion, plugging into the rear socket marked "front" will
840 * disable both the speakers and headphones.
842 * For input, there's a microphone jack, and an "audio in" jack.
843 * These may not do anything useful with this driver yet, because I
844 * haven't setup any initialization verbs for these yet...
847 static hda_nid_t alc880_w810_dac_nids[3] = {
848 /* front, rear/surround, clfe */
852 /* fixed 6 channels */
853 static struct hda_channel_mode alc880_w810_modes[1] = {
857 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
858 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
861 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
862 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
863 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
875 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
876 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
880 static hda_nid_t alc880_z71v_dac_nids[1] = {
883 #define ALC880_Z71V_HP_DAC 0x03
885 /* fixed 2 channels */
886 static struct hda_channel_mode alc880_2_jack_modes[1] = {
890 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
892 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
893 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
894 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
895 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
896 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
907 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
908 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
911 static hda_nid_t alc880_f1734_dac_nids[1] = {
914 #define ALC880_F1734_HP_DAC 0x02
916 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
917 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
918 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
919 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
920 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
921 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
922 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
924 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
933 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
934 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
935 * Mic = 0x18, Line = 0x1a
938 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
939 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
941 static struct snd_kcontrol_new alc880_asus_mixer[] = {
942 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
943 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
944 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
945 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
946 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
947 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
948 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
949 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
958 .name = "Channel Mode",
959 .info = alc_ch_mode_info,
960 .get = alc_ch_mode_get,
961 .put = alc_ch_mode_put,
968 * ALC880 ASUS W1V model
970 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
971 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
972 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
975 /* additional mixers to alc880_asus_mixer */
976 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
977 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
978 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
982 /* additional mixers to alc880_asus_mixer */
983 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
984 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
985 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
990 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
995 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
998 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
999 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1002 /* The multiple "Capture Source" controls confuse alsamixer
1003 * So call somewhat different..
1004 * FIXME: the controls appear in the "playback" view!
1006 /* .name = "Capture Source", */
1007 .name = "Input Source",
1009 .info = alc_mux_enum_info,
1010 .get = alc_mux_enum_get,
1011 .put = alc_mux_enum_put,
1017 * build control elements
1019 static int alc_build_controls(struct hda_codec *codec)
1021 struct alc_spec *spec = codec->spec;
1025 for (i = 0; i < spec->num_mixers; i++) {
1026 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1031 if (spec->multiout.dig_out_nid) {
1032 err = snd_hda_create_spdif_out_ctls(codec,
1033 spec->multiout.dig_out_nid);
1037 if (spec->dig_in_nid) {
1038 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1047 * initialize the codec volumes, etc
1051 * generic initialization of ADC, input mixers and output mixers
1053 static struct hda_verb alc880_volume_init_verbs[] = {
1055 * Unmute ADC0-2 and set the default input to mic-in
1057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1059 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1061 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1064 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1066 * Note: PASD motherboards uses the Line In 2 as the input for front
1069 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1077 * Set up output mixers (0x0c - 0x0f)
1079 /* set vol=0 to output mixers */
1080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1084 /* set up input amps for analog loopback */
1085 /* Amp Indices: DAC = 0, mixer = 1 */
1086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1092 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1093 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1099 * 3-stack pin configuration:
1100 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1102 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1104 * preset connection lists of input pins
1105 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1107 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1108 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1109 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1112 * Set pin mode and muting
1114 /* set front pin widgets 0x14 for output */
1115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1116 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1117 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1118 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1120 /* Mic2 (as headphone out) for HP output */
1121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1123 /* Line In pin widget for input */
1124 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1126 /* Line2 (as front mic) pin widget for input and vref at 80% */
1127 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1129 /* CD pin widget for input */
1130 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1136 * 5-stack pin configuration:
1137 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1138 * line-in/side = 0x1a, f-mic = 0x1b
1140 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1142 * preset connection lists of input pins
1143 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1145 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1146 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1149 * Set pin mode and muting
1151 /* set pin widgets 0x14-0x17 for output */
1152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1154 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1155 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1156 /* unmute pins for output (no gain on this amp) */
1157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1159 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1163 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1165 /* Mic2 (as headphone out) for HP output */
1166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1167 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1168 /* Line In pin widget for input */
1169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1171 /* Line2 (as front mic) pin widget for input and vref at 80% */
1172 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1173 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1174 /* CD pin widget for input */
1175 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1181 * W810 pin configuration:
1182 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1184 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1185 /* hphone/speaker input selector: front DAC */
1186 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1193 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1196 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1202 * Z71V pin configuration:
1203 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1205 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1211 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1214 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1220 * 6-stack pin configuration:
1221 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1222 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1224 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1225 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1232 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1233 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1234 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1236 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1237 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1238 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1239 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1241 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1243 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1244 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1251 * F1734 pin configuration:
1252 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1254 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1255 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1256 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1257 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1258 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1280 * ASUS pin configuration:
1281 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1283 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1284 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1285 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1286 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1287 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1289 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1290 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1293 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1296 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1298 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1299 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1306 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1311 /* Enable GPIO mask and set output */
1312 static struct hda_verb alc880_gpio1_init_verbs[] = {
1313 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1314 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1315 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1320 /* Enable GPIO mask and set output */
1321 static struct hda_verb alc880_gpio2_init_verbs[] = {
1322 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1323 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1324 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1329 /* Clevo m520g init */
1330 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1331 /* headphone output */
1332 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1337 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1340 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1341 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1342 /* Mic1 (rear panel) */
1343 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1345 /* Mic2 (front panel) */
1346 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 /* change to EAPD mode */
1352 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1353 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1358 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1359 /* change to EAPD mode */
1360 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1361 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1363 /* Headphone output */
1364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1366 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1367 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1369 /* Line In pin widget for input */
1370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1371 /* CD pin widget for input */
1372 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1373 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1376 /* change to EAPD mode */
1377 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1378 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1384 * LG m1 express dual
1387 * Rear Line-In/Out (blue): 0x14
1388 * Build-in Mic-In: 0x15
1390 * HP-Out (green): 0x1b
1391 * Mic-In/Out (red): 0x19
1395 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1396 static hda_nid_t alc880_lg_dac_nids[3] = {
1400 /* seems analog CD is not working */
1401 static struct hda_input_mux alc880_lg_capture_source = {
1406 { "Internal Mic", 0x6 },
1410 /* 2,4,6 channel modes */
1411 static struct hda_verb alc880_lg_ch2_init[] = {
1412 /* set line-in and mic-in to input */
1413 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1414 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1418 static struct hda_verb alc880_lg_ch4_init[] = {
1419 /* set line-in to out and mic-in to input */
1420 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1421 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1425 static struct hda_verb alc880_lg_ch6_init[] = {
1426 /* set line-in and mic-in to output */
1427 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1428 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1432 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1433 { 2, alc880_lg_ch2_init },
1434 { 4, alc880_lg_ch4_init },
1435 { 6, alc880_lg_ch6_init },
1438 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1439 /* FIXME: it's not really "master" but front channels */
1440 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1441 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1445 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1447 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1453 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1456 .name = "Channel Mode",
1457 .info = alc_ch_mode_info,
1458 .get = alc_ch_mode_get,
1459 .put = alc_ch_mode_put,
1464 static struct hda_verb alc880_lg_init_verbs[] = {
1465 /* set capture source to mic-in */
1466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1469 /* mute all amp mixer inputs */
1470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1473 /* line-in to input */
1474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1481 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 /* mic-in to input */
1483 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1484 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1495 /* toggle speaker-output according to the hp-jack state */
1496 static void alc880_lg_automute(struct hda_codec *codec)
1498 unsigned int present;
1500 present = snd_hda_codec_read(codec, 0x1b, 0,
1501 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1502 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1503 0x80, present ? 0x80 : 0);
1504 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1505 0x80, present ? 0x80 : 0);
1508 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1510 /* Looks like the unsol event is incompatible with the standard
1511 * definition. 4bit tag is placed at 28 bit!
1513 if ((res >> 28) == 0x01)
1514 alc880_lg_automute(codec);
1523 * Built-in Mic-In: 0x19 (?)
1528 /* seems analog CD is not working */
1529 static struct hda_input_mux alc880_lg_lw_capture_source = {
1533 { "Internal Mic", 0x1 },
1537 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1538 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1539 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1540 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1542 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1543 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1547 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1548 /* set capture source to mic-in */
1549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1550 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1557 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1560 /* mic-in to input */
1561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1567 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1571 /* toggle speaker-output according to the hp-jack state */
1572 static void alc880_lg_lw_automute(struct hda_codec *codec)
1574 unsigned int present;
1576 present = snd_hda_codec_read(codec, 0x1b, 0,
1577 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1578 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1579 0x80, present ? 0x80 : 0);
1580 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1581 0x80, present ? 0x80 : 0);
1584 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1586 /* Looks like the unsol event is incompatible with the standard
1587 * definition. 4bit tag is placed at 28 bit!
1589 if ((res >> 28) == 0x01)
1590 alc880_lg_lw_automute(codec);
1597 static int alc_init(struct hda_codec *codec)
1599 struct alc_spec *spec = codec->spec;
1602 for (i = 0; i < spec->num_init_verbs; i++)
1603 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1605 if (spec->init_hook)
1606 spec->init_hook(codec);
1611 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1613 struct alc_spec *spec = codec->spec;
1615 if (spec->unsol_event)
1616 spec->unsol_event(codec, res);
1623 static int alc_resume(struct hda_codec *codec)
1625 struct alc_spec *spec = codec->spec;
1629 for (i = 0; i < spec->num_mixers; i++)
1630 snd_hda_resume_ctls(codec, spec->mixers[i]);
1631 if (spec->multiout.dig_out_nid)
1632 snd_hda_resume_spdif_out(codec);
1633 if (spec->dig_in_nid)
1634 snd_hda_resume_spdif_in(codec);
1641 * Analog playback callbacks
1643 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1644 struct hda_codec *codec,
1645 struct snd_pcm_substream *substream)
1647 struct alc_spec *spec = codec->spec;
1648 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1651 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1652 struct hda_codec *codec,
1653 unsigned int stream_tag,
1654 unsigned int format,
1655 struct snd_pcm_substream *substream)
1657 struct alc_spec *spec = codec->spec;
1658 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1659 stream_tag, format, substream);
1662 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1663 struct hda_codec *codec,
1664 struct snd_pcm_substream *substream)
1666 struct alc_spec *spec = codec->spec;
1667 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1673 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1674 struct hda_codec *codec,
1675 struct snd_pcm_substream *substream)
1677 struct alc_spec *spec = codec->spec;
1678 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1681 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1682 struct hda_codec *codec,
1683 struct snd_pcm_substream *substream)
1685 struct alc_spec *spec = codec->spec;
1686 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1692 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1693 struct hda_codec *codec,
1694 unsigned int stream_tag,
1695 unsigned int format,
1696 struct snd_pcm_substream *substream)
1698 struct alc_spec *spec = codec->spec;
1700 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1701 stream_tag, 0, format);
1705 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1706 struct hda_codec *codec,
1707 struct snd_pcm_substream *substream)
1709 struct alc_spec *spec = codec->spec;
1711 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1719 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1723 /* NID is set in alc_build_pcms */
1725 .open = alc880_playback_pcm_open,
1726 .prepare = alc880_playback_pcm_prepare,
1727 .cleanup = alc880_playback_pcm_cleanup
1731 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1735 /* NID is set in alc_build_pcms */
1737 .prepare = alc880_capture_pcm_prepare,
1738 .cleanup = alc880_capture_pcm_cleanup
1742 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1746 /* NID is set in alc_build_pcms */
1748 .open = alc880_dig_playback_pcm_open,
1749 .close = alc880_dig_playback_pcm_close
1753 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1757 /* NID is set in alc_build_pcms */
1760 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1761 static struct hda_pcm_stream alc_pcm_null_playback = {
1767 static int alc_build_pcms(struct hda_codec *codec)
1769 struct alc_spec *spec = codec->spec;
1770 struct hda_pcm *info = spec->pcm_rec;
1773 codec->num_pcms = 1;
1774 codec->pcm_info = info;
1776 info->name = spec->stream_name_analog;
1777 if (spec->stream_analog_playback) {
1778 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1779 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1780 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1782 if (spec->stream_analog_capture) {
1783 snd_assert(spec->adc_nids, return -EINVAL);
1784 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1785 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1788 if (spec->channel_mode) {
1789 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1790 for (i = 0; i < spec->num_channel_mode; i++) {
1791 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1792 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1797 /* If the use of more than one ADC is requested for the current
1798 * model, configure a second analog capture-only PCM.
1800 if (spec->num_adc_nids > 1) {
1803 info->name = spec->stream_name_analog;
1804 /* No playback stream for second PCM */
1805 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1806 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1807 if (spec->stream_analog_capture) {
1808 snd_assert(spec->adc_nids, return -EINVAL);
1809 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1810 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1814 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1817 info->name = spec->stream_name_digital;
1818 if (spec->multiout.dig_out_nid &&
1819 spec->stream_digital_playback) {
1820 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1821 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1823 if (spec->dig_in_nid &&
1824 spec->stream_digital_capture) {
1825 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1826 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1833 static void alc_free(struct hda_codec *codec)
1835 struct alc_spec *spec = codec->spec;
1841 if (spec->kctl_alloc) {
1842 for (i = 0; i < spec->num_kctl_used; i++)
1843 kfree(spec->kctl_alloc[i].name);
1844 kfree(spec->kctl_alloc);
1851 static struct hda_codec_ops alc_patch_ops = {
1852 .build_controls = alc_build_controls,
1853 .build_pcms = alc_build_pcms,
1856 .unsol_event = alc_unsol_event,
1858 .resume = alc_resume,
1864 * Test configuration for debugging
1866 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1869 #ifdef CONFIG_SND_DEBUG
1870 static hda_nid_t alc880_test_dac_nids[4] = {
1871 0x02, 0x03, 0x04, 0x05
1874 static struct hda_input_mux alc880_test_capture_source = {
1883 { "Surround", 0x6 },
1887 static struct hda_channel_mode alc880_test_modes[4] = {
1894 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1895 struct snd_ctl_elem_info *uinfo)
1897 static char *texts[] = {
1898 "N/A", "Line Out", "HP Out",
1899 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1901 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1903 uinfo->value.enumerated.items = 8;
1904 if (uinfo->value.enumerated.item >= 8)
1905 uinfo->value.enumerated.item = 7;
1906 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1910 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1911 struct snd_ctl_elem_value *ucontrol)
1913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1914 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1915 unsigned int pin_ctl, item = 0;
1917 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1918 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1919 if (pin_ctl & AC_PINCTL_OUT_EN) {
1920 if (pin_ctl & AC_PINCTL_HP_EN)
1924 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1925 switch (pin_ctl & AC_PINCTL_VREFEN) {
1926 case AC_PINCTL_VREF_HIZ: item = 3; break;
1927 case AC_PINCTL_VREF_50: item = 4; break;
1928 case AC_PINCTL_VREF_GRD: item = 5; break;
1929 case AC_PINCTL_VREF_80: item = 6; break;
1930 case AC_PINCTL_VREF_100: item = 7; break;
1933 ucontrol->value.enumerated.item[0] = item;
1937 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1938 struct snd_ctl_elem_value *ucontrol)
1940 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1941 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1942 static unsigned int ctls[] = {
1943 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1944 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1945 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1946 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1947 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1948 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1950 unsigned int old_ctl, new_ctl;
1952 old_ctl = snd_hda_codec_read(codec, nid, 0,
1953 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1954 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1955 if (old_ctl != new_ctl) {
1956 snd_hda_codec_write(codec, nid, 0,
1957 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1958 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1959 (ucontrol->value.enumerated.item[0] >= 3 ?
1966 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1967 struct snd_ctl_elem_info *uinfo)
1969 static char *texts[] = {
1970 "Front", "Surround", "CLFE", "Side"
1972 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1974 uinfo->value.enumerated.items = 4;
1975 if (uinfo->value.enumerated.item >= 4)
1976 uinfo->value.enumerated.item = 3;
1977 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1981 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
1984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1985 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1988 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1989 ucontrol->value.enumerated.item[0] = sel & 3;
1993 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
1996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1997 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2000 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2001 if (ucontrol->value.enumerated.item[0] != sel) {
2002 sel = ucontrol->value.enumerated.item[0] & 3;
2003 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2009 #define PIN_CTL_TEST(xname,nid) { \
2010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2012 .info = alc_test_pin_ctl_info, \
2013 .get = alc_test_pin_ctl_get, \
2014 .put = alc_test_pin_ctl_put, \
2015 .private_value = nid \
2018 #define PIN_SRC_TEST(xname,nid) { \
2019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2021 .info = alc_test_pin_src_info, \
2022 .get = alc_test_pin_src_get, \
2023 .put = alc_test_pin_src_put, \
2024 .private_value = nid \
2027 static struct snd_kcontrol_new alc880_test_mixer[] = {
2028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2029 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2030 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2031 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2032 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2033 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2034 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2035 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2036 PIN_CTL_TEST("Front Pin Mode", 0x14),
2037 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2038 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2039 PIN_CTL_TEST("Side Pin Mode", 0x17),
2040 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2041 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2042 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2043 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2044 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2045 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2046 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2047 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2048 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2049 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2050 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2051 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2052 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2053 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2054 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2055 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2060 .name = "Channel Mode",
2061 .info = alc_ch_mode_info,
2062 .get = alc_ch_mode_get,
2063 .put = alc_ch_mode_put,
2068 static struct hda_verb alc880_test_init_verbs[] = {
2069 /* Unmute inputs of 0x0c - 0x0f */
2070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2078 /* Vol output for 0x0c-0x0f */
2079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2083 /* Set output pins 0x14-0x17 */
2084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 /* Unmute output pins 0x14-0x17 */
2089 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 /* Set input pins 0x18-0x1c */
2094 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2095 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2098 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2099 /* Mute input pins 0x18-0x1b */
2100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2106 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2110 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2111 /* Analog input/passthru */
2112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2124 static struct hda_board_config alc880_cfg_tbl[] = {
2125 /* Back 3 jack, front 2 jack */
2126 { .modelname = "3stack", .config = ALC880_3ST },
2127 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2128 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2154 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2160 { .modelname = "tcl", .config = ALC880_TCL_S700 },
2161 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2163 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2164 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2165 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2166 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2168 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2169 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2170 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2171 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2174 { .modelname = "clevo", .config = ALC880_CLEVO },
2175 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2176 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2177 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2178 .config = ALC880_CLEVO }, /* Clevo m665n */
2180 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2181 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2182 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2183 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2185 /* Back 5 jack, front 2 jack */
2186 { .modelname = "5stack", .config = ALC880_5ST },
2187 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2188 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2189 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2190 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2191 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2193 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2194 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2195 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2196 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2197 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2198 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2199 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2200 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2201 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2202 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2203 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2204 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2205 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2206 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2207 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2208 /* note subvendor = 0 below */
2209 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2211 { .modelname = "w810", .config = ALC880_W810 },
2212 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2214 { .modelname = "z71v", .config = ALC880_Z71V },
2215 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2217 { .modelname = "6stack", .config = ALC880_6ST },
2218 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2220 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2221 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2223 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2224 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2225 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2226 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2227 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2228 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2229 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2230 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2231 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2232 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2233 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2234 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2236 { .modelname = "asus", .config = ALC880_ASUS },
2237 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2238 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2239 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2240 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2241 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2242 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2243 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2244 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2247 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
2248 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2249 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
2250 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2251 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
2252 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2254 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2255 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2257 { .modelname = "F1734", .config = ALC880_F1734 },
2258 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2259 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2261 { .modelname = "lg", .config = ALC880_LG },
2262 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2263 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
2265 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2266 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2268 #ifdef CONFIG_SND_DEBUG
2269 { .modelname = "test", .config = ALC880_TEST },
2271 { .modelname = "auto", .config = ALC880_AUTO },
2277 * ALC880 codec presets
2279 static struct alc_config_preset alc880_presets[] = {
2281 .mixers = { alc880_three_stack_mixer },
2282 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2283 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2284 .dac_nids = alc880_dac_nids,
2285 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2286 .channel_mode = alc880_threestack_modes,
2288 .input_mux = &alc880_capture_source,
2290 [ALC880_3ST_DIG] = {
2291 .mixers = { alc880_three_stack_mixer },
2292 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2293 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2294 .dac_nids = alc880_dac_nids,
2295 .dig_out_nid = ALC880_DIGOUT_NID,
2296 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2297 .channel_mode = alc880_threestack_modes,
2299 .input_mux = &alc880_capture_source,
2301 [ALC880_TCL_S700] = {
2302 .mixers = { alc880_tcl_s700_mixer },
2303 .init_verbs = { alc880_volume_init_verbs,
2304 alc880_pin_tcl_S700_init_verbs,
2305 alc880_gpio2_init_verbs },
2306 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2307 .dac_nids = alc880_dac_nids,
2309 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2310 .channel_mode = alc880_2_jack_modes,
2311 .input_mux = &alc880_capture_source,
2314 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2315 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2316 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2317 .dac_nids = alc880_dac_nids,
2318 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2319 .channel_mode = alc880_fivestack_modes,
2320 .input_mux = &alc880_capture_source,
2322 [ALC880_5ST_DIG] = {
2323 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2324 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2325 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2326 .dac_nids = alc880_dac_nids,
2327 .dig_out_nid = ALC880_DIGOUT_NID,
2328 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2329 .channel_mode = alc880_fivestack_modes,
2330 .input_mux = &alc880_capture_source,
2333 .mixers = { alc880_six_stack_mixer },
2334 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2335 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2336 .dac_nids = alc880_6st_dac_nids,
2337 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2338 .channel_mode = alc880_sixstack_modes,
2339 .input_mux = &alc880_6stack_capture_source,
2341 [ALC880_6ST_DIG] = {
2342 .mixers = { alc880_six_stack_mixer },
2343 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2344 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2345 .dac_nids = alc880_6st_dac_nids,
2346 .dig_out_nid = ALC880_DIGOUT_NID,
2347 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2348 .channel_mode = alc880_sixstack_modes,
2349 .input_mux = &alc880_6stack_capture_source,
2352 .mixers = { alc880_w810_base_mixer },
2353 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2354 alc880_gpio2_init_verbs },
2355 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2356 .dac_nids = alc880_w810_dac_nids,
2357 .dig_out_nid = ALC880_DIGOUT_NID,
2358 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2359 .channel_mode = alc880_w810_modes,
2360 .input_mux = &alc880_capture_source,
2363 .mixers = { alc880_z71v_mixer },
2364 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2365 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2366 .dac_nids = alc880_z71v_dac_nids,
2367 .dig_out_nid = ALC880_DIGOUT_NID,
2369 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2370 .channel_mode = alc880_2_jack_modes,
2371 .input_mux = &alc880_capture_source,
2374 .mixers = { alc880_f1734_mixer },
2375 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2376 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2377 .dac_nids = alc880_f1734_dac_nids,
2379 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2380 .channel_mode = alc880_2_jack_modes,
2381 .input_mux = &alc880_capture_source,
2384 .mixers = { alc880_asus_mixer },
2385 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2386 alc880_gpio1_init_verbs },
2387 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2388 .dac_nids = alc880_asus_dac_nids,
2389 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2390 .channel_mode = alc880_asus_modes,
2392 .input_mux = &alc880_capture_source,
2394 [ALC880_ASUS_DIG] = {
2395 .mixers = { alc880_asus_mixer },
2396 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2397 alc880_gpio1_init_verbs },
2398 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2399 .dac_nids = alc880_asus_dac_nids,
2400 .dig_out_nid = ALC880_DIGOUT_NID,
2401 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2402 .channel_mode = alc880_asus_modes,
2404 .input_mux = &alc880_capture_source,
2406 [ALC880_ASUS_DIG2] = {
2407 .mixers = { alc880_asus_mixer },
2408 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2409 alc880_gpio2_init_verbs }, /* use GPIO2 */
2410 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2411 .dac_nids = alc880_asus_dac_nids,
2412 .dig_out_nid = ALC880_DIGOUT_NID,
2413 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2414 .channel_mode = alc880_asus_modes,
2416 .input_mux = &alc880_capture_source,
2418 [ALC880_ASUS_W1V] = {
2419 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2420 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2421 alc880_gpio1_init_verbs },
2422 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2423 .dac_nids = alc880_asus_dac_nids,
2424 .dig_out_nid = ALC880_DIGOUT_NID,
2425 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2426 .channel_mode = alc880_asus_modes,
2428 .input_mux = &alc880_capture_source,
2430 [ALC880_UNIWILL_DIG] = {
2431 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2432 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2433 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2434 .dac_nids = alc880_asus_dac_nids,
2435 .dig_out_nid = ALC880_DIGOUT_NID,
2436 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2437 .channel_mode = alc880_asus_modes,
2439 .input_mux = &alc880_capture_source,
2442 .mixers = { alc880_three_stack_mixer },
2443 .init_verbs = { alc880_volume_init_verbs,
2444 alc880_pin_clevo_init_verbs },
2445 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2446 .dac_nids = alc880_dac_nids,
2448 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2449 .channel_mode = alc880_threestack_modes,
2451 .input_mux = &alc880_capture_source,
2454 .mixers = { alc880_lg_mixer },
2455 .init_verbs = { alc880_volume_init_verbs,
2456 alc880_lg_init_verbs },
2457 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2458 .dac_nids = alc880_lg_dac_nids,
2459 .dig_out_nid = ALC880_DIGOUT_NID,
2460 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2461 .channel_mode = alc880_lg_ch_modes,
2463 .input_mux = &alc880_lg_capture_source,
2464 .unsol_event = alc880_lg_unsol_event,
2465 .init_hook = alc880_lg_automute,
2468 .mixers = { alc880_lg_lw_mixer },
2469 .init_verbs = { alc880_volume_init_verbs,
2470 alc880_lg_lw_init_verbs },
2472 .dac_nids = alc880_dac_nids,
2473 .dig_out_nid = ALC880_DIGOUT_NID,
2474 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2475 .channel_mode = alc880_2_jack_modes,
2476 .input_mux = &alc880_lg_lw_capture_source,
2477 .unsol_event = alc880_lg_lw_unsol_event,
2478 .init_hook = alc880_lg_lw_automute,
2480 #ifdef CONFIG_SND_DEBUG
2482 .mixers = { alc880_test_mixer },
2483 .init_verbs = { alc880_test_init_verbs },
2484 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2485 .dac_nids = alc880_test_dac_nids,
2486 .dig_out_nid = ALC880_DIGOUT_NID,
2487 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2488 .channel_mode = alc880_test_modes,
2489 .input_mux = &alc880_test_capture_source,
2495 * Automatic parse of I/O pins from the BIOS configuration
2498 #define NUM_CONTROL_ALLOC 32
2499 #define NUM_VERB_ALLOC 32
2503 ALC_CTL_WIDGET_MUTE,
2506 static struct snd_kcontrol_new alc880_control_templates[] = {
2507 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2508 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2509 HDA_BIND_MUTE(NULL, 0, 0, 0),
2512 /* add dynamic controls */
2513 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2515 struct snd_kcontrol_new *knew;
2517 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2518 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2520 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2523 if (spec->kctl_alloc) {
2524 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2525 kfree(spec->kctl_alloc);
2527 spec->kctl_alloc = knew;
2528 spec->num_kctl_alloc = num;
2531 knew = &spec->kctl_alloc[spec->num_kctl_used];
2532 *knew = alc880_control_templates[type];
2533 knew->name = kstrdup(name, GFP_KERNEL);
2536 knew->private_value = val;
2537 spec->num_kctl_used++;
2541 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2542 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2543 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2544 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2545 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2546 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2547 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2548 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2549 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2550 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2551 #define ALC880_PIN_CD_NID 0x1c
2553 /* fill in the dac_nids table from the parsed pin configuration */
2554 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2560 memset(assigned, 0, sizeof(assigned));
2561 spec->multiout.dac_nids = spec->private_dac_nids;
2563 /* check the pins hardwired to audio widget */
2564 for (i = 0; i < cfg->line_outs; i++) {
2565 nid = cfg->line_out_pins[i];
2566 if (alc880_is_fixed_pin(nid)) {
2567 int idx = alc880_fixed_pin_idx(nid);
2568 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2572 /* left pins can be connect to any audio widget */
2573 for (i = 0; i < cfg->line_outs; i++) {
2574 nid = cfg->line_out_pins[i];
2575 if (alc880_is_fixed_pin(nid))
2577 /* search for an empty channel */
2578 for (j = 0; j < cfg->line_outs; j++) {
2579 if (! assigned[j]) {
2580 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2586 spec->multiout.num_dacs = cfg->line_outs;
2590 /* add playback controls from the parsed DAC table */
2591 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2592 const struct auto_pin_cfg *cfg)
2595 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2599 for (i = 0; i < cfg->line_outs; i++) {
2600 if (! spec->multiout.dac_nids[i])
2602 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2605 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2606 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2608 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2609 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2611 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2612 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2614 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2615 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2618 sprintf(name, "%s Playback Volume", chname[i]);
2619 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2620 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2622 sprintf(name, "%s Playback Switch", chname[i]);
2623 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2624 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2631 /* add playback controls for speaker and HP outputs */
2632 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2642 if (alc880_is_fixed_pin(pin)) {
2643 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2644 /* specify the DAC as the extra output */
2645 if (! spec->multiout.hp_nid)
2646 spec->multiout.hp_nid = nid;
2648 spec->multiout.extra_out_nid[0] = nid;
2649 /* control HP volume/switch on the output mixer amp */
2650 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2651 sprintf(name, "%s Playback Volume", pfx);
2652 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2653 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2655 sprintf(name, "%s Playback Switch", pfx);
2656 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2657 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2659 } else if (alc880_is_multi_pin(pin)) {
2660 /* set manual connection */
2661 /* we have only a switch on HP-out PIN */
2662 sprintf(name, "%s Playback Switch", pfx);
2663 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2664 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2670 /* create input playback/capture controls for the given pin */
2671 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2672 int idx, hda_nid_t mix_nid)
2677 sprintf(name, "%s Playback Volume", ctlname);
2678 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2679 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2681 sprintf(name, "%s Playback Switch", ctlname);
2682 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2683 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2688 /* create playback/capture controls for input pins */
2689 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2690 const struct auto_pin_cfg *cfg)
2692 struct hda_input_mux *imux = &spec->private_imux;
2695 for (i = 0; i < AUTO_PIN_LAST; i++) {
2696 if (alc880_is_input_pin(cfg->input_pins[i])) {
2697 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2698 err = new_analog_input(spec, cfg->input_pins[i],
2699 auto_pin_cfg_labels[i],
2703 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2704 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2711 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2712 hda_nid_t nid, int pin_type,
2716 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2717 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2718 /* need the manual connection? */
2719 if (alc880_is_multi_pin(nid)) {
2720 struct alc_spec *spec = codec->spec;
2721 int idx = alc880_multi_pin_idx(nid);
2722 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2723 AC_VERB_SET_CONNECT_SEL,
2724 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2728 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2730 struct alc_spec *spec = codec->spec;
2733 for (i = 0; i < spec->autocfg.line_outs; i++) {
2734 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2735 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2739 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2741 struct alc_spec *spec = codec->spec;
2744 pin = spec->autocfg.speaker_pins[0];
2745 if (pin) /* connect to front */
2746 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2747 pin = spec->autocfg.hp_pin;
2748 if (pin) /* connect to front */
2749 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2752 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2754 struct alc_spec *spec = codec->spec;
2757 for (i = 0; i < AUTO_PIN_LAST; i++) {
2758 hda_nid_t nid = spec->autocfg.input_pins[i];
2759 if (alc880_is_input_pin(nid)) {
2760 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2761 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2762 if (nid != ALC880_PIN_CD_NID)
2763 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2769 /* parse the BIOS configuration and set up the alc_spec */
2770 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2771 static int alc880_parse_auto_config(struct hda_codec *codec)
2773 struct alc_spec *spec = codec->spec;
2775 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2777 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2778 alc880_ignore)) < 0)
2780 if (! spec->autocfg.line_outs)
2781 return 0; /* can't find valid BIOS pin config */
2783 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2784 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2785 (err = alc880_auto_create_extra_out(spec,
2786 spec->autocfg.speaker_pins[0],
2788 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2789 "Headphone")) < 0 ||
2790 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2793 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2795 if (spec->autocfg.dig_out_pin)
2796 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2797 if (spec->autocfg.dig_in_pin)
2798 spec->dig_in_nid = ALC880_DIGIN_NID;
2800 if (spec->kctl_alloc)
2801 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2803 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2805 spec->num_mux_defs = 1;
2806 spec->input_mux = &spec->private_imux;
2811 /* additional initialization for auto-configuration model */
2812 static void alc880_auto_init(struct hda_codec *codec)
2814 alc880_auto_init_multi_out(codec);
2815 alc880_auto_init_extra_out(codec);
2816 alc880_auto_init_analog_input(codec);
2820 * OK, here we have finally the patch for ALC880
2823 static int patch_alc880(struct hda_codec *codec)
2825 struct alc_spec *spec;
2829 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2835 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2836 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2837 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2838 "trying auto-probe from BIOS...\n");
2839 board_config = ALC880_AUTO;
2842 if (board_config == ALC880_AUTO) {
2843 /* automatic parse from the BIOS config */
2844 err = alc880_parse_auto_config(codec);
2850 "hda_codec: Cannot set up configuration "
2851 "from BIOS. Using 3-stack mode...\n");
2852 board_config = ALC880_3ST;
2856 if (board_config != ALC880_AUTO)
2857 setup_preset(spec, &alc880_presets[board_config]);
2859 spec->stream_name_analog = "ALC880 Analog";
2860 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2861 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2863 spec->stream_name_digital = "ALC880 Digital";
2864 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2865 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2867 if (! spec->adc_nids && spec->input_mux) {
2868 /* check whether NID 0x07 is valid */
2869 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2870 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2871 if (wcap != AC_WID_AUD_IN) {
2872 spec->adc_nids = alc880_adc_nids_alt;
2873 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2874 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2877 spec->adc_nids = alc880_adc_nids;
2878 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2879 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2884 codec->patch_ops = alc_patch_ops;
2885 if (board_config == ALC880_AUTO)
2886 spec->init_hook = alc880_auto_init;
2896 static hda_nid_t alc260_dac_nids[1] = {
2901 static hda_nid_t alc260_adc_nids[1] = {
2906 static hda_nid_t alc260_adc_nids_alt[1] = {
2911 static hda_nid_t alc260_hp_adc_nids[2] = {
2916 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2917 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2919 static hda_nid_t alc260_dual_adc_nids[2] = {
2924 #define ALC260_DIGOUT_NID 0x03
2925 #define ALC260_DIGIN_NID 0x06
2927 static struct hda_input_mux alc260_capture_source = {
2931 { "Front Mic", 0x1 },
2937 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2938 * headphone jack and the internal CD lines since these are the only pins at
2939 * which audio can appear. For flexibility, also allow the option of
2940 * recording the mixer output on the second ADC (ADC0 doesn't have a
2941 * connection to the mixer output).
2943 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2947 { "Mic/Line", 0x0 },
2949 { "Headphone", 0x2 },
2955 { "Mic/Line", 0x0 },
2957 { "Headphone", 0x2 },
2964 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2965 * the Fujitsu S702x, but jacks are marked differently.
2967 static struct hda_input_mux alc260_acer_capture_sources[2] = {
2974 { "Headphone", 0x5 },
2983 { "Headphone", 0x6 },
2989 * This is just place-holder, so there's something for alc_build_pcms to look
2990 * at when it calculates the maximum number of channels. ALC260 has no mixer
2991 * element which allows changing the channel mode, so the verb list is
2994 static struct hda_channel_mode alc260_modes[1] = {
2999 /* Mixer combinations
3001 * basic: base_output + input + pc_beep + capture
3002 * HP: base_output + input + capture_alt
3003 * HP_3013: hp_3013 + input + capture
3004 * fujitsu: fujitsu + capture
3005 * acer: acer + capture
3008 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3009 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3010 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3012 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3013 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3014 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3018 static struct snd_kcontrol_new alc260_input_mixer[] = {
3019 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3020 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3021 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3022 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3024 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3026 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3030 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3031 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3032 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3036 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3037 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3038 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3039 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3040 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3041 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3043 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3048 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3049 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3051 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3053 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3054 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3055 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3056 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3057 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3058 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3059 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3060 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3061 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3062 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3063 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3067 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3068 * versions of the ALC260 don't act on requests to enable mic bias from NID
3069 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3070 * datasheet doesn't mention this restriction. At this stage it's not clear
3071 * whether this behaviour is intentional or is a hardware bug in chip
3072 * revisions available in early 2006. Therefore for now allow the
3073 * "Headphone Jack Mode" control to span all choices, but if it turns out
3074 * that the lack of mic bias for this NID is intentional we could change the
3075 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3077 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3078 * don't appear to make the mic bias available from the "line" jack, even
3079 * though the NID used for this jack (0x14) can supply it. The theory is
3080 * that perhaps Acer have included blocking capacitors between the ALC260
3081 * and the output jack. If this turns out to be the case for all such
3082 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3083 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3085 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3086 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3087 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3088 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3089 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3090 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3092 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3093 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3094 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3095 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3096 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3097 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3098 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3102 /* capture mixer elements */
3103 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3104 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3105 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3106 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3107 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3110 /* The multiple "Capture Source" controls confuse alsamixer
3111 * So call somewhat different..
3112 * FIXME: the controls appear in the "playback" view!
3114 /* .name = "Capture Source", */
3115 .name = "Input Source",
3117 .info = alc_mux_enum_info,
3118 .get = alc_mux_enum_get,
3119 .put = alc_mux_enum_put,
3124 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3125 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3126 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3129 /* The multiple "Capture Source" controls confuse alsamixer
3130 * So call somewhat different..
3131 * FIXME: the controls appear in the "playback" view!
3133 /* .name = "Capture Source", */
3134 .name = "Input Source",
3136 .info = alc_mux_enum_info,
3137 .get = alc_mux_enum_get,
3138 .put = alc_mux_enum_put,
3144 * initialization verbs
3146 static struct hda_verb alc260_init_verbs[] = {
3147 /* Line In pin widget for input */
3148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3149 /* CD pin widget for input */
3150 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3151 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3152 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3153 /* Mic2 (front panel) pin widget for input and vref at 80% */
3154 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3155 /* LINE-2 is used for line-out in rear */
3156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3157 /* select line-out */
3158 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3160 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3162 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3164 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3165 /* mute capture amp left and right */
3166 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3167 /* set connection select to line in (default select for this ADC) */
3168 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3169 /* mute capture amp left and right */
3170 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3171 /* set connection select to line in (default select for this ADC) */
3172 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3173 /* set vol=0 Line-Out mixer amp left and right */
3174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3175 /* unmute pin widget amp left and right (no gain on this amp) */
3176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177 /* set vol=0 HP mixer amp left and right */
3178 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3179 /* unmute pin widget amp left and right (no gain on this amp) */
3180 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3181 /* set vol=0 Mono mixer amp left and right */
3182 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3183 /* unmute pin widget amp left and right (no gain on this amp) */
3184 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185 /* unmute LINE-2 out pin */
3186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3194 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3195 /* mute Front out path */
3196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3198 /* mute Headphone out path */
3199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3201 /* mute Mono out path */
3202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3203 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3207 #if 0 /* should be identical with alc260_init_verbs? */
3208 static struct hda_verb alc260_hp_init_verbs[] = {
3209 /* Headphone and output */
3210 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3212 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3213 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3214 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3215 /* Mic2 (front panel) pin widget for input and vref at 80% */
3216 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3217 /* Line In pin widget for input */
3218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3219 /* Line-2 pin widget for output */
3220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3221 /* CD pin widget for input */
3222 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3223 /* unmute amp left and right */
3224 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3225 /* set connection select to line in (default select for this ADC) */
3226 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3227 /* unmute Line-Out mixer amp left and right (volume = 0) */
3228 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3229 /* mute pin widget amp left and right (no gain on this amp) */
3230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3231 /* unmute HP mixer amp left and right (volume = 0) */
3232 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3233 /* mute pin widget amp left and right (no gain on this amp) */
3234 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3235 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3238 /* unmute Line In */
3239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3242 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3243 /* Unmute Front out path */
3244 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3246 /* Unmute Headphone out path */
3247 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3249 /* Unmute Mono out path */
3250 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3251 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3256 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3257 /* Line out and output */
3258 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3260 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3261 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3262 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3263 /* Mic2 (front panel) pin widget for input and vref at 80% */
3264 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3265 /* Line In pin widget for input */
3266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3267 /* Headphone pin widget for output */
3268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3269 /* CD pin widget for input */
3270 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3271 /* unmute amp left and right */
3272 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3273 /* set connection select to line in (default select for this ADC) */
3274 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3275 /* unmute Line-Out mixer amp left and right (volume = 0) */
3276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3277 /* mute pin widget amp left and right (no gain on this amp) */
3278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3279 /* unmute HP mixer amp left and right (volume = 0) */
3280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3281 /* mute pin widget amp left and right (no gain on this amp) */
3282 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3283 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3286 /* unmute Line In */
3287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3290 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3291 /* Unmute Front out path */
3292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3294 /* Unmute Headphone out path */
3295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3297 /* Unmute Mono out path */
3298 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3303 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3304 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3305 * audio = 0x16, internal speaker = 0x10.
3307 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3308 /* Disable all GPIOs */
3309 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3310 /* Internal speaker is connected to headphone pin */
3311 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3312 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3314 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3315 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3316 /* Ensure all other unused pins are disabled and muted. */
3317 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3319 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3320 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3321 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3322 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3326 /* Disable digital (SPDIF) pins */
3327 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3328 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3330 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3331 * when acting as an output.
3333 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3335 /* Start with output sum widgets muted and their output gains at min */
3336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3337 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3346 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3347 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3348 /* Unmute Line1 pin widget output buffer since it starts as an output.
3349 * If the pin mode is changed by the user the pin mode control will
3350 * take care of enabling the pin's input/output buffers as needed.
3351 * Therefore there's no need to enable the input buffer at this
3354 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3355 /* Unmute input buffer of pin widget used for Line-in (no equiv
3358 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3360 /* Mute capture amp left and right */
3361 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3362 /* Set ADC connection select to match default mixer setting - line
3365 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3367 /* Do the same for the second ADC: mute capture input amp and
3368 * set ADC connection to line in (on mic1 pin)
3370 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3371 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3373 /* Mute all inputs to mixer widget (even unconnected ones) */
3374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3386 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3387 * similar laptops (adapted from Fujitsu init verbs).
3389 static struct hda_verb alc260_acer_init_verbs[] = {
3390 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3391 * the headphone jack. Turn this on and rely on the standard mute
3392 * methods whenever the user wants to turn these outputs off.
3394 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3395 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3396 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3397 /* Internal speaker/Headphone jack is connected to Line-out pin */
3398 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3399 /* Internal microphone/Mic jack is connected to Mic1 pin */
3400 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3401 /* Line In jack is connected to Line1 pin */
3402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3403 /* Ensure all other unused pins are disabled and muted. */
3404 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3405 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3406 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3407 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3408 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3409 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3410 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3411 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3412 /* Disable digital (SPDIF) pins */
3413 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3414 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3416 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3417 * bus when acting as outputs.
3419 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3420 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3422 /* Start with output sum widgets muted and their output gains at min */
3423 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3424 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3427 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3429 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3430 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3431 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3433 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3435 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3436 * inputs. If the pin mode is changed by the user the pin mode control
3437 * will take care of enabling the pin's input/output buffers as needed.
3438 * Therefore there's no need to enable the input buffer at this
3441 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3444 /* Mute capture amp left and right */
3445 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3446 /* Set ADC connection select to match default mixer setting - mic
3449 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3451 /* Do similar with the second ADC: mute capture input amp and
3452 * set ADC connection to mic to match ALSA's default state.
3454 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3455 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3457 /* Mute all inputs to mixer widget (even unconnected ones) */
3458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3470 /* Test configuration for debugging, modelled after the ALC880 test
3473 #ifdef CONFIG_SND_DEBUG
3474 static hda_nid_t alc260_test_dac_nids[1] = {
3477 static hda_nid_t alc260_test_adc_nids[2] = {
3480 /* For testing the ALC260, each input MUX needs its own definition since
3481 * the signal assignments are different. This assumes that the first ADC
3484 static struct hda_input_mux alc260_test_capture_sources[2] = {
3488 { "MIC1 pin", 0x0 },
3489 { "MIC2 pin", 0x1 },
3490 { "LINE1 pin", 0x2 },
3491 { "LINE2 pin", 0x3 },
3493 { "LINE-OUT pin", 0x5 },
3494 { "HP-OUT pin", 0x6 },
3500 { "MIC1 pin", 0x0 },
3501 { "MIC2 pin", 0x1 },
3502 { "LINE1 pin", 0x2 },
3503 { "LINE2 pin", 0x3 },
3506 { "LINE-OUT pin", 0x6 },
3507 { "HP-OUT pin", 0x7 },
3511 static struct snd_kcontrol_new alc260_test_mixer[] = {
3512 /* Output driver widgets */
3513 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3514 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3515 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3516 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3517 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3518 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3520 /* Modes for retasking pin widgets
3521 * Note: the ALC260 doesn't seem to act on requests to enable mic
3522 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3523 * mention this restriction. At this stage it's not clear whether
3524 * this behaviour is intentional or is a hardware bug in chip
3525 * revisions available at least up until early 2006. Therefore for
3526 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3527 * choices, but if it turns out that the lack of mic bias for these
3528 * NIDs is intentional we could change their modes from
3529 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3531 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3532 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3533 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3534 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3535 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3536 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3538 /* Loopback mixer controls */
3539 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3540 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3541 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3542 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3543 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3544 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3545 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3546 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3547 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3548 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3549 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3550 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3551 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3552 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3553 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3554 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3556 /* Controls for GPIO pins, assuming they are configured as outputs */
3557 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3558 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3559 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3560 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3562 /* Switches to allow the digital IO pins to be enabled. The datasheet
3563 * is ambigious as to which NID is which; testing on laptops which
3564 * make this output available should provide clarification.
3566 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3567 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3571 static struct hda_verb alc260_test_init_verbs[] = {
3572 /* Enable all GPIOs as outputs with an initial value of 0 */
3573 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3574 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3575 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3577 /* Enable retasking pins as output, initially without power amp */
3578 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3579 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3583 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3585 /* Disable digital (SPDIF) pins initially, but users can enable
3586 * them via a mixer switch. In the case of SPDIF-out, this initverb
3587 * payload also sets the generation to 0, output to be in "consumer"
3588 * PCM format, copyright asserted, no pre-emphasis and no validity
3591 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3592 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3594 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3595 * OUT1 sum bus when acting as an output.
3597 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3598 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3599 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3600 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3602 /* Start with output sum widgets muted and their output gains at min */
3603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3606 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3609 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3610 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3613 /* Unmute retasking pin widget output buffers since the default
3614 * state appears to be output. As the pin mode is changed by the
3615 * user the pin mode control will take care of enabling the pin's
3616 * input/output buffers as needed.
3618 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3619 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3622 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3623 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3624 /* Also unmute the mono-out pin widget */
3625 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3627 /* Mute capture amp left and right */
3628 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3629 /* Set ADC connection select to match default mixer setting (mic1
3632 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3634 /* Do the same for the second ADC: mute capture input amp and
3635 * set ADC connection to mic1 pin
3637 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3638 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3640 /* Mute all inputs to mixer widget (even unconnected ones) */
3641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3654 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3660 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3666 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3667 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3670 * for BIOS auto-configuration
3673 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3677 unsigned long vol_val, sw_val;
3681 if (nid >= 0x0f && nid < 0x11) {
3682 nid_vol = nid - 0x7;
3683 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3684 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3685 } else if (nid == 0x11) {
3686 nid_vol = nid - 0x7;
3687 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3688 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3689 } else if (nid >= 0x12 && nid <= 0x15) {
3691 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3692 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3696 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3697 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3699 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3700 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3705 /* add playback controls from the parsed DAC table */
3706 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3707 const struct auto_pin_cfg *cfg)
3712 spec->multiout.num_dacs = 1;
3713 spec->multiout.dac_nids = spec->private_dac_nids;
3714 spec->multiout.dac_nids[0] = 0x02;
3716 nid = cfg->line_out_pins[0];
3718 err = alc260_add_playback_controls(spec, nid, "Front");
3723 nid = cfg->speaker_pins[0];
3725 err = alc260_add_playback_controls(spec, nid, "Speaker");
3732 err = alc260_add_playback_controls(spec, nid, "Headphone");
3739 /* create playback/capture controls for input pins */
3740 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3741 const struct auto_pin_cfg *cfg)
3743 struct hda_input_mux *imux = &spec->private_imux;
3746 for (i = 0; i < AUTO_PIN_LAST; i++) {
3747 if (cfg->input_pins[i] >= 0x12) {
3748 idx = cfg->input_pins[i] - 0x12;
3749 err = new_analog_input(spec, cfg->input_pins[i],
3750 auto_pin_cfg_labels[i], idx, 0x07);
3753 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3754 imux->items[imux->num_items].index = idx;
3757 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3758 idx = cfg->input_pins[i] - 0x09;
3759 err = new_analog_input(spec, cfg->input_pins[i],
3760 auto_pin_cfg_labels[i], idx, 0x07);
3763 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3764 imux->items[imux->num_items].index = idx;
3771 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3772 hda_nid_t nid, int pin_type,
3776 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3777 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3778 /* need the manual connection? */
3780 int idx = nid - 0x12;
3781 snd_hda_codec_write(codec, idx + 0x0b, 0,
3782 AC_VERB_SET_CONNECT_SEL, sel_idx);
3787 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3789 struct alc_spec *spec = codec->spec;
3792 nid = spec->autocfg.line_out_pins[0];
3794 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3796 nid = spec->autocfg.speaker_pins[0];
3798 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3800 nid = spec->autocfg.hp_pin;
3802 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3805 #define ALC260_PIN_CD_NID 0x16
3806 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3808 struct alc_spec *spec = codec->spec;
3811 for (i = 0; i < AUTO_PIN_LAST; i++) {
3812 hda_nid_t nid = spec->autocfg.input_pins[i];
3814 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3815 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3816 if (nid != ALC260_PIN_CD_NID)
3817 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3824 * generic initialization of ADC, input mixers and output mixers
3826 static struct hda_verb alc260_volume_init_verbs[] = {
3828 * Unmute ADC0-1 and set the default input to mic-in
3830 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3832 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3833 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3835 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3837 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3840 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3841 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3848 * Set up output mixers (0x08 - 0x0a)
3850 /* set vol=0 to output mixers */
3851 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3853 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3854 /* set up input amps for analog loopback */
3855 /* Amp Indices: DAC = 0, mixer = 1 */
3856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3857 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3859 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3860 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3861 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3866 static int alc260_parse_auto_config(struct hda_codec *codec)
3868 struct alc_spec *spec = codec->spec;
3871 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3873 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3874 alc260_ignore)) < 0)
3876 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3878 if (! spec->kctl_alloc)
3879 return 0; /* can't find valid BIOS pin config */
3880 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3883 spec->multiout.max_channels = 2;
3885 if (spec->autocfg.dig_out_pin)
3886 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3887 if (spec->kctl_alloc)
3888 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3890 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3892 spec->num_mux_defs = 1;
3893 spec->input_mux = &spec->private_imux;
3895 /* check whether NID 0x04 is valid */
3896 wcap = get_wcaps(codec, 0x04);
3897 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3898 if (wcap != AC_WID_AUD_IN) {
3899 spec->adc_nids = alc260_adc_nids_alt;
3900 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3901 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3903 spec->adc_nids = alc260_adc_nids;
3904 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3905 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3912 /* additional initialization for auto-configuration model */
3913 static void alc260_auto_init(struct hda_codec *codec)
3915 alc260_auto_init_multi_out(codec);
3916 alc260_auto_init_analog_input(codec);
3920 * ALC260 configurations
3922 static struct hda_board_config alc260_cfg_tbl[] = {
3923 { .modelname = "basic", .config = ALC260_BASIC },
3924 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3925 .config = ALC260_BASIC }, /* Sony VAIO */
3926 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3927 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
3928 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3929 .config = ALC260_BASIC }, /* Sony VAIO */
3930 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3931 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
3932 { .modelname = "hp", .config = ALC260_HP },
3933 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
3934 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3935 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3936 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
3937 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3938 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3939 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3941 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3942 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3943 { .modelname = "acer", .config = ALC260_ACER },
3944 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
3945 #ifdef CONFIG_SND_DEBUG
3946 { .modelname = "test", .config = ALC260_TEST },
3948 { .modelname = "auto", .config = ALC260_AUTO },
3952 static struct alc_config_preset alc260_presets[] = {
3954 .mixers = { alc260_base_output_mixer,
3956 alc260_pc_beep_mixer,
3957 alc260_capture_mixer },
3958 .init_verbs = { alc260_init_verbs },
3959 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3960 .dac_nids = alc260_dac_nids,
3961 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3962 .adc_nids = alc260_adc_nids,
3963 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3964 .channel_mode = alc260_modes,
3965 .input_mux = &alc260_capture_source,
3968 .mixers = { alc260_base_output_mixer,
3970 alc260_capture_alt_mixer },
3971 .init_verbs = { alc260_init_verbs },
3972 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3973 .dac_nids = alc260_dac_nids,
3974 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3975 .adc_nids = alc260_hp_adc_nids,
3976 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3977 .channel_mode = alc260_modes,
3978 .input_mux = &alc260_capture_source,
3980 [ALC260_HP_3013] = {
3981 .mixers = { alc260_hp_3013_mixer,
3983 alc260_capture_alt_mixer },
3984 .init_verbs = { alc260_hp_3013_init_verbs },
3985 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3986 .dac_nids = alc260_dac_nids,
3987 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3988 .adc_nids = alc260_hp_adc_nids,
3989 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3990 .channel_mode = alc260_modes,
3991 .input_mux = &alc260_capture_source,
3993 [ALC260_FUJITSU_S702X] = {
3994 .mixers = { alc260_fujitsu_mixer,
3995 alc260_capture_mixer },
3996 .init_verbs = { alc260_fujitsu_init_verbs },
3997 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3998 .dac_nids = alc260_dac_nids,
3999 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4000 .adc_nids = alc260_dual_adc_nids,
4001 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4002 .channel_mode = alc260_modes,
4003 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4004 .input_mux = alc260_fujitsu_capture_sources,
4007 .mixers = { alc260_acer_mixer,
4008 alc260_capture_mixer },
4009 .init_verbs = { alc260_acer_init_verbs },
4010 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4011 .dac_nids = alc260_dac_nids,
4012 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4013 .adc_nids = alc260_dual_adc_nids,
4014 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4015 .channel_mode = alc260_modes,
4016 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4017 .input_mux = alc260_acer_capture_sources,
4019 #ifdef CONFIG_SND_DEBUG
4021 .mixers = { alc260_test_mixer,
4022 alc260_capture_mixer },
4023 .init_verbs = { alc260_test_init_verbs },
4024 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4025 .dac_nids = alc260_test_dac_nids,
4026 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4027 .adc_nids = alc260_test_adc_nids,
4028 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4029 .channel_mode = alc260_modes,
4030 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4031 .input_mux = alc260_test_capture_sources,
4036 static int patch_alc260(struct hda_codec *codec)
4038 struct alc_spec *spec;
4039 int err, board_config;
4041 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4047 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4048 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
4049 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4050 "trying auto-probe from BIOS...\n");
4051 board_config = ALC260_AUTO;
4054 if (board_config == ALC260_AUTO) {
4055 /* automatic parse from the BIOS config */
4056 err = alc260_parse_auto_config(codec);
4062 "hda_codec: Cannot set up configuration "
4063 "from BIOS. Using base mode...\n");
4064 board_config = ALC260_BASIC;
4068 if (board_config != ALC260_AUTO)
4069 setup_preset(spec, &alc260_presets[board_config]);
4071 spec->stream_name_analog = "ALC260 Analog";
4072 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4073 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4075 spec->stream_name_digital = "ALC260 Digital";
4076 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4077 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4079 codec->patch_ops = alc_patch_ops;
4080 if (board_config == ALC260_AUTO)
4081 spec->init_hook = alc260_auto_init;
4090 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4091 * configuration. Each pin widget can choose any input DACs and a mixer.
4092 * Each ADC is connected from a mixer of all inputs. This makes possible
4093 * 6-channel independent captures.
4095 * In addition, an independent DAC for the multi-playback (not used in this
4098 #define ALC882_DIGOUT_NID 0x06
4099 #define ALC882_DIGIN_NID 0x0a
4101 static struct hda_channel_mode alc882_ch_modes[1] = {
4105 static hda_nid_t alc882_dac_nids[4] = {
4106 /* front, rear, clfe, rear_surr */
4107 0x02, 0x03, 0x04, 0x05
4110 /* identical with ALC880 */
4111 #define alc882_adc_nids alc880_adc_nids
4112 #define alc882_adc_nids_alt alc880_adc_nids_alt
4115 /* FIXME: should be a matrix-type input source selection */
4117 static struct hda_input_mux alc882_capture_source = {
4121 { "Front Mic", 0x1 },
4126 #define alc882_mux_enum_info alc_mux_enum_info
4127 #define alc882_mux_enum_get alc_mux_enum_get
4129 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4132 struct alc_spec *spec = codec->spec;
4133 const struct hda_input_mux *imux = spec->input_mux;
4134 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4135 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4136 hda_nid_t nid = capture_mixers[adc_idx];
4137 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4138 unsigned int i, idx;
4140 idx = ucontrol->value.enumerated.item[0];
4141 if (idx >= imux->num_items)
4142 idx = imux->num_items - 1;
4143 if (*cur_val == idx && ! codec->in_resume)
4145 for (i = 0; i < imux->num_items; i++) {
4146 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4147 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4148 v | (imux->items[i].index << 8));
4157 static struct hda_verb alc882_sixstack_ch6_init[] = {
4158 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4159 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4160 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4161 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4168 static struct hda_verb alc882_sixstack_ch8_init[] = {
4169 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4170 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4171 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4172 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4176 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4177 { 6, alc882_sixstack_ch6_init },
4178 { 8, alc882_sixstack_ch8_init },
4181 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4182 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4184 static struct snd_kcontrol_new alc882_base_mixer[] = {
4185 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4186 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4187 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4188 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4189 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4190 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4191 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4192 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4193 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4194 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4204 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4205 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4209 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4212 .name = "Channel Mode",
4213 .info = alc_ch_mode_info,
4214 .get = alc_ch_mode_get,
4215 .put = alc_ch_mode_put,
4220 static struct hda_verb alc882_init_verbs[] = {
4221 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4231 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4234 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4235 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4238 /* Front Pin: output 0 (0x0c) */
4239 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4240 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4242 /* Rear Pin: output 1 (0x0d) */
4243 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4244 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4246 /* CLFE Pin: output 2 (0x0e) */
4247 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4248 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4249 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4250 /* Side Pin: output 3 (0x0f) */
4251 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4252 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4253 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4254 /* Mic (rear) pin: input vref at 80% */
4255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4256 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4257 /* Front Mic pin: input vref at 80% */
4258 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4259 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4260 /* Line In pin: input */
4261 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4263 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4264 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4265 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4266 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4267 /* CD pin widget for input */
4268 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4270 /* FIXME: use matrix-type input source selection */
4271 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4272 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4287 /* ADC1: mute amp left and right */
4288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4289 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4290 /* ADC2: mute amp left and right */
4291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4293 /* ADC3: mute amp left and right */
4294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4295 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4300 static struct hda_verb alc882_eapd_verbs[] = {
4301 /* change to EAPD mode */
4302 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4303 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4308 * generic initialization of ADC, input mixers and output mixers
4310 static struct hda_verb alc882_auto_init_verbs[] = {
4312 * Unmute ADC0-2 and set the default input to mic-in
4314 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4316 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4317 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4318 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4319 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4321 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4323 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4326 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4334 * Set up output mixers (0x0c - 0x0f)
4336 /* set vol=0 to output mixers */
4337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4340 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4341 /* set up input amps for analog loopback */
4342 /* Amp Indices: DAC = 0, mixer = 1 */
4343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4351 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4352 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4354 /* FIXME: use matrix-type input source selection */
4355 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4356 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4362 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4367 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4368 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4375 /* capture mixer elements */
4376 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4377 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4378 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4379 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4380 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4383 /* The multiple "Capture Source" controls confuse alsamixer
4384 * So call somewhat different..
4385 * FIXME: the controls appear in the "playback" view!
4387 /* .name = "Capture Source", */
4388 .name = "Input Source",
4390 .info = alc882_mux_enum_info,
4391 .get = alc882_mux_enum_get,
4392 .put = alc882_mux_enum_put,
4397 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4398 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4399 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4400 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4401 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4402 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4403 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4406 /* The multiple "Capture Source" controls confuse alsamixer
4407 * So call somewhat different..
4408 * FIXME: the controls appear in the "playback" view!
4410 /* .name = "Capture Source", */
4411 .name = "Input Source",
4413 .info = alc882_mux_enum_info,
4414 .get = alc882_mux_enum_get,
4415 .put = alc882_mux_enum_put,
4420 /* pcm configuration: identiacal with ALC880 */
4421 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4422 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4423 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4424 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4427 * configuration and preset
4429 static struct hda_board_config alc882_cfg_tbl[] = {
4430 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4431 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4432 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4433 .config = ALC882_6ST_DIG }, /* MSI */
4434 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4435 .config = ALC882_6ST_DIG }, /* Foxconn */
4436 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4437 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
4438 { .modelname = "arima", .config = ALC882_ARIMA },
4439 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4440 .config = ALC882_ARIMA }, /* Arima W820Di1 */
4441 { .modelname = "auto", .config = ALC882_AUTO },
4445 static struct alc_config_preset alc882_presets[] = {
4446 [ALC882_3ST_DIG] = {
4447 .mixers = { alc882_base_mixer },
4448 .init_verbs = { alc882_init_verbs },
4449 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4450 .dac_nids = alc882_dac_nids,
4451 .dig_out_nid = ALC882_DIGOUT_NID,
4452 .dig_in_nid = ALC882_DIGIN_NID,
4453 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4454 .channel_mode = alc882_ch_modes,
4456 .input_mux = &alc882_capture_source,
4458 [ALC882_6ST_DIG] = {
4459 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4460 .init_verbs = { alc882_init_verbs },
4461 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4462 .dac_nids = alc882_dac_nids,
4463 .dig_out_nid = ALC882_DIGOUT_NID,
4464 .dig_in_nid = ALC882_DIGIN_NID,
4465 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4466 .channel_mode = alc882_sixstack_modes,
4467 .input_mux = &alc882_capture_source,
4470 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4471 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4472 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4473 .dac_nids = alc882_dac_nids,
4474 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4475 .channel_mode = alc882_sixstack_modes,
4476 .input_mux = &alc882_capture_source,
4482 * BIOS auto configuration
4484 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4485 hda_nid_t nid, int pin_type,
4489 struct alc_spec *spec = codec->spec;
4492 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4495 idx = spec->multiout.dac_nids[dac_idx] - 2;
4497 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4499 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4503 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4505 struct alc_spec *spec = codec->spec;
4508 for (i = 0; i <= HDA_SIDE; i++) {
4509 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4511 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4515 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4517 struct alc_spec *spec = codec->spec;
4520 pin = spec->autocfg.hp_pin;
4521 if (pin) /* connect to front */
4522 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4525 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4526 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4528 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4530 struct alc_spec *spec = codec->spec;
4533 for (i = 0; i < AUTO_PIN_LAST; i++) {
4534 hda_nid_t nid = spec->autocfg.input_pins[i];
4535 if (alc882_is_input_pin(nid)) {
4536 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4537 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4538 if (nid != ALC882_PIN_CD_NID)
4539 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4545 /* almost identical with ALC880 parser... */
4546 static int alc882_parse_auto_config(struct hda_codec *codec)
4548 struct alc_spec *spec = codec->spec;
4549 int err = alc880_parse_auto_config(codec);
4554 /* hack - override the init verbs */
4555 spec->init_verbs[0] = alc882_auto_init_verbs;
4559 /* additional initialization for auto-configuration model */
4560 static void alc882_auto_init(struct hda_codec *codec)
4562 alc882_auto_init_multi_out(codec);
4563 alc882_auto_init_hp_out(codec);
4564 alc882_auto_init_analog_input(codec);
4567 static int patch_alc882(struct hda_codec *codec)
4569 struct alc_spec *spec;
4570 int err, board_config;
4572 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4578 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4580 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4581 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4582 "trying auto-probe from BIOS...\n");
4583 board_config = ALC882_AUTO;
4586 if (board_config == ALC882_AUTO) {
4587 /* automatic parse from the BIOS config */
4588 err = alc882_parse_auto_config(codec);
4594 "hda_codec: Cannot set up configuration "
4595 "from BIOS. Using base mode...\n");
4596 board_config = ALC882_3ST_DIG;
4600 if (board_config != ALC882_AUTO)
4601 setup_preset(spec, &alc882_presets[board_config]);
4603 spec->stream_name_analog = "ALC882 Analog";
4604 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4605 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4607 spec->stream_name_digital = "ALC882 Digital";
4608 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4609 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4611 if (! spec->adc_nids && spec->input_mux) {
4612 /* check whether NID 0x07 is valid */
4613 unsigned int wcap = get_wcaps(codec, 0x07);
4614 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4615 if (wcap != AC_WID_AUD_IN) {
4616 spec->adc_nids = alc882_adc_nids_alt;
4617 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4618 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4621 spec->adc_nids = alc882_adc_nids;
4622 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4623 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4628 codec->patch_ops = alc_patch_ops;
4629 if (board_config == ALC882_AUTO)
4630 spec->init_hook = alc882_auto_init;
4638 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4639 * configuration. Each pin widget can choose any input DACs and a mixer.
4640 * Each ADC is connected from a mixer of all inputs. This makes possible
4641 * 6-channel independent captures.
4643 * In addition, an independent DAC for the multi-playback (not used in this
4646 #define ALC883_DIGOUT_NID 0x06
4647 #define ALC883_DIGIN_NID 0x0a
4649 static hda_nid_t alc883_dac_nids[4] = {
4650 /* front, rear, clfe, rear_surr */
4651 0x02, 0x04, 0x03, 0x05
4654 static hda_nid_t alc883_adc_nids[2] = {
4659 /* FIXME: should be a matrix-type input source selection */
4661 static struct hda_input_mux alc883_capture_source = {
4665 { "Front Mic", 0x1 },
4670 #define alc883_mux_enum_info alc_mux_enum_info
4671 #define alc883_mux_enum_get alc_mux_enum_get
4673 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4674 struct snd_ctl_elem_value *ucontrol)
4676 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4677 struct alc_spec *spec = codec->spec;
4678 const struct hda_input_mux *imux = spec->input_mux;
4679 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4680 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4681 hda_nid_t nid = capture_mixers[adc_idx];
4682 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4683 unsigned int i, idx;
4685 idx = ucontrol->value.enumerated.item[0];
4686 if (idx >= imux->num_items)
4687 idx = imux->num_items - 1;
4688 if (*cur_val == idx && ! codec->in_resume)
4690 for (i = 0; i < imux->num_items; i++) {
4691 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4692 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4693 v | (imux->items[i].index << 8));
4701 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4708 static struct hda_verb alc883_3ST_ch2_init[] = {
4709 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4710 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4711 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4712 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4719 static struct hda_verb alc883_3ST_ch6_init[] = {
4720 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4721 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4722 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4723 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4724 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4725 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4729 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4730 { 2, alc883_3ST_ch2_init },
4731 { 6, alc883_3ST_ch6_init },
4737 static struct hda_verb alc883_sixstack_ch6_init[] = {
4738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4748 static struct hda_verb alc883_sixstack_ch8_init[] = {
4749 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4750 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4751 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4752 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4756 static struct hda_channel_mode alc883_sixstack_modes[2] = {
4757 { 6, alc883_sixstack_ch6_init },
4758 { 8, alc883_sixstack_ch8_init },
4761 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4762 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4765 static struct snd_kcontrol_new alc883_base_mixer[] = {
4766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4769 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4771 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4772 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4773 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4774 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4775 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4777 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4778 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4779 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4780 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4784 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4785 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4786 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4787 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4788 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4789 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4790 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4793 /* .name = "Capture Source", */
4794 .name = "Input Source",
4796 .info = alc883_mux_enum_info,
4797 .get = alc883_mux_enum_get,
4798 .put = alc883_mux_enum_put,
4803 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4804 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4805 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4809 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4810 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4815 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4816 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4817 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4818 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4819 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4820 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4822 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4823 /* .name = "Capture Source", */
4824 .name = "Input Source",
4826 .info = alc883_mux_enum_info,
4827 .get = alc883_mux_enum_get,
4828 .put = alc883_mux_enum_put,
4833 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4834 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4835 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4836 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4837 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4838 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4839 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4840 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4841 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4849 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4850 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4851 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4852 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4853 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4854 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4855 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4856 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4858 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4859 /* .name = "Capture Source", */
4860 .name = "Input Source",
4862 .info = alc883_mux_enum_info,
4863 .get = alc883_mux_enum_get,
4864 .put = alc883_mux_enum_put,
4869 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4872 .name = "Channel Mode",
4873 .info = alc_ch_mode_info,
4874 .get = alc_ch_mode_get,
4875 .put = alc_ch_mode_put,
4880 static struct hda_verb alc883_init_verbs[] = {
4881 /* ADC1: mute amp left and right */
4882 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4883 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4884 /* ADC2: mute amp left and right */
4885 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4886 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4887 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4901 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4910 /* Front Pin: output 0 (0x0c) */
4911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4912 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4913 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4914 /* Rear Pin: output 1 (0x0d) */
4915 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4917 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4918 /* CLFE Pin: output 2 (0x0e) */
4919 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4921 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4922 /* Side Pin: output 3 (0x0f) */
4923 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4925 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4926 /* Mic (rear) pin: input vref at 80% */
4927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4929 /* Front Mic pin: input vref at 80% */
4930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4932 /* Line In pin: input */
4933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4935 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4939 /* CD pin widget for input */
4940 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4942 /* FIXME: use matrix-type input source selection */
4943 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4958 * generic initialization of ADC, input mixers and output mixers
4960 static struct hda_verb alc883_auto_init_verbs[] = {
4962 * Unmute ADC0-2 and set the default input to mic-in
4964 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4966 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4969 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4971 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4974 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4982 * Set up output mixers (0x0c - 0x0f)
4984 /* set vol=0 to output mixers */
4985 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4989 /* set up input amps for analog loopback */
4990 /* Amp Indices: DAC = 0, mixer = 1 */
4991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4993 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4995 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4996 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4997 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4998 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4999 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5000 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5002 /* FIXME: use matrix-type input source selection */
5003 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5008 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5014 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5020 /* capture mixer elements */
5021 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5022 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5023 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5024 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5025 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5028 /* The multiple "Capture Source" controls confuse alsamixer
5029 * So call somewhat different..
5030 * FIXME: the controls appear in the "playback" view!
5032 /* .name = "Capture Source", */
5033 .name = "Input Source",
5035 .info = alc882_mux_enum_info,
5036 .get = alc882_mux_enum_get,
5037 .put = alc882_mux_enum_put,
5042 /* pcm configuration: identiacal with ALC880 */
5043 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5044 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5045 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5046 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5049 * configuration and preset
5051 static struct hda_board_config alc883_cfg_tbl[] = {
5052 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5053 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5054 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5055 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5056 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5057 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5058 .config = ALC883_3ST_6ch },
5059 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5060 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5061 .config = ALC883_6ST_DIG }, /* MSI */
5062 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5063 .config = ALC883_6ST_DIG }, /* Foxconn */
5064 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5065 { .modelname = "auto", .config = ALC883_AUTO },
5069 static struct alc_config_preset alc883_presets[] = {
5070 [ALC883_3ST_2ch_DIG] = {
5071 .mixers = { alc883_3ST_2ch_mixer },
5072 .init_verbs = { alc883_init_verbs },
5073 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5074 .dac_nids = alc883_dac_nids,
5075 .dig_out_nid = ALC883_DIGOUT_NID,
5076 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5077 .adc_nids = alc883_adc_nids,
5078 .dig_in_nid = ALC883_DIGIN_NID,
5079 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5080 .channel_mode = alc883_3ST_2ch_modes,
5081 .input_mux = &alc883_capture_source,
5083 [ALC883_3ST_6ch_DIG] = {
5084 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5085 .init_verbs = { alc883_init_verbs },
5086 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5087 .dac_nids = alc883_dac_nids,
5088 .dig_out_nid = ALC883_DIGOUT_NID,
5089 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5090 .adc_nids = alc883_adc_nids,
5091 .dig_in_nid = ALC883_DIGIN_NID,
5092 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5093 .channel_mode = alc883_3ST_6ch_modes,
5095 .input_mux = &alc883_capture_source,
5097 [ALC883_3ST_6ch] = {
5098 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5099 .init_verbs = { alc883_init_verbs },
5100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5101 .dac_nids = alc883_dac_nids,
5102 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5103 .adc_nids = alc883_adc_nids,
5104 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5105 .channel_mode = alc883_3ST_6ch_modes,
5107 .input_mux = &alc883_capture_source,
5109 [ALC883_6ST_DIG] = {
5110 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5111 .init_verbs = { alc883_init_verbs },
5112 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5113 .dac_nids = alc883_dac_nids,
5114 .dig_out_nid = ALC883_DIGOUT_NID,
5115 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5116 .adc_nids = alc883_adc_nids,
5117 .dig_in_nid = ALC883_DIGIN_NID,
5118 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5119 .channel_mode = alc883_sixstack_modes,
5120 .input_mux = &alc883_capture_source,
5122 [ALC888_DEMO_BOARD] = {
5123 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5124 .init_verbs = { alc883_init_verbs },
5125 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5126 .dac_nids = alc883_dac_nids,
5127 .dig_out_nid = ALC883_DIGOUT_NID,
5128 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5129 .adc_nids = alc883_adc_nids,
5130 .dig_in_nid = ALC883_DIGIN_NID,
5131 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5132 .channel_mode = alc883_sixstack_modes,
5133 .input_mux = &alc883_capture_source,
5139 * BIOS auto configuration
5141 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5142 hda_nid_t nid, int pin_type,
5146 struct alc_spec *spec = codec->spec;
5149 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5152 idx = spec->multiout.dac_nids[dac_idx] - 2;
5154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5162 static void alc883_auto_init_multi_out(struct hda_codec *codec)
5164 struct alc_spec *spec = codec->spec;
5167 for (i = 0; i <= HDA_SIDE; i++) {
5168 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5170 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5174 static void alc883_auto_init_hp_out(struct hda_codec *codec)
5176 struct alc_spec *spec = codec->spec;
5179 pin = spec->autocfg.hp_pin;
5180 if (pin) /* connect to front */
5182 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5185 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5186 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5188 static void alc883_auto_init_analog_input(struct hda_codec *codec)
5190 struct alc_spec *spec = codec->spec;
5193 for (i = 0; i < AUTO_PIN_LAST; i++) {
5194 hda_nid_t nid = spec->autocfg.input_pins[i];
5195 if (alc883_is_input_pin(nid)) {
5196 snd_hda_codec_write(codec, nid, 0,
5197 AC_VERB_SET_PIN_WIDGET_CONTROL,
5198 (i <= AUTO_PIN_FRONT_MIC ?
5199 PIN_VREF80 : PIN_IN));
5200 if (nid != ALC883_PIN_CD_NID)
5201 snd_hda_codec_write(codec, nid, 0,
5202 AC_VERB_SET_AMP_GAIN_MUTE,
5208 /* almost identical with ALC880 parser... */
5209 static int alc883_parse_auto_config(struct hda_codec *codec)
5211 struct alc_spec *spec = codec->spec;
5212 int err = alc880_parse_auto_config(codec);
5217 /* hack - override the init verbs */
5218 spec->init_verbs[0] = alc883_auto_init_verbs;
5219 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5224 /* additional initialization for auto-configuration model */
5225 static void alc883_auto_init(struct hda_codec *codec)
5227 alc883_auto_init_multi_out(codec);
5228 alc883_auto_init_hp_out(codec);
5229 alc883_auto_init_analog_input(codec);
5232 static int patch_alc883(struct hda_codec *codec)
5234 struct alc_spec *spec;
5235 int err, board_config;
5237 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5243 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5244 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5245 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5246 "trying auto-probe from BIOS...\n");
5247 board_config = ALC883_AUTO;
5250 if (board_config == ALC883_AUTO) {
5251 /* automatic parse from the BIOS config */
5252 err = alc883_parse_auto_config(codec);
5258 "hda_codec: Cannot set up configuration "
5259 "from BIOS. Using base mode...\n");
5260 board_config = ALC883_3ST_2ch_DIG;
5264 if (board_config != ALC883_AUTO)
5265 setup_preset(spec, &alc883_presets[board_config]);
5267 spec->stream_name_analog = "ALC883 Analog";
5268 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5269 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5271 spec->stream_name_digital = "ALC883 Digital";
5272 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5273 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5275 if (! spec->adc_nids && spec->input_mux) {
5276 spec->adc_nids = alc883_adc_nids;
5277 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5280 codec->patch_ops = alc_patch_ops;
5281 if (board_config == ALC883_AUTO)
5282 spec->init_hook = alc883_auto_init;
5291 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5292 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
5294 #define alc262_dac_nids alc260_dac_nids
5295 #define alc262_adc_nids alc882_adc_nids
5296 #define alc262_adc_nids_alt alc882_adc_nids_alt
5298 #define alc262_modes alc260_modes
5299 #define alc262_capture_source alc882_capture_source
5301 static struct snd_kcontrol_new alc262_base_mixer[] = {
5302 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5303 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5304 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5305 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5306 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5307 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5310 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5311 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5312 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5313 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5315 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5316 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5317 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5321 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5322 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5323 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5324 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5325 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5326 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5330 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5331 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5334 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5335 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5336 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5337 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5338 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5339 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5343 #define alc262_capture_mixer alc882_capture_mixer
5344 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
5347 * generic initialization of ADC, input mixers and output mixers
5349 static struct hda_verb alc262_init_verbs[] = {
5351 * Unmute ADC0-2 and set the default input to mic-in
5353 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5357 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5360 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5362 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5365 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5373 * Set up output mixers (0x0c - 0x0e)
5375 /* set vol=0 to output mixers */
5376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379 /* set up input amps for analog loopback */
5380 /* Amp Indices: DAC = 0, mixer = 1 */
5381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5392 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5393 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5396 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5397 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5399 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5401 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5402 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5404 /* FIXME: use matrix-type input source selection */
5405 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5406 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5407 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5408 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5427 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5430 #define ALC_HP_EVENT 0x37
5432 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5433 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5438 static struct hda_input_mux alc262_fujitsu_capture_source = {
5446 static struct hda_input_mux alc262_HP_capture_source = {
5450 { "Front Mic", 0x3 },
5457 /* mute/unmute internal speaker according to the hp jack and mute state */
5458 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5460 struct alc_spec *spec = codec->spec;
5463 if (force || ! spec->sense_updated) {
5464 unsigned int present;
5465 /* need to execute and sync at first */
5466 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5467 present = snd_hda_codec_read(codec, 0x14, 0,
5468 AC_VERB_GET_PIN_SENSE, 0);
5469 spec->jack_present = (present & 0x80000000) != 0;
5470 spec->sense_updated = 1;
5472 if (spec->jack_present) {
5473 /* mute internal speaker */
5474 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5476 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5479 /* unmute internal speaker if necessary */
5480 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5481 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5483 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5484 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5489 /* unsolicited event for HP jack sensing */
5490 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5493 if ((res >> 26) != ALC_HP_EVENT)
5495 alc262_fujitsu_automute(codec, 1);
5498 /* bind volumes of both NID 0x0c and 0x0d */
5499 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5500 struct snd_ctl_elem_value *ucontrol)
5502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5503 long *valp = ucontrol->value.integer.value;
5506 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5507 0x7f, valp[0] & 0x7f);
5508 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5509 0x7f, valp[1] & 0x7f);
5510 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5511 0x7f, valp[0] & 0x7f);
5512 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5513 0x7f, valp[1] & 0x7f);
5517 /* bind hp and internal speaker mute (with plug check) */
5518 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5519 struct snd_ctl_elem_value *ucontrol)
5521 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5522 long *valp = ucontrol->value.integer.value;
5525 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5526 0x80, valp[0] ? 0 : 0x80);
5527 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5528 0x80, valp[1] ? 0 : 0x80);
5529 if (change || codec->in_resume)
5530 alc262_fujitsu_automute(codec, codec->in_resume);
5534 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5536 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5537 .name = "Master Playback Volume",
5538 .info = snd_hda_mixer_amp_volume_info,
5539 .get = snd_hda_mixer_amp_volume_get,
5540 .put = alc262_fujitsu_master_vol_put,
5541 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5545 .name = "Master Playback Switch",
5546 .info = snd_hda_mixer_amp_switch_info,
5547 .get = snd_hda_mixer_amp_switch_get,
5548 .put = alc262_fujitsu_master_sw_put,
5549 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5551 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5552 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5553 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5559 /* additional init verbs for Benq laptops */
5560 static struct hda_verb alc262_EAPD_verbs[] = {
5561 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5562 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5566 /* add playback controls from the parsed DAC table */
5567 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5572 spec->multiout.num_dacs = 1; /* only use one dac */
5573 spec->multiout.dac_nids = spec->private_dac_nids;
5574 spec->multiout.dac_nids[0] = 2;
5576 nid = cfg->line_out_pins[0];
5578 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5579 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5581 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5582 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5586 nid = cfg->speaker_pins[0];
5589 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5590 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5592 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5593 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5596 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5597 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5603 /* spec->multiout.hp_nid = 2; */
5605 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5606 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5608 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5609 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5612 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5613 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5620 /* identical with ALC880 */
5621 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5624 * generic initialization of ADC, input mixers and output mixers
5626 static struct hda_verb alc262_volume_init_verbs[] = {
5628 * Unmute ADC0-2 and set the default input to mic-in
5630 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5632 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5634 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5637 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5639 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5642 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5650 * Set up output mixers (0x0c - 0x0f)
5652 /* set vol=0 to output mixers */
5653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5657 /* set up input amps for analog loopback */
5658 /* Amp Indices: DAC = 0, mixer = 1 */
5659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5666 /* FIXME: use matrix-type input source selection */
5667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5668 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5687 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5689 * Unmute ADC0-2 and set the default input to mic-in
5691 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5693 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5695 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5696 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5698 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5700 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5703 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5713 * Set up output mixers (0x0c - 0x0e)
5715 /* set vol=0 to output mixers */
5716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5720 /* set up input amps for analog loopback */
5721 /* Amp Indices: DAC = 0, mixer = 1 */
5722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5731 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5733 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5736 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5739 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5740 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5743 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5746 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5748 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5749 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5750 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5753 /* FIXME: use matrix-type input source selection */
5754 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5755 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5757 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5758 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5762 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5763 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5767 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5774 /* pcm configuration: identiacal with ALC880 */
5775 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
5776 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
5777 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
5778 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
5781 * BIOS auto configuration
5783 static int alc262_parse_auto_config(struct hda_codec *codec)
5785 struct alc_spec *spec = codec->spec;
5787 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5789 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5790 alc262_ignore)) < 0)
5792 if (! spec->autocfg.line_outs)
5793 return 0; /* can't find valid BIOS pin config */
5794 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5795 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5798 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5800 if (spec->autocfg.dig_out_pin)
5801 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5802 if (spec->autocfg.dig_in_pin)
5803 spec->dig_in_nid = ALC262_DIGIN_NID;
5805 if (spec->kctl_alloc)
5806 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5808 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
5809 spec->num_mux_defs = 1;
5810 spec->input_mux = &spec->private_imux;
5815 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
5816 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
5817 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
5820 /* init callback for auto-configuration model -- overriding the default init */
5821 static void alc262_auto_init(struct hda_codec *codec)
5823 alc262_auto_init_multi_out(codec);
5824 alc262_auto_init_hp_out(codec);
5825 alc262_auto_init_analog_input(codec);
5829 * configuration and preset
5831 static struct hda_board_config alc262_cfg_tbl[] = {
5832 { .modelname = "basic", .config = ALC262_BASIC },
5833 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
5834 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5835 .config = ALC262_FUJITSU },
5836 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
5837 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5838 .config = ALC262_HP_BPC }, /* xw4400 */
5839 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5840 .config = ALC262_HP_BPC }, /* xw6400 */
5841 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5842 .config = ALC262_HP_BPC }, /* xw8400 */
5843 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5844 .config = ALC262_HP_BPC }, /* xw9400 */
5845 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5846 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5847 .config = ALC262_BENQ_ED8 },
5848 { .modelname = "auto", .config = ALC262_AUTO },
5852 static struct alc_config_preset alc262_presets[] = {
5854 .mixers = { alc262_base_mixer },
5855 .init_verbs = { alc262_init_verbs },
5856 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5857 .dac_nids = alc262_dac_nids,
5859 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5860 .channel_mode = alc262_modes,
5861 .input_mux = &alc262_capture_source,
5863 [ALC262_FUJITSU] = {
5864 .mixers = { alc262_fujitsu_mixer },
5865 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5866 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5867 .dac_nids = alc262_dac_nids,
5869 .dig_out_nid = ALC262_DIGOUT_NID,
5870 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5871 .channel_mode = alc262_modes,
5872 .input_mux = &alc262_fujitsu_capture_source,
5873 .unsol_event = alc262_fujitsu_unsol_event,
5876 .mixers = { alc262_HP_BPC_mixer },
5877 .init_verbs = { alc262_HP_BPC_init_verbs },
5878 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5879 .dac_nids = alc262_dac_nids,
5881 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5882 .channel_mode = alc262_modes,
5883 .input_mux = &alc262_HP_capture_source,
5885 [ALC262_BENQ_ED8] = {
5886 .mixers = { alc262_base_mixer },
5887 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5888 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5889 .dac_nids = alc262_dac_nids,
5891 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5892 .channel_mode = alc262_modes,
5893 .input_mux = &alc262_capture_source,
5897 static int patch_alc262(struct hda_codec *codec)
5899 struct alc_spec *spec;
5903 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5909 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5912 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5913 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5914 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5915 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5919 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
5921 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
5922 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5923 "trying auto-probe from BIOS...\n");
5924 board_config = ALC262_AUTO;
5927 if (board_config == ALC262_AUTO) {
5928 /* automatic parse from the BIOS config */
5929 err = alc262_parse_auto_config(codec);
5935 "hda_codec: Cannot set up configuration "
5936 "from BIOS. Using base mode...\n");
5937 board_config = ALC262_BASIC;
5941 if (board_config != ALC262_AUTO)
5942 setup_preset(spec, &alc262_presets[board_config]);
5944 spec->stream_name_analog = "ALC262 Analog";
5945 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5946 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5948 spec->stream_name_digital = "ALC262 Digital";
5949 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5950 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5952 if (! spec->adc_nids && spec->input_mux) {
5953 /* check whether NID 0x07 is valid */
5954 unsigned int wcap = get_wcaps(codec, 0x07);
5956 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5957 if (wcap != AC_WID_AUD_IN) {
5958 spec->adc_nids = alc262_adc_nids_alt;
5959 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5960 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5963 spec->adc_nids = alc262_adc_nids;
5964 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5965 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5970 codec->patch_ops = alc_patch_ops;
5971 if (board_config == ALC262_AUTO)
5972 spec->init_hook = alc262_auto_init;
5978 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5982 * set the path ways for 2 channel output
5983 * need to set the codec line out and mic 1 pin widgets to inputs
5985 static struct hda_verb alc861_threestack_ch2_init[] = {
5986 /* set pin widget 1Ah (line in) for input */
5987 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5988 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5989 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5991 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5993 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
5994 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6000 * need to set the codec line out and mic 1 pin widgets to outputs
6002 static struct hda_verb alc861_threestack_ch6_init[] = {
6003 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6004 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6005 /* set pin widget 18h (mic1) for output (CLFE)*/
6006 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6008 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6009 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6011 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6013 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6014 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6019 static struct hda_channel_mode alc861_threestack_modes[2] = {
6020 { 2, alc861_threestack_ch2_init },
6021 { 6, alc861_threestack_ch6_init },
6026 static struct snd_kcontrol_new alc861_base_mixer[] = {
6027 /* output mixer control */
6028 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6029 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6031 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6032 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6034 /*Input mixer control */
6035 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6036 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6037 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6038 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6039 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6040 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6041 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6042 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6043 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6046 /* Capture mixer control */
6047 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6048 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6051 .name = "Capture Source",
6053 .info = alc_mux_enum_info,
6054 .get = alc_mux_enum_get,
6055 .put = alc_mux_enum_put,
6060 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6061 /* output mixer control */
6062 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6063 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6065 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6066 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6068 /* Input mixer control */
6069 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6070 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6071 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6072 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6073 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6074 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6076 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6080 /* Capture mixer control */
6081 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6082 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6085 .name = "Capture Source",
6087 .info = alc_mux_enum_info,
6088 .get = alc_mux_enum_get,
6089 .put = alc_mux_enum_put,
6092 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6093 .name = "Channel Mode",
6094 .info = alc_ch_mode_info,
6095 .get = alc_ch_mode_get,
6096 .put = alc_ch_mode_put,
6097 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6103 * generic initialization of ADC, input mixers and output mixers
6105 static struct hda_verb alc861_base_init_verbs[] = {
6107 * Unmute ADC0 and set the default input to mic-in
6109 /* port-A for surround (rear panel) */
6110 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6111 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6112 /* port-B for mic-in (rear panel) with vref */
6113 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6114 /* port-C for line-in (rear panel) */
6115 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6116 /* port-D for Front */
6117 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6118 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6119 /* port-E for HP out (front panel) */
6120 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6121 /* route front PCM to HP */
6122 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6123 /* port-F for mic-in (front panel) with vref */
6124 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6125 /* port-G for CLFE (rear panel) */
6126 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6127 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6128 /* port-H for side (rear panel) */
6129 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6130 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6132 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6133 /* route front mic to ADC1*/
6134 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6137 /* Unmute DAC0~3 & spdif out*/
6138 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6139 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6141 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6144 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6145 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6146 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6147 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6148 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6150 /* Unmute Stereo Mixer 15 */
6151 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6156 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6157 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6158 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6159 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6160 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6164 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6165 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6170 static struct hda_verb alc861_threestack_init_verbs[] = {
6172 * Unmute ADC0 and set the default input to mic-in
6174 /* port-A for surround (rear panel) */
6175 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6176 /* port-B for mic-in (rear panel) with vref */
6177 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6178 /* port-C for line-in (rear panel) */
6179 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6180 /* port-D for Front */
6181 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6182 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6183 /* port-E for HP out (front panel) */
6184 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6185 /* route front PCM to HP */
6186 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6187 /* port-F for mic-in (front panel) with vref */
6188 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6189 /* port-G for CLFE (rear panel) */
6190 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6191 /* port-H for side (rear panel) */
6192 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6194 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6195 /* route front mic to ADC1*/
6196 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6198 /* Unmute DAC0~3 & spdif out*/
6199 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6200 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6201 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6202 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6205 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6206 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6207 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6208 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6209 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6211 /* Unmute Stereo Mixer 15 */
6212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6217 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6218 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6220 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6222 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6224 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6230 * generic initialization of ADC, input mixers and output mixers
6232 static struct hda_verb alc861_auto_init_verbs[] = {
6234 * Unmute ADC0 and set the default input to mic-in
6236 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6239 /* Unmute DAC0~3 & spdif out*/
6240 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6241 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6242 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6243 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6246 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6247 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6248 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6249 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6250 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6252 /* Unmute Stereo Mixer 15 */
6253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6258 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6260 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6262 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6268 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6276 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6281 /* pcm configuration: identiacal with ALC880 */
6282 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
6283 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
6284 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
6285 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
6288 #define ALC861_DIGOUT_NID 0x07
6290 static struct hda_channel_mode alc861_8ch_modes[1] = {
6294 static hda_nid_t alc861_dac_nids[4] = {
6295 /* front, surround, clfe, side */
6296 0x03, 0x06, 0x05, 0x04
6299 static hda_nid_t alc660_dac_nids[3] = {
6300 /* front, clfe, surround */
6304 static hda_nid_t alc861_adc_nids[1] = {
6309 static struct hda_input_mux alc861_capture_source = {
6313 { "Front Mic", 0x3 },
6320 /* fill in the dac_nids table from the parsed pin configuration */
6321 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6326 spec->multiout.dac_nids = spec->private_dac_nids;
6327 for (i = 0; i < cfg->line_outs; i++) {
6328 nid = cfg->line_out_pins[i];
6330 if (i >= ARRAY_SIZE(alc861_dac_nids))
6332 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6335 spec->multiout.num_dacs = cfg->line_outs;
6339 /* add playback controls from the parsed DAC table */
6340 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6341 const struct auto_pin_cfg *cfg)
6344 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6348 for (i = 0; i < cfg->line_outs; i++) {
6349 nid = spec->multiout.dac_nids[i];
6354 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6355 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6357 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6358 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6361 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6362 if (nid == alc861_dac_nids[idx])
6364 sprintf(name, "%s Playback Switch", chname[idx]);
6365 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6366 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6373 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6381 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6383 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6384 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6386 spec->multiout.hp_nid = nid;
6391 /* create playback/capture controls for input pins */
6392 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6394 struct hda_input_mux *imux = &spec->private_imux;
6395 int i, err, idx, idx1;
6397 for (i = 0; i < AUTO_PIN_LAST; i++) {
6398 switch(cfg->input_pins[i]) {
6423 err = new_analog_input(spec, cfg->input_pins[i],
6424 auto_pin_cfg_labels[i], idx, 0x15);
6428 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
6429 imux->items[imux->num_items].index = idx1;
6435 static struct snd_kcontrol_new alc861_capture_mixer[] = {
6436 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6437 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6440 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6441 /* The multiple "Capture Source" controls confuse alsamixer
6442 * So call somewhat different..
6443 *FIXME: the controls appear in the "playback" view!
6445 /* .name = "Capture Source", */
6446 .name = "Input Source",
6448 .info = alc_mux_enum_info,
6449 .get = alc_mux_enum_get,
6450 .put = alc_mux_enum_put,
6455 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6456 int pin_type, int dac_idx)
6460 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6461 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6465 static void alc861_auto_init_multi_out(struct hda_codec *codec)
6467 struct alc_spec *spec = codec->spec;
6470 for (i = 0; i < spec->autocfg.line_outs; i++) {
6471 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6473 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6477 static void alc861_auto_init_hp_out(struct hda_codec *codec)
6479 struct alc_spec *spec = codec->spec;
6482 pin = spec->autocfg.hp_pin;
6483 if (pin) /* connect to front */
6484 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6487 static void alc861_auto_init_analog_input(struct hda_codec *codec)
6489 struct alc_spec *spec = codec->spec;
6492 for (i = 0; i < AUTO_PIN_LAST; i++) {
6493 hda_nid_t nid = spec->autocfg.input_pins[i];
6494 if ((nid>=0x0c) && (nid <=0x11)) {
6495 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6496 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6501 /* parse the BIOS configuration and set up the alc_spec */
6502 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6503 static int alc861_parse_auto_config(struct hda_codec *codec)
6505 struct alc_spec *spec = codec->spec;
6507 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6509 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6510 alc861_ignore)) < 0)
6512 if (! spec->autocfg.line_outs)
6513 return 0; /* can't find valid BIOS pin config */
6515 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6516 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6517 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6518 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6521 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6523 if (spec->autocfg.dig_out_pin)
6524 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6526 if (spec->kctl_alloc)
6527 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6529 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6531 spec->num_mux_defs = 1;
6532 spec->input_mux = &spec->private_imux;
6534 spec->adc_nids = alc861_adc_nids;
6535 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6536 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6542 /* additional initialization for auto-configuration model */
6543 static void alc861_auto_init(struct hda_codec *codec)
6545 alc861_auto_init_multi_out(codec);
6546 alc861_auto_init_hp_out(codec);
6547 alc861_auto_init_analog_input(codec);
6552 * configuration and preset
6554 static struct hda_board_config alc861_cfg_tbl[] = {
6555 { .modelname = "3stack", .config = ALC861_3ST },
6556 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6557 .config = ALC861_3ST },
6558 { .modelname = "3stack-660", .config = ALC660_3ST },
6559 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6560 .config = ALC660_3ST },
6561 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6562 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
6563 { .modelname = "auto", .config = ALC861_AUTO },
6567 static struct alc_config_preset alc861_presets[] = {
6569 .mixers = { alc861_3ST_mixer },
6570 .init_verbs = { alc861_threestack_init_verbs },
6571 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6572 .dac_nids = alc861_dac_nids,
6573 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6574 .channel_mode = alc861_threestack_modes,
6576 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6577 .adc_nids = alc861_adc_nids,
6578 .input_mux = &alc861_capture_source,
6580 [ALC861_3ST_DIG] = {
6581 .mixers = { alc861_base_mixer },
6582 .init_verbs = { alc861_threestack_init_verbs },
6583 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6584 .dac_nids = alc861_dac_nids,
6585 .dig_out_nid = ALC861_DIGOUT_NID,
6586 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6587 .channel_mode = alc861_threestack_modes,
6589 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6590 .adc_nids = alc861_adc_nids,
6591 .input_mux = &alc861_capture_source,
6593 [ALC861_6ST_DIG] = {
6594 .mixers = { alc861_base_mixer },
6595 .init_verbs = { alc861_base_init_verbs },
6596 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6597 .dac_nids = alc861_dac_nids,
6598 .dig_out_nid = ALC861_DIGOUT_NID,
6599 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6600 .channel_mode = alc861_8ch_modes,
6601 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6602 .adc_nids = alc861_adc_nids,
6603 .input_mux = &alc861_capture_source,
6606 .mixers = { alc861_3ST_mixer },
6607 .init_verbs = { alc861_threestack_init_verbs },
6608 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6609 .dac_nids = alc660_dac_nids,
6610 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6611 .channel_mode = alc861_threestack_modes,
6613 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6614 .adc_nids = alc861_adc_nids,
6615 .input_mux = &alc861_capture_source,
6620 static int patch_alc861(struct hda_codec *codec)
6622 struct alc_spec *spec;
6626 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6632 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
6634 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
6635 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6636 "trying auto-probe from BIOS...\n");
6637 board_config = ALC861_AUTO;
6640 if (board_config == ALC861_AUTO) {
6641 /* automatic parse from the BIOS config */
6642 err = alc861_parse_auto_config(codec);
6648 "hda_codec: Cannot set up configuration "
6649 "from BIOS. Using base mode...\n");
6650 board_config = ALC861_3ST_DIG;
6654 if (board_config != ALC861_AUTO)
6655 setup_preset(spec, &alc861_presets[board_config]);
6657 spec->stream_name_analog = "ALC861 Analog";
6658 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6659 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6661 spec->stream_name_digital = "ALC861 Digital";
6662 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6663 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6665 codec->patch_ops = alc_patch_ops;
6666 if (board_config == ALC861_AUTO)
6667 spec->init_hook = alc861_auto_init;
6675 struct hda_codec_preset snd_hda_preset_realtek[] = {
6676 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6677 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6678 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6679 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6680 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
6681 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6682 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6683 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6684 .patch = patch_alc861 },
6685 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6686 .patch = patch_alc861 },