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 = 0xe214, .config = ALC880_3ST },
2147 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2149 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2150 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2151 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2154 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2155 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2156 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2157 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2158 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2159 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2161 { .modelname = "tcl", .config = ALC880_TCL_S700 },
2162 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2164 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2165 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2166 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2167 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2169 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2170 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2171 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2172 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2175 { .modelname = "clevo", .config = ALC880_CLEVO },
2176 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
2177 .config = ALC880_CLEVO }, /* Clevo m520G NB */
2178 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
2179 .config = ALC880_CLEVO }, /* Clevo m665n */
2181 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2182 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2183 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2184 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2186 /* Back 5 jack, front 2 jack */
2187 { .modelname = "5stack", .config = ALC880_5ST },
2188 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2189 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2190 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2191 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2192 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2194 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2195 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2196 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2197 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2198 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2199 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2200 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2201 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2202 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2203 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2204 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2205 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2206 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2207 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2208 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2209 /* note subvendor = 0 below */
2210 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2212 { .modelname = "w810", .config = ALC880_W810 },
2213 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2215 { .modelname = "z71v", .config = ALC880_Z71V },
2216 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2218 { .modelname = "6stack", .config = ALC880_6ST },
2219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2220 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2221 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2222 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2224 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2225 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2226 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2227 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2228 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2229 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2230 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2231 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2232 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2233 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2234 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2235 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2237 { .modelname = "asus", .config = ALC880_ASUS },
2238 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2239 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2240 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2241 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2242 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2243 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2244 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
2245 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2246 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2247 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2248 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2249 { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
2250 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2251 { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
2252 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2253 { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
2254 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2256 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2257 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2259 { .modelname = "F1734", .config = ALC880_F1734 },
2260 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2261 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2263 { .modelname = "lg", .config = ALC880_LG },
2264 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2265 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
2267 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2268 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2270 #ifdef CONFIG_SND_DEBUG
2271 { .modelname = "test", .config = ALC880_TEST },
2273 { .modelname = "auto", .config = ALC880_AUTO },
2279 * ALC880 codec presets
2281 static struct alc_config_preset alc880_presets[] = {
2283 .mixers = { alc880_three_stack_mixer },
2284 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2285 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2286 .dac_nids = alc880_dac_nids,
2287 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2288 .channel_mode = alc880_threestack_modes,
2290 .input_mux = &alc880_capture_source,
2292 [ALC880_3ST_DIG] = {
2293 .mixers = { alc880_three_stack_mixer },
2294 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2295 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2296 .dac_nids = alc880_dac_nids,
2297 .dig_out_nid = ALC880_DIGOUT_NID,
2298 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2299 .channel_mode = alc880_threestack_modes,
2301 .input_mux = &alc880_capture_source,
2303 [ALC880_TCL_S700] = {
2304 .mixers = { alc880_tcl_s700_mixer },
2305 .init_verbs = { alc880_volume_init_verbs,
2306 alc880_pin_tcl_S700_init_verbs,
2307 alc880_gpio2_init_verbs },
2308 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2309 .dac_nids = alc880_dac_nids,
2311 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2312 .channel_mode = alc880_2_jack_modes,
2313 .input_mux = &alc880_capture_source,
2316 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2317 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2318 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2319 .dac_nids = alc880_dac_nids,
2320 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2321 .channel_mode = alc880_fivestack_modes,
2322 .input_mux = &alc880_capture_source,
2324 [ALC880_5ST_DIG] = {
2325 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2326 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2327 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2328 .dac_nids = alc880_dac_nids,
2329 .dig_out_nid = ALC880_DIGOUT_NID,
2330 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2331 .channel_mode = alc880_fivestack_modes,
2332 .input_mux = &alc880_capture_source,
2335 .mixers = { alc880_six_stack_mixer },
2336 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2337 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2338 .dac_nids = alc880_6st_dac_nids,
2339 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2340 .channel_mode = alc880_sixstack_modes,
2341 .input_mux = &alc880_6stack_capture_source,
2343 [ALC880_6ST_DIG] = {
2344 .mixers = { alc880_six_stack_mixer },
2345 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2346 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2347 .dac_nids = alc880_6st_dac_nids,
2348 .dig_out_nid = ALC880_DIGOUT_NID,
2349 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2350 .channel_mode = alc880_sixstack_modes,
2351 .input_mux = &alc880_6stack_capture_source,
2354 .mixers = { alc880_w810_base_mixer },
2355 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2356 alc880_gpio2_init_verbs },
2357 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2358 .dac_nids = alc880_w810_dac_nids,
2359 .dig_out_nid = ALC880_DIGOUT_NID,
2360 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2361 .channel_mode = alc880_w810_modes,
2362 .input_mux = &alc880_capture_source,
2365 .mixers = { alc880_z71v_mixer },
2366 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2367 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2368 .dac_nids = alc880_z71v_dac_nids,
2369 .dig_out_nid = ALC880_DIGOUT_NID,
2371 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2372 .channel_mode = alc880_2_jack_modes,
2373 .input_mux = &alc880_capture_source,
2376 .mixers = { alc880_f1734_mixer },
2377 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2378 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2379 .dac_nids = alc880_f1734_dac_nids,
2381 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2382 .channel_mode = alc880_2_jack_modes,
2383 .input_mux = &alc880_capture_source,
2386 .mixers = { alc880_asus_mixer },
2387 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2388 alc880_gpio1_init_verbs },
2389 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2390 .dac_nids = alc880_asus_dac_nids,
2391 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2392 .channel_mode = alc880_asus_modes,
2394 .input_mux = &alc880_capture_source,
2396 [ALC880_ASUS_DIG] = {
2397 .mixers = { alc880_asus_mixer },
2398 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2399 alc880_gpio1_init_verbs },
2400 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2401 .dac_nids = alc880_asus_dac_nids,
2402 .dig_out_nid = ALC880_DIGOUT_NID,
2403 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2404 .channel_mode = alc880_asus_modes,
2406 .input_mux = &alc880_capture_source,
2408 [ALC880_ASUS_DIG2] = {
2409 .mixers = { alc880_asus_mixer },
2410 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2411 alc880_gpio2_init_verbs }, /* use GPIO2 */
2412 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2413 .dac_nids = alc880_asus_dac_nids,
2414 .dig_out_nid = ALC880_DIGOUT_NID,
2415 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2416 .channel_mode = alc880_asus_modes,
2418 .input_mux = &alc880_capture_source,
2420 [ALC880_ASUS_W1V] = {
2421 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2422 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2423 alc880_gpio1_init_verbs },
2424 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2425 .dac_nids = alc880_asus_dac_nids,
2426 .dig_out_nid = ALC880_DIGOUT_NID,
2427 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2428 .channel_mode = alc880_asus_modes,
2430 .input_mux = &alc880_capture_source,
2432 [ALC880_UNIWILL_DIG] = {
2433 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2434 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2435 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2436 .dac_nids = alc880_asus_dac_nids,
2437 .dig_out_nid = ALC880_DIGOUT_NID,
2438 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2439 .channel_mode = alc880_asus_modes,
2441 .input_mux = &alc880_capture_source,
2444 .mixers = { alc880_three_stack_mixer },
2445 .init_verbs = { alc880_volume_init_verbs,
2446 alc880_pin_clevo_init_verbs },
2447 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2448 .dac_nids = alc880_dac_nids,
2450 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2451 .channel_mode = alc880_threestack_modes,
2453 .input_mux = &alc880_capture_source,
2456 .mixers = { alc880_lg_mixer },
2457 .init_verbs = { alc880_volume_init_verbs,
2458 alc880_lg_init_verbs },
2459 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2460 .dac_nids = alc880_lg_dac_nids,
2461 .dig_out_nid = ALC880_DIGOUT_NID,
2462 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2463 .channel_mode = alc880_lg_ch_modes,
2465 .input_mux = &alc880_lg_capture_source,
2466 .unsol_event = alc880_lg_unsol_event,
2467 .init_hook = alc880_lg_automute,
2470 .mixers = { alc880_lg_lw_mixer },
2471 .init_verbs = { alc880_volume_init_verbs,
2472 alc880_lg_lw_init_verbs },
2474 .dac_nids = alc880_dac_nids,
2475 .dig_out_nid = ALC880_DIGOUT_NID,
2476 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2477 .channel_mode = alc880_2_jack_modes,
2478 .input_mux = &alc880_lg_lw_capture_source,
2479 .unsol_event = alc880_lg_lw_unsol_event,
2480 .init_hook = alc880_lg_lw_automute,
2482 #ifdef CONFIG_SND_DEBUG
2484 .mixers = { alc880_test_mixer },
2485 .init_verbs = { alc880_test_init_verbs },
2486 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2487 .dac_nids = alc880_test_dac_nids,
2488 .dig_out_nid = ALC880_DIGOUT_NID,
2489 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2490 .channel_mode = alc880_test_modes,
2491 .input_mux = &alc880_test_capture_source,
2497 * Automatic parse of I/O pins from the BIOS configuration
2500 #define NUM_CONTROL_ALLOC 32
2501 #define NUM_VERB_ALLOC 32
2505 ALC_CTL_WIDGET_MUTE,
2508 static struct snd_kcontrol_new alc880_control_templates[] = {
2509 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2510 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2511 HDA_BIND_MUTE(NULL, 0, 0, 0),
2514 /* add dynamic controls */
2515 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2517 struct snd_kcontrol_new *knew;
2519 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2520 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2522 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2525 if (spec->kctl_alloc) {
2526 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2527 kfree(spec->kctl_alloc);
2529 spec->kctl_alloc = knew;
2530 spec->num_kctl_alloc = num;
2533 knew = &spec->kctl_alloc[spec->num_kctl_used];
2534 *knew = alc880_control_templates[type];
2535 knew->name = kstrdup(name, GFP_KERNEL);
2538 knew->private_value = val;
2539 spec->num_kctl_used++;
2543 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2544 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2545 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2546 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2547 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2548 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2549 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2550 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2551 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2552 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2553 #define ALC880_PIN_CD_NID 0x1c
2555 /* fill in the dac_nids table from the parsed pin configuration */
2556 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2562 memset(assigned, 0, sizeof(assigned));
2563 spec->multiout.dac_nids = spec->private_dac_nids;
2565 /* check the pins hardwired to audio widget */
2566 for (i = 0; i < cfg->line_outs; i++) {
2567 nid = cfg->line_out_pins[i];
2568 if (alc880_is_fixed_pin(nid)) {
2569 int idx = alc880_fixed_pin_idx(nid);
2570 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2574 /* left pins can be connect to any audio widget */
2575 for (i = 0; i < cfg->line_outs; i++) {
2576 nid = cfg->line_out_pins[i];
2577 if (alc880_is_fixed_pin(nid))
2579 /* search for an empty channel */
2580 for (j = 0; j < cfg->line_outs; j++) {
2581 if (! assigned[j]) {
2582 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2588 spec->multiout.num_dacs = cfg->line_outs;
2592 /* add playback controls from the parsed DAC table */
2593 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2594 const struct auto_pin_cfg *cfg)
2597 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2601 for (i = 0; i < cfg->line_outs; i++) {
2602 if (! spec->multiout.dac_nids[i])
2604 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2607 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2608 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2610 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2611 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2613 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2614 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2616 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2617 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2620 sprintf(name, "%s Playback Volume", chname[i]);
2621 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2622 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2624 sprintf(name, "%s Playback Switch", chname[i]);
2625 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2626 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2633 /* add playback controls for speaker and HP outputs */
2634 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2644 if (alc880_is_fixed_pin(pin)) {
2645 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2646 /* specify the DAC as the extra output */
2647 if (! spec->multiout.hp_nid)
2648 spec->multiout.hp_nid = nid;
2650 spec->multiout.extra_out_nid[0] = nid;
2651 /* control HP volume/switch on the output mixer amp */
2652 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2653 sprintf(name, "%s Playback Volume", pfx);
2654 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2655 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2657 sprintf(name, "%s Playback Switch", pfx);
2658 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2659 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2661 } else if (alc880_is_multi_pin(pin)) {
2662 /* set manual connection */
2663 /* we have only a switch on HP-out PIN */
2664 sprintf(name, "%s Playback Switch", pfx);
2665 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2666 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2672 /* create input playback/capture controls for the given pin */
2673 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2674 int idx, hda_nid_t mix_nid)
2679 sprintf(name, "%s Playback Volume", ctlname);
2680 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2681 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2683 sprintf(name, "%s Playback Switch", ctlname);
2684 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2685 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2690 /* create playback/capture controls for input pins */
2691 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2692 const struct auto_pin_cfg *cfg)
2694 struct hda_input_mux *imux = &spec->private_imux;
2697 for (i = 0; i < AUTO_PIN_LAST; i++) {
2698 if (alc880_is_input_pin(cfg->input_pins[i])) {
2699 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2700 err = new_analog_input(spec, cfg->input_pins[i],
2701 auto_pin_cfg_labels[i],
2705 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2706 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2713 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2714 hda_nid_t nid, int pin_type,
2718 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2719 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2720 /* need the manual connection? */
2721 if (alc880_is_multi_pin(nid)) {
2722 struct alc_spec *spec = codec->spec;
2723 int idx = alc880_multi_pin_idx(nid);
2724 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2725 AC_VERB_SET_CONNECT_SEL,
2726 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2730 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2732 struct alc_spec *spec = codec->spec;
2735 for (i = 0; i < spec->autocfg.line_outs; i++) {
2736 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2737 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2741 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2743 struct alc_spec *spec = codec->spec;
2746 pin = spec->autocfg.speaker_pins[0];
2747 if (pin) /* connect to front */
2748 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2749 pin = spec->autocfg.hp_pin;
2750 if (pin) /* connect to front */
2751 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2754 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2756 struct alc_spec *spec = codec->spec;
2759 for (i = 0; i < AUTO_PIN_LAST; i++) {
2760 hda_nid_t nid = spec->autocfg.input_pins[i];
2761 if (alc880_is_input_pin(nid)) {
2762 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2763 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2764 if (nid != ALC880_PIN_CD_NID)
2765 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2771 /* parse the BIOS configuration and set up the alc_spec */
2772 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2773 static int alc880_parse_auto_config(struct hda_codec *codec)
2775 struct alc_spec *spec = codec->spec;
2777 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2779 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2780 alc880_ignore)) < 0)
2782 if (! spec->autocfg.line_outs)
2783 return 0; /* can't find valid BIOS pin config */
2785 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2786 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2787 (err = alc880_auto_create_extra_out(spec,
2788 spec->autocfg.speaker_pins[0],
2790 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2791 "Headphone")) < 0 ||
2792 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2795 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2797 if (spec->autocfg.dig_out_pin)
2798 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2799 if (spec->autocfg.dig_in_pin)
2800 spec->dig_in_nid = ALC880_DIGIN_NID;
2802 if (spec->kctl_alloc)
2803 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2805 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2807 spec->num_mux_defs = 1;
2808 spec->input_mux = &spec->private_imux;
2813 /* additional initialization for auto-configuration model */
2814 static void alc880_auto_init(struct hda_codec *codec)
2816 alc880_auto_init_multi_out(codec);
2817 alc880_auto_init_extra_out(codec);
2818 alc880_auto_init_analog_input(codec);
2822 * OK, here we have finally the patch for ALC880
2825 static int patch_alc880(struct hda_codec *codec)
2827 struct alc_spec *spec;
2831 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2837 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2838 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2839 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2840 "trying auto-probe from BIOS...\n");
2841 board_config = ALC880_AUTO;
2844 if (board_config == ALC880_AUTO) {
2845 /* automatic parse from the BIOS config */
2846 err = alc880_parse_auto_config(codec);
2852 "hda_codec: Cannot set up configuration "
2853 "from BIOS. Using 3-stack mode...\n");
2854 board_config = ALC880_3ST;
2858 if (board_config != ALC880_AUTO)
2859 setup_preset(spec, &alc880_presets[board_config]);
2861 spec->stream_name_analog = "ALC880 Analog";
2862 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2863 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2865 spec->stream_name_digital = "ALC880 Digital";
2866 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2867 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2869 if (! spec->adc_nids && spec->input_mux) {
2870 /* check whether NID 0x07 is valid */
2871 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2872 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2873 if (wcap != AC_WID_AUD_IN) {
2874 spec->adc_nids = alc880_adc_nids_alt;
2875 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2876 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2879 spec->adc_nids = alc880_adc_nids;
2880 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2881 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2886 codec->patch_ops = alc_patch_ops;
2887 if (board_config == ALC880_AUTO)
2888 spec->init_hook = alc880_auto_init;
2898 static hda_nid_t alc260_dac_nids[1] = {
2903 static hda_nid_t alc260_adc_nids[1] = {
2908 static hda_nid_t alc260_adc_nids_alt[1] = {
2913 static hda_nid_t alc260_hp_adc_nids[2] = {
2918 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2919 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2921 static hda_nid_t alc260_dual_adc_nids[2] = {
2926 #define ALC260_DIGOUT_NID 0x03
2927 #define ALC260_DIGIN_NID 0x06
2929 static struct hda_input_mux alc260_capture_source = {
2933 { "Front Mic", 0x1 },
2939 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2940 * headphone jack and the internal CD lines since these are the only pins at
2941 * which audio can appear. For flexibility, also allow the option of
2942 * recording the mixer output on the second ADC (ADC0 doesn't have a
2943 * connection to the mixer output).
2945 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2949 { "Mic/Line", 0x0 },
2951 { "Headphone", 0x2 },
2957 { "Mic/Line", 0x0 },
2959 { "Headphone", 0x2 },
2966 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2967 * the Fujitsu S702x, but jacks are marked differently.
2969 static struct hda_input_mux alc260_acer_capture_sources[2] = {
2976 { "Headphone", 0x5 },
2985 { "Headphone", 0x6 },
2991 * This is just place-holder, so there's something for alc_build_pcms to look
2992 * at when it calculates the maximum number of channels. ALC260 has no mixer
2993 * element which allows changing the channel mode, so the verb list is
2996 static struct hda_channel_mode alc260_modes[1] = {
3001 /* Mixer combinations
3003 * basic: base_output + input + pc_beep + capture
3004 * HP: base_output + input + capture_alt
3005 * HP_3013: hp_3013 + input + capture
3006 * fujitsu: fujitsu + capture
3007 * acer: acer + capture
3010 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3011 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3012 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3013 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3014 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3015 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3016 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3020 static struct snd_kcontrol_new alc260_input_mixer[] = {
3021 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3022 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3024 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3026 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3032 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3033 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3034 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3038 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3039 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3040 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3041 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3042 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3045 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3046 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3050 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3051 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3053 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3054 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3055 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3056 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3057 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3058 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3059 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3060 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3061 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3062 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3063 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3064 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3065 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3069 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3070 * versions of the ALC260 don't act on requests to enable mic bias from NID
3071 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3072 * datasheet doesn't mention this restriction. At this stage it's not clear
3073 * whether this behaviour is intentional or is a hardware bug in chip
3074 * revisions available in early 2006. Therefore for now allow the
3075 * "Headphone Jack Mode" control to span all choices, but if it turns out
3076 * that the lack of mic bias for this NID is intentional we could change the
3077 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3079 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3080 * don't appear to make the mic bias available from the "line" jack, even
3081 * though the NID used for this jack (0x14) can supply it. The theory is
3082 * that perhaps Acer have included blocking capacitors between the ALC260
3083 * and the output jack. If this turns out to be the case for all such
3084 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3085 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3087 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3088 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3089 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3090 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3091 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3092 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3094 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3095 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3096 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3097 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3098 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3099 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3100 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3104 /* capture mixer elements */
3105 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3106 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3107 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3108 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3109 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3112 /* The multiple "Capture Source" controls confuse alsamixer
3113 * So call somewhat different..
3114 * FIXME: the controls appear in the "playback" view!
3116 /* .name = "Capture Source", */
3117 .name = "Input Source",
3119 .info = alc_mux_enum_info,
3120 .get = alc_mux_enum_get,
3121 .put = alc_mux_enum_put,
3126 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3127 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3128 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3131 /* The multiple "Capture Source" controls confuse alsamixer
3132 * So call somewhat different..
3133 * FIXME: the controls appear in the "playback" view!
3135 /* .name = "Capture Source", */
3136 .name = "Input Source",
3138 .info = alc_mux_enum_info,
3139 .get = alc_mux_enum_get,
3140 .put = alc_mux_enum_put,
3146 * initialization verbs
3148 static struct hda_verb alc260_init_verbs[] = {
3149 /* Line In pin widget for input */
3150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3151 /* CD pin widget for input */
3152 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3153 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3154 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3155 /* Mic2 (front panel) pin widget for input and vref at 80% */
3156 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3157 /* LINE-2 is used for line-out in rear */
3158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3159 /* select line-out */
3160 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3162 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3164 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3166 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3167 /* mute capture amp left and right */
3168 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3169 /* set connection select to line in (default select for this ADC) */
3170 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3171 /* mute capture amp left and right */
3172 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3173 /* set connection select to line in (default select for this ADC) */
3174 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3175 /* set vol=0 Line-Out mixer amp left and right */
3176 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3177 /* unmute pin widget amp left and right (no gain on this amp) */
3178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3179 /* set vol=0 HP mixer amp left and right */
3180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3181 /* unmute pin widget amp left and right (no gain on this amp) */
3182 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 /* set vol=0 Mono mixer amp left and right */
3184 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3185 /* unmute pin widget amp left and right (no gain on this amp) */
3186 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* unmute LINE-2 out pin */
3188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3196 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3197 /* mute Front out path */
3198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3200 /* mute Headphone out path */
3201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3203 /* mute Mono out path */
3204 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3205 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3209 #if 0 /* should be identical with alc260_init_verbs? */
3210 static struct hda_verb alc260_hp_init_verbs[] = {
3211 /* Headphone and output */
3212 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3214 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3215 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3216 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3217 /* Mic2 (front panel) pin widget for input and vref at 80% */
3218 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3219 /* Line In pin widget for input */
3220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3221 /* Line-2 pin widget for output */
3222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3223 /* CD pin widget for input */
3224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3225 /* unmute amp left and right */
3226 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3227 /* set connection select to line in (default select for this ADC) */
3228 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3229 /* unmute Line-Out mixer amp left and right (volume = 0) */
3230 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3231 /* mute pin widget amp left and right (no gain on this amp) */
3232 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3233 /* unmute HP mixer amp left and right (volume = 0) */
3234 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3235 /* mute pin widget amp left and right (no gain on this amp) */
3236 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3237 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3240 /* unmute Line In */
3241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3243 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3244 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3245 /* Unmute Front out path */
3246 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3248 /* Unmute Headphone out path */
3249 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3251 /* Unmute Mono out path */
3252 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3253 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3258 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3259 /* Line out and output */
3260 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3262 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3263 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3264 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3265 /* Mic2 (front panel) pin widget for input and vref at 80% */
3266 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3267 /* Line In pin widget for input */
3268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3269 /* Headphone pin widget for output */
3270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3271 /* CD pin widget for input */
3272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3273 /* unmute amp left and right */
3274 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3275 /* set connection select to line in (default select for this ADC) */
3276 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3277 /* unmute Line-Out mixer amp left and right (volume = 0) */
3278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3279 /* mute pin widget amp left and right (no gain on this amp) */
3280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3281 /* unmute HP mixer amp left and right (volume = 0) */
3282 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3283 /* mute pin widget amp left and right (no gain on this amp) */
3284 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3285 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3288 /* unmute Line In */
3289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3292 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3293 /* Unmute Front out path */
3294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3296 /* Unmute Headphone out path */
3297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3299 /* Unmute Mono out path */
3300 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3305 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3306 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3307 * audio = 0x16, internal speaker = 0x10.
3309 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3310 /* Disable all GPIOs */
3311 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3312 /* Internal speaker is connected to headphone pin */
3313 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3314 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3316 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3317 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3318 /* Ensure all other unused pins are disabled and muted. */
3319 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3320 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3321 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3322 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3323 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3324 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3328 /* Disable digital (SPDIF) pins */
3329 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3330 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3332 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3333 * when acting as an output.
3335 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3337 /* Start with output sum widgets muted and their output gains at min */
3338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3348 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3349 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3350 /* Unmute Line1 pin widget output buffer since it starts as an output.
3351 * If the pin mode is changed by the user the pin mode control will
3352 * take care of enabling the pin's input/output buffers as needed.
3353 * Therefore there's no need to enable the input buffer at this
3356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3357 /* Unmute input buffer of pin widget used for Line-in (no equiv
3360 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3362 /* Mute capture amp left and right */
3363 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3364 /* Set ADC connection select to match default mixer setting - line
3367 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3369 /* Do the same for the second ADC: mute capture input amp and
3370 * set ADC connection to line in (on mic1 pin)
3372 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3373 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3375 /* Mute all inputs to mixer widget (even unconnected ones) */
3376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3380 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3388 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3389 * similar laptops (adapted from Fujitsu init verbs).
3391 static struct hda_verb alc260_acer_init_verbs[] = {
3392 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3393 * the headphone jack. Turn this on and rely on the standard mute
3394 * methods whenever the user wants to turn these outputs off.
3396 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3397 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3398 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3399 /* Internal speaker/Headphone jack is connected to Line-out pin */
3400 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3401 /* Internal microphone/Mic jack is connected to Mic1 pin */
3402 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3403 /* Line In jack is connected to Line1 pin */
3404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3405 /* Ensure all other unused pins are disabled and muted. */
3406 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3407 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3408 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3409 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3410 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3411 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3414 /* Disable digital (SPDIF) pins */
3415 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3416 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3418 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3419 * bus when acting as outputs.
3421 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3422 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3424 /* Start with output sum widgets muted and their output gains at min */
3425 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3427 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3428 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3431 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3432 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3433 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3435 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3437 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3438 * inputs. If the pin mode is changed by the user the pin mode control
3439 * will take care of enabling the pin's input/output buffers as needed.
3440 * Therefore there's no need to enable the input buffer at this
3443 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3446 /* Mute capture amp left and right */
3447 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3448 /* Set ADC connection select to match default mixer setting - mic
3451 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3453 /* Do similar with the second ADC: mute capture input amp and
3454 * set ADC connection to mic to match ALSA's default state.
3456 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3457 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3459 /* Mute all inputs to mixer widget (even unconnected ones) */
3460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3472 /* Test configuration for debugging, modelled after the ALC880 test
3475 #ifdef CONFIG_SND_DEBUG
3476 static hda_nid_t alc260_test_dac_nids[1] = {
3479 static hda_nid_t alc260_test_adc_nids[2] = {
3482 /* For testing the ALC260, each input MUX needs its own definition since
3483 * the signal assignments are different. This assumes that the first ADC
3486 static struct hda_input_mux alc260_test_capture_sources[2] = {
3490 { "MIC1 pin", 0x0 },
3491 { "MIC2 pin", 0x1 },
3492 { "LINE1 pin", 0x2 },
3493 { "LINE2 pin", 0x3 },
3495 { "LINE-OUT pin", 0x5 },
3496 { "HP-OUT pin", 0x6 },
3502 { "MIC1 pin", 0x0 },
3503 { "MIC2 pin", 0x1 },
3504 { "LINE1 pin", 0x2 },
3505 { "LINE2 pin", 0x3 },
3508 { "LINE-OUT pin", 0x6 },
3509 { "HP-OUT pin", 0x7 },
3513 static struct snd_kcontrol_new alc260_test_mixer[] = {
3514 /* Output driver widgets */
3515 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3516 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3517 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3518 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3519 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3520 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3522 /* Modes for retasking pin widgets
3523 * Note: the ALC260 doesn't seem to act on requests to enable mic
3524 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3525 * mention this restriction. At this stage it's not clear whether
3526 * this behaviour is intentional or is a hardware bug in chip
3527 * revisions available at least up until early 2006. Therefore for
3528 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3529 * choices, but if it turns out that the lack of mic bias for these
3530 * NIDs is intentional we could change their modes from
3531 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3533 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3534 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3535 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3536 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3537 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3538 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3540 /* Loopback mixer controls */
3541 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3542 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3543 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3544 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3545 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3546 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3547 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3548 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3549 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3550 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3551 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3552 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3553 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3554 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3555 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3556 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3558 /* Controls for GPIO pins, assuming they are configured as outputs */
3559 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3560 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3561 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3562 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3564 /* Switches to allow the digital IO pins to be enabled. The datasheet
3565 * is ambigious as to which NID is which; testing on laptops which
3566 * make this output available should provide clarification.
3568 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3569 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3573 static struct hda_verb alc260_test_init_verbs[] = {
3574 /* Enable all GPIOs as outputs with an initial value of 0 */
3575 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3576 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3577 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3579 /* Enable retasking pins as output, initially without power amp */
3580 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3581 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3582 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3584 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3585 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3587 /* Disable digital (SPDIF) pins initially, but users can enable
3588 * them via a mixer switch. In the case of SPDIF-out, this initverb
3589 * payload also sets the generation to 0, output to be in "consumer"
3590 * PCM format, copyright asserted, no pre-emphasis and no validity
3593 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3594 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3596 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3597 * OUT1 sum bus when acting as an output.
3599 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3600 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3601 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3602 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3604 /* Start with output sum widgets muted and their output gains at min */
3605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3607 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3608 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3610 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3611 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3612 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3613 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3615 /* Unmute retasking pin widget output buffers since the default
3616 * state appears to be output. As the pin mode is changed by the
3617 * user the pin mode control will take care of enabling the pin's
3618 * input/output buffers as needed.
3620 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3624 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3625 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3626 /* Also unmute the mono-out pin widget */
3627 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3629 /* Mute capture amp left and right */
3630 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3631 /* Set ADC connection select to match default mixer setting (mic1
3634 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3636 /* Do the same for the second ADC: mute capture input amp and
3637 * set ADC connection to mic1 pin
3639 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3640 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3642 /* Mute all inputs to mixer widget (even unconnected ones) */
3643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3656 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3662 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3668 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3669 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3672 * for BIOS auto-configuration
3675 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3679 unsigned long vol_val, sw_val;
3683 if (nid >= 0x0f && nid < 0x11) {
3684 nid_vol = nid - 0x7;
3685 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3686 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3687 } else if (nid == 0x11) {
3688 nid_vol = nid - 0x7;
3689 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3690 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3691 } else if (nid >= 0x12 && nid <= 0x15) {
3693 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3694 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3698 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3699 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3701 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3702 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3707 /* add playback controls from the parsed DAC table */
3708 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3709 const struct auto_pin_cfg *cfg)
3714 spec->multiout.num_dacs = 1;
3715 spec->multiout.dac_nids = spec->private_dac_nids;
3716 spec->multiout.dac_nids[0] = 0x02;
3718 nid = cfg->line_out_pins[0];
3720 err = alc260_add_playback_controls(spec, nid, "Front");
3725 nid = cfg->speaker_pins[0];
3727 err = alc260_add_playback_controls(spec, nid, "Speaker");
3734 err = alc260_add_playback_controls(spec, nid, "Headphone");
3741 /* create playback/capture controls for input pins */
3742 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3743 const struct auto_pin_cfg *cfg)
3745 struct hda_input_mux *imux = &spec->private_imux;
3748 for (i = 0; i < AUTO_PIN_LAST; i++) {
3749 if (cfg->input_pins[i] >= 0x12) {
3750 idx = cfg->input_pins[i] - 0x12;
3751 err = new_analog_input(spec, cfg->input_pins[i],
3752 auto_pin_cfg_labels[i], idx, 0x07);
3755 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3756 imux->items[imux->num_items].index = idx;
3759 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3760 idx = cfg->input_pins[i] - 0x09;
3761 err = new_analog_input(spec, cfg->input_pins[i],
3762 auto_pin_cfg_labels[i], idx, 0x07);
3765 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3766 imux->items[imux->num_items].index = idx;
3773 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3774 hda_nid_t nid, int pin_type,
3778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3779 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3780 /* need the manual connection? */
3782 int idx = nid - 0x12;
3783 snd_hda_codec_write(codec, idx + 0x0b, 0,
3784 AC_VERB_SET_CONNECT_SEL, sel_idx);
3789 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3791 struct alc_spec *spec = codec->spec;
3794 nid = spec->autocfg.line_out_pins[0];
3796 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3798 nid = spec->autocfg.speaker_pins[0];
3800 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3802 nid = spec->autocfg.hp_pin;
3804 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3807 #define ALC260_PIN_CD_NID 0x16
3808 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3810 struct alc_spec *spec = codec->spec;
3813 for (i = 0; i < AUTO_PIN_LAST; i++) {
3814 hda_nid_t nid = spec->autocfg.input_pins[i];
3816 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3817 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3818 if (nid != ALC260_PIN_CD_NID)
3819 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3826 * generic initialization of ADC, input mixers and output mixers
3828 static struct hda_verb alc260_volume_init_verbs[] = {
3830 * Unmute ADC0-1 and set the default input to mic-in
3832 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3833 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3834 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3839 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3842 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3845 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3850 * Set up output mixers (0x08 - 0x0a)
3852 /* set vol=0 to output mixers */
3853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3855 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3856 /* set up input amps for analog loopback */
3857 /* Amp Indices: DAC = 0, mixer = 1 */
3858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3860 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3862 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3868 static int alc260_parse_auto_config(struct hda_codec *codec)
3870 struct alc_spec *spec = codec->spec;
3873 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3875 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3876 alc260_ignore)) < 0)
3878 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3880 if (! spec->kctl_alloc)
3881 return 0; /* can't find valid BIOS pin config */
3882 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3885 spec->multiout.max_channels = 2;
3887 if (spec->autocfg.dig_out_pin)
3888 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3889 if (spec->kctl_alloc)
3890 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3892 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3894 spec->num_mux_defs = 1;
3895 spec->input_mux = &spec->private_imux;
3897 /* check whether NID 0x04 is valid */
3898 wcap = get_wcaps(codec, 0x04);
3899 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3900 if (wcap != AC_WID_AUD_IN) {
3901 spec->adc_nids = alc260_adc_nids_alt;
3902 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3903 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3905 spec->adc_nids = alc260_adc_nids;
3906 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3907 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3914 /* additional initialization for auto-configuration model */
3915 static void alc260_auto_init(struct hda_codec *codec)
3917 alc260_auto_init_multi_out(codec);
3918 alc260_auto_init_analog_input(codec);
3922 * ALC260 configurations
3924 static struct hda_board_config alc260_cfg_tbl[] = {
3925 { .modelname = "basic", .config = ALC260_BASIC },
3926 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3927 .config = ALC260_BASIC }, /* Sony VAIO */
3928 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
3929 .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
3930 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
3931 .config = ALC260_BASIC }, /* Sony VAIO */
3932 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3933 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
3934 { .modelname = "hp", .config = ALC260_HP },
3935 { .modelname = "hp-3013", .config = ALC260_HP_3013 },
3936 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
3937 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3938 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
3939 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3940 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3941 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3942 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3943 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3944 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3945 { .modelname = "acer", .config = ALC260_ACER },
3946 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
3947 #ifdef CONFIG_SND_DEBUG
3948 { .modelname = "test", .config = ALC260_TEST },
3950 { .modelname = "auto", .config = ALC260_AUTO },
3954 static struct alc_config_preset alc260_presets[] = {
3956 .mixers = { alc260_base_output_mixer,
3958 alc260_pc_beep_mixer,
3959 alc260_capture_mixer },
3960 .init_verbs = { alc260_init_verbs },
3961 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3962 .dac_nids = alc260_dac_nids,
3963 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3964 .adc_nids = alc260_adc_nids,
3965 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3966 .channel_mode = alc260_modes,
3967 .input_mux = &alc260_capture_source,
3970 .mixers = { alc260_base_output_mixer,
3972 alc260_capture_alt_mixer },
3973 .init_verbs = { alc260_init_verbs },
3974 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3975 .dac_nids = alc260_dac_nids,
3976 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3977 .adc_nids = alc260_hp_adc_nids,
3978 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3979 .channel_mode = alc260_modes,
3980 .input_mux = &alc260_capture_source,
3982 [ALC260_HP_3013] = {
3983 .mixers = { alc260_hp_3013_mixer,
3985 alc260_capture_alt_mixer },
3986 .init_verbs = { alc260_hp_3013_init_verbs },
3987 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3988 .dac_nids = alc260_dac_nids,
3989 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3990 .adc_nids = alc260_hp_adc_nids,
3991 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3992 .channel_mode = alc260_modes,
3993 .input_mux = &alc260_capture_source,
3995 [ALC260_FUJITSU_S702X] = {
3996 .mixers = { alc260_fujitsu_mixer,
3997 alc260_capture_mixer },
3998 .init_verbs = { alc260_fujitsu_init_verbs },
3999 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4000 .dac_nids = alc260_dac_nids,
4001 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4002 .adc_nids = alc260_dual_adc_nids,
4003 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4004 .channel_mode = alc260_modes,
4005 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4006 .input_mux = alc260_fujitsu_capture_sources,
4009 .mixers = { alc260_acer_mixer,
4010 alc260_capture_mixer },
4011 .init_verbs = { alc260_acer_init_verbs },
4012 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4013 .dac_nids = alc260_dac_nids,
4014 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4015 .adc_nids = alc260_dual_adc_nids,
4016 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4017 .channel_mode = alc260_modes,
4018 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4019 .input_mux = alc260_acer_capture_sources,
4021 #ifdef CONFIG_SND_DEBUG
4023 .mixers = { alc260_test_mixer,
4024 alc260_capture_mixer },
4025 .init_verbs = { alc260_test_init_verbs },
4026 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4027 .dac_nids = alc260_test_dac_nids,
4028 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4029 .adc_nids = alc260_test_adc_nids,
4030 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4031 .channel_mode = alc260_modes,
4032 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4033 .input_mux = alc260_test_capture_sources,
4038 static int patch_alc260(struct hda_codec *codec)
4040 struct alc_spec *spec;
4041 int err, board_config;
4043 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4049 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
4050 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
4051 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4052 "trying auto-probe from BIOS...\n");
4053 board_config = ALC260_AUTO;
4056 if (board_config == ALC260_AUTO) {
4057 /* automatic parse from the BIOS config */
4058 err = alc260_parse_auto_config(codec);
4064 "hda_codec: Cannot set up configuration "
4065 "from BIOS. Using base mode...\n");
4066 board_config = ALC260_BASIC;
4070 if (board_config != ALC260_AUTO)
4071 setup_preset(spec, &alc260_presets[board_config]);
4073 spec->stream_name_analog = "ALC260 Analog";
4074 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4075 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4077 spec->stream_name_digital = "ALC260 Digital";
4078 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4079 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4081 codec->patch_ops = alc_patch_ops;
4082 if (board_config == ALC260_AUTO)
4083 spec->init_hook = alc260_auto_init;
4092 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4093 * configuration. Each pin widget can choose any input DACs and a mixer.
4094 * Each ADC is connected from a mixer of all inputs. This makes possible
4095 * 6-channel independent captures.
4097 * In addition, an independent DAC for the multi-playback (not used in this
4100 #define ALC882_DIGOUT_NID 0x06
4101 #define ALC882_DIGIN_NID 0x0a
4103 static struct hda_channel_mode alc882_ch_modes[1] = {
4107 static hda_nid_t alc882_dac_nids[4] = {
4108 /* front, rear, clfe, rear_surr */
4109 0x02, 0x03, 0x04, 0x05
4112 /* identical with ALC880 */
4113 #define alc882_adc_nids alc880_adc_nids
4114 #define alc882_adc_nids_alt alc880_adc_nids_alt
4117 /* FIXME: should be a matrix-type input source selection */
4119 static struct hda_input_mux alc882_capture_source = {
4123 { "Front Mic", 0x1 },
4128 #define alc882_mux_enum_info alc_mux_enum_info
4129 #define alc882_mux_enum_get alc_mux_enum_get
4131 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4134 struct alc_spec *spec = codec->spec;
4135 const struct hda_input_mux *imux = spec->input_mux;
4136 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4137 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4138 hda_nid_t nid = capture_mixers[adc_idx];
4139 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4140 unsigned int i, idx;
4142 idx = ucontrol->value.enumerated.item[0];
4143 if (idx >= imux->num_items)
4144 idx = imux->num_items - 1;
4145 if (*cur_val == idx && ! codec->in_resume)
4147 for (i = 0; i < imux->num_items; i++) {
4148 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4149 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4150 v | (imux->items[i].index << 8));
4159 static struct hda_verb alc882_sixstack_ch6_init[] = {
4160 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4161 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4162 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4163 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4170 static struct hda_verb alc882_sixstack_ch8_init[] = {
4171 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4172 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4173 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4174 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4178 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4179 { 6, alc882_sixstack_ch6_init },
4180 { 8, alc882_sixstack_ch8_init },
4183 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4184 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4186 static struct snd_kcontrol_new alc882_base_mixer[] = {
4187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4188 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4189 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4190 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4191 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4192 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4193 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4194 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4195 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4196 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4204 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4205 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4206 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4207 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4211 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4214 .name = "Channel Mode",
4215 .info = alc_ch_mode_info,
4216 .get = alc_ch_mode_get,
4217 .put = alc_ch_mode_put,
4222 static struct hda_verb alc882_init_verbs[] = {
4223 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4240 /* Front Pin: output 0 (0x0c) */
4241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4244 /* Rear Pin: output 1 (0x0d) */
4245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4248 /* CLFE Pin: output 2 (0x0e) */
4249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4250 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4251 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4252 /* Side Pin: output 3 (0x0f) */
4253 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4254 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4255 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4256 /* Mic (rear) pin: input vref at 80% */
4257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4259 /* Front Mic pin: input vref at 80% */
4260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4262 /* Line In pin: input */
4263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4265 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4269 /* CD pin widget for input */
4270 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4272 /* FIXME: use matrix-type input source selection */
4273 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4274 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4289 /* ADC1: mute amp left and right */
4290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4291 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4292 /* ADC2: mute amp left and right */
4293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4294 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4295 /* ADC3: mute amp left and right */
4296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4297 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4302 static struct hda_verb alc882_eapd_verbs[] = {
4303 /* change to EAPD mode */
4304 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4305 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4310 * generic initialization of ADC, input mixers and output mixers
4312 static struct hda_verb alc882_auto_init_verbs[] = {
4314 * Unmute ADC0-2 and set the default input to mic-in
4316 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4318 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4320 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4321 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4323 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4325 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4328 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4336 * Set up output mixers (0x0c - 0x0f)
4338 /* set vol=0 to output mixers */
4339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4340 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4341 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4342 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4343 /* set up input amps for analog loopback */
4344 /* Amp Indices: DAC = 0, mixer = 1 */
4345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4349 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4350 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4353 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4354 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4356 /* FIXME: use matrix-type input source selection */
4357 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4358 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4377 /* capture mixer elements */
4378 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4379 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4380 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4381 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4382 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4384 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4385 /* The multiple "Capture Source" controls confuse alsamixer
4386 * So call somewhat different..
4387 * FIXME: the controls appear in the "playback" view!
4389 /* .name = "Capture Source", */
4390 .name = "Input Source",
4392 .info = alc882_mux_enum_info,
4393 .get = alc882_mux_enum_get,
4394 .put = alc882_mux_enum_put,
4399 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4400 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4401 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4402 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4403 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4404 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4405 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4408 /* The multiple "Capture Source" controls confuse alsamixer
4409 * So call somewhat different..
4410 * FIXME: the controls appear in the "playback" view!
4412 /* .name = "Capture Source", */
4413 .name = "Input Source",
4415 .info = alc882_mux_enum_info,
4416 .get = alc882_mux_enum_get,
4417 .put = alc882_mux_enum_put,
4422 /* pcm configuration: identiacal with ALC880 */
4423 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4424 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4425 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4426 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4429 * configuration and preset
4431 static struct hda_board_config alc882_cfg_tbl[] = {
4432 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4433 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4434 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
4435 .config = ALC882_6ST_DIG }, /* MSI */
4436 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
4437 .config = ALC882_6ST_DIG }, /* Foxconn */
4438 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
4439 .config = ALC882_6ST_DIG }, /* ECS to Intel*/
4440 { .modelname = "arima", .config = ALC882_ARIMA },
4441 { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
4442 .config = ALC882_ARIMA }, /* Arima W820Di1 */
4443 { .modelname = "auto", .config = ALC882_AUTO },
4447 static struct alc_config_preset alc882_presets[] = {
4448 [ALC882_3ST_DIG] = {
4449 .mixers = { alc882_base_mixer },
4450 .init_verbs = { alc882_init_verbs },
4451 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4452 .dac_nids = alc882_dac_nids,
4453 .dig_out_nid = ALC882_DIGOUT_NID,
4454 .dig_in_nid = ALC882_DIGIN_NID,
4455 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4456 .channel_mode = alc882_ch_modes,
4458 .input_mux = &alc882_capture_source,
4460 [ALC882_6ST_DIG] = {
4461 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4462 .init_verbs = { alc882_init_verbs },
4463 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4464 .dac_nids = alc882_dac_nids,
4465 .dig_out_nid = ALC882_DIGOUT_NID,
4466 .dig_in_nid = ALC882_DIGIN_NID,
4467 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4468 .channel_mode = alc882_sixstack_modes,
4469 .input_mux = &alc882_capture_source,
4472 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4473 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
4474 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4475 .dac_nids = alc882_dac_nids,
4476 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4477 .channel_mode = alc882_sixstack_modes,
4478 .input_mux = &alc882_capture_source,
4484 * BIOS auto configuration
4486 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4487 hda_nid_t nid, int pin_type,
4491 struct alc_spec *spec = codec->spec;
4494 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4497 idx = spec->multiout.dac_nids[dac_idx] - 2;
4499 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4500 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4501 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4505 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4507 struct alc_spec *spec = codec->spec;
4510 for (i = 0; i <= HDA_SIDE; i++) {
4511 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4513 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4517 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4519 struct alc_spec *spec = codec->spec;
4522 pin = spec->autocfg.hp_pin;
4523 if (pin) /* connect to front */
4524 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4527 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4528 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4530 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4532 struct alc_spec *spec = codec->spec;
4535 for (i = 0; i < AUTO_PIN_LAST; i++) {
4536 hda_nid_t nid = spec->autocfg.input_pins[i];
4537 if (alc882_is_input_pin(nid)) {
4538 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4539 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4540 if (nid != ALC882_PIN_CD_NID)
4541 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4547 /* almost identical with ALC880 parser... */
4548 static int alc882_parse_auto_config(struct hda_codec *codec)
4550 struct alc_spec *spec = codec->spec;
4551 int err = alc880_parse_auto_config(codec);
4556 /* hack - override the init verbs */
4557 spec->init_verbs[0] = alc882_auto_init_verbs;
4561 /* additional initialization for auto-configuration model */
4562 static void alc882_auto_init(struct hda_codec *codec)
4564 alc882_auto_init_multi_out(codec);
4565 alc882_auto_init_hp_out(codec);
4566 alc882_auto_init_analog_input(codec);
4569 static int patch_alc882(struct hda_codec *codec)
4571 struct alc_spec *spec;
4572 int err, board_config;
4574 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4580 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4582 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4583 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
4584 "trying auto-probe from BIOS...\n");
4585 board_config = ALC882_AUTO;
4588 if (board_config == ALC882_AUTO) {
4589 /* automatic parse from the BIOS config */
4590 err = alc882_parse_auto_config(codec);
4596 "hda_codec: Cannot set up configuration "
4597 "from BIOS. Using base mode...\n");
4598 board_config = ALC882_3ST_DIG;
4602 if (board_config != ALC882_AUTO)
4603 setup_preset(spec, &alc882_presets[board_config]);
4605 spec->stream_name_analog = "ALC882 Analog";
4606 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4607 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4609 spec->stream_name_digital = "ALC882 Digital";
4610 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4611 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4613 if (! spec->adc_nids && spec->input_mux) {
4614 /* check whether NID 0x07 is valid */
4615 unsigned int wcap = get_wcaps(codec, 0x07);
4616 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4617 if (wcap != AC_WID_AUD_IN) {
4618 spec->adc_nids = alc882_adc_nids_alt;
4619 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4620 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4623 spec->adc_nids = alc882_adc_nids;
4624 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4625 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4630 codec->patch_ops = alc_patch_ops;
4631 if (board_config == ALC882_AUTO)
4632 spec->init_hook = alc882_auto_init;
4640 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
4641 * configuration. Each pin widget can choose any input DACs and a mixer.
4642 * Each ADC is connected from a mixer of all inputs. This makes possible
4643 * 6-channel independent captures.
4645 * In addition, an independent DAC for the multi-playback (not used in this
4648 #define ALC883_DIGOUT_NID 0x06
4649 #define ALC883_DIGIN_NID 0x0a
4651 static hda_nid_t alc883_dac_nids[4] = {
4652 /* front, rear, clfe, rear_surr */
4653 0x02, 0x04, 0x03, 0x05
4656 static hda_nid_t alc883_adc_nids[2] = {
4661 /* FIXME: should be a matrix-type input source selection */
4663 static struct hda_input_mux alc883_capture_source = {
4667 { "Front Mic", 0x1 },
4672 #define alc883_mux_enum_info alc_mux_enum_info
4673 #define alc883_mux_enum_get alc_mux_enum_get
4675 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
4676 struct snd_ctl_elem_value *ucontrol)
4678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4679 struct alc_spec *spec = codec->spec;
4680 const struct hda_input_mux *imux = spec->input_mux;
4681 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4682 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4683 hda_nid_t nid = capture_mixers[adc_idx];
4684 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4685 unsigned int i, idx;
4687 idx = ucontrol->value.enumerated.item[0];
4688 if (idx >= imux->num_items)
4689 idx = imux->num_items - 1;
4690 if (*cur_val == idx && ! codec->in_resume)
4692 for (i = 0; i < imux->num_items; i++) {
4693 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4694 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4695 v | (imux->items[i].index << 8));
4703 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
4710 static struct hda_verb alc883_3ST_ch2_init[] = {
4711 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4712 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4713 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4714 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4721 static struct hda_verb alc883_3ST_ch6_init[] = {
4722 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4723 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4724 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4725 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4726 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4727 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4731 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
4732 { 2, alc883_3ST_ch2_init },
4733 { 6, alc883_3ST_ch6_init },
4739 static struct hda_verb alc883_sixstack_ch6_init[] = {
4740 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4750 static struct hda_verb alc883_sixstack_ch8_init[] = {
4751 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4752 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4753 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4754 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4758 static struct hda_channel_mode alc883_sixstack_modes[2] = {
4759 { 6, alc883_sixstack_ch6_init },
4760 { 8, alc883_sixstack_ch8_init },
4763 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4764 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4767 static struct snd_kcontrol_new alc883_base_mixer[] = {
4768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4770 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4771 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4772 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4773 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4774 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4775 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4776 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4777 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4781 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4782 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4785 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4786 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4787 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4788 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4789 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4790 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4791 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4792 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4795 /* .name = "Capture Source", */
4796 .name = "Input Source",
4798 .info = alc883_mux_enum_info,
4799 .get = alc883_mux_enum_get,
4800 .put = alc883_mux_enum_put,
4805 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
4806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4807 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4809 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4810 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4817 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4818 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4819 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4820 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4821 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4822 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4825 /* .name = "Capture Source", */
4826 .name = "Input Source",
4828 .info = alc883_mux_enum_info,
4829 .get = alc883_mux_enum_get,
4830 .put = alc883_mux_enum_put,
4835 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
4836 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4837 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4838 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4839 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4840 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4841 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4842 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4843 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4853 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4854 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4855 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4856 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4861 /* .name = "Capture Source", */
4862 .name = "Input Source",
4864 .info = alc883_mux_enum_info,
4865 .get = alc883_mux_enum_get,
4866 .put = alc883_mux_enum_put,
4871 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
4873 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4874 .name = "Channel Mode",
4875 .info = alc_ch_mode_info,
4876 .get = alc_ch_mode_get,
4877 .put = alc_ch_mode_put,
4882 static struct hda_verb alc883_init_verbs[] = {
4883 /* ADC1: mute amp left and right */
4884 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4885 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4886 /* ADC2: mute amp left and right */
4887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4889 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4900 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4904 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4909 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4910 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4912 /* Front Pin: output 0 (0x0c) */
4913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4914 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4915 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4916 /* Rear Pin: output 1 (0x0d) */
4917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4919 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4920 /* CLFE Pin: output 2 (0x0e) */
4921 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4923 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4924 /* Side Pin: output 3 (0x0f) */
4925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4926 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4927 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4928 /* Mic (rear) pin: input vref at 80% */
4929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4931 /* Front Mic pin: input vref at 80% */
4932 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4933 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4934 /* Line In pin: input */
4935 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4936 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4937 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4940 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4941 /* CD pin widget for input */
4942 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4944 /* FIXME: use matrix-type input source selection */
4945 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4949 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4960 * generic initialization of ADC, input mixers and output mixers
4962 static struct hda_verb alc883_auto_init_verbs[] = {
4964 * Unmute ADC0-2 and set the default input to mic-in
4966 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4968 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4971 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4973 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4976 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4978 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4979 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4984 * Set up output mixers (0x0c - 0x0f)
4986 /* set vol=0 to output mixers */
4987 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4988 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4989 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4990 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4991 /* set up input amps for analog loopback */
4992 /* Amp Indices: DAC = 0, mixer = 1 */
4993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5001 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5002 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5004 /* FIXME: use matrix-type input source selection */
5005 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5010 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5011 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5016 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5022 /* capture mixer elements */
5023 static struct snd_kcontrol_new alc883_capture_mixer[] = {
5024 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5025 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5026 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5027 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5030 /* The multiple "Capture Source" controls confuse alsamixer
5031 * So call somewhat different..
5032 * FIXME: the controls appear in the "playback" view!
5034 /* .name = "Capture Source", */
5035 .name = "Input Source",
5037 .info = alc882_mux_enum_info,
5038 .get = alc882_mux_enum_get,
5039 .put = alc882_mux_enum_put,
5044 /* pcm configuration: identiacal with ALC880 */
5045 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
5046 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
5047 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
5048 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
5051 * configuration and preset
5053 static struct hda_board_config alc883_cfg_tbl[] = {
5054 { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
5055 { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
5056 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
5057 .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
5058 { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
5059 { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
5060 .config = ALC883_3ST_6ch },
5061 { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
5062 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
5063 .config = ALC883_6ST_DIG }, /* MSI */
5064 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
5065 .config = ALC883_6ST_DIG }, /* Foxconn */
5066 { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
5067 { .modelname = "auto", .config = ALC883_AUTO },
5071 static struct alc_config_preset alc883_presets[] = {
5072 [ALC883_3ST_2ch_DIG] = {
5073 .mixers = { alc883_3ST_2ch_mixer },
5074 .init_verbs = { alc883_init_verbs },
5075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5076 .dac_nids = alc883_dac_nids,
5077 .dig_out_nid = ALC883_DIGOUT_NID,
5078 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5079 .adc_nids = alc883_adc_nids,
5080 .dig_in_nid = ALC883_DIGIN_NID,
5081 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
5082 .channel_mode = alc883_3ST_2ch_modes,
5083 .input_mux = &alc883_capture_source,
5085 [ALC883_3ST_6ch_DIG] = {
5086 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5087 .init_verbs = { alc883_init_verbs },
5088 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5089 .dac_nids = alc883_dac_nids,
5090 .dig_out_nid = ALC883_DIGOUT_NID,
5091 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5092 .adc_nids = alc883_adc_nids,
5093 .dig_in_nid = ALC883_DIGIN_NID,
5094 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5095 .channel_mode = alc883_3ST_6ch_modes,
5097 .input_mux = &alc883_capture_source,
5099 [ALC883_3ST_6ch] = {
5100 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5101 .init_verbs = { alc883_init_verbs },
5102 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5103 .dac_nids = alc883_dac_nids,
5104 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5105 .adc_nids = alc883_adc_nids,
5106 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
5107 .channel_mode = alc883_3ST_6ch_modes,
5109 .input_mux = &alc883_capture_source,
5111 [ALC883_6ST_DIG] = {
5112 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5113 .init_verbs = { alc883_init_verbs },
5114 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5115 .dac_nids = alc883_dac_nids,
5116 .dig_out_nid = ALC883_DIGOUT_NID,
5117 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5118 .adc_nids = alc883_adc_nids,
5119 .dig_in_nid = ALC883_DIGIN_NID,
5120 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5121 .channel_mode = alc883_sixstack_modes,
5122 .input_mux = &alc883_capture_source,
5124 [ALC888_DEMO_BOARD] = {
5125 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5126 .init_verbs = { alc883_init_verbs },
5127 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
5128 .dac_nids = alc883_dac_nids,
5129 .dig_out_nid = ALC883_DIGOUT_NID,
5130 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
5131 .adc_nids = alc883_adc_nids,
5132 .dig_in_nid = ALC883_DIGIN_NID,
5133 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
5134 .channel_mode = alc883_sixstack_modes,
5135 .input_mux = &alc883_capture_source,
5141 * BIOS auto configuration
5143 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5144 hda_nid_t nid, int pin_type,
5148 struct alc_spec *spec = codec->spec;
5151 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5154 idx = spec->multiout.dac_nids[dac_idx] - 2;
5156 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5158 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5160 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5164 static void alc883_auto_init_multi_out(struct hda_codec *codec)
5166 struct alc_spec *spec = codec->spec;
5169 for (i = 0; i <= HDA_SIDE; i++) {
5170 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5172 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
5176 static void alc883_auto_init_hp_out(struct hda_codec *codec)
5178 struct alc_spec *spec = codec->spec;
5181 pin = spec->autocfg.hp_pin;
5182 if (pin) /* connect to front */
5184 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5187 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
5188 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
5190 static void alc883_auto_init_analog_input(struct hda_codec *codec)
5192 struct alc_spec *spec = codec->spec;
5195 for (i = 0; i < AUTO_PIN_LAST; i++) {
5196 hda_nid_t nid = spec->autocfg.input_pins[i];
5197 if (alc883_is_input_pin(nid)) {
5198 snd_hda_codec_write(codec, nid, 0,
5199 AC_VERB_SET_PIN_WIDGET_CONTROL,
5200 (i <= AUTO_PIN_FRONT_MIC ?
5201 PIN_VREF80 : PIN_IN));
5202 if (nid != ALC883_PIN_CD_NID)
5203 snd_hda_codec_write(codec, nid, 0,
5204 AC_VERB_SET_AMP_GAIN_MUTE,
5210 /* almost identical with ALC880 parser... */
5211 static int alc883_parse_auto_config(struct hda_codec *codec)
5213 struct alc_spec *spec = codec->spec;
5214 int err = alc880_parse_auto_config(codec);
5219 /* hack - override the init verbs */
5220 spec->init_verbs[0] = alc883_auto_init_verbs;
5221 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5226 /* additional initialization for auto-configuration model */
5227 static void alc883_auto_init(struct hda_codec *codec)
5229 alc883_auto_init_multi_out(codec);
5230 alc883_auto_init_hp_out(codec);
5231 alc883_auto_init_analog_input(codec);
5234 static int patch_alc883(struct hda_codec *codec)
5236 struct alc_spec *spec;
5237 int err, board_config;
5239 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5245 board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
5246 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
5247 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
5248 "trying auto-probe from BIOS...\n");
5249 board_config = ALC883_AUTO;
5252 if (board_config == ALC883_AUTO) {
5253 /* automatic parse from the BIOS config */
5254 err = alc883_parse_auto_config(codec);
5260 "hda_codec: Cannot set up configuration "
5261 "from BIOS. Using base mode...\n");
5262 board_config = ALC883_3ST_2ch_DIG;
5266 if (board_config != ALC883_AUTO)
5267 setup_preset(spec, &alc883_presets[board_config]);
5269 spec->stream_name_analog = "ALC883 Analog";
5270 spec->stream_analog_playback = &alc883_pcm_analog_playback;
5271 spec->stream_analog_capture = &alc883_pcm_analog_capture;
5273 spec->stream_name_digital = "ALC883 Digital";
5274 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5275 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5277 if (! spec->adc_nids && spec->input_mux) {
5278 spec->adc_nids = alc883_adc_nids;
5279 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5282 codec->patch_ops = alc_patch_ops;
5283 if (board_config == ALC883_AUTO)
5284 spec->init_hook = alc883_auto_init;
5293 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
5294 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
5296 #define alc262_dac_nids alc260_dac_nids
5297 #define alc262_adc_nids alc882_adc_nids
5298 #define alc262_adc_nids_alt alc882_adc_nids_alt
5300 #define alc262_modes alc260_modes
5301 #define alc262_capture_source alc882_capture_source
5303 static struct snd_kcontrol_new alc262_base_mixer[] = {
5304 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5305 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5306 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5307 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5308 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5309 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5312 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5313 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5314 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5315 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
5316 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
5317 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5318 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5319 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5323 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
5324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5325 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5327 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5328 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
5330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5332 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
5333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
5334 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5335 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5336 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5337 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5338 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
5339 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
5340 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
5341 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
5345 #define alc262_capture_mixer alc882_capture_mixer
5346 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
5349 * generic initialization of ADC, input mixers and output mixers
5351 static struct hda_verb alc262_init_verbs[] = {
5353 * Unmute ADC0-2 and set the default input to mic-in
5355 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5357 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5359 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5362 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5364 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5367 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5375 * Set up output mixers (0x0c - 0x0e)
5377 /* set vol=0 to output mixers */
5378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5381 /* set up input amps for analog loopback */
5382 /* Amp Indices: DAC = 0, mixer = 1 */
5383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5393 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5394 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5395 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5397 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5399 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5401 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5403 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5404 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5406 /* FIXME: use matrix-type input source selection */
5407 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5408 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5409 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5412 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5429 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
5432 #define ALC_HP_EVENT 0x37
5434 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
5435 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
5436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5440 static struct hda_input_mux alc262_fujitsu_capture_source = {
5448 static struct hda_input_mux alc262_HP_capture_source = {
5452 { "Front Mic", 0x3 },
5459 /* mute/unmute internal speaker according to the hp jack and mute state */
5460 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
5462 struct alc_spec *spec = codec->spec;
5465 if (force || ! spec->sense_updated) {
5466 unsigned int present;
5467 /* need to execute and sync at first */
5468 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
5469 present = snd_hda_codec_read(codec, 0x14, 0,
5470 AC_VERB_GET_PIN_SENSE, 0);
5471 spec->jack_present = (present & 0x80000000) != 0;
5472 spec->sense_updated = 1;
5474 if (spec->jack_present) {
5475 /* mute internal speaker */
5476 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5478 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5481 /* unmute internal speaker if necessary */
5482 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
5483 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5485 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
5486 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5491 /* unsolicited event for HP jack sensing */
5492 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
5495 if ((res >> 26) != ALC_HP_EVENT)
5497 alc262_fujitsu_automute(codec, 1);
5500 /* bind volumes of both NID 0x0c and 0x0d */
5501 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
5502 struct snd_ctl_elem_value *ucontrol)
5504 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5505 long *valp = ucontrol->value.integer.value;
5508 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
5509 0x7f, valp[0] & 0x7f);
5510 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
5511 0x7f, valp[1] & 0x7f);
5512 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
5513 0x7f, valp[0] & 0x7f);
5514 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
5515 0x7f, valp[1] & 0x7f);
5519 /* bind hp and internal speaker mute (with plug check) */
5520 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
5521 struct snd_ctl_elem_value *ucontrol)
5523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5524 long *valp = ucontrol->value.integer.value;
5527 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5528 0x80, valp[0] ? 0 : 0x80);
5529 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5530 0x80, valp[1] ? 0 : 0x80);
5531 if (change || codec->in_resume)
5532 alc262_fujitsu_automute(codec, codec->in_resume);
5536 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
5538 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5539 .name = "Master Playback Volume",
5540 .info = snd_hda_mixer_amp_volume_info,
5541 .get = snd_hda_mixer_amp_volume_get,
5542 .put = alc262_fujitsu_master_vol_put,
5543 .tlv = { .c = snd_hda_mixer_amp_tlv },
5544 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
5547 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5548 .name = "Master Playback Switch",
5549 .info = snd_hda_mixer_amp_switch_info,
5550 .get = snd_hda_mixer_amp_switch_get,
5551 .put = alc262_fujitsu_master_sw_put,
5552 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
5554 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5555 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5556 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5562 /* additional init verbs for Benq laptops */
5563 static struct hda_verb alc262_EAPD_verbs[] = {
5564 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5565 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5569 /* add playback controls from the parsed DAC table */
5570 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5575 spec->multiout.num_dacs = 1; /* only use one dac */
5576 spec->multiout.dac_nids = spec->private_dac_nids;
5577 spec->multiout.dac_nids[0] = 2;
5579 nid = cfg->line_out_pins[0];
5581 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
5582 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
5584 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
5585 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5589 nid = cfg->speaker_pins[0];
5592 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
5593 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5595 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5596 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5599 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
5600 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5606 /* spec->multiout.hp_nid = 2; */
5608 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
5609 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
5611 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5612 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5615 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5616 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5623 /* identical with ALC880 */
5624 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
5627 * generic initialization of ADC, input mixers and output mixers
5629 static struct hda_verb alc262_volume_init_verbs[] = {
5631 * Unmute ADC0-2 and set the default input to mic-in
5633 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5635 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5637 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5640 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5642 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5645 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5649 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5650 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5653 * Set up output mixers (0x0c - 0x0f)
5655 /* set vol=0 to output mixers */
5656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5660 /* set up input amps for analog loopback */
5661 /* Amp Indices: DAC = 0, mixer = 1 */
5662 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5663 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5664 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5665 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5666 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5667 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5669 /* FIXME: use matrix-type input source selection */
5670 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5671 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5678 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5679 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5680 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5683 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5690 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
5692 * Unmute ADC0-2 and set the default input to mic-in
5694 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5696 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5697 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5698 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5699 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5701 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5703 * Note: PASD motherboards uses the Line In 2 as the input for front panel
5706 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5708 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5709 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5710 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5711 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5712 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
5713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
5716 * Set up output mixers (0x0c - 0x0e)
5718 /* set vol=0 to output mixers */
5719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5720 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5721 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5723 /* set up input amps for analog loopback */
5724 /* Amp Indices: DAC = 0, mixer = 1 */
5725 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5727 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5729 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5739 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5740 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5742 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5743 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5745 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5746 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5748 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5749 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5750 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
5752 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5753 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
5756 /* FIXME: use matrix-type input source selection */
5757 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5758 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5759 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5760 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5762 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5764 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5765 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
5771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
5772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
5777 /* pcm configuration: identiacal with ALC880 */
5778 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
5779 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
5780 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
5781 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
5784 * BIOS auto configuration
5786 static int alc262_parse_auto_config(struct hda_codec *codec)
5788 struct alc_spec *spec = codec->spec;
5790 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
5792 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5793 alc262_ignore)) < 0)
5795 if (! spec->autocfg.line_outs)
5796 return 0; /* can't find valid BIOS pin config */
5797 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5798 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5801 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5803 if (spec->autocfg.dig_out_pin)
5804 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
5805 if (spec->autocfg.dig_in_pin)
5806 spec->dig_in_nid = ALC262_DIGIN_NID;
5808 if (spec->kctl_alloc)
5809 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5811 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
5812 spec->num_mux_defs = 1;
5813 spec->input_mux = &spec->private_imux;
5818 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
5819 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
5820 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
5823 /* init callback for auto-configuration model -- overriding the default init */
5824 static void alc262_auto_init(struct hda_codec *codec)
5826 alc262_auto_init_multi_out(codec);
5827 alc262_auto_init_hp_out(codec);
5828 alc262_auto_init_analog_input(codec);
5832 * configuration and preset
5834 static struct hda_board_config alc262_cfg_tbl[] = {
5835 { .modelname = "basic", .config = ALC262_BASIC },
5836 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
5837 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5838 .config = ALC262_FUJITSU },
5839 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
5840 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c,
5841 .config = ALC262_HP_BPC }, /* xw4400 */
5842 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5843 .config = ALC262_HP_BPC }, /* xw6400 */
5844 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
5845 .config = ALC262_HP_BPC }, /* xw8400 */
5846 { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
5847 .config = ALC262_HP_BPC }, /* xw9400 */
5848 { .modelname = "benq", .config = ALC262_BENQ_ED8 },
5849 { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
5850 .config = ALC262_BENQ_ED8 },
5851 { .modelname = "auto", .config = ALC262_AUTO },
5855 static struct alc_config_preset alc262_presets[] = {
5857 .mixers = { alc262_base_mixer },
5858 .init_verbs = { alc262_init_verbs },
5859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5860 .dac_nids = alc262_dac_nids,
5862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5863 .channel_mode = alc262_modes,
5864 .input_mux = &alc262_capture_source,
5866 [ALC262_FUJITSU] = {
5867 .mixers = { alc262_fujitsu_mixer },
5868 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
5869 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5870 .dac_nids = alc262_dac_nids,
5872 .dig_out_nid = ALC262_DIGOUT_NID,
5873 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5874 .channel_mode = alc262_modes,
5875 .input_mux = &alc262_fujitsu_capture_source,
5876 .unsol_event = alc262_fujitsu_unsol_event,
5879 .mixers = { alc262_HP_BPC_mixer },
5880 .init_verbs = { alc262_HP_BPC_init_verbs },
5881 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5882 .dac_nids = alc262_dac_nids,
5884 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5885 .channel_mode = alc262_modes,
5886 .input_mux = &alc262_HP_capture_source,
5888 [ALC262_BENQ_ED8] = {
5889 .mixers = { alc262_base_mixer },
5890 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
5891 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
5892 .dac_nids = alc262_dac_nids,
5894 .num_channel_mode = ARRAY_SIZE(alc262_modes),
5895 .channel_mode = alc262_modes,
5896 .input_mux = &alc262_capture_source,
5900 static int patch_alc262(struct hda_codec *codec)
5902 struct alc_spec *spec;
5906 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5912 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
5915 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5916 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
5917 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
5918 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
5922 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
5924 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
5925 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
5926 "trying auto-probe from BIOS...\n");
5927 board_config = ALC262_AUTO;
5930 if (board_config == ALC262_AUTO) {
5931 /* automatic parse from the BIOS config */
5932 err = alc262_parse_auto_config(codec);
5938 "hda_codec: Cannot set up configuration "
5939 "from BIOS. Using base mode...\n");
5940 board_config = ALC262_BASIC;
5944 if (board_config != ALC262_AUTO)
5945 setup_preset(spec, &alc262_presets[board_config]);
5947 spec->stream_name_analog = "ALC262 Analog";
5948 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5949 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5951 spec->stream_name_digital = "ALC262 Digital";
5952 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5953 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5955 if (! spec->adc_nids && spec->input_mux) {
5956 /* check whether NID 0x07 is valid */
5957 unsigned int wcap = get_wcaps(codec, 0x07);
5959 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5960 if (wcap != AC_WID_AUD_IN) {
5961 spec->adc_nids = alc262_adc_nids_alt;
5962 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5963 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5966 spec->adc_nids = alc262_adc_nids;
5967 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5968 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5973 codec->patch_ops = alc_patch_ops;
5974 if (board_config == ALC262_AUTO)
5975 spec->init_hook = alc262_auto_init;
5981 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5985 * set the path ways for 2 channel output
5986 * need to set the codec line out and mic 1 pin widgets to inputs
5988 static struct hda_verb alc861_threestack_ch2_init[] = {
5989 /* set pin widget 1Ah (line in) for input */
5990 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5991 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5992 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5994 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5996 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
5997 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
6003 * need to set the codec line out and mic 1 pin widgets to outputs
6005 static struct hda_verb alc861_threestack_ch6_init[] = {
6006 /* set pin widget 1Ah (line in) for output (Back Surround)*/
6007 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6008 /* set pin widget 18h (mic1) for output (CLFE)*/
6009 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6011 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
6012 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
6014 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
6016 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6017 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
6022 static struct hda_channel_mode alc861_threestack_modes[2] = {
6023 { 2, alc861_threestack_ch2_init },
6024 { 6, alc861_threestack_ch6_init },
6026 /* Set mic1 as input and unmute the mixer */
6027 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
6028 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6029 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
6032 /* Set mic1 as output and mute mixer */
6033 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
6034 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6035 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
6039 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6040 { 2, alc861_uniwill_m31_ch2_init },
6041 { 4, alc861_uniwill_m31_ch4_init },
6046 static struct snd_kcontrol_new alc861_base_mixer[] = {
6047 /* output mixer control */
6048 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6049 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6050 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6051 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6052 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
6054 /*Input mixer control */
6055 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6056 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6057 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6058 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6059 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6060 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6062 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6063 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6066 /* Capture mixer control */
6067 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6068 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6071 .name = "Capture Source",
6073 .info = alc_mux_enum_info,
6074 .get = alc_mux_enum_get,
6075 .put = alc_mux_enum_put,
6080 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
6081 /* output mixer control */
6082 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6083 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6084 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6085 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6086 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6088 /* Input mixer control */
6089 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6090 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6091 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6092 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6093 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6094 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6096 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6097 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6100 /* Capture mixer control */
6101 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6102 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6105 .name = "Capture Source",
6107 .info = alc_mux_enum_info,
6108 .get = alc_mux_enum_get,
6109 .put = alc_mux_enum_put,
6112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6113 .name = "Channel Mode",
6114 .info = alc_ch_mode_info,
6115 .get = alc_ch_mode_get,
6116 .put = alc_ch_mode_put,
6117 .private_value = ARRAY_SIZE(alc861_threestack_modes),
6121 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
6122 /* output mixer control */
6123 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
6124 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
6125 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
6126 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
6127 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
6129 /* Input mixer control */
6130 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
6131 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
6132 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
6133 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
6134 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
6135 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
6136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
6137 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
6138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
6139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
6141 /* Capture mixer control */
6142 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6143 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6145 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6146 .name = "Capture Source",
6148 .info = alc_mux_enum_info,
6149 .get = alc_mux_enum_get,
6150 .put = alc_mux_enum_put,
6153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6154 .name = "Channel Mode",
6155 .info = alc_ch_mode_info,
6156 .get = alc_ch_mode_get,
6157 .put = alc_ch_mode_put,
6158 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
6164 * generic initialization of ADC, input mixers and output mixers
6166 static struct hda_verb alc861_base_init_verbs[] = {
6168 * Unmute ADC0 and set the default input to mic-in
6170 /* port-A for surround (rear panel) */
6171 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6172 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
6173 /* port-B for mic-in (rear panel) with vref */
6174 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6175 /* port-C for line-in (rear panel) */
6176 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6177 /* port-D for Front */
6178 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6179 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6180 /* port-E for HP out (front panel) */
6181 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6182 /* route front PCM to HP */
6183 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6184 /* port-F for mic-in (front panel) with vref */
6185 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6186 /* port-G for CLFE (rear panel) */
6187 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6188 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
6189 /* port-H for side (rear panel) */
6190 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6191 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
6193 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6194 /* route front mic to ADC1*/
6195 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6198 /* Unmute DAC0~3 & spdif out*/
6199 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6200 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6201 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6202 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6205 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6206 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6207 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6208 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6209 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6211 /* Unmute Stereo Mixer 15 */
6212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6217 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6218 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6220 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6222 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6223 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6224 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6226 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6231 static struct hda_verb alc861_threestack_init_verbs[] = {
6233 * Unmute ADC0 and set the default input to mic-in
6235 /* port-A for surround (rear panel) */
6236 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6237 /* port-B for mic-in (rear panel) with vref */
6238 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6239 /* port-C for line-in (rear panel) */
6240 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6241 /* port-D for Front */
6242 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6243 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6244 /* port-E for HP out (front panel) */
6245 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
6246 /* route front PCM to HP */
6247 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6248 /* port-F for mic-in (front panel) with vref */
6249 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6250 /* port-G for CLFE (rear panel) */
6251 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6252 /* port-H for side (rear panel) */
6253 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6255 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6256 /* route front mic to ADC1*/
6257 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6258 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6259 /* Unmute DAC0~3 & spdif out*/
6260 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6261 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6262 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6263 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6266 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6267 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6268 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6269 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6270 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6272 /* Unmute Stereo Mixer 15 */
6273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6278 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6279 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6280 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6281 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6283 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6284 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6285 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6287 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6291 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
6293 * Unmute ADC0 and set the default input to mic-in
6295 /* port-A for surround (rear panel) */
6296 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6297 /* port-B for mic-in (rear panel) with vref */
6298 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6299 /* port-C for line-in (rear panel) */
6300 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6301 /* port-D for Front */
6302 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
6303 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
6304 /* port-E for HP out (front panel) */
6305 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
6306 /* route front PCM to HP */
6307 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
6308 /* port-F for mic-in (front panel) with vref */
6309 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6310 /* port-G for CLFE (rear panel) */
6311 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6312 /* port-H for side (rear panel) */
6313 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6315 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6316 /* route front mic to ADC1*/
6317 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6318 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6319 /* Unmute DAC0~3 & spdif out*/
6320 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6321 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6322 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6323 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6324 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6326 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6327 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6328 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6329 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6330 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6332 /* Unmute Stereo Mixer 15 */
6333 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6334 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
6338 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6339 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6340 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6341 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6342 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6343 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6344 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6345 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
6347 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6352 * generic initialization of ADC, input mixers and output mixers
6354 static struct hda_verb alc861_auto_init_verbs[] = {
6356 * Unmute ADC0 and set the default input to mic-in
6358 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6359 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6361 /* Unmute DAC0~3 & spdif out*/
6362 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6363 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6364 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6365 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6368 /* Unmute Mixer 14 (mic) 1c (Line in)*/
6369 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6370 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6371 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6372 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6374 /* Unmute Stereo Mixer 15 */
6375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6376 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6378 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
6380 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6381 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6382 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6383 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6384 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6386 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6387 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6389 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6390 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6393 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6394 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6395 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6396 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
6398 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
6403 /* pcm configuration: identiacal with ALC880 */
6404 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
6405 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
6406 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
6407 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
6410 #define ALC861_DIGOUT_NID 0x07
6412 static struct hda_channel_mode alc861_8ch_modes[1] = {
6416 static hda_nid_t alc861_dac_nids[4] = {
6417 /* front, surround, clfe, side */
6418 0x03, 0x06, 0x05, 0x04
6421 static hda_nid_t alc660_dac_nids[3] = {
6422 /* front, clfe, surround */
6426 static hda_nid_t alc861_adc_nids[1] = {
6431 static struct hda_input_mux alc861_capture_source = {
6435 { "Front Mic", 0x3 },
6442 /* fill in the dac_nids table from the parsed pin configuration */
6443 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6448 spec->multiout.dac_nids = spec->private_dac_nids;
6449 for (i = 0; i < cfg->line_outs; i++) {
6450 nid = cfg->line_out_pins[i];
6452 if (i >= ARRAY_SIZE(alc861_dac_nids))
6454 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
6457 spec->multiout.num_dacs = cfg->line_outs;
6461 /* add playback controls from the parsed DAC table */
6462 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
6463 const struct auto_pin_cfg *cfg)
6466 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
6470 for (i = 0; i < cfg->line_outs; i++) {
6471 nid = spec->multiout.dac_nids[i];
6476 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
6477 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
6479 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
6480 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
6483 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
6484 if (nid == alc861_dac_nids[idx])
6486 sprintf(name, "%s Playback Switch", chname[idx]);
6487 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
6488 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6495 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
6503 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
6505 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
6506 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
6508 spec->multiout.hp_nid = nid;
6513 /* create playback/capture controls for input pins */
6514 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
6516 struct hda_input_mux *imux = &spec->private_imux;
6517 int i, err, idx, idx1;
6519 for (i = 0; i < AUTO_PIN_LAST; i++) {
6520 switch(cfg->input_pins[i]) {
6545 err = new_analog_input(spec, cfg->input_pins[i],
6546 auto_pin_cfg_labels[i], idx, 0x15);
6550 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
6551 imux->items[imux->num_items].index = idx1;
6557 static struct snd_kcontrol_new alc861_capture_mixer[] = {
6558 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6559 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6562 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6563 /* The multiple "Capture Source" controls confuse alsamixer
6564 * So call somewhat different..
6565 *FIXME: the controls appear in the "playback" view!
6567 /* .name = "Capture Source", */
6568 .name = "Input Source",
6570 .info = alc_mux_enum_info,
6571 .get = alc_mux_enum_get,
6572 .put = alc_mux_enum_put,
6577 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
6578 int pin_type, int dac_idx)
6582 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
6583 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
6587 static void alc861_auto_init_multi_out(struct hda_codec *codec)
6589 struct alc_spec *spec = codec->spec;
6592 for (i = 0; i < spec->autocfg.line_outs; i++) {
6593 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6595 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
6599 static void alc861_auto_init_hp_out(struct hda_codec *codec)
6601 struct alc_spec *spec = codec->spec;
6604 pin = spec->autocfg.hp_pin;
6605 if (pin) /* connect to front */
6606 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
6609 static void alc861_auto_init_analog_input(struct hda_codec *codec)
6611 struct alc_spec *spec = codec->spec;
6614 for (i = 0; i < AUTO_PIN_LAST; i++) {
6615 hda_nid_t nid = spec->autocfg.input_pins[i];
6616 if ((nid>=0x0c) && (nid <=0x11)) {
6617 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6618 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
6623 /* parse the BIOS configuration and set up the alc_spec */
6624 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
6625 static int alc861_parse_auto_config(struct hda_codec *codec)
6627 struct alc_spec *spec = codec->spec;
6629 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
6631 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6632 alc861_ignore)) < 0)
6634 if (! spec->autocfg.line_outs)
6635 return 0; /* can't find valid BIOS pin config */
6637 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
6638 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
6639 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
6640 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
6643 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
6645 if (spec->autocfg.dig_out_pin)
6646 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
6648 if (spec->kctl_alloc)
6649 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
6651 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
6653 spec->num_mux_defs = 1;
6654 spec->input_mux = &spec->private_imux;
6656 spec->adc_nids = alc861_adc_nids;
6657 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
6658 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
6664 /* additional initialization for auto-configuration model */
6665 static void alc861_auto_init(struct hda_codec *codec)
6667 alc861_auto_init_multi_out(codec);
6668 alc861_auto_init_hp_out(codec);
6669 alc861_auto_init_analog_input(codec);
6674 * configuration and preset
6676 static struct hda_board_config alc861_cfg_tbl[] = {
6677 { .modelname = "3stack", .config = ALC861_3ST },
6678 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
6679 .config = ALC861_3ST },
6680 { .modelname = "3stack-660", .config = ALC660_3ST },
6681 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
6682 .config = ALC660_3ST },
6683 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
6684 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
6685 { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
6686 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
6687 .config = ALC861_UNIWILL_M31 },
6688 { .modelname = "auto", .config = ALC861_AUTO },
6692 static struct alc_config_preset alc861_presets[] = {
6694 .mixers = { alc861_3ST_mixer },
6695 .init_verbs = { alc861_threestack_init_verbs },
6696 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6697 .dac_nids = alc861_dac_nids,
6698 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6699 .channel_mode = alc861_threestack_modes,
6701 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6702 .adc_nids = alc861_adc_nids,
6703 .input_mux = &alc861_capture_source,
6705 [ALC861_3ST_DIG] = {
6706 .mixers = { alc861_base_mixer },
6707 .init_verbs = { alc861_threestack_init_verbs },
6708 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6709 .dac_nids = alc861_dac_nids,
6710 .dig_out_nid = ALC861_DIGOUT_NID,
6711 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6712 .channel_mode = alc861_threestack_modes,
6714 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6715 .adc_nids = alc861_adc_nids,
6716 .input_mux = &alc861_capture_source,
6718 [ALC861_6ST_DIG] = {
6719 .mixers = { alc861_base_mixer },
6720 .init_verbs = { alc861_base_init_verbs },
6721 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6722 .dac_nids = alc861_dac_nids,
6723 .dig_out_nid = ALC861_DIGOUT_NID,
6724 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
6725 .channel_mode = alc861_8ch_modes,
6726 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6727 .adc_nids = alc861_adc_nids,
6728 .input_mux = &alc861_capture_source,
6731 .mixers = { alc861_3ST_mixer },
6732 .init_verbs = { alc861_threestack_init_verbs },
6733 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
6734 .dac_nids = alc660_dac_nids,
6735 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
6736 .channel_mode = alc861_threestack_modes,
6738 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6739 .adc_nids = alc861_adc_nids,
6740 .input_mux = &alc861_capture_source,
6742 [ALC861_UNIWILL_M31] = {
6743 .mixers = { alc861_uniwill_m31_mixer },
6744 .init_verbs = { alc861_uniwill_m31_init_verbs },
6745 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
6746 .dac_nids = alc861_dac_nids,
6747 .dig_out_nid = ALC861_DIGOUT_NID,
6748 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
6749 .channel_mode = alc861_uniwill_m31_modes,
6751 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
6752 .adc_nids = alc861_adc_nids,
6753 .input_mux = &alc861_capture_source,
6759 static int patch_alc861(struct hda_codec *codec)
6761 struct alc_spec *spec;
6765 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
6771 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
6773 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
6774 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
6775 "trying auto-probe from BIOS...\n");
6776 board_config = ALC861_AUTO;
6779 if (board_config == ALC861_AUTO) {
6780 /* automatic parse from the BIOS config */
6781 err = alc861_parse_auto_config(codec);
6787 "hda_codec: Cannot set up configuration "
6788 "from BIOS. Using base mode...\n");
6789 board_config = ALC861_3ST_DIG;
6793 if (board_config != ALC861_AUTO)
6794 setup_preset(spec, &alc861_presets[board_config]);
6796 spec->stream_name_analog = "ALC861 Analog";
6797 spec->stream_analog_playback = &alc861_pcm_analog_playback;
6798 spec->stream_analog_capture = &alc861_pcm_analog_capture;
6800 spec->stream_name_digital = "ALC861 Digital";
6801 spec->stream_digital_playback = &alc861_pcm_digital_playback;
6802 spec->stream_digital_capture = &alc861_pcm_digital_capture;
6804 codec->patch_ops = alc_patch_ops;
6805 if (board_config == ALC861_AUTO)
6806 spec->init_hook = alc861_auto_init;
6814 struct hda_codec_preset snd_hda_preset_realtek[] = {
6815 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
6816 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
6817 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
6818 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
6819 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
6820 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
6821 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
6822 { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
6823 .patch = patch_alc861 },
6824 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
6825 .patch = patch_alc861 },