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 */
119 #define GPIO_MASK 0x03
122 /* codec parameterization */
123 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
124 unsigned int num_mixers;
126 const struct hda_verb *init_verbs[5]; /* initialization verbs
130 unsigned int num_init_verbs;
132 char *stream_name_analog; /* analog PCM stream */
133 struct hda_pcm_stream *stream_analog_playback;
134 struct hda_pcm_stream *stream_analog_capture;
136 char *stream_name_digital; /* digital PCM stream */
137 struct hda_pcm_stream *stream_digital_playback;
138 struct hda_pcm_stream *stream_digital_capture;
141 struct hda_multi_out multiout; /* playback set-up
142 * max_channels, dacs must be set
143 * dig_out_nid and hp_nid are optional
147 unsigned int num_adc_nids;
149 hda_nid_t dig_in_nid; /* digital-in NID; optional */
152 unsigned int num_mux_defs;
153 const struct hda_input_mux *input_mux;
154 unsigned int cur_mux[3];
157 const struct hda_channel_mode *channel_mode;
158 int num_channel_mode;
161 /* PCM information */
162 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
164 /* dynamic controls, init_verbs and input_mux */
165 struct auto_pin_cfg autocfg;
166 unsigned int num_kctl_alloc, num_kctl_used;
167 struct snd_kcontrol_new *kctl_alloc;
168 struct hda_input_mux private_imux;
169 hda_nid_t private_dac_nids[5];
172 void (*init_hook)(struct hda_codec *codec);
173 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
175 /* for pin sensing */
176 unsigned int sense_updated: 1;
177 unsigned int jack_present: 1;
181 * configuration template - to be copied to the spec instance
183 struct alc_config_preset {
184 struct snd_kcontrol_new *mixers[5]; /* should be identical size
187 const struct hda_verb *init_verbs[5];
188 unsigned int num_dacs;
190 hda_nid_t dig_out_nid; /* optional */
191 hda_nid_t hp_nid; /* optional */
192 unsigned int num_adc_nids;
194 hda_nid_t dig_in_nid;
195 unsigned int num_channel_mode;
196 const struct hda_channel_mode *channel_mode;
198 unsigned int num_mux_defs;
199 const struct hda_input_mux *input_mux;
200 void (*unsol_event)(struct hda_codec *, unsigned int);
201 void (*init_hook)(struct hda_codec *);
208 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
209 struct snd_ctl_elem_info *uinfo)
211 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
212 struct alc_spec *spec = codec->spec;
213 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
214 if (mux_idx >= spec->num_mux_defs)
216 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
219 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
220 struct snd_ctl_elem_value *ucontrol)
222 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
223 struct alc_spec *spec = codec->spec;
224 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
226 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
230 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
231 struct snd_ctl_elem_value *ucontrol)
233 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
234 struct alc_spec *spec = codec->spec;
235 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
236 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
237 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
238 spec->adc_nids[adc_idx],
239 &spec->cur_mux[adc_idx]);
244 * channel mode setting
246 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
247 struct snd_ctl_elem_info *uinfo)
249 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
250 struct alc_spec *spec = codec->spec;
251 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
252 spec->num_channel_mode);
255 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
256 struct snd_ctl_elem_value *ucontrol)
258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
259 struct alc_spec *spec = codec->spec;
260 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
261 spec->num_channel_mode,
262 spec->multiout.max_channels);
265 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
266 struct snd_ctl_elem_value *ucontrol)
268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
269 struct alc_spec *spec = codec->spec;
270 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
271 spec->num_channel_mode,
272 &spec->multiout.max_channels);
273 if (! err && spec->need_dac_fix)
274 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
279 * Control the mode of pin widget settings via the mixer. "pc" is used
280 * instead of "%" to avoid consequences of accidently treating the % as
281 * being part of a format specifier. Maximum allowed length of a value is
282 * 63 characters plus NULL terminator.
284 * Note: some retasking pin complexes seem to ignore requests for input
285 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
286 * are requested. Therefore order this list so that this behaviour will not
287 * cause problems when mixer clients move through the enum sequentially.
288 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
291 static char *alc_pin_mode_names[] = {
292 "Mic 50pc bias", "Mic 80pc bias",
293 "Line in", "Line out", "Headphone out",
295 static unsigned char alc_pin_mode_values[] = {
296 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
298 /* The control can present all 5 options, or it can limit the options based
299 * in the pin being assumed to be exclusively an input or an output pin. In
300 * addition, "input" pins may or may not process the mic bias option
301 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
302 * accept requests for bias as of chip versions up to March 2006) and/or
303 * wiring in the computer.
305 #define ALC_PIN_DIR_IN 0x00
306 #define ALC_PIN_DIR_OUT 0x01
307 #define ALC_PIN_DIR_INOUT 0x02
308 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
309 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
311 /* Info about the pin modes supported by the different pin direction modes.
312 * For each direction the minimum and maximum values are given.
314 static signed char alc_pin_mode_dir_info[5][2] = {
315 { 0, 2 }, /* ALC_PIN_DIR_IN */
316 { 3, 4 }, /* ALC_PIN_DIR_OUT */
317 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
318 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
319 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
321 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
322 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
323 #define alc_pin_mode_n_items(_dir) \
324 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
326 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
327 struct snd_ctl_elem_info *uinfo)
329 unsigned int item_num = uinfo->value.enumerated.item;
330 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
332 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
334 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
336 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
337 item_num = alc_pin_mode_min(dir);
338 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
342 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
343 struct snd_ctl_elem_value *ucontrol)
346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
347 hda_nid_t nid = kcontrol->private_value & 0xffff;
348 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
349 long *valp = ucontrol->value.integer.value;
350 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
351 AC_VERB_GET_PIN_WIDGET_CONTROL,
354 /* Find enumerated value for current pinctl setting */
355 i = alc_pin_mode_min(dir);
356 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
358 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
362 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
363 struct snd_ctl_elem_value *ucontrol)
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
367 hda_nid_t nid = kcontrol->private_value & 0xffff;
368 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
369 long val = *ucontrol->value.integer.value;
370 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
371 AC_VERB_GET_PIN_WIDGET_CONTROL,
374 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
375 val = alc_pin_mode_min(dir);
377 change = pinctl != alc_pin_mode_values[val];
379 /* Set pin mode to that requested */
380 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
381 alc_pin_mode_values[val]);
383 /* Also enable the retasking pin's input/output as required
384 * for the requested pin mode. Enum values of 2 or less are
387 * Dynamically switching the input/output buffers probably
388 * reduces noise slightly (particularly on input) so we'll
389 * do it. However, having both input and output buffers
390 * enabled simultaneously doesn't seem to be problematic if
391 * this turns out to be necessary in the future.
394 snd_hda_codec_write(codec, nid, 0,
395 AC_VERB_SET_AMP_GAIN_MUTE,
397 snd_hda_codec_write(codec, nid, 0,
398 AC_VERB_SET_AMP_GAIN_MUTE,
401 snd_hda_codec_write(codec, nid, 0,
402 AC_VERB_SET_AMP_GAIN_MUTE,
404 snd_hda_codec_write(codec, nid, 0,
405 AC_VERB_SET_AMP_GAIN_MUTE,
412 #define ALC_PIN_MODE(xname, nid, dir) \
413 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
414 .info = alc_pin_mode_info, \
415 .get = alc_pin_mode_get, \
416 .put = alc_pin_mode_put, \
417 .private_value = nid | (dir<<16) }
419 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
420 * together using a mask with more than one bit set. This control is
421 * currently used only by the ALC260 test model. At this stage they are not
422 * needed for any "production" models.
424 #ifdef CONFIG_SND_DEBUG
425 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_info *uinfo)
428 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
430 uinfo->value.integer.min = 0;
431 uinfo->value.integer.max = 1;
434 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
435 struct snd_ctl_elem_value *ucontrol)
437 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
438 hda_nid_t nid = kcontrol->private_value & 0xffff;
439 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
440 long *valp = ucontrol->value.integer.value;
441 unsigned int val = snd_hda_codec_read(codec, nid, 0,
442 AC_VERB_GET_GPIO_DATA, 0x00);
444 *valp = (val & mask) != 0;
447 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_value *ucontrol)
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 hda_nid_t nid = kcontrol->private_value & 0xffff;
453 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
454 long val = *ucontrol->value.integer.value;
455 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
456 AC_VERB_GET_GPIO_DATA,
459 /* Set/unset the masked GPIO bit(s) as needed */
460 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
465 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
469 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
470 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
471 .info = alc_gpio_data_info, \
472 .get = alc_gpio_data_get, \
473 .put = alc_gpio_data_put, \
474 .private_value = nid | (mask<<16) }
475 #endif /* CONFIG_SND_DEBUG */
477 /* A switch control to allow the enabling of the digital IO pins on the
478 * ALC260. This is incredibly simplistic; the intention of this control is
479 * to provide something in the test model allowing digital outputs to be
480 * identified if present. If models are found which can utilise these
481 * outputs a more complete mixer control can be devised for those models if
484 #ifdef CONFIG_SND_DEBUG
485 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_info *uinfo)
488 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
490 uinfo->value.integer.min = 0;
491 uinfo->value.integer.max = 1;
494 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
495 struct snd_ctl_elem_value *ucontrol)
497 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
498 hda_nid_t nid = kcontrol->private_value & 0xffff;
499 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
500 long *valp = ucontrol->value.integer.value;
501 unsigned int val = snd_hda_codec_read(codec, nid, 0,
502 AC_VERB_GET_DIGI_CONVERT, 0x00);
504 *valp = (val & mask) != 0;
507 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol)
511 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
512 hda_nid_t nid = kcontrol->private_value & 0xffff;
513 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
514 long val = *ucontrol->value.integer.value;
515 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
516 AC_VERB_GET_DIGI_CONVERT,
519 /* Set/unset the masked control bit(s) as needed */
520 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
525 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
530 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
531 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
532 .info = alc_spdif_ctrl_info, \
533 .get = alc_spdif_ctrl_get, \
534 .put = alc_spdif_ctrl_put, \
535 .private_value = nid | (mask<<16) }
536 #endif /* CONFIG_SND_DEBUG */
539 * set up from the preset table
541 static void setup_preset(struct alc_spec *spec,
542 const struct alc_config_preset *preset)
546 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
547 spec->mixers[spec->num_mixers++] = preset->mixers[i];
548 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
550 spec->init_verbs[spec->num_init_verbs++] =
551 preset->init_verbs[i];
553 spec->channel_mode = preset->channel_mode;
554 spec->num_channel_mode = preset->num_channel_mode;
555 spec->need_dac_fix = preset->need_dac_fix;
557 spec->multiout.max_channels = spec->channel_mode[0].channels;
559 spec->multiout.num_dacs = preset->num_dacs;
560 spec->multiout.dac_nids = preset->dac_nids;
561 spec->multiout.dig_out_nid = preset->dig_out_nid;
562 spec->multiout.hp_nid = preset->hp_nid;
564 spec->num_mux_defs = preset->num_mux_defs;
565 if (! spec->num_mux_defs)
566 spec->num_mux_defs = 1;
567 spec->input_mux = preset->input_mux;
569 spec->num_adc_nids = preset->num_adc_nids;
570 spec->adc_nids = preset->adc_nids;
571 spec->dig_in_nid = preset->dig_in_nid;
573 spec->unsol_event = preset->unsol_event;
574 spec->init_hook = preset->init_hook;
578 * ALC880 3-stack model
580 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
581 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
582 * F-Mic = 0x1b, HP = 0x19
585 static hda_nid_t alc880_dac_nids[4] = {
586 /* front, rear, clfe, rear_surr */
587 0x02, 0x05, 0x04, 0x03
590 static hda_nid_t alc880_adc_nids[3] = {
595 /* The datasheet says the node 0x07 is connected from inputs,
596 * but it shows zero connection in the real implementation on some devices.
597 * Note: this is a 915GAV bug, fixed on 915GLV
599 static hda_nid_t alc880_adc_nids_alt[2] = {
604 #define ALC880_DIGOUT_NID 0x06
605 #define ALC880_DIGIN_NID 0x0a
607 static struct hda_input_mux alc880_capture_source = {
611 { "Front Mic", 0x3 },
617 /* channel source setting (2/6 channel selection for 3-stack) */
619 static struct hda_verb alc880_threestack_ch2_init[] = {
620 /* set line-in to input, mute it */
621 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
622 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
623 /* set mic-in to input vref 80%, mute it */
624 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
625 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
630 static struct hda_verb alc880_threestack_ch6_init[] = {
631 /* set line-in to output, unmute it */
632 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
633 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
634 /* set mic-in to output, unmute it */
635 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
636 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
640 static struct hda_channel_mode alc880_threestack_modes[2] = {
641 { 2, alc880_threestack_ch2_init },
642 { 6, alc880_threestack_ch6_init },
645 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
646 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
647 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
648 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
649 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
650 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
651 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
652 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
653 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
654 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
655 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
656 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
657 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
660 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
661 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
662 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
663 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
666 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
667 .name = "Channel Mode",
668 .info = alc_ch_mode_info,
669 .get = alc_ch_mode_get,
670 .put = alc_ch_mode_put,
675 /* capture mixer elements */
676 static struct snd_kcontrol_new alc880_capture_mixer[] = {
677 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
678 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
679 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
680 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
681 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
682 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
684 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
685 /* The multiple "Capture Source" controls confuse alsamixer
686 * So call somewhat different..
687 * FIXME: the controls appear in the "playback" view!
689 /* .name = "Capture Source", */
690 .name = "Input Source",
692 .info = alc_mux_enum_info,
693 .get = alc_mux_enum_get,
694 .put = alc_mux_enum_put,
699 /* capture mixer elements (in case NID 0x07 not available) */
700 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
701 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
702 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
703 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
704 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
707 /* The multiple "Capture Source" controls confuse alsamixer
708 * So call somewhat different..
709 * FIXME: the controls appear in the "playback" view!
711 /* .name = "Capture Source", */
712 .name = "Input Source",
714 .info = alc_mux_enum_info,
715 .get = alc_mux_enum_get,
716 .put = alc_mux_enum_put,
724 * ALC880 5-stack model
726 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
728 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
729 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
732 /* additional mixers to alc880_three_stack_mixer */
733 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
734 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
735 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
739 /* channel source setting (6/8 channel selection for 5-stack) */
741 static struct hda_verb alc880_fivestack_ch6_init[] = {
742 /* set line-in to input, mute it */
743 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
744 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
749 static struct hda_verb alc880_fivestack_ch8_init[] = {
750 /* set line-in to output, unmute it */
751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
756 static struct hda_channel_mode alc880_fivestack_modes[2] = {
757 { 6, alc880_fivestack_ch6_init },
758 { 8, alc880_fivestack_ch8_init },
763 * ALC880 6-stack model
765 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
767 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
768 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
771 static hda_nid_t alc880_6st_dac_nids[4] = {
772 /* front, rear, clfe, rear_surr */
773 0x02, 0x03, 0x04, 0x05
776 static struct hda_input_mux alc880_6stack_capture_source = {
780 { "Front Mic", 0x1 },
786 /* fixed 8-channels */
787 static struct hda_channel_mode alc880_sixstack_modes[1] = {
791 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
795 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
796 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
800 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
801 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
807 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
808 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
809 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
810 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
811 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
814 .name = "Channel Mode",
815 .info = alc_ch_mode_info,
816 .get = alc_ch_mode_get,
817 .put = alc_ch_mode_put,
826 * W810 has rear IO for:
829 * Center/LFE (DAC 04)
832 * The system also has a pair of internal speakers, and a headphone jack.
833 * These are both connected to Line2 on the codec, hence to DAC 02.
835 * There is a variable resistor to control the speaker or headphone
836 * volume. This is a hardware-only device without a software API.
838 * Plugging headphones in will disable the internal speakers. This is
839 * implemented in hardware, not via the driver using jack sense. In
840 * a similar fashion, plugging into the rear socket marked "front" will
841 * disable both the speakers and headphones.
843 * For input, there's a microphone jack, and an "audio in" jack.
844 * These may not do anything useful with this driver yet, because I
845 * haven't setup any initialization verbs for these yet...
848 static hda_nid_t alc880_w810_dac_nids[3] = {
849 /* front, rear/surround, clfe */
853 /* fixed 6 channels */
854 static struct hda_channel_mode alc880_w810_modes[1] = {
858 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
859 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
861 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
862 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
863 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
864 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
865 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
866 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
867 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
876 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
877 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
881 static hda_nid_t alc880_z71v_dac_nids[1] = {
884 #define ALC880_Z71V_HP_DAC 0x03
886 /* fixed 2 channels */
887 static struct hda_channel_mode alc880_2_jack_modes[1] = {
891 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
892 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
894 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
895 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
908 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
909 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
912 static hda_nid_t alc880_f1734_dac_nids[1] = {
915 #define ALC880_F1734_HP_DAC 0x02
917 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
919 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
920 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
921 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
925 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
934 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
935 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
936 * Mic = 0x18, Line = 0x1a
939 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
940 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
942 static struct snd_kcontrol_new alc880_asus_mixer[] = {
943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
944 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
945 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
946 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
947 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
948 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
949 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
950 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
953 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
954 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
959 .name = "Channel Mode",
960 .info = alc_ch_mode_info,
961 .get = alc_ch_mode_get,
962 .put = alc_ch_mode_put,
969 * ALC880 ASUS W1V model
971 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
972 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
973 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
976 /* additional mixers to alc880_asus_mixer */
977 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
978 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
979 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
983 /* additional mixers to alc880_asus_mixer */
984 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
985 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
986 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
991 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
993 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
996 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
999 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1000 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1003 /* The multiple "Capture Source" controls confuse alsamixer
1004 * So call somewhat different..
1005 * FIXME: the controls appear in the "playback" view!
1007 /* .name = "Capture Source", */
1008 .name = "Input Source",
1010 .info = alc_mux_enum_info,
1011 .get = alc_mux_enum_get,
1012 .put = alc_mux_enum_put,
1018 * build control elements
1020 static int alc_build_controls(struct hda_codec *codec)
1022 struct alc_spec *spec = codec->spec;
1026 for (i = 0; i < spec->num_mixers; i++) {
1027 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1032 if (spec->multiout.dig_out_nid) {
1033 err = snd_hda_create_spdif_out_ctls(codec,
1034 spec->multiout.dig_out_nid);
1038 if (spec->dig_in_nid) {
1039 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1048 * initialize the codec volumes, etc
1052 * generic initialization of ADC, input mixers and output mixers
1054 static struct hda_verb alc880_volume_init_verbs[] = {
1056 * Unmute ADC0-2 and set the default input to mic-in
1058 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1060 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1062 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1065 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1067 * Note: PASD motherboards uses the Line In 2 as the input for front
1070 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1078 * Set up output mixers (0x0c - 0x0f)
1080 /* set vol=0 to output mixers */
1081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1082 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1085 /* set up input amps for analog loopback */
1086 /* Amp Indices: DAC = 0, mixer = 1 */
1087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1093 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1094 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1100 * 3-stack pin configuration:
1101 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1103 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1105 * preset connection lists of input pins
1106 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1108 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1109 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1110 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1113 * Set pin mode and muting
1115 /* set front pin widgets 0x14 for output */
1116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1117 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1118 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1119 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1121 /* Mic2 (as headphone out) for HP output */
1122 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1123 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1124 /* Line In pin widget for input */
1125 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1127 /* Line2 (as front mic) pin widget for input and vref at 80% */
1128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1129 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1130 /* CD pin widget for input */
1131 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1137 * 5-stack pin configuration:
1138 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1139 * line-in/side = 0x1a, f-mic = 0x1b
1141 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1143 * preset connection lists of input pins
1144 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1146 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1147 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1150 * Set pin mode and muting
1152 /* set pin widgets 0x14-0x17 for output */
1153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1155 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1156 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1157 /* unmute pins for output (no gain on this amp) */
1158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1160 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1161 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1163 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1164 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1165 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1166 /* Mic2 (as headphone out) for HP output */
1167 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1168 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1169 /* Line In pin widget for input */
1170 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1171 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1172 /* Line2 (as front mic) pin widget for input and vref at 80% */
1173 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1174 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1175 /* CD pin widget for input */
1176 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1182 * W810 pin configuration:
1183 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1185 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1186 /* hphone/speaker input selector: front DAC */
1187 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1190 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1191 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1193 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1196 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1197 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1203 * Z71V pin configuration:
1204 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1206 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1213 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1215 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1221 * 6-stack pin configuration:
1222 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1223 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1225 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1226 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1231 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1233 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1234 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1235 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1237 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1239 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1240 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1241 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1242 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1243 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1245 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1252 * F1734 pin configuration:
1253 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1255 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1256 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1257 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1258 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1259 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1267 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1270 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1274 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1281 * ASUS pin configuration:
1282 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1284 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1285 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1286 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1287 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1288 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1290 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1291 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1296 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1300 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1302 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1304 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1305 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1307 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1312 /* Enable GPIO mask and set output */
1313 static struct hda_verb alc880_gpio1_init_verbs[] = {
1314 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1315 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1316 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1321 /* Enable GPIO mask and set output */
1322 static struct hda_verb alc880_gpio2_init_verbs[] = {
1323 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1324 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1325 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1330 /* Clevo m520g init */
1331 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1332 /* headphone output */
1333 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1336 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1338 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1341 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1342 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1343 /* Mic1 (rear panel) */
1344 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1345 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1346 /* Mic2 (front panel) */
1347 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1348 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 /* change to EAPD mode */
1353 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1354 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1359 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1360 /* change to EAPD mode */
1361 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1362 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1364 /* Headphone output */
1365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1370 /* Line In pin widget for input */
1371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1372 /* CD pin widget for input */
1373 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1374 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1377 /* change to EAPD mode */
1378 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1379 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1385 * LG m1 express dual
1388 * Rear Line-In/Out (blue): 0x14
1389 * Build-in Mic-In: 0x15
1391 * HP-Out (green): 0x1b
1392 * Mic-In/Out (red): 0x19
1396 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1397 static hda_nid_t alc880_lg_dac_nids[3] = {
1401 /* seems analog CD is not working */
1402 static struct hda_input_mux alc880_lg_capture_source = {
1407 { "Internal Mic", 0x6 },
1411 /* 2,4,6 channel modes */
1412 static struct hda_verb alc880_lg_ch2_init[] = {
1413 /* set line-in and mic-in to input */
1414 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1415 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1419 static struct hda_verb alc880_lg_ch4_init[] = {
1420 /* set line-in to out and mic-in to input */
1421 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1422 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1426 static struct hda_verb alc880_lg_ch6_init[] = {
1427 /* set line-in and mic-in to output */
1428 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1429 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1433 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1434 { 2, alc880_lg_ch2_init },
1435 { 4, alc880_lg_ch4_init },
1436 { 6, alc880_lg_ch6_init },
1439 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1440 /* FIXME: it's not really "master" but front channels */
1441 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1442 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1443 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1445 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1446 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1447 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1448 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1450 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1452 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1453 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1454 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1457 .name = "Channel Mode",
1458 .info = alc_ch_mode_info,
1459 .get = alc_ch_mode_get,
1460 .put = alc_ch_mode_put,
1465 static struct hda_verb alc880_lg_init_verbs[] = {
1466 /* set capture source to mic-in */
1467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1468 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1469 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1470 /* mute all amp mixer inputs */
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1474 /* line-in to input */
1475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1478 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1479 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1482 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1483 /* mic-in to input */
1484 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1486 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1496 /* toggle speaker-output according to the hp-jack state */
1497 static void alc880_lg_automute(struct hda_codec *codec)
1499 unsigned int present;
1501 present = snd_hda_codec_read(codec, 0x1b, 0,
1502 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1503 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1504 0x80, present ? 0x80 : 0);
1505 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1506 0x80, present ? 0x80 : 0);
1509 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1511 /* Looks like the unsol event is incompatible with the standard
1512 * definition. 4bit tag is placed at 28 bit!
1514 if ((res >> 28) == 0x01)
1515 alc880_lg_automute(codec);
1524 * Built-in Mic-In: 0x19 (?)
1529 /* seems analog CD is not working */
1530 static struct hda_input_mux alc880_lg_lw_capture_source = {
1534 { "Internal Mic", 0x1 },
1538 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1539 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1540 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1543 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1544 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1548 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1549 /* set capture source to mic-in */
1550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1551 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1558 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1560 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1561 /* mic-in to input */
1562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1563 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1565 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1568 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1572 /* toggle speaker-output according to the hp-jack state */
1573 static void alc880_lg_lw_automute(struct hda_codec *codec)
1575 unsigned int present;
1577 present = snd_hda_codec_read(codec, 0x1b, 0,
1578 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1579 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1580 0x80, present ? 0x80 : 0);
1581 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1582 0x80, present ? 0x80 : 0);
1585 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1587 /* Looks like the unsol event is incompatible with the standard
1588 * definition. 4bit tag is placed at 28 bit!
1590 if ((res >> 28) == 0x01)
1591 alc880_lg_lw_automute(codec);
1598 static int alc_init(struct hda_codec *codec)
1600 struct alc_spec *spec = codec->spec;
1603 for (i = 0; i < spec->num_init_verbs; i++)
1604 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1606 if (spec->init_hook)
1607 spec->init_hook(codec);
1612 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1614 struct alc_spec *spec = codec->spec;
1616 if (spec->unsol_event)
1617 spec->unsol_event(codec, res);
1624 static int alc_resume(struct hda_codec *codec)
1626 struct alc_spec *spec = codec->spec;
1630 for (i = 0; i < spec->num_mixers; i++)
1631 snd_hda_resume_ctls(codec, spec->mixers[i]);
1632 if (spec->multiout.dig_out_nid)
1633 snd_hda_resume_spdif_out(codec);
1634 if (spec->dig_in_nid)
1635 snd_hda_resume_spdif_in(codec);
1642 * Analog playback callbacks
1644 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1645 struct hda_codec *codec,
1646 struct snd_pcm_substream *substream)
1648 struct alc_spec *spec = codec->spec;
1649 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1652 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1653 struct hda_codec *codec,
1654 unsigned int stream_tag,
1655 unsigned int format,
1656 struct snd_pcm_substream *substream)
1658 struct alc_spec *spec = codec->spec;
1659 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1660 stream_tag, format, substream);
1663 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1664 struct hda_codec *codec,
1665 struct snd_pcm_substream *substream)
1667 struct alc_spec *spec = codec->spec;
1668 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1674 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1675 struct hda_codec *codec,
1676 struct snd_pcm_substream *substream)
1678 struct alc_spec *spec = codec->spec;
1679 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1682 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1683 struct hda_codec *codec,
1684 struct snd_pcm_substream *substream)
1686 struct alc_spec *spec = codec->spec;
1687 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1693 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1694 struct hda_codec *codec,
1695 unsigned int stream_tag,
1696 unsigned int format,
1697 struct snd_pcm_substream *substream)
1699 struct alc_spec *spec = codec->spec;
1701 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1702 stream_tag, 0, format);
1706 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1707 struct hda_codec *codec,
1708 struct snd_pcm_substream *substream)
1710 struct alc_spec *spec = codec->spec;
1712 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1720 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1724 /* NID is set in alc_build_pcms */
1726 .open = alc880_playback_pcm_open,
1727 .prepare = alc880_playback_pcm_prepare,
1728 .cleanup = alc880_playback_pcm_cleanup
1732 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1736 /* NID is set in alc_build_pcms */
1738 .prepare = alc880_capture_pcm_prepare,
1739 .cleanup = alc880_capture_pcm_cleanup
1743 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1747 /* NID is set in alc_build_pcms */
1749 .open = alc880_dig_playback_pcm_open,
1750 .close = alc880_dig_playback_pcm_close
1754 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1758 /* NID is set in alc_build_pcms */
1761 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1762 static struct hda_pcm_stream alc_pcm_null_playback = {
1768 static int alc_build_pcms(struct hda_codec *codec)
1770 struct alc_spec *spec = codec->spec;
1771 struct hda_pcm *info = spec->pcm_rec;
1774 codec->num_pcms = 1;
1775 codec->pcm_info = info;
1777 info->name = spec->stream_name_analog;
1778 if (spec->stream_analog_playback) {
1779 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1780 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1781 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1783 if (spec->stream_analog_capture) {
1784 snd_assert(spec->adc_nids, return -EINVAL);
1785 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1786 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1789 if (spec->channel_mode) {
1790 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1791 for (i = 0; i < spec->num_channel_mode; i++) {
1792 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1793 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1798 /* If the use of more than one ADC is requested for the current
1799 * model, configure a second analog capture-only PCM.
1801 if (spec->num_adc_nids > 1) {
1804 info->name = spec->stream_name_analog;
1805 /* No playback stream for second PCM */
1806 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1807 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1808 if (spec->stream_analog_capture) {
1809 snd_assert(spec->adc_nids, return -EINVAL);
1810 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1811 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1815 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1818 info->name = spec->stream_name_digital;
1819 if (spec->multiout.dig_out_nid &&
1820 spec->stream_digital_playback) {
1821 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1822 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1824 if (spec->dig_in_nid &&
1825 spec->stream_digital_capture) {
1826 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1827 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1834 static void alc_free(struct hda_codec *codec)
1836 struct alc_spec *spec = codec->spec;
1842 if (spec->kctl_alloc) {
1843 for (i = 0; i < spec->num_kctl_used; i++)
1844 kfree(spec->kctl_alloc[i].name);
1845 kfree(spec->kctl_alloc);
1852 static struct hda_codec_ops alc_patch_ops = {
1853 .build_controls = alc_build_controls,
1854 .build_pcms = alc_build_pcms,
1857 .unsol_event = alc_unsol_event,
1859 .resume = alc_resume,
1865 * Test configuration for debugging
1867 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1870 #ifdef CONFIG_SND_DEBUG
1871 static hda_nid_t alc880_test_dac_nids[4] = {
1872 0x02, 0x03, 0x04, 0x05
1875 static struct hda_input_mux alc880_test_capture_source = {
1884 { "Surround", 0x6 },
1888 static struct hda_channel_mode alc880_test_modes[4] = {
1895 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1896 struct snd_ctl_elem_info *uinfo)
1898 static char *texts[] = {
1899 "N/A", "Line Out", "HP Out",
1900 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1902 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1904 uinfo->value.enumerated.items = 8;
1905 if (uinfo->value.enumerated.item >= 8)
1906 uinfo->value.enumerated.item = 7;
1907 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1911 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1912 struct snd_ctl_elem_value *ucontrol)
1914 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1915 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1916 unsigned int pin_ctl, item = 0;
1918 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1919 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1920 if (pin_ctl & AC_PINCTL_OUT_EN) {
1921 if (pin_ctl & AC_PINCTL_HP_EN)
1925 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1926 switch (pin_ctl & AC_PINCTL_VREFEN) {
1927 case AC_PINCTL_VREF_HIZ: item = 3; break;
1928 case AC_PINCTL_VREF_50: item = 4; break;
1929 case AC_PINCTL_VREF_GRD: item = 5; break;
1930 case AC_PINCTL_VREF_80: item = 6; break;
1931 case AC_PINCTL_VREF_100: item = 7; break;
1934 ucontrol->value.enumerated.item[0] = item;
1938 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1939 struct snd_ctl_elem_value *ucontrol)
1941 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1942 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1943 static unsigned int ctls[] = {
1944 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1945 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1946 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1947 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1948 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1949 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1951 unsigned int old_ctl, new_ctl;
1953 old_ctl = snd_hda_codec_read(codec, nid, 0,
1954 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1955 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1956 if (old_ctl != new_ctl) {
1957 snd_hda_codec_write(codec, nid, 0,
1958 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1960 (ucontrol->value.enumerated.item[0] >= 3 ?
1967 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1968 struct snd_ctl_elem_info *uinfo)
1970 static char *texts[] = {
1971 "Front", "Surround", "CLFE", "Side"
1973 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1975 uinfo->value.enumerated.items = 4;
1976 if (uinfo->value.enumerated.item >= 4)
1977 uinfo->value.enumerated.item = 3;
1978 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1982 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1983 struct snd_ctl_elem_value *ucontrol)
1985 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1986 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1989 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1990 ucontrol->value.enumerated.item[0] = sel & 3;
1994 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1995 struct snd_ctl_elem_value *ucontrol)
1997 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1998 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2001 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2002 if (ucontrol->value.enumerated.item[0] != sel) {
2003 sel = ucontrol->value.enumerated.item[0] & 3;
2004 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
2010 #define PIN_CTL_TEST(xname,nid) { \
2011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2013 .info = alc_test_pin_ctl_info, \
2014 .get = alc_test_pin_ctl_get, \
2015 .put = alc_test_pin_ctl_put, \
2016 .private_value = nid \
2019 #define PIN_SRC_TEST(xname,nid) { \
2020 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2022 .info = alc_test_pin_src_info, \
2023 .get = alc_test_pin_src_get, \
2024 .put = alc_test_pin_src_put, \
2025 .private_value = nid \
2028 static struct snd_kcontrol_new alc880_test_mixer[] = {
2029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2030 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2031 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2032 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2033 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2034 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2035 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2036 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2037 PIN_CTL_TEST("Front Pin Mode", 0x14),
2038 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2039 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2040 PIN_CTL_TEST("Side Pin Mode", 0x17),
2041 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2042 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2043 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2044 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2045 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2046 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2047 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2048 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2049 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2050 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2051 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2052 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2053 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2054 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2055 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2056 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2061 .name = "Channel Mode",
2062 .info = alc_ch_mode_info,
2063 .get = alc_ch_mode_get,
2064 .put = alc_ch_mode_put,
2069 static struct hda_verb alc880_test_init_verbs[] = {
2070 /* Unmute inputs of 0x0c - 0x0f */
2071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2079 /* Vol output for 0x0c-0x0f */
2080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2084 /* Set output pins 0x14-0x17 */
2085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2087 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2089 /* Unmute output pins 0x14-0x17 */
2090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2092 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2094 /* Set input pins 0x18-0x1c */
2095 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2096 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2097 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2099 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2100 /* Mute input pins 0x18-0x1b */
2101 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2102 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2103 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2107 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2108 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2109 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2110 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2111 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2112 /* Analog input/passthru */
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2125 static struct hda_board_config alc880_cfg_tbl[] = {
2126 /* Back 3 jack, front 2 jack */
2127 { .modelname = "3stack", .config = ALC880_3ST },
2128 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
2147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
2150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2154 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2159 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2160 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2161 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2162 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2164 { .modelname = "tcl", .config = ALC880_TCL_S700 },
2165 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2167 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2168 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2169 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2170 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2172 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2173 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2174 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2175 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2178 { .modelname = "clevo", .config = ALC880_CLEVO },
2179 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2180 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2181 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2182 .config = ALC880_CLEVO }, /* Clevo m665n */
2184 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2185 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2186 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2187 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2189 /* Back 5 jack, front 2 jack */
2190 { .modelname = "5stack", .config = ALC880_5ST },
2191 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2192 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2193 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2194 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2195 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2197 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2198 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2199 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2200 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2201 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2202 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2203 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2204 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2205 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2206 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2207 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2208 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2209 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2210 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2211 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2212 /* note subvendor = 0 below */
2213 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2215 { .modelname = "w810", .config = ALC880_W810 },
2216 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2218 { .modelname = "z71v", .config = ALC880_Z71V },
2219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2221 { .modelname = "6stack", .config = ALC880_6ST },
2222 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2223 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2224 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2225 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2227 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2228 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2229 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2230 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2231 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2232 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2233 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2234 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2235 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2236 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2237 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2238 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2240 { .modelname = "asus", .config = ALC880_ASUS },
2241 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2242 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2243 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2244 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2247 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
2248 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2249 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2250 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2251 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2252 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
2253 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2254 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
2255 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2256 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
2257 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2259 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2260 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2262 { .modelname = "F1734", .config = ALC880_F1734 },
2263 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2264 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2266 { .modelname = "lg", .config = ALC880_LG },
2267 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2268 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
2270 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2271 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2273 #ifdef CONFIG_SND_DEBUG
2274 { .modelname = "test", .config = ALC880_TEST },
2276 { .modelname = "auto", .config = ALC880_AUTO },
2282 * ALC880 codec presets
2284 static struct alc_config_preset alc880_presets[] = {
2286 .mixers = { alc880_three_stack_mixer },
2287 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2288 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2289 .dac_nids = alc880_dac_nids,
2290 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2291 .channel_mode = alc880_threestack_modes,
2293 .input_mux = &alc880_capture_source,
2295 [ALC880_3ST_DIG] = {
2296 .mixers = { alc880_three_stack_mixer },
2297 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2298 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2299 .dac_nids = alc880_dac_nids,
2300 .dig_out_nid = ALC880_DIGOUT_NID,
2301 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2302 .channel_mode = alc880_threestack_modes,
2304 .input_mux = &alc880_capture_source,
2306 [ALC880_TCL_S700] = {
2307 .mixers = { alc880_tcl_s700_mixer },
2308 .init_verbs = { alc880_volume_init_verbs,
2309 alc880_pin_tcl_S700_init_verbs,
2310 alc880_gpio2_init_verbs },
2311 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2312 .dac_nids = alc880_dac_nids,
2314 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2315 .channel_mode = alc880_2_jack_modes,
2316 .input_mux = &alc880_capture_source,
2319 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2320 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2321 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2322 .dac_nids = alc880_dac_nids,
2323 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2324 .channel_mode = alc880_fivestack_modes,
2325 .input_mux = &alc880_capture_source,
2327 [ALC880_5ST_DIG] = {
2328 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2329 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2330 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2331 .dac_nids = alc880_dac_nids,
2332 .dig_out_nid = ALC880_DIGOUT_NID,
2333 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2334 .channel_mode = alc880_fivestack_modes,
2335 .input_mux = &alc880_capture_source,
2338 .mixers = { alc880_six_stack_mixer },
2339 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2340 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2341 .dac_nids = alc880_6st_dac_nids,
2342 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2343 .channel_mode = alc880_sixstack_modes,
2344 .input_mux = &alc880_6stack_capture_source,
2346 [ALC880_6ST_DIG] = {
2347 .mixers = { alc880_six_stack_mixer },
2348 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2349 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2350 .dac_nids = alc880_6st_dac_nids,
2351 .dig_out_nid = ALC880_DIGOUT_NID,
2352 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2353 .channel_mode = alc880_sixstack_modes,
2354 .input_mux = &alc880_6stack_capture_source,
2357 .mixers = { alc880_w810_base_mixer },
2358 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2359 alc880_gpio2_init_verbs },
2360 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2361 .dac_nids = alc880_w810_dac_nids,
2362 .dig_out_nid = ALC880_DIGOUT_NID,
2363 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2364 .channel_mode = alc880_w810_modes,
2365 .input_mux = &alc880_capture_source,
2368 .mixers = { alc880_z71v_mixer },
2369 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2370 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2371 .dac_nids = alc880_z71v_dac_nids,
2372 .dig_out_nid = ALC880_DIGOUT_NID,
2374 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2375 .channel_mode = alc880_2_jack_modes,
2376 .input_mux = &alc880_capture_source,
2379 .mixers = { alc880_f1734_mixer },
2380 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2381 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2382 .dac_nids = alc880_f1734_dac_nids,
2384 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2385 .channel_mode = alc880_2_jack_modes,
2386 .input_mux = &alc880_capture_source,
2389 .mixers = { alc880_asus_mixer },
2390 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2391 alc880_gpio1_init_verbs },
2392 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2393 .dac_nids = alc880_asus_dac_nids,
2394 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2395 .channel_mode = alc880_asus_modes,
2397 .input_mux = &alc880_capture_source,
2399 [ALC880_ASUS_DIG] = {
2400 .mixers = { alc880_asus_mixer },
2401 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2402 alc880_gpio1_init_verbs },
2403 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2404 .dac_nids = alc880_asus_dac_nids,
2405 .dig_out_nid = ALC880_DIGOUT_NID,
2406 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2407 .channel_mode = alc880_asus_modes,
2409 .input_mux = &alc880_capture_source,
2411 [ALC880_ASUS_DIG2] = {
2412 .mixers = { alc880_asus_mixer },
2413 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2414 alc880_gpio2_init_verbs }, /* use GPIO2 */
2415 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2416 .dac_nids = alc880_asus_dac_nids,
2417 .dig_out_nid = ALC880_DIGOUT_NID,
2418 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2419 .channel_mode = alc880_asus_modes,
2421 .input_mux = &alc880_capture_source,
2423 [ALC880_ASUS_W1V] = {
2424 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2425 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2426 alc880_gpio1_init_verbs },
2427 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2428 .dac_nids = alc880_asus_dac_nids,
2429 .dig_out_nid = ALC880_DIGOUT_NID,
2430 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2431 .channel_mode = alc880_asus_modes,
2433 .input_mux = &alc880_capture_source,
2435 [ALC880_UNIWILL_DIG] = {
2436 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2437 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2438 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2439 .dac_nids = alc880_asus_dac_nids,
2440 .dig_out_nid = ALC880_DIGOUT_NID,
2441 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2442 .channel_mode = alc880_asus_modes,
2444 .input_mux = &alc880_capture_source,
2447 .mixers = { alc880_three_stack_mixer },
2448 .init_verbs = { alc880_volume_init_verbs,
2449 alc880_pin_clevo_init_verbs },
2450 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2451 .dac_nids = alc880_dac_nids,
2453 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2454 .channel_mode = alc880_threestack_modes,
2456 .input_mux = &alc880_capture_source,
2459 .mixers = { alc880_lg_mixer },
2460 .init_verbs = { alc880_volume_init_verbs,
2461 alc880_lg_init_verbs },
2462 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2463 .dac_nids = alc880_lg_dac_nids,
2464 .dig_out_nid = ALC880_DIGOUT_NID,
2465 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2466 .channel_mode = alc880_lg_ch_modes,
2468 .input_mux = &alc880_lg_capture_source,
2469 .unsol_event = alc880_lg_unsol_event,
2470 .init_hook = alc880_lg_automute,
2473 .mixers = { alc880_lg_lw_mixer },
2474 .init_verbs = { alc880_volume_init_verbs,
2475 alc880_lg_lw_init_verbs },
2477 .dac_nids = alc880_dac_nids,
2478 .dig_out_nid = ALC880_DIGOUT_NID,
2479 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2480 .channel_mode = alc880_2_jack_modes,
2481 .input_mux = &alc880_lg_lw_capture_source,
2482 .unsol_event = alc880_lg_lw_unsol_event,
2483 .init_hook = alc880_lg_lw_automute,
2485 #ifdef CONFIG_SND_DEBUG
2487 .mixers = { alc880_test_mixer },
2488 .init_verbs = { alc880_test_init_verbs },
2489 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2490 .dac_nids = alc880_test_dac_nids,
2491 .dig_out_nid = ALC880_DIGOUT_NID,
2492 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2493 .channel_mode = alc880_test_modes,
2494 .input_mux = &alc880_test_capture_source,
2500 * Automatic parse of I/O pins from the BIOS configuration
2503 #define NUM_CONTROL_ALLOC 32
2504 #define NUM_VERB_ALLOC 32
2508 ALC_CTL_WIDGET_MUTE,
2511 static struct snd_kcontrol_new alc880_control_templates[] = {
2512 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2513 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2514 HDA_BIND_MUTE(NULL, 0, 0, 0),
2517 /* add dynamic controls */
2518 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2520 struct snd_kcontrol_new *knew;
2522 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2523 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2525 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2528 if (spec->kctl_alloc) {
2529 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2530 kfree(spec->kctl_alloc);
2532 spec->kctl_alloc = knew;
2533 spec->num_kctl_alloc = num;
2536 knew = &spec->kctl_alloc[spec->num_kctl_used];
2537 *knew = alc880_control_templates[type];
2538 knew->name = kstrdup(name, GFP_KERNEL);
2541 knew->private_value = val;
2542 spec->num_kctl_used++;
2546 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2547 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2548 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2549 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2550 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2551 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2552 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2553 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2554 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2555 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2556 #define ALC880_PIN_CD_NID 0x1c
2558 /* fill in the dac_nids table from the parsed pin configuration */
2559 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2565 memset(assigned, 0, sizeof(assigned));
2566 spec->multiout.dac_nids = spec->private_dac_nids;
2568 /* check the pins hardwired to audio widget */
2569 for (i = 0; i < cfg->line_outs; i++) {
2570 nid = cfg->line_out_pins[i];
2571 if (alc880_is_fixed_pin(nid)) {
2572 int idx = alc880_fixed_pin_idx(nid);
2573 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2577 /* left pins can be connect to any audio widget */
2578 for (i = 0; i < cfg->line_outs; i++) {
2579 nid = cfg->line_out_pins[i];
2580 if (alc880_is_fixed_pin(nid))
2582 /* search for an empty channel */
2583 for (j = 0; j < cfg->line_outs; j++) {
2584 if (! assigned[j]) {
2585 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2591 spec->multiout.num_dacs = cfg->line_outs;
2595 /* add playback controls from the parsed DAC table */
2596 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2597 const struct auto_pin_cfg *cfg)
2600 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2604 for (i = 0; i < cfg->line_outs; i++) {
2605 if (! spec->multiout.dac_nids[i])
2607 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2610 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2611 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2613 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2614 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2616 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2617 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2619 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2620 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2623 sprintf(name, "%s Playback Volume", chname[i]);
2624 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2625 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2627 sprintf(name, "%s Playback Switch", chname[i]);
2628 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2629 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2636 /* add playback controls for speaker and HP outputs */
2637 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2647 if (alc880_is_fixed_pin(pin)) {
2648 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2649 /* specify the DAC as the extra output */
2650 if (! spec->multiout.hp_nid)
2651 spec->multiout.hp_nid = nid;
2653 spec->multiout.extra_out_nid[0] = nid;
2654 /* control HP volume/switch on the output mixer amp */
2655 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2656 sprintf(name, "%s Playback Volume", pfx);
2657 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2658 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2660 sprintf(name, "%s Playback Switch", pfx);
2661 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2662 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2664 } else if (alc880_is_multi_pin(pin)) {
2665 /* set manual connection */
2666 /* we have only a switch on HP-out PIN */
2667 sprintf(name, "%s Playback Switch", pfx);
2668 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2669 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2675 /* create input playback/capture controls for the given pin */
2676 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2677 int idx, hda_nid_t mix_nid)
2682 sprintf(name, "%s Playback Volume", ctlname);
2683 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2684 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2686 sprintf(name, "%s Playback Switch", ctlname);
2687 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2688 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2693 /* create playback/capture controls for input pins */
2694 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2695 const struct auto_pin_cfg *cfg)
2697 struct hda_input_mux *imux = &spec->private_imux;
2700 for (i = 0; i < AUTO_PIN_LAST; i++) {
2701 if (alc880_is_input_pin(cfg->input_pins[i])) {
2702 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2703 err = new_analog_input(spec, cfg->input_pins[i],
2704 auto_pin_cfg_labels[i],
2708 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2709 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2716 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2717 hda_nid_t nid, int pin_type,
2721 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2722 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2723 /* need the manual connection? */
2724 if (alc880_is_multi_pin(nid)) {
2725 struct alc_spec *spec = codec->spec;
2726 int idx = alc880_multi_pin_idx(nid);
2727 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2728 AC_VERB_SET_CONNECT_SEL,
2729 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2733 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2735 struct alc_spec *spec = codec->spec;
2738 for (i = 0; i < spec->autocfg.line_outs; i++) {
2739 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2740 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2744 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2746 struct alc_spec *spec = codec->spec;
2749 pin = spec->autocfg.speaker_pins[0];
2750 if (pin) /* connect to front */
2751 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2752 pin = spec->autocfg.hp_pin;
2753 if (pin) /* connect to front */
2754 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2757 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2759 struct alc_spec *spec = codec->spec;
2762 for (i = 0; i < AUTO_PIN_LAST; i++) {
2763 hda_nid_t nid = spec->autocfg.input_pins[i];
2764 if (alc880_is_input_pin(nid)) {
2765 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2766 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2767 if (nid != ALC880_PIN_CD_NID)
2768 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2774 /* parse the BIOS configuration and set up the alc_spec */
2775 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2776 static int alc880_parse_auto_config(struct hda_codec *codec)
2778 struct alc_spec *spec = codec->spec;
2780 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2782 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2783 alc880_ignore)) < 0)
2785 if (! spec->autocfg.line_outs)
2786 return 0; /* can't find valid BIOS pin config */
2788 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2789 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2790 (err = alc880_auto_create_extra_out(spec,
2791 spec->autocfg.speaker_pins[0],
2793 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2794 "Headphone")) < 0 ||
2795 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2798 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2800 if (spec->autocfg.dig_out_pin)
2801 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2802 if (spec->autocfg.dig_in_pin)
2803 spec->dig_in_nid = ALC880_DIGIN_NID;
2805 if (spec->kctl_alloc)
2806 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2808 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2810 spec->num_mux_defs = 1;
2811 spec->input_mux = &spec->private_imux;
2816 /* additional initialization for auto-configuration model */
2817 static void alc880_auto_init(struct hda_codec *codec)
2819 alc880_auto_init_multi_out(codec);
2820 alc880_auto_init_extra_out(codec);
2821 alc880_auto_init_analog_input(codec);
2825 * OK, here we have finally the patch for ALC880
2828 static int patch_alc880(struct hda_codec *codec)
2830 struct alc_spec *spec;
2834 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2840 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2841 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2842 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2843 "trying auto-probe from BIOS...\n");
2844 board_config = ALC880_AUTO;
2847 if (board_config == ALC880_AUTO) {
2848 /* automatic parse from the BIOS config */
2849 err = alc880_parse_auto_config(codec);
2855 "hda_codec: Cannot set up configuration "
2856 "from BIOS. Using 3-stack mode...\n");
2857 board_config = ALC880_3ST;
2861 if (board_config != ALC880_AUTO)
2862 setup_preset(spec, &alc880_presets[board_config]);
2864 spec->stream_name_analog = "ALC880 Analog";
2865 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2866 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2868 spec->stream_name_digital = "ALC880 Digital";
2869 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2870 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2872 if (! spec->adc_nids && spec->input_mux) {
2873 /* check whether NID 0x07 is valid */
2874 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2875 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2876 if (wcap != AC_WID_AUD_IN) {
2877 spec->adc_nids = alc880_adc_nids_alt;
2878 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2879 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2882 spec->adc_nids = alc880_adc_nids;
2883 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2884 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2889 codec->patch_ops = alc_patch_ops;
2890 if (board_config == ALC880_AUTO)
2891 spec->init_hook = alc880_auto_init;
2901 static hda_nid_t alc260_dac_nids[1] = {
2906 static hda_nid_t alc260_adc_nids[1] = {
2911 static hda_nid_t alc260_adc_nids_alt[1] = {
2916 static hda_nid_t alc260_hp_adc_nids[2] = {
2921 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2922 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2924 static hda_nid_t alc260_dual_adc_nids[2] = {
2929 #define ALC260_DIGOUT_NID 0x03
2930 #define ALC260_DIGIN_NID 0x06
2932 static struct hda_input_mux alc260_capture_source = {
2936 { "Front Mic", 0x1 },
2942 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2943 * headphone jack and the internal CD lines since these are the only pins at
2944 * which audio can appear. For flexibility, also allow the option of
2945 * recording the mixer output on the second ADC (ADC0 doesn't have a
2946 * connection to the mixer output).
2948 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2952 { "Mic/Line", 0x0 },
2954 { "Headphone", 0x2 },
2960 { "Mic/Line", 0x0 },
2962 { "Headphone", 0x2 },
2969 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2970 * the Fujitsu S702x, but jacks are marked differently.
2972 static struct hda_input_mux alc260_acer_capture_sources[2] = {
2979 { "Headphone", 0x5 },
2988 { "Headphone", 0x6 },
2994 * This is just place-holder, so there's something for alc_build_pcms to look
2995 * at when it calculates the maximum number of channels. ALC260 has no mixer
2996 * element which allows changing the channel mode, so the verb list is
2999 static struct hda_channel_mode alc260_modes[1] = {
3004 /* Mixer combinations
3006 * basic: base_output + input + pc_beep + capture
3007 * HP: base_output + input + capture_alt
3008 * HP_3013: hp_3013 + input + capture
3009 * fujitsu: fujitsu + capture
3010 * acer: acer + capture
3013 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3014 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3016 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3017 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3018 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3019 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3023 static struct snd_kcontrol_new alc260_input_mixer[] = {
3024 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3025 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3026 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3027 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3029 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3030 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3031 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3035 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3036 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3037 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3041 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3042 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3043 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3045 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3046 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3047 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3048 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3049 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3053 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3054 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3056 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3057 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3058 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3059 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3060 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3061 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3062 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3063 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3064 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3065 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3066 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3067 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3068 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3072 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3073 * versions of the ALC260 don't act on requests to enable mic bias from NID
3074 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3075 * datasheet doesn't mention this restriction. At this stage it's not clear
3076 * whether this behaviour is intentional or is a hardware bug in chip
3077 * revisions available in early 2006. Therefore for now allow the
3078 * "Headphone Jack Mode" control to span all choices, but if it turns out
3079 * that the lack of mic bias for this NID is intentional we could change the
3080 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3082 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3083 * don't appear to make the mic bias available from the "line" jack, even
3084 * though the NID used for this jack (0x14) can supply it. The theory is
3085 * that perhaps Acer have included blocking capacitors between the ALC260
3086 * and the output jack. If this turns out to be the case for all such
3087 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3088 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3090 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3091 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3092 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3093 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3094 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3095 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3097 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3098 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3099 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3100 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3101 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3102 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3103 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3107 /* capture mixer elements */
3108 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3109 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3110 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3111 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3112 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3115 /* The multiple "Capture Source" controls confuse alsamixer
3116 * So call somewhat different..
3117 * FIXME: the controls appear in the "playback" view!
3119 /* .name = "Capture Source", */
3120 .name = "Input Source",
3122 .info = alc_mux_enum_info,
3123 .get = alc_mux_enum_get,
3124 .put = alc_mux_enum_put,
3129 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3130 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3131 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3134 /* The multiple "Capture Source" controls confuse alsamixer
3135 * So call somewhat different..
3136 * FIXME: the controls appear in the "playback" view!
3138 /* .name = "Capture Source", */
3139 .name = "Input Source",
3141 .info = alc_mux_enum_info,
3142 .get = alc_mux_enum_get,
3143 .put = alc_mux_enum_put,
3149 * initialization verbs
3151 static struct hda_verb alc260_init_verbs[] = {
3152 /* Line In pin widget for input */
3153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3154 /* CD pin widget for input */
3155 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3156 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3157 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3158 /* Mic2 (front panel) pin widget for input and vref at 80% */
3159 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3160 /* LINE-2 is used for line-out in rear */
3161 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3162 /* select line-out */
3163 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3165 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3167 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3169 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3170 /* mute capture amp left and right */
3171 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3172 /* set connection select to line in (default select for this ADC) */
3173 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3174 /* mute capture amp left and right */
3175 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3176 /* set connection select to line in (default select for this ADC) */
3177 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3178 /* set vol=0 Line-Out mixer amp left and right */
3179 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3180 /* unmute pin widget amp left and right (no gain on this amp) */
3181 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3182 /* set vol=0 HP mixer amp left and right */
3183 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3184 /* unmute pin widget amp left and right (no gain on this amp) */
3185 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186 /* set vol=0 Mono mixer amp left and right */
3187 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3188 /* unmute pin widget amp left and right (no gain on this amp) */
3189 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190 /* unmute LINE-2 out pin */
3191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3192 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3199 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3200 /* mute Front out path */
3201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3203 /* mute Headphone out path */
3204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3206 /* mute Mono out path */
3207 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3208 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3212 #if 0 /* should be identical with alc260_init_verbs? */
3213 static struct hda_verb alc260_hp_init_verbs[] = {
3214 /* Headphone and output */
3215 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3217 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3218 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3219 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3220 /* Mic2 (front panel) pin widget for input and vref at 80% */
3221 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3222 /* Line In pin widget for input */
3223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3224 /* Line-2 pin widget for output */
3225 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3226 /* CD pin widget for input */
3227 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3228 /* unmute amp left and right */
3229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3230 /* set connection select to line in (default select for this ADC) */
3231 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3232 /* unmute Line-Out mixer amp left and right (volume = 0) */
3233 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3234 /* mute pin widget amp left and right (no gain on this amp) */
3235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3236 /* unmute HP mixer amp left and right (volume = 0) */
3237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3238 /* mute pin widget amp left and right (no gain on this amp) */
3239 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3240 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3243 /* unmute Line In */
3244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3247 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3248 /* Unmute Front out path */
3249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3250 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3251 /* Unmute Headphone out path */
3252 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3253 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3254 /* Unmute Mono out path */
3255 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3256 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3261 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3262 /* Line out and output */
3263 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3265 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3266 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3267 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3268 /* Mic2 (front panel) pin widget for input and vref at 80% */
3269 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3270 /* Line In pin widget for input */
3271 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3272 /* Headphone pin widget for output */
3273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3274 /* CD pin widget for input */
3275 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3276 /* unmute amp left and right */
3277 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3278 /* set connection select to line in (default select for this ADC) */
3279 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3280 /* unmute Line-Out mixer amp left and right (volume = 0) */
3281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3282 /* mute pin widget amp left and right (no gain on this amp) */
3283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3284 /* unmute HP mixer amp left and right (volume = 0) */
3285 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3286 /* mute pin widget amp left and right (no gain on this amp) */
3287 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3288 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3291 /* unmute Line In */
3292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3296 /* Unmute Front out path */
3297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3298 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3299 /* Unmute Headphone out path */
3300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3302 /* Unmute Mono out path */
3303 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3304 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3308 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3309 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3310 * audio = 0x16, internal speaker = 0x10.
3312 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3313 /* Disable all GPIOs */
3314 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3315 /* Internal speaker is connected to headphone pin */
3316 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3317 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3318 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3319 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3320 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3321 /* Ensure all other unused pins are disabled and muted. */
3322 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3323 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3324 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3325 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3326 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3327 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3328 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3331 /* Disable digital (SPDIF) pins */
3332 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3333 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3335 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3336 * when acting as an output.
3338 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3340 /* Start with output sum widgets muted and their output gains at min */
3341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3342 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3344 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3345 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3346 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3347 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3348 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3349 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3351 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3352 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3353 /* Unmute Line1 pin widget output buffer since it starts as an output.
3354 * If the pin mode is changed by the user the pin mode control will
3355 * take care of enabling the pin's input/output buffers as needed.
3356 * Therefore there's no need to enable the input buffer at this
3359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3360 /* Unmute input buffer of pin widget used for Line-in (no equiv
3363 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3365 /* Mute capture amp left and right */
3366 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3367 /* Set ADC connection select to match default mixer setting - line
3370 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3372 /* Do the same for the second ADC: mute capture input amp and
3373 * set ADC connection to line in (on mic1 pin)
3375 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3376 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3378 /* Mute all inputs to mixer widget (even unconnected ones) */
3379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3391 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3392 * similar laptops (adapted from Fujitsu init verbs).
3394 static struct hda_verb alc260_acer_init_verbs[] = {
3395 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3396 * the headphone jack. Turn this on and rely on the standard mute
3397 * methods whenever the user wants to turn these outputs off.
3399 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3400 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3401 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3402 /* Internal speaker/Headphone jack is connected to Line-out pin */
3403 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3404 /* Internal microphone/Mic jack is connected to Mic1 pin */
3405 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3406 /* Line In jack is connected to Line1 pin */
3407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3408 /* Ensure all other unused pins are disabled and muted. */
3409 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3410 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3411 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3412 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3413 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3414 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3416 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3417 /* Disable digital (SPDIF) pins */
3418 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3419 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3421 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3422 * bus when acting as outputs.
3424 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3425 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3427 /* Start with output sum widgets muted and their output gains at min */
3428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3429 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3431 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3432 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3434 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3435 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3436 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3438 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3439 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3440 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3441 * inputs. If the pin mode is changed by the user the pin mode control
3442 * will take care of enabling the pin's input/output buffers as needed.
3443 * Therefore there's no need to enable the input buffer at this
3446 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3447 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3449 /* Mute capture amp left and right */
3450 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3451 /* Set ADC connection select to match default mixer setting - mic
3454 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3456 /* Do similar with the second ADC: mute capture input amp and
3457 * set ADC connection to mic to match ALSA's default state.
3459 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3460 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3462 /* Mute all inputs to mixer widget (even unconnected ones) */
3463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3469 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3470 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3475 /* Test configuration for debugging, modelled after the ALC880 test
3478 #ifdef CONFIG_SND_DEBUG
3479 static hda_nid_t alc260_test_dac_nids[1] = {
3482 static hda_nid_t alc260_test_adc_nids[2] = {
3485 /* For testing the ALC260, each input MUX needs its own definition since
3486 * the signal assignments are different. This assumes that the first ADC
3489 static struct hda_input_mux alc260_test_capture_sources[2] = {
3493 { "MIC1 pin", 0x0 },
3494 { "MIC2 pin", 0x1 },
3495 { "LINE1 pin", 0x2 },
3496 { "LINE2 pin", 0x3 },
3498 { "LINE-OUT pin", 0x5 },
3499 { "HP-OUT pin", 0x6 },
3505 { "MIC1 pin", 0x0 },
3506 { "MIC2 pin", 0x1 },
3507 { "LINE1 pin", 0x2 },
3508 { "LINE2 pin", 0x3 },
3511 { "LINE-OUT pin", 0x6 },
3512 { "HP-OUT pin", 0x7 },
3516 static struct snd_kcontrol_new alc260_test_mixer[] = {
3517 /* Output driver widgets */
3518 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3519 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3520 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3521 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3522 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3523 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3525 /* Modes for retasking pin widgets
3526 * Note: the ALC260 doesn't seem to act on requests to enable mic
3527 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3528 * mention this restriction. At this stage it's not clear whether
3529 * this behaviour is intentional or is a hardware bug in chip
3530 * revisions available at least up until early 2006. Therefore for
3531 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3532 * choices, but if it turns out that the lack of mic bias for these
3533 * NIDs is intentional we could change their modes from
3534 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3536 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3537 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3538 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3539 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3540 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3541 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3543 /* Loopback mixer controls */
3544 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3545 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3546 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3547 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3548 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3549 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3550 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3551 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3552 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3553 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3554 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3555 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3556 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3557 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3558 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3559 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3561 /* Controls for GPIO pins, assuming they are configured as outputs */
3562 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3563 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3564 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3565 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3567 /* Switches to allow the digital IO pins to be enabled. The datasheet
3568 * is ambigious as to which NID is which; testing on laptops which
3569 * make this output available should provide clarification.
3571 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3572 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3576 static struct hda_verb alc260_test_init_verbs[] = {
3577 /* Enable all GPIOs as outputs with an initial value of 0 */
3578 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3579 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3580 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3582 /* Enable retasking pins as output, initially without power amp */
3583 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3584 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3587 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3588 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3590 /* Disable digital (SPDIF) pins initially, but users can enable
3591 * them via a mixer switch. In the case of SPDIF-out, this initverb
3592 * payload also sets the generation to 0, output to be in "consumer"
3593 * PCM format, copyright asserted, no pre-emphasis and no validity
3596 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3597 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3599 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3600 * OUT1 sum bus when acting as an output.
3602 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3603 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3604 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3605 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3607 /* Start with output sum widgets muted and their output gains at min */
3608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3611 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3614 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3615 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3616 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3618 /* Unmute retasking pin widget output buffers since the default
3619 * state appears to be output. As the pin mode is changed by the
3620 * user the pin mode control will take care of enabling the pin's
3621 * input/output buffers as needed.
3623 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3624 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3627 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3628 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3629 /* Also unmute the mono-out pin widget */
3630 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3632 /* Mute capture amp left and right */
3633 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3634 /* Set ADC connection select to match default mixer setting (mic1
3637 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3639 /* Do the same for the second ADC: mute capture input amp and
3640 * set ADC connection to mic1 pin
3642 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3643 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3645 /* Mute all inputs to mixer widget (even unconnected ones) */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3659 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3665 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3671 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3672 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3675 * for BIOS auto-configuration
3678 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3682 unsigned long vol_val, sw_val;
3686 if (nid >= 0x0f && nid < 0x11) {
3687 nid_vol = nid - 0x7;
3688 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3689 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3690 } else if (nid == 0x11) {
3691 nid_vol = nid - 0x7;
3692 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3693 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3694 } else if (nid >= 0x12 && nid <= 0x15) {
3696 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3697 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3701 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3702 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3704 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3705 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3710 /* add playback controls from the parsed DAC table */
3711 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3712 const struct auto_pin_cfg *cfg)
3717 spec->multiout.num_dacs = 1;
3718 spec->multiout.dac_nids = spec->private_dac_nids;
3719 spec->multiout.dac_nids[0] = 0x02;
3721 nid = cfg->line_out_pins[0];
3723 err = alc260_add_playback_controls(spec, nid, "Front");
3728 nid = cfg->speaker_pins[0];
3730 err = alc260_add_playback_controls(spec, nid, "Speaker");
3737 err = alc260_add_playback_controls(spec, nid, "Headphone");
3744 /* create playback/capture controls for input pins */
3745 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3746 const struct auto_pin_cfg *cfg)
3748 struct hda_input_mux *imux = &spec->private_imux;
3751 for (i = 0; i < AUTO_PIN_LAST; i++) {
3752 if (cfg->input_pins[i] >= 0x12) {
3753 idx = cfg->input_pins[i] - 0x12;
3754 err = new_analog_input(spec, cfg->input_pins[i],
3755 auto_pin_cfg_labels[i], idx, 0x07);
3758 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3759 imux->items[imux->num_items].index = idx;
3762 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3763 idx = cfg->input_pins[i] - 0x09;
3764 err = new_analog_input(spec, cfg->input_pins[i],
3765 auto_pin_cfg_labels[i], idx, 0x07);
3768 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3769 imux->items[imux->num_items].index = idx;
3776 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3777 hda_nid_t nid, int pin_type,
3781 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3783 /* need the manual connection? */
3785 int idx = nid - 0x12;
3786 snd_hda_codec_write(codec, idx + 0x0b, 0,
3787 AC_VERB_SET_CONNECT_SEL, sel_idx);
3792 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3794 struct alc_spec *spec = codec->spec;
3797 nid = spec->autocfg.line_out_pins[0];
3799 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3801 nid = spec->autocfg.speaker_pins[0];
3803 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3805 nid = spec->autocfg.hp_pin;
3807 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3810 #define ALC260_PIN_CD_NID 0x16
3811 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3813 struct alc_spec *spec = codec->spec;
3816 for (i = 0; i < AUTO_PIN_LAST; i++) {
3817 hda_nid_t nid = spec->autocfg.input_pins[i];
3819 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3820 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3821 if (nid != ALC260_PIN_CD_NID)
3822 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3829 * generic initialization of ADC, input mixers and output mixers
3831 static struct hda_verb alc260_volume_init_verbs[] = {
3833 * Unmute ADC0-1 and set the default input to mic-in
3835 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3836 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3838 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3840 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3842 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3845 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3853 * Set up output mixers (0x08 - 0x0a)
3855 /* set vol=0 to output mixers */
3856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3858 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3859 /* set up input amps for analog loopback */
3860 /* Amp Indices: DAC = 0, mixer = 1 */
3861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3862 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3864 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3865 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3866 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3871 static int alc260_parse_auto_config(struct hda_codec *codec)
3873 struct alc_spec *spec = codec->spec;
3876 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3878 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3879 alc260_ignore)) < 0)
3881 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3883 if (! spec->kctl_alloc)
3884 return 0; /* can't find valid BIOS pin config */
3885 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3888 spec->multiout.max_channels = 2;
3890 if (spec->autocfg.dig_out_pin)
3891 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3892 if (spec->kctl_alloc)
3893 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3895 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3897 spec->num_mux_defs = 1;
3898 spec->input_mux = &spec->private_imux;
3900 /* check whether NID 0x04 is valid */
3901 wcap = get_wcaps(codec, 0x04);
3902 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3903 if (wcap != AC_WID_AUD_IN) {
3904 spec->adc_nids = alc260_adc_nids_alt;
3905 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3906 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3908 spec->adc_nids = alc260_adc_nids;
3909 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3910 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3917 /* additional initialization for auto-configuration model */
3918 static void alc260_auto_init(struct hda_codec *codec)
3920 alc260_auto_init_multi_out(codec);
3921 alc260_auto_init_analog_input(codec);
3925 * ALC260 configurations
3927 static struct hda_board_config alc260_cfg_tbl[] = {
3928 { .modelname = "basic", .config = ALC260_BASIC },
3929 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3930 .config = ALC260_BASIC }, /* Sony VAIO */
3931 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3932 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
3933 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3934 .config = ALC260_BASIC }, /* Sony VAIO */
3935 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3936 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
3937 { .modelname = "hp", .config = ALC260_HP },
3938 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
3939 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
3940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3941 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
3942 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3943 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3944 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3945 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3946 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3947 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3948 { .modelname = "acer", .config = ALC260_ACER },
3949 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
3950 #ifdef CONFIG_SND_DEBUG
3951 { .modelname = "test", .config = ALC260_TEST },
3953 { .modelname = "auto", .config = ALC260_AUTO },
3957 static struct alc_config_preset alc260_presets[] = {
3959 .mixers = { alc260_base_output_mixer,
3961 alc260_pc_beep_mixer,
3962 alc260_capture_mixer },
3963 .init_verbs = { alc260_init_verbs },
3964 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3965 .dac_nids = alc260_dac_nids,
3966 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3967 .adc_nids = alc260_adc_nids,
3968 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3969 .channel_mode = alc260_modes,
3970 .input_mux = &alc260_capture_source,
3973 .mixers = { alc260_base_output_mixer,
3975 alc260_capture_alt_mixer },
3976 .init_verbs = { alc260_init_verbs },
3977 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3978 .dac_nids = alc260_dac_nids,
3979 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3980 .adc_nids = alc260_hp_adc_nids,
3981 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3982 .channel_mode = alc260_modes,
3983 .input_mux = &alc260_capture_source,
3985 [ALC260_HP_3013] = {
3986 .mixers = { alc260_hp_3013_mixer,
3988 alc260_capture_alt_mixer },
3989 .init_verbs = { alc260_hp_3013_init_verbs },
3990 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3991 .dac_nids = alc260_dac_nids,
3992 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3993 .adc_nids = alc260_hp_adc_nids,
3994 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3995 .channel_mode = alc260_modes,
3996 .input_mux = &alc260_capture_source,
3998 [ALC260_FUJITSU_S702X] = {
3999 .mixers = { alc260_fujitsu_mixer,
4000 alc260_capture_mixer },
4001 .init_verbs = { alc260_fujitsu_init_verbs },
4002 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4003 .dac_nids = alc260_dac_nids,
4004 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4005 .adc_nids = alc260_dual_adc_nids,
4006 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4007 .channel_mode = alc260_modes,
4008 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4009 .input_mux = alc260_fujitsu_capture_sources,
4012 .mixers = { alc260_acer_mixer,
4013 alc260_capture_mixer },
4014 .init_verbs = { alc260_acer_init_verbs },
4015 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4016 .dac_nids = alc260_dac_nids,
4017 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4018 .adc_nids = alc260_dual_adc_nids,
4019 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4020 .channel_mode = alc260_modes,
4021 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4022 .input_mux = alc260_acer_capture_sources,
4024 #ifdef CONFIG_SND_DEBUG
4026 .mixers = { alc260_test_mixer,
4027 alc260_capture_mixer },
4028 .init_verbs = { alc260_test_init_verbs },
4029 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4030 .dac_nids = alc260_test_dac_nids,
4031 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4032 .adc_nids = alc260_test_adc_nids,
4033 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4034 .channel_mode = alc260_modes,
4035 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4036 .input_mux = alc260_test_capture_sources,
4041 static int patch_alc260(struct hda_codec *codec)
4043 struct alc_spec *spec;
4044 int err, board_config;
4046 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4052 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4053 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
4054 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4055 "trying auto-probe from BIOS...\n");
4056 board_config = ALC260_AUTO;
4059 if (board_config == ALC260_AUTO) {
4060 /* automatic parse from the BIOS config */
4061 err = alc260_parse_auto_config(codec);
4067 "hda_codec: Cannot set up configuration "
4068 "from BIOS. Using base mode...\n");
4069 board_config = ALC260_BASIC;
4073 if (board_config != ALC260_AUTO)
4074 setup_preset(spec, &alc260_presets[board_config]);
4076 spec->stream_name_analog = "ALC260 Analog";
4077 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4078 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4080 spec->stream_name_digital = "ALC260 Digital";
4081 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4082 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4084 codec->patch_ops = alc_patch_ops;
4085 if (board_config == ALC260_AUTO)
4086 spec->init_hook = alc260_auto_init;
4095 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4096 * configuration. Each pin widget can choose any input DACs and a mixer.
4097 * Each ADC is connected from a mixer of all inputs. This makes possible
4098 * 6-channel independent captures.
4100 * In addition, an independent DAC for the multi-playback (not used in this
4103 #define ALC882_DIGOUT_NID 0x06
4104 #define ALC882_DIGIN_NID 0x0a
4106 static struct hda_channel_mode alc882_ch_modes[1] = {
4110 static hda_nid_t alc882_dac_nids[4] = {
4111 /* front, rear, clfe, rear_surr */
4112 0x02, 0x03, 0x04, 0x05
4115 /* identical with ALC880 */
4116 #define alc882_adc_nids alc880_adc_nids
4117 #define alc882_adc_nids_alt alc880_adc_nids_alt
4120 /* FIXME: should be a matrix-type input source selection */
4122 static struct hda_input_mux alc882_capture_source = {
4126 { "Front Mic", 0x1 },
4131 #define alc882_mux_enum_info alc_mux_enum_info
4132 #define alc882_mux_enum_get alc_mux_enum_get
4134 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4136 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4137 struct alc_spec *spec = codec->spec;
4138 const struct hda_input_mux *imux = spec->input_mux;
4139 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4140 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4141 hda_nid_t nid = capture_mixers[adc_idx];
4142 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4143 unsigned int i, idx;
4145 idx = ucontrol->value.enumerated.item[0];
4146 if (idx >= imux->num_items)
4147 idx = imux->num_items - 1;
4148 if (*cur_val == idx && ! codec->in_resume)
4150 for (i = 0; i < imux->num_items; i++) {
4151 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4152 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4153 v | (imux->items[i].index << 8));
4162 static struct hda_verb alc882_sixstack_ch6_init[] = {
4163 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4164 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4165 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4166 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4173 static struct hda_verb alc882_sixstack_ch8_init[] = {
4174 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4175 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4176 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4177 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4181 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4182 { 6, alc882_sixstack_ch6_init },
4183 { 8, alc882_sixstack_ch8_init },
4186 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4187 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4189 static struct snd_kcontrol_new alc882_base_mixer[] = {
4190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4191 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4192 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4193 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4194 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4195 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4196 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4197 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4198 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4199 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4200 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4207 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4209 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4210 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4214 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4217 .name = "Channel Mode",
4218 .info = alc_ch_mode_info,
4219 .get = alc_ch_mode_get,
4220 .put = alc_ch_mode_put,
4225 static struct hda_verb alc882_init_verbs[] = {
4226 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4239 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4243 /* Front Pin: output 0 (0x0c) */
4244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4245 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4247 /* Rear Pin: output 1 (0x0d) */
4248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4251 /* CLFE Pin: output 2 (0x0e) */
4252 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4253 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4254 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4255 /* Side Pin: output 3 (0x0f) */
4256 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4257 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4258 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4259 /* Mic (rear) pin: input vref at 80% */
4260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4262 /* Front Mic pin: input vref at 80% */
4263 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4265 /* Line In pin: input */
4266 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4268 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4271 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4272 /* CD pin widget for input */
4273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4275 /* FIXME: use matrix-type input source selection */
4276 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4277 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4292 /* ADC1: mute amp left and right */
4293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4294 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4295 /* ADC2: mute amp left and right */
4296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4297 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4298 /* ADC3: mute amp left and right */
4299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4300 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4305 static struct hda_verb alc882_eapd_verbs[] = {
4306 /* change to EAPD mode */
4307 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4308 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4313 * generic initialization of ADC, input mixers and output mixers
4315 static struct hda_verb alc882_auto_init_verbs[] = {
4317 * Unmute ADC0-2 and set the default input to mic-in
4319 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4320 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4321 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4323 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4326 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4328 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4331 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4334 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4339 * Set up output mixers (0x0c - 0x0f)
4341 /* set vol=0 to output mixers */
4342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4345 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4346 /* set up input amps for analog loopback */
4347 /* Amp Indices: DAC = 0, mixer = 1 */
4348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4350 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4351 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4352 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4353 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4354 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4355 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4356 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4357 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4359 /* FIXME: use matrix-type input source selection */
4360 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4361 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4365 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4380 /* capture mixer elements */
4381 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4382 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4383 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4384 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4385 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4388 /* The multiple "Capture Source" controls confuse alsamixer
4389 * So call somewhat different..
4390 * FIXME: the controls appear in the "playback" view!
4392 /* .name = "Capture Source", */
4393 .name = "Input Source",
4395 .info = alc882_mux_enum_info,
4396 .get = alc882_mux_enum_get,
4397 .put = alc882_mux_enum_put,
4402 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4403 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4404 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4405 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4406 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4407 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4408 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4411 /* The multiple "Capture Source" controls confuse alsamixer
4412 * So call somewhat different..
4413 * FIXME: the controls appear in the "playback" view!
4415 /* .name = "Capture Source", */
4416 .name = "Input Source",
4418 .info = alc882_mux_enum_info,
4419 .get = alc882_mux_enum_get,
4420 .put = alc882_mux_enum_put,
4425 /* pcm configuration: identiacal with ALC880 */
4426 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4427 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4428 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4429 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4432 * configuration and preset
4434 static struct hda_board_config alc882_cfg_tbl[] = {
4435 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4436 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4437 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4438 .config = ALC882_6ST_DIG }, /* MSI */
4439 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4440 .config = ALC882_6ST_DIG }, /* Foxconn */
4441 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4442 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
4443 { .modelname = "arima", .config = ALC882_ARIMA },
4444 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4445 .config = ALC882_ARIMA }, /* Arima W820Di1 */
4446 { .modelname = "auto", .config = ALC882_AUTO },
4450 static struct alc_config_preset alc882_presets[] = {
4451 [ALC882_3ST_DIG] = {
4452 .mixers = { alc882_base_mixer },
4453 .init_verbs = { alc882_init_verbs },
4454 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4455 .dac_nids = alc882_dac_nids,
4456 .dig_out_nid = ALC882_DIGOUT_NID,
4457 .dig_in_nid = ALC882_DIGIN_NID,
4458 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4459 .channel_mode = alc882_ch_modes,
4461 .input_mux = &alc882_capture_source,
4463 [ALC882_6ST_DIG] = {
4464 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4465 .init_verbs = { alc882_init_verbs },
4466 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4467 .dac_nids = alc882_dac_nids,
4468 .dig_out_nid = ALC882_DIGOUT_NID,
4469 .dig_in_nid = ALC882_DIGIN_NID,
4470 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4471 .channel_mode = alc882_sixstack_modes,
4472 .input_mux = &alc882_capture_source,
4475 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4476 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4477 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4478 .dac_nids = alc882_dac_nids,
4479 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4480 .channel_mode = alc882_sixstack_modes,
4481 .input_mux = &alc882_capture_source,
4487 * BIOS auto configuration
4489 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4490 hda_nid_t nid, int pin_type,
4494 struct alc_spec *spec = codec->spec;
4497 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4500 idx = spec->multiout.dac_nids[dac_idx] - 2;
4502 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4503 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4504 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4508 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4510 struct alc_spec *spec = codec->spec;
4513 for (i = 0; i <= HDA_SIDE; i++) {
4514 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4516 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4520 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4522 struct alc_spec *spec = codec->spec;
4525 pin = spec->autocfg.hp_pin;
4526 if (pin) /* connect to front */
4527 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4530 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4531 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4533 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4535 struct alc_spec *spec = codec->spec;
4538 for (i = 0; i < AUTO_PIN_LAST; i++) {
4539 hda_nid_t nid = spec->autocfg.input_pins[i];
4540 if (alc882_is_input_pin(nid)) {
4541 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4542 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4543 if (nid != ALC882_PIN_CD_NID)
4544 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4550 /* almost identical with ALC880 parser... */
4551 static int alc882_parse_auto_config(struct hda_codec *codec)
4553 struct alc_spec *spec = codec->spec;
4554 int err = alc880_parse_auto_config(codec);
4559 /* hack - override the init verbs */
4560 spec->init_verbs[0] = alc882_auto_init_verbs;
4564 /* additional initialization for auto-configuration model */
4565 static void alc882_auto_init(struct hda_codec *codec)
4567 alc882_auto_init_multi_out(codec);
4568 alc882_auto_init_hp_out(codec);
4569 alc882_auto_init_analog_input(codec);
4572 static int patch_alc882(struct hda_codec *codec)
4574 struct alc_spec *spec;
4575 int err, board_config;
4577 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4583 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4585 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4586 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4587 "trying auto-probe from BIOS...\n");
4588 board_config = ALC882_AUTO;
4591 if (board_config == ALC882_AUTO) {
4592 /* automatic parse from the BIOS config */
4593 err = alc882_parse_auto_config(codec);
4599 "hda_codec: Cannot set up configuration "
4600 "from BIOS. Using base mode...\n");
4601 board_config = ALC882_3ST_DIG;
4605 if (board_config != ALC882_AUTO)
4606 setup_preset(spec, &alc882_presets[board_config]);
4608 spec->stream_name_analog = "ALC882 Analog";
4609 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4610 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4612 spec->stream_name_digital = "ALC882 Digital";
4613 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4614 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4616 if (! spec->adc_nids && spec->input_mux) {
4617 /* check whether NID 0x07 is valid */
4618 unsigned int wcap = get_wcaps(codec, 0x07);
4619 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4620 if (wcap != AC_WID_AUD_IN) {
4621 spec->adc_nids = alc882_adc_nids_alt;
4622 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4623 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4626 spec->adc_nids = alc882_adc_nids;
4627 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4628 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4633 codec->patch_ops = alc_patch_ops;
4634 if (board_config == ALC882_AUTO)
4635 spec->init_hook = alc882_auto_init;
4643 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4644 * configuration. Each pin widget can choose any input DACs and a mixer.
4645 * Each ADC is connected from a mixer of all inputs. This makes possible
4646 * 6-channel independent captures.
4648 * In addition, an independent DAC for the multi-playback (not used in this
4651 #define ALC883_DIGOUT_NID 0x06
4652 #define ALC883_DIGIN_NID 0x0a
4654 static hda_nid_t alc883_dac_nids[4] = {
4655 /* front, rear, clfe, rear_surr */
4656 0x02, 0x04, 0x03, 0x05
4659 static hda_nid_t alc883_adc_nids[2] = {
4664 /* FIXME: should be a matrix-type input source selection */
4666 static struct hda_input_mux alc883_capture_source = {
4670 { "Front Mic", 0x1 },
4675 #define alc883_mux_enum_info alc_mux_enum_info
4676 #define alc883_mux_enum_get alc_mux_enum_get
4678 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4679 struct snd_ctl_elem_value *ucontrol)
4681 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4682 struct alc_spec *spec = codec->spec;
4683 const struct hda_input_mux *imux = spec->input_mux;
4684 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4685 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4686 hda_nid_t nid = capture_mixers[adc_idx];
4687 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4688 unsigned int i, idx;
4690 idx = ucontrol->value.enumerated.item[0];
4691 if (idx >= imux->num_items)
4692 idx = imux->num_items - 1;
4693 if (*cur_val == idx && ! codec->in_resume)
4695 for (i = 0; i < imux->num_items; i++) {
4696 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4697 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4698 v | (imux->items[i].index << 8));
4706 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4713 static struct hda_verb alc883_3ST_ch2_init[] = {
4714 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4715 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4716 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4717 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4724 static struct hda_verb alc883_3ST_ch6_init[] = {
4725 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4726 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4727 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4728 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4729 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4730 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4734 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4735 { 2, alc883_3ST_ch2_init },
4736 { 6, alc883_3ST_ch6_init },
4742 static struct hda_verb alc883_sixstack_ch6_init[] = {
4743 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4744 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4745 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4746 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4753 static struct hda_verb alc883_sixstack_ch8_init[] = {
4754 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4755 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4756 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4757 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4761 static struct hda_channel_mode alc883_sixstack_modes[2] = {
4762 { 6, alc883_sixstack_ch6_init },
4763 { 8, alc883_sixstack_ch8_init },
4766 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4767 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4770 static struct snd_kcontrol_new alc883_base_mixer[] = {
4771 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4772 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4773 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4774 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4776 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4779 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4780 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4785 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4788 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4790 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4791 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4792 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4793 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4794 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4795 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4797 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4798 /* .name = "Capture Source", */
4799 .name = "Input Source",
4801 .info = alc883_mux_enum_info,
4802 .get = alc883_mux_enum_get,
4803 .put = alc883_mux_enum_put,
4808 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4809 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4810 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4812 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4813 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4814 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4815 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4816 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4817 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4818 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4819 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4820 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4821 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4822 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4823 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4824 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4825 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4828 /* .name = "Capture Source", */
4829 .name = "Input Source",
4831 .info = alc883_mux_enum_info,
4832 .get = alc883_mux_enum_get,
4833 .put = alc883_mux_enum_put,
4838 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4839 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4840 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4841 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4842 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4843 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4844 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4845 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4846 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4847 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4848 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4849 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4854 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4855 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4856 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4857 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4858 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4859 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4860 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4861 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4863 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4864 /* .name = "Capture Source", */
4865 .name = "Input Source",
4867 .info = alc883_mux_enum_info,
4868 .get = alc883_mux_enum_get,
4869 .put = alc883_mux_enum_put,
4874 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4877 .name = "Channel Mode",
4878 .info = alc_ch_mode_info,
4879 .get = alc_ch_mode_get,
4880 .put = alc_ch_mode_put,
4885 static struct hda_verb alc883_init_verbs[] = {
4886 /* ADC1: mute amp left and right */
4887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4888 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4889 /* ADC2: mute amp left and right */
4890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4891 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4892 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4897 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4901 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4905 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4911 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4912 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4913 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4915 /* Front Pin: output 0 (0x0c) */
4916 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4918 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4919 /* Rear Pin: output 1 (0x0d) */
4920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4921 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4922 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4923 /* CLFE Pin: output 2 (0x0e) */
4924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4925 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4926 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4927 /* Side Pin: output 3 (0x0f) */
4928 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4929 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4930 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4931 /* Mic (rear) pin: input vref at 80% */
4932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4933 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4934 /* Front Mic pin: input vref at 80% */
4935 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4936 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4937 /* Line In pin: input */
4938 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4940 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4941 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4942 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4943 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4944 /* CD pin widget for input */
4945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4947 /* FIXME: use matrix-type input source selection */
4948 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4951 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4963 * generic initialization of ADC, input mixers and output mixers
4965 static struct hda_verb alc883_auto_init_verbs[] = {
4967 * Unmute ADC0-2 and set the default input to mic-in
4969 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4970 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4971 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4972 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4974 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4976 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4979 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4987 * Set up output mixers (0x0c - 0x0f)
4989 /* set vol=0 to output mixers */
4990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4993 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4994 /* set up input amps for analog loopback */
4995 /* Amp Indices: DAC = 0, mixer = 1 */
4996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5004 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5005 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5007 /* FIXME: use matrix-type input source selection */
5008 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5010 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5011 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5012 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5013 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5014 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5016 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5019 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5020 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5025 /* capture mixer elements */
5026 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5027 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5028 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5029 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5030 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5033 /* The multiple "Capture Source" controls confuse alsamixer
5034 * So call somewhat different..
5035 * FIXME: the controls appear in the "playback" view!
5037 /* .name = "Capture Source", */
5038 .name = "Input Source",
5040 .info = alc882_mux_enum_info,
5041 .get = alc882_mux_enum_get,
5042 .put = alc882_mux_enum_put,
5047 /* pcm configuration: identiacal with ALC880 */
5048 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5049 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5050 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5051 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5054 * configuration and preset
5056 static struct hda_board_config alc883_cfg_tbl[] = {
5057 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5058 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5059 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5060 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5061 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5062 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5063 .config = ALC883_3ST_6ch },
5064 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
5065 .config = ALC883_3ST_6ch }, /* D102GGC */
5066 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5067 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5068 .config = ALC883_6ST_DIG }, /* MSI */
5069 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5070 .config = ALC883_6ST_DIG }, /* Foxconn */
5071 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5072 { .modelname = "auto", .config = ALC883_AUTO },
5076 static struct alc_config_preset alc883_presets[] = {
5077 [ALC883_3ST_2ch_DIG] = {
5078 .mixers = { alc883_3ST_2ch_mixer },
5079 .init_verbs = { alc883_init_verbs },
5080 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5081 .dac_nids = alc883_dac_nids,
5082 .dig_out_nid = ALC883_DIGOUT_NID,
5083 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5084 .adc_nids = alc883_adc_nids,
5085 .dig_in_nid = ALC883_DIGIN_NID,
5086 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5087 .channel_mode = alc883_3ST_2ch_modes,
5088 .input_mux = &alc883_capture_source,
5090 [ALC883_3ST_6ch_DIG] = {
5091 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5092 .init_verbs = { alc883_init_verbs },
5093 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5094 .dac_nids = alc883_dac_nids,
5095 .dig_out_nid = ALC883_DIGOUT_NID,
5096 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5097 .adc_nids = alc883_adc_nids,
5098 .dig_in_nid = ALC883_DIGIN_NID,
5099 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5100 .channel_mode = alc883_3ST_6ch_modes,
5102 .input_mux = &alc883_capture_source,
5104 [ALC883_3ST_6ch] = {
5105 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5106 .init_verbs = { alc883_init_verbs },
5107 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5108 .dac_nids = alc883_dac_nids,
5109 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5110 .adc_nids = alc883_adc_nids,
5111 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5112 .channel_mode = alc883_3ST_6ch_modes,
5114 .input_mux = &alc883_capture_source,
5116 [ALC883_6ST_DIG] = {
5117 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5118 .init_verbs = { alc883_init_verbs },
5119 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5120 .dac_nids = alc883_dac_nids,
5121 .dig_out_nid = ALC883_DIGOUT_NID,
5122 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5123 .adc_nids = alc883_adc_nids,
5124 .dig_in_nid = ALC883_DIGIN_NID,
5125 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5126 .channel_mode = alc883_sixstack_modes,
5127 .input_mux = &alc883_capture_source,
5129 [ALC888_DEMO_BOARD] = {
5130 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5131 .init_verbs = { alc883_init_verbs },
5132 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5133 .dac_nids = alc883_dac_nids,
5134 .dig_out_nid = ALC883_DIGOUT_NID,
5135 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5136 .adc_nids = alc883_adc_nids,
5137 .dig_in_nid = ALC883_DIGIN_NID,
5138 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5139 .channel_mode = alc883_sixstack_modes,
5140 .input_mux = &alc883_capture_source,
5146 * BIOS auto configuration
5148 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5149 hda_nid_t nid, int pin_type,
5153 struct alc_spec *spec = codec->spec;
5156 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5159 idx = spec->multiout.dac_nids[dac_idx] - 2;
5161 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5163 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5165 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5169 static void alc883_auto_init_multi_out(struct hda_codec *codec)
5171 struct alc_spec *spec = codec->spec;
5174 for (i = 0; i <= HDA_SIDE; i++) {
5175 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5177 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5181 static void alc883_auto_init_hp_out(struct hda_codec *codec)
5183 struct alc_spec *spec = codec->spec;
5186 pin = spec->autocfg.hp_pin;
5187 if (pin) /* connect to front */
5189 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5192 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5193 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5195 static void alc883_auto_init_analog_input(struct hda_codec *codec)
5197 struct alc_spec *spec = codec->spec;
5200 for (i = 0; i < AUTO_PIN_LAST; i++) {
5201 hda_nid_t nid = spec->autocfg.input_pins[i];
5202 if (alc883_is_input_pin(nid)) {
5203 snd_hda_codec_write(codec, nid, 0,
5204 AC_VERB_SET_PIN_WIDGET_CONTROL,
5205 (i <= AUTO_PIN_FRONT_MIC ?
5206 PIN_VREF80 : PIN_IN));
5207 if (nid != ALC883_PIN_CD_NID)
5208 snd_hda_codec_write(codec, nid, 0,
5209 AC_VERB_SET_AMP_GAIN_MUTE,
5215 /* almost identical with ALC880 parser... */
5216 static int alc883_parse_auto_config(struct hda_codec *codec)
5218 struct alc_spec *spec = codec->spec;
5219 int err = alc880_parse_auto_config(codec);
5224 /* hack - override the init verbs */
5225 spec->init_verbs[0] = alc883_auto_init_verbs;
5226 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5231 /* additional initialization for auto-configuration model */
5232 static void alc883_auto_init(struct hda_codec *codec)
5234 alc883_auto_init_multi_out(codec);
5235 alc883_auto_init_hp_out(codec);
5236 alc883_auto_init_analog_input(codec);
5239 static int patch_alc883(struct hda_codec *codec)
5241 struct alc_spec *spec;
5242 int err, board_config;
5244 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5250 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5251 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5252 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5253 "trying auto-probe from BIOS...\n");
5254 board_config = ALC883_AUTO;
5257 if (board_config == ALC883_AUTO) {
5258 /* automatic parse from the BIOS config */
5259 err = alc883_parse_auto_config(codec);
5265 "hda_codec: Cannot set up configuration "
5266 "from BIOS. Using base mode...\n");
5267 board_config = ALC883_3ST_2ch_DIG;
5271 if (board_config != ALC883_AUTO)
5272 setup_preset(spec, &alc883_presets[board_config]);
5274 spec->stream_name_analog = "ALC883 Analog";
5275 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5276 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5278 spec->stream_name_digital = "ALC883 Digital";
5279 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5280 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5282 if (! spec->adc_nids && spec->input_mux) {
5283 spec->adc_nids = alc883_adc_nids;
5284 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5287 codec->patch_ops = alc_patch_ops;
5288 if (board_config == ALC883_AUTO)
5289 spec->init_hook = alc883_auto_init;
5298 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5299 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
5301 #define alc262_dac_nids alc260_dac_nids
5302 #define alc262_adc_nids alc882_adc_nids
5303 #define alc262_adc_nids_alt alc882_adc_nids_alt
5305 #define alc262_modes alc260_modes
5306 #define alc262_capture_source alc882_capture_source
5308 static struct snd_kcontrol_new alc262_base_mixer[] = {
5309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5310 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5311 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5312 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5313 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5314 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5317 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5318 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5319 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5320 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5322 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5323 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5324 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5328 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5329 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5330 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5332 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5333 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5339 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5340 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5341 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5342 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5343 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5344 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5345 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5346 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5350 #define alc262_capture_mixer alc882_capture_mixer
5351 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
5354 * generic initialization of ADC, input mixers and output mixers
5356 static struct hda_verb alc262_init_verbs[] = {
5358 * Unmute ADC0-2 and set the default input to mic-in
5360 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5362 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5363 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5364 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5367 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5369 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5372 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5380 * Set up output mixers (0x0c - 0x0e)
5382 /* set vol=0 to output mixers */
5383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5386 /* set up input amps for analog loopback */
5387 /* Amp Indices: DAC = 0, mixer = 1 */
5388 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5389 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5390 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5395 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5397 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5398 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5399 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5400 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5402 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5404 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5405 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5408 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5409 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5411 /* FIXME: use matrix-type input source selection */
5412 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5413 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5414 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5416 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5420 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5434 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5437 #define ALC_HP_EVENT 0x37
5439 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5440 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5445 static struct hda_input_mux alc262_fujitsu_capture_source = {
5453 static struct hda_input_mux alc262_HP_capture_source = {
5457 { "Front Mic", 0x3 },
5464 /* mute/unmute internal speaker according to the hp jack and mute state */
5465 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5467 struct alc_spec *spec = codec->spec;
5470 if (force || ! spec->sense_updated) {
5471 unsigned int present;
5472 /* need to execute and sync at first */
5473 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5474 present = snd_hda_codec_read(codec, 0x14, 0,
5475 AC_VERB_GET_PIN_SENSE, 0);
5476 spec->jack_present = (present & 0x80000000) != 0;
5477 spec->sense_updated = 1;
5479 if (spec->jack_present) {
5480 /* mute internal speaker */
5481 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5483 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5486 /* unmute internal speaker if necessary */
5487 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5488 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5490 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5491 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5496 /* unsolicited event for HP jack sensing */
5497 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5500 if ((res >> 26) != ALC_HP_EVENT)
5502 alc262_fujitsu_automute(codec, 1);
5505 /* bind volumes of both NID 0x0c and 0x0d */
5506 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5507 struct snd_ctl_elem_value *ucontrol)
5509 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5510 long *valp = ucontrol->value.integer.value;
5513 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5514 0x7f, valp[0] & 0x7f);
5515 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5516 0x7f, valp[1] & 0x7f);
5517 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5518 0x7f, valp[0] & 0x7f);
5519 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5520 0x7f, valp[1] & 0x7f);
5524 /* bind hp and internal speaker mute (with plug check) */
5525 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5526 struct snd_ctl_elem_value *ucontrol)
5528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5529 long *valp = ucontrol->value.integer.value;
5532 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5533 0x80, valp[0] ? 0 : 0x80);
5534 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5535 0x80, valp[1] ? 0 : 0x80);
5536 if (change || codec->in_resume)
5537 alc262_fujitsu_automute(codec, codec->in_resume);
5541 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5543 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5544 .name = "Master Playback Volume",
5545 .info = snd_hda_mixer_amp_volume_info,
5546 .get = snd_hda_mixer_amp_volume_get,
5547 .put = alc262_fujitsu_master_vol_put,
5548 .tlv = { .c = snd_hda_mixer_amp_tlv },
5549 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5552 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5553 .name = "Master Playback Switch",
5554 .info = snd_hda_mixer_amp_switch_info,
5555 .get = snd_hda_mixer_amp_switch_get,
5556 .put = alc262_fujitsu_master_sw_put,
5557 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5559 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5560 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5561 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5562 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5563 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5567 /* additional init verbs for Benq laptops */
5568 static struct hda_verb alc262_EAPD_verbs[] = {
5569 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5570 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5574 /* add playback controls from the parsed DAC table */
5575 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5580 spec->multiout.num_dacs = 1; /* only use one dac */
5581 spec->multiout.dac_nids = spec->private_dac_nids;
5582 spec->multiout.dac_nids[0] = 2;
5584 nid = cfg->line_out_pins[0];
5586 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5587 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5589 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5590 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5594 nid = cfg->speaker_pins[0];
5597 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5598 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5600 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5601 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5604 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5605 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5611 /* spec->multiout.hp_nid = 2; */
5613 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5614 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5616 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5617 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5620 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5621 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5628 /* identical with ALC880 */
5629 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5632 * generic initialization of ADC, input mixers and output mixers
5634 static struct hda_verb alc262_volume_init_verbs[] = {
5636 * Unmute ADC0-2 and set the default input to mic-in
5638 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5639 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5640 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5641 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5642 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5643 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5645 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5647 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5650 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5651 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5652 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5653 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5654 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5655 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5658 * Set up output mixers (0x0c - 0x0f)
5660 /* set vol=0 to output mixers */
5661 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5665 /* set up input amps for analog loopback */
5666 /* Amp Indices: DAC = 0, mixer = 1 */
5667 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5669 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5670 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5671 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5672 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5674 /* FIXME: use matrix-type input source selection */
5675 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5676 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5677 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5678 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5679 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5680 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5682 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5683 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5684 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5685 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5689 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5695 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5697 * Unmute ADC0-2 and set the default input to mic-in
5699 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5701 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5702 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5703 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5704 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5706 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5708 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5711 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5716 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5718 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5721 * Set up output mixers (0x0c - 0x0e)
5723 /* set vol=0 to output mixers */
5724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5728 /* set up input amps for analog loopback */
5729 /* Amp Indices: DAC = 0, mixer = 1 */
5730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5732 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5735 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5738 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5739 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5741 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5744 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5748 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5751 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5753 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5754 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5755 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5756 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5757 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5758 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5761 /* FIXME: use matrix-type input source selection */
5762 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5763 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5764 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5765 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5766 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5770 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5771 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5772 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5775 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5782 /* pcm configuration: identiacal with ALC880 */
5783 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
5784 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
5785 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
5786 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
5789 * BIOS auto configuration
5791 static int alc262_parse_auto_config(struct hda_codec *codec)
5793 struct alc_spec *spec = codec->spec;
5795 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5797 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5798 alc262_ignore)) < 0)
5800 if (! spec->autocfg.line_outs)
5801 return 0; /* can't find valid BIOS pin config */
5802 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5803 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5806 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5808 if (spec->autocfg.dig_out_pin)
5809 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5810 if (spec->autocfg.dig_in_pin)
5811 spec->dig_in_nid = ALC262_DIGIN_NID;
5813 if (spec->kctl_alloc)
5814 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5816 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
5817 spec->num_mux_defs = 1;
5818 spec->input_mux = &spec->private_imux;
5823 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
5824 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
5825 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
5828 /* init callback for auto-configuration model -- overriding the default init */
5829 static void alc262_auto_init(struct hda_codec *codec)
5831 alc262_auto_init_multi_out(codec);
5832 alc262_auto_init_hp_out(codec);
5833 alc262_auto_init_analog_input(codec);
5837 * configuration and preset
5839 static struct hda_board_config alc262_cfg_tbl[] = {
5840 { .modelname = "basic", .config = ALC262_BASIC },
5841 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
5842 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5843 .config = ALC262_FUJITSU },
5844 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
5845 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5846 .config = ALC262_HP_BPC }, /* xw4400 */
5847 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5848 .config = ALC262_HP_BPC }, /* xw6400 */
5849 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5850 .config = ALC262_HP_BPC }, /* xw8400 */
5851 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5852 .config = ALC262_HP_BPC }, /* xw9400 */
5853 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5854 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5855 .config = ALC262_BENQ_ED8 },
5856 { .modelname = "auto", .config = ALC262_AUTO },
5860 static struct alc_config_preset alc262_presets[] = {
5862 .mixers = { alc262_base_mixer },
5863 .init_verbs = { alc262_init_verbs },
5864 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5865 .dac_nids = alc262_dac_nids,
5867 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5868 .channel_mode = alc262_modes,
5869 .input_mux = &alc262_capture_source,
5871 [ALC262_FUJITSU] = {
5872 .mixers = { alc262_fujitsu_mixer },
5873 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5874 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5875 .dac_nids = alc262_dac_nids,
5877 .dig_out_nid = ALC262_DIGOUT_NID,
5878 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5879 .channel_mode = alc262_modes,
5880 .input_mux = &alc262_fujitsu_capture_source,
5881 .unsol_event = alc262_fujitsu_unsol_event,
5884 .mixers = { alc262_HP_BPC_mixer },
5885 .init_verbs = { alc262_HP_BPC_init_verbs },
5886 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5887 .dac_nids = alc262_dac_nids,
5889 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5890 .channel_mode = alc262_modes,
5891 .input_mux = &alc262_HP_capture_source,
5893 [ALC262_BENQ_ED8] = {
5894 .mixers = { alc262_base_mixer },
5895 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5896 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5897 .dac_nids = alc262_dac_nids,
5899 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5900 .channel_mode = alc262_modes,
5901 .input_mux = &alc262_capture_source,
5905 static int patch_alc262(struct hda_codec *codec)
5907 struct alc_spec *spec;
5911 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5917 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5920 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5921 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5922 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5923 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5927 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
5929 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
5930 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5931 "trying auto-probe from BIOS...\n");
5932 board_config = ALC262_AUTO;
5935 if (board_config == ALC262_AUTO) {
5936 /* automatic parse from the BIOS config */
5937 err = alc262_parse_auto_config(codec);
5943 "hda_codec: Cannot set up configuration "
5944 "from BIOS. Using base mode...\n");
5945 board_config = ALC262_BASIC;
5949 if (board_config != ALC262_AUTO)
5950 setup_preset(spec, &alc262_presets[board_config]);
5952 spec->stream_name_analog = "ALC262 Analog";
5953 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5954 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5956 spec->stream_name_digital = "ALC262 Digital";
5957 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5958 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5960 if (! spec->adc_nids && spec->input_mux) {
5961 /* check whether NID 0x07 is valid */
5962 unsigned int wcap = get_wcaps(codec, 0x07);
5964 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5965 if (wcap != AC_WID_AUD_IN) {
5966 spec->adc_nids = alc262_adc_nids_alt;
5967 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5968 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5971 spec->adc_nids = alc262_adc_nids;
5972 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5973 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5978 codec->patch_ops = alc_patch_ops;
5979 if (board_config == ALC262_AUTO)
5980 spec->init_hook = alc262_auto_init;
5986 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5990 * set the path ways for 2 channel output
5991 * need to set the codec line out and mic 1 pin widgets to inputs
5993 static struct hda_verb alc861_threestack_ch2_init[] = {
5994 /* set pin widget 1Ah (line in) for input */
5995 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5996 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5997 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5999 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
6001 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6002 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6008 * need to set the codec line out and mic 1 pin widgets to outputs
6010 static struct hda_verb alc861_threestack_ch6_init[] = {
6011 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6012 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6013 /* set pin widget 18h (mic1) for output (CLFE)*/
6014 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6016 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6017 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6019 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6021 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6022 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6027 static struct hda_channel_mode alc861_threestack_modes[2] = {
6028 { 2, alc861_threestack_ch2_init },
6029 { 6, alc861_threestack_ch6_init },
6031 /* Set mic1 as input and unmute the mixer */
6032 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6033 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6034 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6037 /* Set mic1 as output and mute mixer */
6038 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6039 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6040 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6044 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6045 { 2, alc861_uniwill_m31_ch2_init },
6046 { 4, alc861_uniwill_m31_ch4_init },
6051 static struct snd_kcontrol_new alc861_base_mixer[] = {
6052 /* output mixer control */
6053 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6054 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6055 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6056 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6057 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6059 /*Input mixer control */
6060 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6061 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6062 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6063 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6064 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6065 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6066 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6067 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6068 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6069 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6071 /* Capture mixer control */
6072 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6073 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6076 .name = "Capture Source",
6078 .info = alc_mux_enum_info,
6079 .get = alc_mux_enum_get,
6080 .put = alc_mux_enum_put,
6085 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6086 /* output mixer control */
6087 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6088 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6089 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6090 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6091 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6093 /* Input mixer control */
6094 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6095 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6096 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6097 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6098 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6099 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6101 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6105 /* Capture mixer control */
6106 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6107 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6110 .name = "Capture Source",
6112 .info = alc_mux_enum_info,
6113 .get = alc_mux_enum_get,
6114 .put = alc_mux_enum_put,
6117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6118 .name = "Channel Mode",
6119 .info = alc_ch_mode_info,
6120 .get = alc_ch_mode_get,
6121 .put = alc_ch_mode_put,
6122 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6126 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6127 /* output mixer control */
6128 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6129 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6130 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6131 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6132 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6134 /* Input mixer control */
6135 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6136 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6137 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6138 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6139 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6140 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6142 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6143 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6146 /* Capture mixer control */
6147 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6148 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6151 .name = "Capture Source",
6153 .info = alc_mux_enum_info,
6154 .get = alc_mux_enum_get,
6155 .put = alc_mux_enum_put,
6158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6159 .name = "Channel Mode",
6160 .info = alc_ch_mode_info,
6161 .get = alc_ch_mode_get,
6162 .put = alc_ch_mode_put,
6163 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6169 * generic initialization of ADC, input mixers and output mixers
6171 static struct hda_verb alc861_base_init_verbs[] = {
6173 * Unmute ADC0 and set the default input to mic-in
6175 /* port-A for surround (rear panel) */
6176 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6177 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6178 /* port-B for mic-in (rear panel) with vref */
6179 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6180 /* port-C for line-in (rear panel) */
6181 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6182 /* port-D for Front */
6183 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6184 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6185 /* port-E for HP out (front panel) */
6186 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6187 /* route front PCM to HP */
6188 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6189 /* port-F for mic-in (front panel) with vref */
6190 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6191 /* port-G for CLFE (rear panel) */
6192 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6193 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6194 /* port-H for side (rear panel) */
6195 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6196 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6198 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6199 /* route front mic to ADC1*/
6200 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6203 /* Unmute DAC0~3 & spdif out*/
6204 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6205 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6206 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6207 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6210 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6211 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6212 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6213 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6214 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6216 /* Unmute Stereo Mixer 15 */
6217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6222 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6224 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6225 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6226 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6227 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6229 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6231 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6236 static struct hda_verb alc861_threestack_init_verbs[] = {
6238 * Unmute ADC0 and set the default input to mic-in
6240 /* port-A for surround (rear panel) */
6241 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6242 /* port-B for mic-in (rear panel) with vref */
6243 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6244 /* port-C for line-in (rear panel) */
6245 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6246 /* port-D for Front */
6247 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6248 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6249 /* port-E for HP out (front panel) */
6250 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6251 /* route front PCM to HP */
6252 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6253 /* port-F for mic-in (front panel) with vref */
6254 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6255 /* port-G for CLFE (rear panel) */
6256 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6257 /* port-H for side (rear panel) */
6258 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6260 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6261 /* route front mic to ADC1*/
6262 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6264 /* Unmute DAC0~3 & spdif out*/
6265 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6266 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6267 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6268 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6271 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6272 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6273 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6274 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6275 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6277 /* Unmute Stereo Mixer 15 */
6278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6283 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6284 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6285 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6286 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6288 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6291 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6296 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
6298 * Unmute ADC0 and set the default input to mic-in
6300 /* port-A for surround (rear panel) */
6301 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6302 /* port-B for mic-in (rear panel) with vref */
6303 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6304 /* port-C for line-in (rear panel) */
6305 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6306 /* port-D for Front */
6307 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6308 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6309 /* port-E for HP out (front panel) */
6310 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
6311 /* route front PCM to HP */
6312 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6313 /* port-F for mic-in (front panel) with vref */
6314 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6315 /* port-G for CLFE (rear panel) */
6316 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6317 /* port-H for side (rear panel) */
6318 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6320 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6321 /* route front mic to ADC1*/
6322 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6323 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6324 /* Unmute DAC0~3 & spdif out*/
6325 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6326 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6327 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6328 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6331 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6332 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6333 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6334 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6335 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6337 /* Unmute Stereo Mixer 15 */
6338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6344 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6345 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6346 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6349 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6351 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6357 * generic initialization of ADC, input mixers and output mixers
6359 static struct hda_verb alc861_auto_init_verbs[] = {
6361 * Unmute ADC0 and set the default input to mic-in
6363 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6366 /* Unmute DAC0~3 & spdif out*/
6367 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6368 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6369 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6370 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6371 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6373 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6374 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6375 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6376 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6377 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6379 /* Unmute Stereo Mixer 15 */
6380 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6381 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6382 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6383 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6385 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6386 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6387 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6388 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6389 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6390 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6391 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6392 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6394 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6395 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6396 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6397 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6398 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6399 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6400 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6401 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6403 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6408 /* pcm configuration: identiacal with ALC880 */
6409 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
6410 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
6411 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
6412 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
6415 #define ALC861_DIGOUT_NID 0x07
6417 static struct hda_channel_mode alc861_8ch_modes[1] = {
6421 static hda_nid_t alc861_dac_nids[4] = {
6422 /* front, surround, clfe, side */
6423 0x03, 0x06, 0x05, 0x04
6426 static hda_nid_t alc660_dac_nids[3] = {
6427 /* front, clfe, surround */
6431 static hda_nid_t alc861_adc_nids[1] = {
6436 static struct hda_input_mux alc861_capture_source = {
6440 { "Front Mic", 0x3 },
6447 /* fill in the dac_nids table from the parsed pin configuration */
6448 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6453 spec->multiout.dac_nids = spec->private_dac_nids;
6454 for (i = 0; i < cfg->line_outs; i++) {
6455 nid = cfg->line_out_pins[i];
6457 if (i >= ARRAY_SIZE(alc861_dac_nids))
6459 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6462 spec->multiout.num_dacs = cfg->line_outs;
6466 /* add playback controls from the parsed DAC table */
6467 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6468 const struct auto_pin_cfg *cfg)
6471 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6475 for (i = 0; i < cfg->line_outs; i++) {
6476 nid = spec->multiout.dac_nids[i];
6481 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6482 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6484 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6485 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6488 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6489 if (nid == alc861_dac_nids[idx])
6491 sprintf(name, "%s Playback Switch", chname[idx]);
6492 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6493 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6500 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6508 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6510 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6511 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6513 spec->multiout.hp_nid = nid;
6518 /* create playback/capture controls for input pins */
6519 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6521 struct hda_input_mux *imux = &spec->private_imux;
6522 int i, err, idx, idx1;
6524 for (i = 0; i < AUTO_PIN_LAST; i++) {
6525 switch(cfg->input_pins[i]) {
6550 err = new_analog_input(spec, cfg->input_pins[i],
6551 auto_pin_cfg_labels[i], idx, 0x15);
6555 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
6556 imux->items[imux->num_items].index = idx1;
6562 static struct snd_kcontrol_new alc861_capture_mixer[] = {
6563 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6564 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6568 /* The multiple "Capture Source" controls confuse alsamixer
6569 * So call somewhat different..
6570 *FIXME: the controls appear in the "playback" view!
6572 /* .name = "Capture Source", */
6573 .name = "Input Source",
6575 .info = alc_mux_enum_info,
6576 .get = alc_mux_enum_get,
6577 .put = alc_mux_enum_put,
6582 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6583 int pin_type, int dac_idx)
6587 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6588 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6592 static void alc861_auto_init_multi_out(struct hda_codec *codec)
6594 struct alc_spec *spec = codec->spec;
6597 for (i = 0; i < spec->autocfg.line_outs; i++) {
6598 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6600 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6604 static void alc861_auto_init_hp_out(struct hda_codec *codec)
6606 struct alc_spec *spec = codec->spec;
6609 pin = spec->autocfg.hp_pin;
6610 if (pin) /* connect to front */
6611 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6614 static void alc861_auto_init_analog_input(struct hda_codec *codec)
6616 struct alc_spec *spec = codec->spec;
6619 for (i = 0; i < AUTO_PIN_LAST; i++) {
6620 hda_nid_t nid = spec->autocfg.input_pins[i];
6621 if ((nid>=0x0c) && (nid <=0x11)) {
6622 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6623 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6628 /* parse the BIOS configuration and set up the alc_spec */
6629 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6630 static int alc861_parse_auto_config(struct hda_codec *codec)
6632 struct alc_spec *spec = codec->spec;
6634 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6636 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6637 alc861_ignore)) < 0)
6639 if (! spec->autocfg.line_outs)
6640 return 0; /* can't find valid BIOS pin config */
6642 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6643 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6644 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6645 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6648 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6650 if (spec->autocfg.dig_out_pin)
6651 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6653 if (spec->kctl_alloc)
6654 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6656 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6658 spec->num_mux_defs = 1;
6659 spec->input_mux = &spec->private_imux;
6661 spec->adc_nids = alc861_adc_nids;
6662 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6663 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6669 /* additional initialization for auto-configuration model */
6670 static void alc861_auto_init(struct hda_codec *codec)
6672 alc861_auto_init_multi_out(codec);
6673 alc861_auto_init_hp_out(codec);
6674 alc861_auto_init_analog_input(codec);
6679 * configuration and preset
6681 static struct hda_board_config alc861_cfg_tbl[] = {
6682 { .modelname = "3stack", .config = ALC861_3ST },
6683 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6684 .config = ALC861_3ST },
6685 { .modelname = "3stack-660", .config = ALC660_3ST },
6686 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6687 .config = ALC660_3ST },
6688 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6689 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
6690 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
6691 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
6692 .config = ALC861_UNIWILL_M31 },
6693 { .modelname = "auto", .config = ALC861_AUTO },
6697 static struct alc_config_preset alc861_presets[] = {
6699 .mixers = { alc861_3ST_mixer },
6700 .init_verbs = { alc861_threestack_init_verbs },
6701 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6702 .dac_nids = alc861_dac_nids,
6703 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6704 .channel_mode = alc861_threestack_modes,
6706 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6707 .adc_nids = alc861_adc_nids,
6708 .input_mux = &alc861_capture_source,
6710 [ALC861_3ST_DIG] = {
6711 .mixers = { alc861_base_mixer },
6712 .init_verbs = { alc861_threestack_init_verbs },
6713 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6714 .dac_nids = alc861_dac_nids,
6715 .dig_out_nid = ALC861_DIGOUT_NID,
6716 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6717 .channel_mode = alc861_threestack_modes,
6719 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6720 .adc_nids = alc861_adc_nids,
6721 .input_mux = &alc861_capture_source,
6723 [ALC861_6ST_DIG] = {
6724 .mixers = { alc861_base_mixer },
6725 .init_verbs = { alc861_base_init_verbs },
6726 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6727 .dac_nids = alc861_dac_nids,
6728 .dig_out_nid = ALC861_DIGOUT_NID,
6729 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6730 .channel_mode = alc861_8ch_modes,
6731 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6732 .adc_nids = alc861_adc_nids,
6733 .input_mux = &alc861_capture_source,
6736 .mixers = { alc861_3ST_mixer },
6737 .init_verbs = { alc861_threestack_init_verbs },
6738 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6739 .dac_nids = alc660_dac_nids,
6740 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6741 .channel_mode = alc861_threestack_modes,
6743 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6744 .adc_nids = alc861_adc_nids,
6745 .input_mux = &alc861_capture_source,
6747 [ALC861_UNIWILL_M31] = {
6748 .mixers = { alc861_uniwill_m31_mixer },
6749 .init_verbs = { alc861_uniwill_m31_init_verbs },
6750 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6751 .dac_nids = alc861_dac_nids,
6752 .dig_out_nid = ALC861_DIGOUT_NID,
6753 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
6754 .channel_mode = alc861_uniwill_m31_modes,
6756 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6757 .adc_nids = alc861_adc_nids,
6758 .input_mux = &alc861_capture_source,
6764 static int patch_alc861(struct hda_codec *codec)
6766 struct alc_spec *spec;
6770 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6776 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
6778 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
6779 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6780 "trying auto-probe from BIOS...\n");
6781 board_config = ALC861_AUTO;
6784 if (board_config == ALC861_AUTO) {
6785 /* automatic parse from the BIOS config */
6786 err = alc861_parse_auto_config(codec);
6792 "hda_codec: Cannot set up configuration "
6793 "from BIOS. Using base mode...\n");
6794 board_config = ALC861_3ST_DIG;
6798 if (board_config != ALC861_AUTO)
6799 setup_preset(spec, &alc861_presets[board_config]);
6801 spec->stream_name_analog = "ALC861 Analog";
6802 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6803 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6805 spec->stream_name_digital = "ALC861 Digital";
6806 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6807 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6809 codec->patch_ops = alc_patch_ops;
6810 if (board_config == ALC861_AUTO)
6811 spec->init_hook = alc861_auto_init;
6819 struct hda_codec_preset snd_hda_preset_realtek[] = {
6820 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6821 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6822 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6823 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6824 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
6825 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6826 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6827 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6828 .patch = patch_alc861 },
6829 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6830 .patch = patch_alc861 },