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 */
82 ALC262_MODEL_LAST /* last tag */
103 #define GPIO_MASK 0x03
106 /* codec parameterization */
107 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
108 unsigned int num_mixers;
110 const struct hda_verb *init_verbs[5]; /* initialization verbs
111 * don't forget NULL termination!
113 unsigned int num_init_verbs;
115 char *stream_name_analog; /* analog PCM stream */
116 struct hda_pcm_stream *stream_analog_playback;
117 struct hda_pcm_stream *stream_analog_capture;
119 char *stream_name_digital; /* digital PCM stream */
120 struct hda_pcm_stream *stream_digital_playback;
121 struct hda_pcm_stream *stream_digital_capture;
124 struct hda_multi_out multiout; /* playback set-up
125 * max_channels, dacs must be set
126 * dig_out_nid and hp_nid are optional
130 unsigned int num_adc_nids;
132 hda_nid_t dig_in_nid; /* digital-in NID; optional */
135 const struct hda_input_mux *input_mux;
136 unsigned int cur_mux[3];
139 const struct hda_channel_mode *channel_mode;
140 int num_channel_mode;
142 /* PCM information */
143 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
145 /* dynamic controls, init_verbs and input_mux */
146 struct auto_pin_cfg autocfg;
147 unsigned int num_kctl_alloc, num_kctl_used;
148 struct snd_kcontrol_new *kctl_alloc;
149 struct hda_input_mux private_imux;
150 hda_nid_t private_dac_nids[5];
153 void (*init_hook)(struct hda_codec *codec);
154 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
156 /* for pin sensing */
157 unsigned int sense_updated: 1;
158 unsigned int jack_present: 1;
162 * configuration template - to be copied to the spec instance
164 struct alc_config_preset {
165 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
166 const struct hda_verb *init_verbs[5];
167 unsigned int num_dacs;
169 hda_nid_t dig_out_nid; /* optional */
170 hda_nid_t hp_nid; /* optional */
171 unsigned int num_adc_nids;
173 hda_nid_t dig_in_nid;
174 unsigned int num_channel_mode;
175 const struct hda_channel_mode *channel_mode;
176 const struct hda_input_mux *input_mux;
177 void (*unsol_event)(struct hda_codec *, unsigned int);
178 void (*init_hook)(struct hda_codec *);
185 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
187 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
188 struct alc_spec *spec = codec->spec;
189 return snd_hda_input_mux_info(spec->input_mux, uinfo);
192 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
194 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
195 struct alc_spec *spec = codec->spec;
196 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
198 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
202 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
204 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
205 struct alc_spec *spec = codec->spec;
206 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
207 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
208 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
213 * channel mode setting
215 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
217 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
218 struct alc_spec *spec = codec->spec;
219 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
220 spec->num_channel_mode);
223 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
225 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
226 struct alc_spec *spec = codec->spec;
227 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
228 spec->num_channel_mode, spec->multiout.max_channels);
231 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
233 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
234 struct alc_spec *spec = codec->spec;
235 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
236 spec->num_channel_mode, &spec->multiout.max_channels);
240 * Control the mode of pin widget settings via the mixer. "pc" is used
241 * instead of "%" to avoid consequences of accidently treating the % as
242 * being part of a format specifier. Maximum allowed length of a value is
243 * 63 characters plus NULL terminator.
245 * Note: some retasking pin complexes seem to ignore requests for input
246 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
247 * are requested. Therefore order this list so that this behaviour will not
248 * cause problems when mixer clients move through the enum sequentially.
249 * NIDs 0x0f and 0x10 have been observed to have this behaviour.
251 static char *alc_pin_mode_names[] = {
252 "Mic 50pc bias", "Mic 80pc bias",
253 "Line in", "Line out", "Headphone out",
255 static unsigned char alc_pin_mode_values[] = {
256 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
258 /* The control can present all 5 options, or it can limit the options based
259 * in the pin being assumed to be exclusively an input or an output pin.
261 #define ALC_PIN_DIR_IN 0x00
262 #define ALC_PIN_DIR_OUT 0x01
263 #define ALC_PIN_DIR_INOUT 0x02
265 /* Info about the pin modes supported by the three different pin directions.
266 * For each direction the minimum and maximum values are given.
268 static signed char alc_pin_mode_dir_info[3][2] = {
269 { 0, 2 }, /* ALC_PIN_DIR_IN */
270 { 3, 4 }, /* ALC_PIN_DIR_OUT */
271 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
273 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
274 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
275 #define alc_pin_mode_n_items(_dir) \
276 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
278 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
280 unsigned int item_num = uinfo->value.enumerated.item;
281 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
283 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
285 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
287 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
288 item_num = alc_pin_mode_min(dir);
289 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
293 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
297 hda_nid_t nid = kcontrol->private_value & 0xffff;
298 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
299 long *valp = ucontrol->value.integer.value;
300 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
302 /* Find enumerated value for current pinctl setting */
303 i = alc_pin_mode_min(dir);
304 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
306 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
310 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 hda_nid_t nid = kcontrol->private_value & 0xffff;
315 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
316 long val = *ucontrol->value.integer.value;
317 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
319 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
320 val = alc_pin_mode_min(dir);
322 change = pinctl != alc_pin_mode_values[val];
324 /* Set pin mode to that requested */
325 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
326 alc_pin_mode_values[val]);
328 /* Also enable the retasking pin's input/output as required
329 * for the requested pin mode. Enum values of 2 or less are
332 * Dynamically switching the input/output buffers probably
333 * reduces noise slightly, particularly on input. However,
334 * havingboth input and output buffers enabled
335 * simultaneously doesn't seem to be problematic.
338 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
340 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
343 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
345 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
352 #define ALC_PIN_MODE(xname, nid, dir) \
353 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
354 .info = alc_pin_mode_info, \
355 .get = alc_pin_mode_get, \
356 .put = alc_pin_mode_put, \
357 .private_value = nid | (dir<<16) }
359 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
360 * together using a mask with more than one bit set. This control is
361 * currently used only by the ALC260 test model. At this stage they are not
362 * needed for any "production" models.
364 #ifdef CONFIG_SND_DEBUG
365 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
367 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
369 uinfo->value.integer.min = 0;
370 uinfo->value.integer.max = 1;
373 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
376 hda_nid_t nid = kcontrol->private_value & 0xffff;
377 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
378 long *valp = ucontrol->value.integer.value;
379 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
381 *valp = (val & mask) != 0;
384 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
388 hda_nid_t nid = kcontrol->private_value & 0xffff;
389 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
390 long val = *ucontrol->value.integer.value;
391 unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
393 /* Set/unset the masked GPIO bit(s) as needed */
394 change = (val==0?0:mask) != (gpio_data & mask);
399 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data);
403 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
404 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
405 .info = alc_gpio_data_info, \
406 .get = alc_gpio_data_get, \
407 .put = alc_gpio_data_put, \
408 .private_value = nid | (mask<<16) }
409 #endif /* CONFIG_SND_DEBUG */
411 /* A switch control to allow the enabling of the digital IO pins on the
412 * ALC260. This is incredibly simplistic; the intention of this control is
413 * to provide something in the test model allowing digital outputs to be
414 * identified if present. If models are found which can utilise these
415 * outputs a more complete mixer control can be devised for those models if
418 #ifdef CONFIG_SND_DEBUG
419 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
421 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
423 uinfo->value.integer.min = 0;
424 uinfo->value.integer.max = 1;
427 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
429 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
430 hda_nid_t nid = kcontrol->private_value & 0xffff;
431 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
432 long *valp = ucontrol->value.integer.value;
433 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
435 *valp = (val & mask) != 0;
438 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
442 hda_nid_t nid = kcontrol->private_value & 0xffff;
443 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
444 long val = *ucontrol->value.integer.value;
445 unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
447 /* Set/unset the masked control bit(s) as needed */
448 change = (val==0?0:mask) != (ctrl_data & mask);
453 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
457 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
458 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
459 .info = alc_spdif_ctrl_info, \
460 .get = alc_spdif_ctrl_get, \
461 .put = alc_spdif_ctrl_put, \
462 .private_value = nid | (mask<<16) }
463 #endif /* CONFIG_SND_DEBUG */
466 * set up from the preset table
468 static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
472 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
473 spec->mixers[spec->num_mixers++] = preset->mixers[i];
474 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
475 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
477 spec->channel_mode = preset->channel_mode;
478 spec->num_channel_mode = preset->num_channel_mode;
480 spec->multiout.max_channels = spec->channel_mode[0].channels;
482 spec->multiout.num_dacs = preset->num_dacs;
483 spec->multiout.dac_nids = preset->dac_nids;
484 spec->multiout.dig_out_nid = preset->dig_out_nid;
485 spec->multiout.hp_nid = preset->hp_nid;
487 spec->input_mux = preset->input_mux;
489 spec->num_adc_nids = preset->num_adc_nids;
490 spec->adc_nids = preset->adc_nids;
491 spec->dig_in_nid = preset->dig_in_nid;
493 spec->unsol_event = preset->unsol_event;
494 spec->init_hook = preset->init_hook;
498 * ALC880 3-stack model
500 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
501 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
505 static hda_nid_t alc880_dac_nids[4] = {
506 /* front, rear, clfe, rear_surr */
507 0x02, 0x05, 0x04, 0x03
510 static hda_nid_t alc880_adc_nids[3] = {
515 /* The datasheet says the node 0x07 is connected from inputs,
516 * but it shows zero connection in the real implementation on some devices.
517 * Note: this is a 915GAV bug, fixed on 915GLV
519 static hda_nid_t alc880_adc_nids_alt[2] = {
524 #define ALC880_DIGOUT_NID 0x06
525 #define ALC880_DIGIN_NID 0x0a
527 static struct hda_input_mux alc880_capture_source = {
531 { "Front Mic", 0x3 },
537 /* channel source setting (2/6 channel selection for 3-stack) */
539 static struct hda_verb alc880_threestack_ch2_init[] = {
540 /* set line-in to input, mute it */
541 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
542 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
543 /* set mic-in to input vref 80%, mute it */
544 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
545 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
550 static struct hda_verb alc880_threestack_ch6_init[] = {
551 /* set line-in to output, unmute it */
552 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
553 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
554 /* set mic-in to output, unmute it */
555 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
556 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
560 static struct hda_channel_mode alc880_threestack_modes[2] = {
561 { 2, alc880_threestack_ch2_init },
562 { 6, alc880_threestack_ch6_init },
565 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
567 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
569 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
570 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
571 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
572 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
573 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
576 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
577 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
578 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
580 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
582 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
583 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
587 .name = "Channel Mode",
588 .info = alc_ch_mode_info,
589 .get = alc_ch_mode_get,
590 .put = alc_ch_mode_put,
595 /* capture mixer elements */
596 static struct snd_kcontrol_new alc880_capture_mixer[] = {
597 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
598 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
599 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
600 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
601 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
602 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
605 /* The multiple "Capture Source" controls confuse alsamixer
606 * So call somewhat different..
607 * FIXME: the controls appear in the "playback" view!
609 /* .name = "Capture Source", */
610 .name = "Input Source",
612 .info = alc_mux_enum_info,
613 .get = alc_mux_enum_get,
614 .put = alc_mux_enum_put,
619 /* capture mixer elements (in case NID 0x07 not available) */
620 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
621 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
622 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
623 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
624 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
626 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
627 /* The multiple "Capture Source" controls confuse alsamixer
628 * So call somewhat different..
629 * FIXME: the controls appear in the "playback" view!
631 /* .name = "Capture Source", */
632 .name = "Input Source",
634 .info = alc_mux_enum_info,
635 .get = alc_mux_enum_get,
636 .put = alc_mux_enum_put,
644 * ALC880 5-stack model
646 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
647 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
648 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
651 /* additional mixers to alc880_three_stack_mixer */
652 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
653 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
654 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
658 /* channel source setting (6/8 channel selection for 5-stack) */
660 static struct hda_verb alc880_fivestack_ch6_init[] = {
661 /* set line-in to input, mute it */
662 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
663 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
668 static struct hda_verb alc880_fivestack_ch8_init[] = {
669 /* set line-in to output, unmute it */
670 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
671 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
675 static struct hda_channel_mode alc880_fivestack_modes[2] = {
676 { 6, alc880_fivestack_ch6_init },
677 { 8, alc880_fivestack_ch8_init },
682 * ALC880 6-stack model
684 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
685 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
686 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
689 static hda_nid_t alc880_6st_dac_nids[4] = {
690 /* front, rear, clfe, rear_surr */
691 0x02, 0x03, 0x04, 0x05
694 static struct hda_input_mux alc880_6stack_capture_source = {
698 { "Front Mic", 0x1 },
704 /* fixed 8-channels */
705 static struct hda_channel_mode alc880_sixstack_modes[1] = {
709 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
710 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
711 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
712 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
713 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
714 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
715 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
716 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
717 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
718 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
719 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
720 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
721 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
726 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
727 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
728 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
729 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
731 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
732 .name = "Channel Mode",
733 .info = alc_ch_mode_info,
734 .get = alc_ch_mode_get,
735 .put = alc_ch_mode_put,
744 * W810 has rear IO for:
747 * Center/LFE (DAC 04)
750 * The system also has a pair of internal speakers, and a headphone jack.
751 * These are both connected to Line2 on the codec, hence to DAC 02.
753 * There is a variable resistor to control the speaker or headphone
754 * volume. This is a hardware-only device without a software API.
756 * Plugging headphones in will disable the internal speakers. This is
757 * implemented in hardware, not via the driver using jack sense. In
758 * a similar fashion, plugging into the rear socket marked "front" will
759 * disable both the speakers and headphones.
761 * For input, there's a microphone jack, and an "audio in" jack.
762 * These may not do anything useful with this driver yet, because I
763 * haven't setup any initialization verbs for these yet...
766 static hda_nid_t alc880_w810_dac_nids[3] = {
767 /* front, rear/surround, clfe */
771 /* fixed 6 channels */
772 static struct hda_channel_mode alc880_w810_modes[1] = {
776 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
777 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
778 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
781 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
784 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
785 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
794 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
795 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
798 static hda_nid_t alc880_z71v_dac_nids[1] = {
801 #define ALC880_Z71V_HP_DAC 0x03
803 /* fixed 2 channels */
804 static struct hda_channel_mode alc880_2_jack_modes[1] = {
808 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
809 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
810 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
811 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
812 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
825 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
826 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
829 static hda_nid_t alc880_f1734_dac_nids[1] = {
832 #define ALC880_F1734_HP_DAC 0x02
834 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
835 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
836 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
837 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
838 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
839 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
840 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
851 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
852 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
853 * Mic = 0x18, Line = 0x1a
856 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
857 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
859 static struct snd_kcontrol_new alc880_asus_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_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
876 .name = "Channel Mode",
877 .info = alc_ch_mode_info,
878 .get = alc_ch_mode_get,
879 .put = alc_ch_mode_put,
886 * ALC880 ASUS W1V model
888 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
889 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
890 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
893 /* additional mixers to alc880_asus_mixer */
894 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
895 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
896 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
900 /* additional mixers to alc880_asus_mixer */
901 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
902 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
903 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
908 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
909 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
910 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
912 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
913 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
916 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
917 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
919 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
920 /* The multiple "Capture Source" controls confuse alsamixer
921 * So call somewhat different..
922 * FIXME: the controls appear in the "playback" view!
924 /* .name = "Capture Source", */
925 .name = "Input Source",
927 .info = alc_mux_enum_info,
928 .get = alc_mux_enum_get,
929 .put = alc_mux_enum_put,
935 * build control elements
937 static int alc_build_controls(struct hda_codec *codec)
939 struct alc_spec *spec = codec->spec;
943 for (i = 0; i < spec->num_mixers; i++) {
944 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
949 if (spec->multiout.dig_out_nid) {
950 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
954 if (spec->dig_in_nid) {
955 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
964 * initialize the codec volumes, etc
968 * generic initialization of ADC, input mixers and output mixers
970 static struct hda_verb alc880_volume_init_verbs[] = {
972 * Unmute ADC0-2 and set the default input to mic-in
974 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
976 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
977 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
978 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
979 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
981 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
983 * Note: PASD motherboards uses the Line In 2 as the input for front panel
986 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
994 * Set up output mixers (0x0c - 0x0f)
996 /* set vol=0 to output mixers */
997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1001 /* set up input amps for analog loopback */
1002 /* Amp Indices: DAC = 0, mixer = 1 */
1003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1005 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1007 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1009 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1010 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1016 * 3-stack pin configuration:
1017 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1019 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1021 * preset connection lists of input pins
1022 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1024 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1025 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1026 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1029 * Set pin mode and muting
1031 /* set front pin widgets 0x14 for output */
1032 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1034 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1035 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1037 /* Mic2 (as headphone out) for HP output */
1038 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1039 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1040 /* Line In pin widget for input */
1041 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1042 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1043 /* Line2 (as front mic) pin widget for input and vref at 80% */
1044 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1046 /* CD pin widget for input */
1047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1053 * 5-stack pin configuration:
1054 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1055 * line-in/side = 0x1a, f-mic = 0x1b
1057 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1059 * preset connection lists of input pins
1060 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1062 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1063 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1066 * Set pin mode and muting
1068 /* set pin widgets 0x14-0x17 for output */
1069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1071 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1072 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1073 /* unmute pins for output (no gain on this amp) */
1074 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1079 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1080 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1081 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1082 /* Mic2 (as headphone out) for HP output */
1083 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1084 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1085 /* Line In pin widget for input */
1086 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1088 /* Line2 (as front mic) pin widget for input and vref at 80% */
1089 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1090 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1091 /* CD pin widget for input */
1092 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1098 * W810 pin configuration:
1099 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1101 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1102 /* hphone/speaker input selector: front DAC */
1103 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1105 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1106 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1109 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1110 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1112 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1113 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1119 * Z71V pin configuration:
1120 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1122 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1124 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1128 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1129 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1130 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1131 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1137 * 6-stack pin configuration:
1138 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
1139 * line = 0x1a, HP = 0x1b
1141 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1142 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1145 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1146 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1148 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1149 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1150 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1151 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1154 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1155 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1156 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1157 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1158 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1159 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1160 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1161 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1168 * F1734 pin configuration:
1169 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1171 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1172 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1173 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1174 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1175 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1178 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1180 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1182 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1184 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1185 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1186 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1187 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1188 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1189 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1190 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1197 * ASUS pin configuration:
1198 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1200 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1201 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1202 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1203 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1204 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1209 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1211 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1212 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1213 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1215 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1217 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1219 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1221 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1222 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1223 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1228 /* Enable GPIO mask and set output */
1229 static struct hda_verb alc880_gpio1_init_verbs[] = {
1230 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1231 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1232 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1237 /* Enable GPIO mask and set output */
1238 static struct hda_verb alc880_gpio2_init_verbs[] = {
1239 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1240 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1241 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1246 /* Clevo m520g init */
1247 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1248 /* headphone output */
1249 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1257 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1258 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1259 /* Mic1 (rear panel) */
1260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1262 /* Mic2 (front panel) */
1263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1266 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1268 /* change to EAPD mode */
1269 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1270 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1275 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1276 /* Headphone output */
1277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1279 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1280 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1282 /* Line In pin widget for input */
1283 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1284 /* CD pin widget for input */
1285 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1286 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1287 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1289 /* change to EAPD mode */
1290 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1291 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1297 * LG m1 express dual
1300 * Rear Line-In/Out (blue): 0x14
1301 * Build-in Mic-In: 0x15
1303 * HP-Out (green): 0x1b
1304 * Mic-In/Out (red): 0x19
1308 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1309 static hda_nid_t alc880_lg_dac_nids[3] = {
1313 /* seems analog CD is not working */
1314 static struct hda_input_mux alc880_lg_capture_source = {
1319 { "Internal Mic", 0x6 },
1323 /* 2,4,6 channel modes */
1324 static struct hda_verb alc880_lg_ch2_init[] = {
1325 /* set line-in and mic-in to input */
1326 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1327 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1331 static struct hda_verb alc880_lg_ch4_init[] = {
1332 /* set line-in to out and mic-in to input */
1333 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1334 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1338 static struct hda_verb alc880_lg_ch6_init[] = {
1339 /* set line-in and mic-in to output */
1340 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1341 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1345 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1346 { 2, alc880_lg_ch2_init },
1347 { 4, alc880_lg_ch4_init },
1348 { 6, alc880_lg_ch6_init },
1351 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1352 /* FIXME: it's not really "master" but front channels */
1353 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1354 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1355 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1356 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1357 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1358 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1359 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1360 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1363 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1364 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1365 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1366 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1369 .name = "Channel Mode",
1370 .info = alc_ch_mode_info,
1371 .get = alc_ch_mode_get,
1372 .put = alc_ch_mode_put,
1377 static struct hda_verb alc880_lg_init_verbs[] = {
1378 /* set capture source to mic-in */
1379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1380 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1382 /* mute all amp mixer inputs */
1383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1386 /* line-in to input */
1387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1393 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1394 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 /* mic-in to input */
1396 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1398 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1400 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1401 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1402 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1404 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1408 /* toggle speaker-output according to the hp-jack state */
1409 static void alc880_lg_automute(struct hda_codec *codec)
1411 unsigned int present;
1413 present = snd_hda_codec_read(codec, 0x1b, 0,
1414 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1415 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1416 0x80, present ? 0x80 : 0);
1417 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1418 0x80, present ? 0x80 : 0);
1421 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1423 /* Looks like the unsol event is incompatible with the standard
1424 * definition. 4bit tag is placed at 28 bit!
1426 if ((res >> 28) == 0x01)
1427 alc880_lg_automute(codec);
1436 * Built-in Mic-In: 0x19 (?)
1441 /* seems analog CD is not working */
1442 static struct hda_input_mux alc880_lg_lw_capture_source = {
1446 { "Internal Mic", 0x1 },
1450 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1451 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1452 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1455 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1456 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1460 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1461 /* set capture source to mic-in */
1462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1465 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1472 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473 /* mic-in to input */
1474 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1475 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1478 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1480 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1484 /* toggle speaker-output according to the hp-jack state */
1485 static void alc880_lg_lw_automute(struct hda_codec *codec)
1487 unsigned int present;
1489 present = snd_hda_codec_read(codec, 0x1b, 0,
1490 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1491 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1492 0x80, present ? 0x80 : 0);
1493 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1494 0x80, present ? 0x80 : 0);
1497 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1499 /* Looks like the unsol event is incompatible with the standard
1500 * definition. 4bit tag is placed at 28 bit!
1502 if ((res >> 28) == 0x01)
1503 alc880_lg_lw_automute(codec);
1510 static int alc_init(struct hda_codec *codec)
1512 struct alc_spec *spec = codec->spec;
1515 for (i = 0; i < spec->num_init_verbs; i++)
1516 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1518 if (spec->init_hook)
1519 spec->init_hook(codec);
1524 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1526 struct alc_spec *spec = codec->spec;
1528 if (spec->unsol_event)
1529 spec->unsol_event(codec, res);
1536 static int alc_resume(struct hda_codec *codec)
1538 struct alc_spec *spec = codec->spec;
1542 for (i = 0; i < spec->num_mixers; i++)
1543 snd_hda_resume_ctls(codec, spec->mixers[i]);
1544 if (spec->multiout.dig_out_nid)
1545 snd_hda_resume_spdif_out(codec);
1546 if (spec->dig_in_nid)
1547 snd_hda_resume_spdif_in(codec);
1554 * Analog playback callbacks
1556 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1557 struct hda_codec *codec,
1558 struct snd_pcm_substream *substream)
1560 struct alc_spec *spec = codec->spec;
1561 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1564 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1565 struct hda_codec *codec,
1566 unsigned int stream_tag,
1567 unsigned int format,
1568 struct snd_pcm_substream *substream)
1570 struct alc_spec *spec = codec->spec;
1571 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1575 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1576 struct hda_codec *codec,
1577 struct snd_pcm_substream *substream)
1579 struct alc_spec *spec = codec->spec;
1580 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1586 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1587 struct hda_codec *codec,
1588 struct snd_pcm_substream *substream)
1590 struct alc_spec *spec = codec->spec;
1591 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1594 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1595 struct hda_codec *codec,
1596 struct snd_pcm_substream *substream)
1598 struct alc_spec *spec = codec->spec;
1599 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1605 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1606 struct hda_codec *codec,
1607 unsigned int stream_tag,
1608 unsigned int format,
1609 struct snd_pcm_substream *substream)
1611 struct alc_spec *spec = codec->spec;
1613 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1614 stream_tag, 0, format);
1618 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1619 struct hda_codec *codec,
1620 struct snd_pcm_substream *substream)
1622 struct alc_spec *spec = codec->spec;
1624 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1631 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1635 /* NID is set in alc_build_pcms */
1637 .open = alc880_playback_pcm_open,
1638 .prepare = alc880_playback_pcm_prepare,
1639 .cleanup = alc880_playback_pcm_cleanup
1643 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1647 /* NID is set in alc_build_pcms */
1649 .prepare = alc880_capture_pcm_prepare,
1650 .cleanup = alc880_capture_pcm_cleanup
1654 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1658 /* NID is set in alc_build_pcms */
1660 .open = alc880_dig_playback_pcm_open,
1661 .close = alc880_dig_playback_pcm_close
1665 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1669 /* NID is set in alc_build_pcms */
1672 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1673 static struct hda_pcm_stream alc_pcm_null_playback = {
1679 static int alc_build_pcms(struct hda_codec *codec)
1681 struct alc_spec *spec = codec->spec;
1682 struct hda_pcm *info = spec->pcm_rec;
1685 codec->num_pcms = 1;
1686 codec->pcm_info = info;
1688 info->name = spec->stream_name_analog;
1689 if (spec->stream_analog_playback) {
1690 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1691 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1692 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1694 if (spec->stream_analog_capture) {
1695 snd_assert(spec->adc_nids, return -EINVAL);
1696 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1697 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1700 if (spec->channel_mode) {
1701 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1702 for (i = 0; i < spec->num_channel_mode; i++) {
1703 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1704 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1709 /* If the use of more than one ADC is requested for the current
1710 * model, configure a second analog capture-only PCM.
1712 if (spec->num_adc_nids > 1) {
1715 info->name = spec->stream_name_analog;
1716 /* No playback stream for second PCM */
1717 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1718 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1719 if (spec->stream_analog_capture) {
1720 snd_assert(spec->adc_nids, return -EINVAL);
1721 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1722 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1726 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1729 info->name = spec->stream_name_digital;
1730 if (spec->multiout.dig_out_nid &&
1731 spec->stream_digital_playback) {
1732 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1733 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1735 if (spec->dig_in_nid &&
1736 spec->stream_digital_capture) {
1737 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1738 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1745 static void alc_free(struct hda_codec *codec)
1747 struct alc_spec *spec = codec->spec;
1753 if (spec->kctl_alloc) {
1754 for (i = 0; i < spec->num_kctl_used; i++)
1755 kfree(spec->kctl_alloc[i].name);
1756 kfree(spec->kctl_alloc);
1763 static struct hda_codec_ops alc_patch_ops = {
1764 .build_controls = alc_build_controls,
1765 .build_pcms = alc_build_pcms,
1768 .unsol_event = alc_unsol_event,
1770 .resume = alc_resume,
1776 * Test configuration for debugging
1778 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1781 #ifdef CONFIG_SND_DEBUG
1782 static hda_nid_t alc880_test_dac_nids[4] = {
1783 0x02, 0x03, 0x04, 0x05
1786 static struct hda_input_mux alc880_test_capture_source = {
1795 { "Surround", 0x6 },
1799 static struct hda_channel_mode alc880_test_modes[4] = {
1806 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1808 static char *texts[] = {
1809 "N/A", "Line Out", "HP Out",
1810 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1812 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1814 uinfo->value.enumerated.items = 8;
1815 if (uinfo->value.enumerated.item >= 8)
1816 uinfo->value.enumerated.item = 7;
1817 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1821 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1824 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1825 unsigned int pin_ctl, item = 0;
1827 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1828 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1829 if (pin_ctl & AC_PINCTL_OUT_EN) {
1830 if (pin_ctl & AC_PINCTL_HP_EN)
1834 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1835 switch (pin_ctl & AC_PINCTL_VREFEN) {
1836 case AC_PINCTL_VREF_HIZ: item = 3; break;
1837 case AC_PINCTL_VREF_50: item = 4; break;
1838 case AC_PINCTL_VREF_GRD: item = 5; break;
1839 case AC_PINCTL_VREF_80: item = 6; break;
1840 case AC_PINCTL_VREF_100: item = 7; break;
1843 ucontrol->value.enumerated.item[0] = item;
1847 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1849 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1850 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1851 static unsigned int ctls[] = {
1852 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1853 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1854 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1855 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1856 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1857 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1859 unsigned int old_ctl, new_ctl;
1861 old_ctl = snd_hda_codec_read(codec, nid, 0,
1862 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1863 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1864 if (old_ctl != new_ctl) {
1865 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1867 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1873 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1875 static char *texts[] = {
1876 "Front", "Surround", "CLFE", "Side"
1878 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1880 uinfo->value.enumerated.items = 4;
1881 if (uinfo->value.enumerated.item >= 4)
1882 uinfo->value.enumerated.item = 3;
1883 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1887 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1890 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1893 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1894 ucontrol->value.enumerated.item[0] = sel & 3;
1898 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1900 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1901 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1904 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1905 if (ucontrol->value.enumerated.item[0] != sel) {
1906 sel = ucontrol->value.enumerated.item[0] & 3;
1907 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1913 #define PIN_CTL_TEST(xname,nid) { \
1914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1916 .info = alc_test_pin_ctl_info, \
1917 .get = alc_test_pin_ctl_get, \
1918 .put = alc_test_pin_ctl_put, \
1919 .private_value = nid \
1922 #define PIN_SRC_TEST(xname,nid) { \
1923 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1925 .info = alc_test_pin_src_info, \
1926 .get = alc_test_pin_src_get, \
1927 .put = alc_test_pin_src_put, \
1928 .private_value = nid \
1931 static struct snd_kcontrol_new alc880_test_mixer[] = {
1932 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1933 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1934 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1935 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1936 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1937 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1938 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1939 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1940 PIN_CTL_TEST("Front Pin Mode", 0x14),
1941 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1942 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1943 PIN_CTL_TEST("Side Pin Mode", 0x17),
1944 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1945 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1946 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1947 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1948 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1949 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1950 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1951 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1952 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1953 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1954 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1955 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1956 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1957 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1958 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1959 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1960 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1961 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1963 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1964 .name = "Channel Mode",
1965 .info = alc_ch_mode_info,
1966 .get = alc_ch_mode_get,
1967 .put = alc_ch_mode_put,
1972 static struct hda_verb alc880_test_init_verbs[] = {
1973 /* Unmute inputs of 0x0c - 0x0f */
1974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1975 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1976 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1977 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1978 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1979 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1980 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1981 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1982 /* Vol output for 0x0c-0x0f */
1983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1984 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1985 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1986 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1987 /* Set output pins 0x14-0x17 */
1988 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1991 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1992 /* Unmute output pins 0x14-0x17 */
1993 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1994 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1995 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1997 /* Set input pins 0x18-0x1c */
1998 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1999 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2000 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2001 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2002 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2003 /* Mute input pins 0x18-0x1b */
2004 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2005 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2006 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2007 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2009 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2010 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2011 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2012 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2014 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2015 /* Analog input/passthru */
2016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2028 static struct hda_board_config alc880_cfg_tbl[] = {
2029 /* Back 3 jack, front 2 jack */
2030 { .modelname = "3stack", .config = ALC880_3ST },
2031 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2032 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2033 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2034 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2035 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2036 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2037 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2038 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2039 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2040 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2041 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2042 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2043 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2044 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2045 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2046 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2047 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2048 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2049 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2050 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2051 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2052 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2053 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2054 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2055 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2056 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2057 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2058 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2059 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2060 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2061 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2062 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2064 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2066 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2067 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2068 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2069 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2071 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2072 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2073 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2074 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2075 /* Clevo m520G NB */
2076 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
2078 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2079 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2080 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2081 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2083 /* Back 5 jack, front 2 jack */
2084 { .modelname = "5stack", .config = ALC880_5ST },
2085 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2086 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2087 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2088 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2089 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2091 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2092 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2093 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2094 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2095 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2096 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2097 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2098 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2099 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2100 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2101 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2102 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2103 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2104 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2105 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2106 /* note subvendor = 0 below */
2107 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2109 { .modelname = "w810", .config = ALC880_W810 },
2110 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2112 { .modelname = "z71v", .config = ALC880_Z71V },
2113 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2115 { .modelname = "6stack", .config = ALC880_6ST },
2116 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2117 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2118 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2119 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2121 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2122 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2123 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2124 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2125 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2126 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2127 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2128 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2129 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2130 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2131 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2133 { .modelname = "asus", .config = ALC880_ASUS },
2134 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2135 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2136 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2137 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2138 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2139 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2140 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2141 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2142 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2143 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2144 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2145 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2146 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2148 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2149 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2151 { .modelname = "F1734", .config = ALC880_F1734 },
2152 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2153 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2155 { .modelname = "lg", .config = ALC880_LG },
2156 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2158 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2159 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2161 #ifdef CONFIG_SND_DEBUG
2162 { .modelname = "test", .config = ALC880_TEST },
2164 { .modelname = "auto", .config = ALC880_AUTO },
2170 * ALC880 codec presets
2172 static struct alc_config_preset alc880_presets[] = {
2174 .mixers = { alc880_three_stack_mixer },
2175 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2176 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2177 .dac_nids = alc880_dac_nids,
2178 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2179 .channel_mode = alc880_threestack_modes,
2180 .input_mux = &alc880_capture_source,
2182 [ALC880_3ST_DIG] = {
2183 .mixers = { alc880_three_stack_mixer },
2184 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2185 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2186 .dac_nids = alc880_dac_nids,
2187 .dig_out_nid = ALC880_DIGOUT_NID,
2188 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2189 .channel_mode = alc880_threestack_modes,
2190 .input_mux = &alc880_capture_source,
2192 [ALC880_TCL_S700] = {
2193 .mixers = { alc880_tcl_s700_mixer },
2194 .init_verbs = { alc880_volume_init_verbs,
2195 alc880_pin_tcl_S700_init_verbs,
2196 alc880_gpio2_init_verbs },
2197 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2198 .dac_nids = alc880_dac_nids,
2200 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2201 .channel_mode = alc880_2_jack_modes,
2202 .input_mux = &alc880_capture_source,
2205 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2206 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2207 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2208 .dac_nids = alc880_dac_nids,
2209 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2210 .channel_mode = alc880_fivestack_modes,
2211 .input_mux = &alc880_capture_source,
2213 [ALC880_5ST_DIG] = {
2214 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2215 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2216 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2217 .dac_nids = alc880_dac_nids,
2218 .dig_out_nid = ALC880_DIGOUT_NID,
2219 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2220 .channel_mode = alc880_fivestack_modes,
2221 .input_mux = &alc880_capture_source,
2224 .mixers = { alc880_six_stack_mixer },
2225 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2226 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2227 .dac_nids = alc880_6st_dac_nids,
2228 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2229 .channel_mode = alc880_sixstack_modes,
2230 .input_mux = &alc880_6stack_capture_source,
2232 [ALC880_6ST_DIG] = {
2233 .mixers = { alc880_six_stack_mixer },
2234 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2235 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2236 .dac_nids = alc880_6st_dac_nids,
2237 .dig_out_nid = ALC880_DIGOUT_NID,
2238 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2239 .channel_mode = alc880_sixstack_modes,
2240 .input_mux = &alc880_6stack_capture_source,
2243 .mixers = { alc880_w810_base_mixer },
2244 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2245 alc880_gpio2_init_verbs },
2246 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2247 .dac_nids = alc880_w810_dac_nids,
2248 .dig_out_nid = ALC880_DIGOUT_NID,
2249 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2250 .channel_mode = alc880_w810_modes,
2251 .input_mux = &alc880_capture_source,
2254 .mixers = { alc880_z71v_mixer },
2255 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2256 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2257 .dac_nids = alc880_z71v_dac_nids,
2258 .dig_out_nid = ALC880_DIGOUT_NID,
2260 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2261 .channel_mode = alc880_2_jack_modes,
2262 .input_mux = &alc880_capture_source,
2265 .mixers = { alc880_f1734_mixer },
2266 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2267 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2268 .dac_nids = alc880_f1734_dac_nids,
2270 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2271 .channel_mode = alc880_2_jack_modes,
2272 .input_mux = &alc880_capture_source,
2275 .mixers = { alc880_asus_mixer },
2276 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2277 alc880_gpio1_init_verbs },
2278 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2279 .dac_nids = alc880_asus_dac_nids,
2280 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2281 .channel_mode = alc880_asus_modes,
2282 .input_mux = &alc880_capture_source,
2284 [ALC880_ASUS_DIG] = {
2285 .mixers = { alc880_asus_mixer },
2286 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2287 alc880_gpio1_init_verbs },
2288 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2289 .dac_nids = alc880_asus_dac_nids,
2290 .dig_out_nid = ALC880_DIGOUT_NID,
2291 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2292 .channel_mode = alc880_asus_modes,
2293 .input_mux = &alc880_capture_source,
2295 [ALC880_ASUS_DIG2] = {
2296 .mixers = { alc880_asus_mixer },
2297 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2298 alc880_gpio2_init_verbs }, /* use GPIO2 */
2299 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2300 .dac_nids = alc880_asus_dac_nids,
2301 .dig_out_nid = ALC880_DIGOUT_NID,
2302 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2303 .channel_mode = alc880_asus_modes,
2304 .input_mux = &alc880_capture_source,
2306 [ALC880_ASUS_W1V] = {
2307 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2308 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2309 alc880_gpio1_init_verbs },
2310 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2311 .dac_nids = alc880_asus_dac_nids,
2312 .dig_out_nid = ALC880_DIGOUT_NID,
2313 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2314 .channel_mode = alc880_asus_modes,
2315 .input_mux = &alc880_capture_source,
2317 [ALC880_UNIWILL_DIG] = {
2318 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2319 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2320 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2321 .dac_nids = alc880_asus_dac_nids,
2322 .dig_out_nid = ALC880_DIGOUT_NID,
2323 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2324 .channel_mode = alc880_asus_modes,
2325 .input_mux = &alc880_capture_source,
2328 .mixers = { alc880_three_stack_mixer },
2329 .init_verbs = { alc880_volume_init_verbs,
2330 alc880_pin_clevo_init_verbs },
2331 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2332 .dac_nids = alc880_dac_nids,
2334 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2335 .channel_mode = alc880_threestack_modes,
2336 .input_mux = &alc880_capture_source,
2339 .mixers = { alc880_lg_mixer },
2340 .init_verbs = { alc880_volume_init_verbs,
2341 alc880_lg_init_verbs },
2342 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2343 .dac_nids = alc880_lg_dac_nids,
2344 .dig_out_nid = ALC880_DIGOUT_NID,
2345 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2346 .channel_mode = alc880_lg_ch_modes,
2347 .input_mux = &alc880_lg_capture_source,
2348 .unsol_event = alc880_lg_unsol_event,
2349 .init_hook = alc880_lg_automute,
2352 .mixers = { alc880_lg_lw_mixer },
2353 .init_verbs = { alc880_volume_init_verbs,
2354 alc880_lg_lw_init_verbs },
2356 .dac_nids = alc880_dac_nids,
2357 .dig_out_nid = ALC880_DIGOUT_NID,
2358 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2359 .channel_mode = alc880_2_jack_modes,
2360 .input_mux = &alc880_lg_lw_capture_source,
2361 .unsol_event = alc880_lg_lw_unsol_event,
2362 .init_hook = alc880_lg_lw_automute,
2364 #ifdef CONFIG_SND_DEBUG
2366 .mixers = { alc880_test_mixer },
2367 .init_verbs = { alc880_test_init_verbs },
2368 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2369 .dac_nids = alc880_test_dac_nids,
2370 .dig_out_nid = ALC880_DIGOUT_NID,
2371 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2372 .channel_mode = alc880_test_modes,
2373 .input_mux = &alc880_test_capture_source,
2379 * Automatic parse of I/O pins from the BIOS configuration
2382 #define NUM_CONTROL_ALLOC 32
2383 #define NUM_VERB_ALLOC 32
2387 ALC_CTL_WIDGET_MUTE,
2390 static struct snd_kcontrol_new alc880_control_templates[] = {
2391 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2392 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2393 HDA_BIND_MUTE(NULL, 0, 0, 0),
2396 /* add dynamic controls */
2397 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2399 struct snd_kcontrol_new *knew;
2401 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2402 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2404 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2407 if (spec->kctl_alloc) {
2408 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2409 kfree(spec->kctl_alloc);
2411 spec->kctl_alloc = knew;
2412 spec->num_kctl_alloc = num;
2415 knew = &spec->kctl_alloc[spec->num_kctl_used];
2416 *knew = alc880_control_templates[type];
2417 knew->name = kstrdup(name, GFP_KERNEL);
2420 knew->private_value = val;
2421 spec->num_kctl_used++;
2425 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2426 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2427 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2428 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2429 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2430 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2431 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2432 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2433 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2434 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2435 #define ALC880_PIN_CD_NID 0x1c
2437 /* fill in the dac_nids table from the parsed pin configuration */
2438 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2444 memset(assigned, 0, sizeof(assigned));
2445 spec->multiout.dac_nids = spec->private_dac_nids;
2447 /* check the pins hardwired to audio widget */
2448 for (i = 0; i < cfg->line_outs; i++) {
2449 nid = cfg->line_out_pins[i];
2450 if (alc880_is_fixed_pin(nid)) {
2451 int idx = alc880_fixed_pin_idx(nid);
2452 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2456 /* left pins can be connect to any audio widget */
2457 for (i = 0; i < cfg->line_outs; i++) {
2458 nid = cfg->line_out_pins[i];
2459 if (alc880_is_fixed_pin(nid))
2461 /* search for an empty channel */
2462 for (j = 0; j < cfg->line_outs; j++) {
2463 if (! assigned[j]) {
2464 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2470 spec->multiout.num_dacs = cfg->line_outs;
2474 /* add playback controls from the parsed DAC table */
2475 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2476 const struct auto_pin_cfg *cfg)
2479 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2483 for (i = 0; i < cfg->line_outs; i++) {
2484 if (! spec->multiout.dac_nids[i])
2486 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2489 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2490 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2492 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2493 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2495 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2496 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2498 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2499 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2502 sprintf(name, "%s Playback Volume", chname[i]);
2503 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2504 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2506 sprintf(name, "%s Playback Switch", chname[i]);
2507 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2508 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2515 /* add playback controls for speaker and HP outputs */
2516 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2526 if (alc880_is_fixed_pin(pin)) {
2527 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2528 /* specify the DAC as the extra output */
2529 if (! spec->multiout.hp_nid)
2530 spec->multiout.hp_nid = nid;
2532 spec->multiout.extra_out_nid[0] = nid;
2533 /* control HP volume/switch on the output mixer amp */
2534 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2535 sprintf(name, "%s Playback Volume", pfx);
2536 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2537 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2539 sprintf(name, "%s Playback Switch", pfx);
2540 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2541 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2543 } else if (alc880_is_multi_pin(pin)) {
2544 /* set manual connection */
2545 /* we have only a switch on HP-out PIN */
2546 sprintf(name, "%s Playback Switch", pfx);
2547 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2548 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2554 /* create input playback/capture controls for the given pin */
2555 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2556 int idx, hda_nid_t mix_nid)
2561 sprintf(name, "%s Playback Volume", ctlname);
2562 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2563 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2565 sprintf(name, "%s Playback Switch", ctlname);
2566 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2567 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2572 /* create playback/capture controls for input pins */
2573 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2574 const struct auto_pin_cfg *cfg)
2576 struct hda_input_mux *imux = &spec->private_imux;
2579 for (i = 0; i < AUTO_PIN_LAST; i++) {
2580 if (alc880_is_input_pin(cfg->input_pins[i])) {
2581 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2582 err = new_analog_input(spec, cfg->input_pins[i],
2583 auto_pin_cfg_labels[i],
2587 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2588 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2595 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2596 hda_nid_t nid, int pin_type,
2600 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2601 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2602 /* need the manual connection? */
2603 if (alc880_is_multi_pin(nid)) {
2604 struct alc_spec *spec = codec->spec;
2605 int idx = alc880_multi_pin_idx(nid);
2606 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2607 AC_VERB_SET_CONNECT_SEL,
2608 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2612 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2614 struct alc_spec *spec = codec->spec;
2617 for (i = 0; i < spec->autocfg.line_outs; i++) {
2618 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2619 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2623 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2625 struct alc_spec *spec = codec->spec;
2628 pin = spec->autocfg.speaker_pins[0];
2629 if (pin) /* connect to front */
2630 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2631 pin = spec->autocfg.hp_pin;
2632 if (pin) /* connect to front */
2633 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2636 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2638 struct alc_spec *spec = codec->spec;
2641 for (i = 0; i < AUTO_PIN_LAST; i++) {
2642 hda_nid_t nid = spec->autocfg.input_pins[i];
2643 if (alc880_is_input_pin(nid)) {
2644 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2645 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2646 if (nid != ALC880_PIN_CD_NID)
2647 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2653 /* parse the BIOS configuration and set up the alc_spec */
2654 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2655 static int alc880_parse_auto_config(struct hda_codec *codec)
2657 struct alc_spec *spec = codec->spec;
2659 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2661 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2662 alc880_ignore)) < 0)
2664 if (! spec->autocfg.line_outs)
2665 return 0; /* can't find valid BIOS pin config */
2667 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2668 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2669 (err = alc880_auto_create_extra_out(spec,
2670 spec->autocfg.speaker_pins[0],
2672 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2673 "Headphone")) < 0 ||
2674 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2677 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2679 if (spec->autocfg.dig_out_pin)
2680 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2681 if (spec->autocfg.dig_in_pin)
2682 spec->dig_in_nid = ALC880_DIGIN_NID;
2684 if (spec->kctl_alloc)
2685 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2687 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2689 spec->input_mux = &spec->private_imux;
2694 /* additional initialization for auto-configuration model */
2695 static void alc880_auto_init(struct hda_codec *codec)
2697 alc880_auto_init_multi_out(codec);
2698 alc880_auto_init_extra_out(codec);
2699 alc880_auto_init_analog_input(codec);
2703 * OK, here we have finally the patch for ALC880
2706 static int patch_alc880(struct hda_codec *codec)
2708 struct alc_spec *spec;
2712 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2718 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2719 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2720 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2721 board_config = ALC880_AUTO;
2724 if (board_config == ALC880_AUTO) {
2725 /* automatic parse from the BIOS config */
2726 err = alc880_parse_auto_config(codec);
2731 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2732 board_config = ALC880_3ST;
2736 if (board_config != ALC880_AUTO)
2737 setup_preset(spec, &alc880_presets[board_config]);
2739 spec->stream_name_analog = "ALC880 Analog";
2740 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2741 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2743 spec->stream_name_digital = "ALC880 Digital";
2744 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2745 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2747 if (! spec->adc_nids && spec->input_mux) {
2748 /* check whether NID 0x07 is valid */
2749 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2750 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2751 if (wcap != AC_WID_AUD_IN) {
2752 spec->adc_nids = alc880_adc_nids_alt;
2753 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2754 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2757 spec->adc_nids = alc880_adc_nids;
2758 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2759 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2764 codec->patch_ops = alc_patch_ops;
2765 if (board_config == ALC880_AUTO)
2766 spec->init_hook = alc880_auto_init;
2776 static hda_nid_t alc260_dac_nids[1] = {
2781 static hda_nid_t alc260_adc_nids[1] = {
2786 static hda_nid_t alc260_adc_nids_alt[1] = {
2791 static hda_nid_t alc260_hp_adc_nids[2] = {
2796 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2797 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2799 static hda_nid_t alc260_dual_adc_nids[2] = {
2804 #define ALC260_DIGOUT_NID 0x03
2805 #define ALC260_DIGIN_NID 0x06
2807 static struct hda_input_mux alc260_capture_source = {
2811 { "Front Mic", 0x1 },
2817 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2818 * headphone jack and the internal CD lines.
2820 static struct hda_input_mux alc260_fujitsu_capture_source = {
2823 { "Mic/Line", 0x0 },
2825 { "Headphone", 0x2 },
2829 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to
2830 * the Fujitsu S702x, but jacks are marked differently. We won't allow
2831 * retasking the Headphone jack, so it won't be available here.
2833 static struct hda_input_mux alc260_acer_capture_source = {
2843 * This is just place-holder, so there's something for alc_build_pcms to look
2844 * at when it calculates the maximum number of channels. ALC260 has no mixer
2845 * element which allows changing the channel mode, so the verb list is
2848 static struct hda_channel_mode alc260_modes[1] = {
2853 /* Mixer combinations
2855 * basic: base_output + input + pc_beep + capture
2856 * HP: base_output + input + capture_alt
2857 * HP_3013: hp_3013 + input + capture
2858 * fujitsu: fujitsu + capture
2859 * acer: acer + capture
2862 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
2863 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2864 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2865 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2866 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2867 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2868 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2872 static struct snd_kcontrol_new alc260_input_mixer[] = {
2873 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2874 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2875 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2876 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2878 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2879 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2880 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2884 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2885 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2886 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2890 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2891 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2892 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2893 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2894 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2895 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2897 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2898 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
2902 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
2903 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2904 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
2905 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
2906 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2907 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2908 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2909 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
2910 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
2911 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2912 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2913 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2914 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
2918 static struct snd_kcontrol_new alc260_acer_mixer[] = {
2919 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2920 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
2921 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2922 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2924 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2925 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
2926 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2927 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2928 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
2929 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2930 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2934 /* capture mixer elements */
2935 static struct snd_kcontrol_new alc260_capture_mixer[] = {
2936 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2937 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2938 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
2939 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
2941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2942 /* The multiple "Capture Source" controls confuse alsamixer
2943 * So call somewhat different..
2944 * FIXME: the controls appear in the "playback" view!
2946 /* .name = "Capture Source", */
2947 .name = "Input Source",
2949 .info = alc_mux_enum_info,
2950 .get = alc_mux_enum_get,
2951 .put = alc_mux_enum_put,
2956 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
2957 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2958 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2961 /* The multiple "Capture Source" controls confuse alsamixer
2962 * So call somewhat different..
2963 * FIXME: the controls appear in the "playback" view!
2965 /* .name = "Capture Source", */
2966 .name = "Input Source",
2968 .info = alc_mux_enum_info,
2969 .get = alc_mux_enum_get,
2970 .put = alc_mux_enum_put,
2976 * initialization verbs
2978 static struct hda_verb alc260_init_verbs[] = {
2979 /* Line In pin widget for input */
2980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2981 /* CD pin widget for input */
2982 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2983 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2984 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2985 /* Mic2 (front panel) pin widget for input and vref at 80% */
2986 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2987 /* LINE-2 is used for line-out in rear */
2988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2989 /* select line-out */
2990 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
2992 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2994 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2996 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2997 /* mute capture amp left and right */
2998 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2999 /* set connection select to line in (default select for this ADC) */
3000 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3001 /* mute capture amp left and right */
3002 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3003 /* set connection select to line in (default select for this ADC) */
3004 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3005 /* set vol=0 Line-Out mixer amp left and right */
3006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3007 /* unmute pin widget amp left and right (no gain on this amp) */
3008 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3009 /* set vol=0 HP mixer amp left and right */
3010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3011 /* unmute pin widget amp left and right (no gain on this amp) */
3012 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3013 /* set vol=0 Mono mixer amp left and right */
3014 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3015 /* unmute pin widget amp left and right (no gain on this amp) */
3016 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3017 /* unmute LINE-2 out pin */
3018 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3026 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3027 /* mute Front out path */
3028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3030 /* mute Headphone out path */
3031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3033 /* mute Mono out path */
3034 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3035 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3039 static struct hda_verb alc260_hp_init_verbs[] = {
3040 /* Headphone and output */
3041 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3043 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3044 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3045 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3046 /* Mic2 (front panel) pin widget for input and vref at 80% */
3047 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3048 /* Line In pin widget for input */
3049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3050 /* Line-2 pin widget for output */
3051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3052 /* CD pin widget for input */
3053 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3054 /* unmute amp left and right */
3055 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3056 /* set connection select to line in (default select for this ADC) */
3057 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3058 /* unmute Line-Out mixer amp left and right (volume = 0) */
3059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3060 /* mute pin widget amp left and right (no gain on this amp) */
3061 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3062 /* unmute HP mixer amp left and right (volume = 0) */
3063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3064 /* mute pin widget amp left and right (no gain on this amp) */
3065 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3066 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3069 /* unmute Line In */
3070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3073 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3074 /* Unmute Front out path */
3075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3076 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3077 /* Unmute Headphone out path */
3078 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3080 /* Unmute Mono out path */
3081 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3082 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3086 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3087 /* Line out and output */
3088 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3090 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3091 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3092 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3093 /* Mic2 (front panel) pin widget for input and vref at 80% */
3094 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3095 /* Line In pin widget for input */
3096 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3097 /* Headphone pin widget for output */
3098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3099 /* CD pin widget for input */
3100 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3101 /* unmute amp left and right */
3102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3103 /* set connection select to line in (default select for this ADC) */
3104 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3105 /* unmute Line-Out mixer amp left and right (volume = 0) */
3106 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3107 /* mute pin widget amp left and right (no gain on this amp) */
3108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3109 /* unmute HP mixer amp left and right (volume = 0) */
3110 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3111 /* mute pin widget amp left and right (no gain on this amp) */
3112 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3113 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3116 /* unmute Line In */
3117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3120 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3121 /* Unmute Front out path */
3122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3124 /* Unmute Headphone out path */
3125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3127 /* Unmute Mono out path */
3128 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3133 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3136 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3137 /* Disable all GPIOs */
3138 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3139 /* Internal speaker is connected to headphone pin */
3140 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3141 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3143 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3144 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3145 /* Ensure all other unused pins are disabled and muted. */
3146 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3148 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3149 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3150 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3151 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3155 /* Disable digital (SPDIF) pins */
3156 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3157 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3159 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3160 * when acting as an output.
3162 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3164 /* Start with output sum widgets muted and their output gains at min */
3165 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3171 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3173 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3175 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3176 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3177 /* Unmute Line1 pin widget output buffer since it starts as an output.
3178 * If the pin mode is changed by the user the pin mode control will
3179 * take care of enabling the pin's input/output buffers as needed.
3180 * Therefore there's no need to enable the input buffer at this
3183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184 /* Unmute input buffer of pin widget used for Line-in (no equiv
3187 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3189 /* Mute capture amp left and right */
3190 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3191 /* Set ADC connection select to match default mixer setting - line
3194 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3196 /* Do the same for the second ADC: mute capture input amp and
3197 * set ADC connection to line in (on mic1 pin)
3199 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3200 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3202 /* Mute all inputs to mixer widget (even unconnected ones) */
3203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3204 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3215 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3216 * similar laptops (adapted from Fujitsu init verbs).
3218 static struct hda_verb alc260_acer_init_verbs[] = {
3219 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3220 * the headphone jack. Turn this on and rely on the standard mute
3221 * methods whenever the user wants to turn these outputs off.
3223 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3224 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3225 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3226 /* Internal speaker/Headphone jack is connected to Line-out pin */
3227 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3228 /* Internal microphone/Mic jack is connected to Mic1 pin */
3229 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3230 /* Line In jack is connected to Line1 pin */
3231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3232 /* Ensure all other unused pins are disabled and muted. */
3233 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3234 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3235 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3236 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3237 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3238 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3241 /* Disable digital (SPDIF) pins */
3242 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3243 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3245 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3246 * bus when acting as outputs.
3248 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3249 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3251 /* Start with output sum widgets muted and their output gains at min */
3252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3258 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3259 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3260 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3262 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3263 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3264 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3265 * inputs. If the pin mode is changed by the user the pin mode control
3266 * will take care of enabling the pin's input/output buffers as needed.
3267 * Therefore there's no need to enable the input buffer at this
3270 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3273 /* Mute capture amp left and right */
3274 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3275 /* Set ADC connection select to match default mixer setting - mic
3278 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3280 /* Do similar with the second ADC: mute capture input amp and
3281 * set ADC connection to line (on line1 pin)
3283 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3284 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3286 /* Mute all inputs to mixer widget (even unconnected ones) */
3287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3299 /* Test configuration for debugging, modelled after the ALC880 test
3302 #ifdef CONFIG_SND_DEBUG
3303 static hda_nid_t alc260_test_dac_nids[1] = {
3306 static hda_nid_t alc260_test_adc_nids[2] = {
3309 /* This is a bit messy since the two input muxes in the ALC260 have slight
3310 * variations in their signal assignments. The ideal way to deal with this
3311 * is to extend alc_spec.input_mux to allow a different input MUX for each
3312 * ADC. For the purposes of the test model it's sufficient to just list
3313 * both options for affected signal indices. The separate input mux
3314 * functionality only needs to be considered if a model comes along which
3315 * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
3318 static struct hda_input_mux alc260_test_capture_source = {
3321 { "MIC1 pin", 0x0 },
3322 { "MIC2 pin", 0x1 },
3323 { "LINE1 pin", 0x2 },
3324 { "LINE2 pin", 0x3 },
3326 { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
3327 { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
3328 { "HP-OUT pin (cap2 only)", 0x7 },
3331 static struct snd_kcontrol_new alc260_test_mixer[] = {
3332 /* Output driver widgets */
3333 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3334 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3335 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3336 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3337 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3338 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3340 /* Modes for retasking pin widgets */
3341 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3342 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3343 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3344 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3345 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3346 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3348 /* Loopback mixer controls */
3349 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3350 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3351 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3352 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3353 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3354 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3355 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3356 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3357 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3358 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3359 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3360 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3361 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3362 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3363 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3364 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3366 /* Controls for GPIO pins, assuming they are configured as outputs */
3367 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3368 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3369 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3370 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3372 /* Switches to allow the digital IO pins to be enabled. The datasheet
3373 * is ambigious as to which NID is which; testing on laptops which
3374 * make this output available should provide clarification.
3376 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3377 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3381 static struct hda_verb alc260_test_init_verbs[] = {
3382 /* Enable all GPIOs as outputs with an initial value of 0 */
3383 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3384 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3385 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3387 /* Enable retasking pins as output, initially without power amp */
3388 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3389 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3391 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3392 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3393 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3395 /* Disable digital (SPDIF) pins initially, but users can enable
3396 * them via a mixer switch. In the case of SPDIF-out, this initverb
3397 * payload also sets the generation to 0, output to be in "consumer"
3398 * PCM format, copyright asserted, no pre-emphasis and no validity
3401 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3402 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3404 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3405 * OUT1 sum bus when acting as an output.
3407 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3408 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3409 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3410 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3412 /* Start with output sum widgets muted and their output gains at min */
3413 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3414 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3416 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3417 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3418 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3419 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3420 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3421 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3423 /* Unmute retasking pin widget output buffers since the default
3424 * state appears to be output. As the pin mode is changed by the
3425 * user the pin mode control will take care of enabling the pin's
3426 * input/output buffers as needed.
3428 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3429 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3430 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3431 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3432 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3433 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3434 /* Also unmute the mono-out pin widget */
3435 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3437 /* Mute capture amp left and right */
3438 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3439 /* Set ADC connection select to match default mixer setting (mic1
3442 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3444 /* Do the same for the second ADC: mute capture input amp and
3445 * set ADC connection to mic1 pin
3447 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3448 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3450 /* Mute all inputs to mixer widget (even unconnected ones) */
3451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3464 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3470 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3476 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3477 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3480 * for BIOS auto-configuration
3483 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3487 unsigned long vol_val, sw_val;
3491 if (nid >= 0x0f && nid < 0x11) {
3492 nid_vol = nid - 0x7;
3493 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3494 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3495 } else if (nid == 0x11) {
3496 nid_vol = nid - 0x7;
3497 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3498 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3499 } else if (nid >= 0x12 && nid <= 0x15) {
3501 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3502 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3506 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3507 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3509 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3510 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3515 /* add playback controls from the parsed DAC table */
3516 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3517 const struct auto_pin_cfg *cfg)
3522 spec->multiout.num_dacs = 1;
3523 spec->multiout.dac_nids = spec->private_dac_nids;
3524 spec->multiout.dac_nids[0] = 0x02;
3526 nid = cfg->line_out_pins[0];
3528 err = alc260_add_playback_controls(spec, nid, "Front");
3533 nid = cfg->speaker_pins[0];
3535 err = alc260_add_playback_controls(spec, nid, "Speaker");
3542 err = alc260_add_playback_controls(spec, nid, "Headphone");
3549 /* create playback/capture controls for input pins */
3550 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3551 const struct auto_pin_cfg *cfg)
3553 struct hda_input_mux *imux = &spec->private_imux;
3556 for (i = 0; i < AUTO_PIN_LAST; i++) {
3557 if (cfg->input_pins[i] >= 0x12) {
3558 idx = cfg->input_pins[i] - 0x12;
3559 err = new_analog_input(spec, cfg->input_pins[i],
3560 auto_pin_cfg_labels[i], idx, 0x07);
3563 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3564 imux->items[imux->num_items].index = idx;
3567 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3568 idx = cfg->input_pins[i] - 0x09;
3569 err = new_analog_input(spec, cfg->input_pins[i],
3570 auto_pin_cfg_labels[i], idx, 0x07);
3573 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3574 imux->items[imux->num_items].index = idx;
3581 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3582 hda_nid_t nid, int pin_type,
3586 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3587 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3588 /* need the manual connection? */
3590 int idx = nid - 0x12;
3591 snd_hda_codec_write(codec, idx + 0x0b, 0,
3592 AC_VERB_SET_CONNECT_SEL, sel_idx);
3597 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3599 struct alc_spec *spec = codec->spec;
3602 nid = spec->autocfg.line_out_pins[0];
3604 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3606 nid = spec->autocfg.speaker_pins[0];
3608 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3610 nid = spec->autocfg.hp_pin;
3612 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3615 #define ALC260_PIN_CD_NID 0x16
3616 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3618 struct alc_spec *spec = codec->spec;
3621 for (i = 0; i < AUTO_PIN_LAST; i++) {
3622 hda_nid_t nid = spec->autocfg.input_pins[i];
3624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3625 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3626 if (nid != ALC260_PIN_CD_NID)
3627 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3634 * generic initialization of ADC, input mixers and output mixers
3636 static struct hda_verb alc260_volume_init_verbs[] = {
3638 * Unmute ADC0-1 and set the default input to mic-in
3640 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3641 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3642 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3643 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3645 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3647 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3650 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3658 * Set up output mixers (0x08 - 0x0a)
3660 /* set vol=0 to output mixers */
3661 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3663 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3664 /* set up input amps for analog loopback */
3665 /* Amp Indices: DAC = 0, mixer = 1 */
3666 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3668 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3671 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3676 static int alc260_parse_auto_config(struct hda_codec *codec)
3678 struct alc_spec *spec = codec->spec;
3681 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3683 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3684 alc260_ignore)) < 0)
3686 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3688 if (! spec->kctl_alloc)
3689 return 0; /* can't find valid BIOS pin config */
3690 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3693 spec->multiout.max_channels = 2;
3695 if (spec->autocfg.dig_out_pin)
3696 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3697 if (spec->kctl_alloc)
3698 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3700 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3702 spec->input_mux = &spec->private_imux;
3704 /* check whether NID 0x04 is valid */
3705 wcap = get_wcaps(codec, 0x04);
3706 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3707 if (wcap != AC_WID_AUD_IN) {
3708 spec->adc_nids = alc260_adc_nids_alt;
3709 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3710 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3712 spec->adc_nids = alc260_adc_nids;
3713 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3714 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3721 /* additional initialization for auto-configuration model */
3722 static void alc260_auto_init(struct hda_codec *codec)
3724 alc260_auto_init_multi_out(codec);
3725 alc260_auto_init_analog_input(codec);
3729 * ALC260 configurations
3731 static struct hda_board_config alc260_cfg_tbl[] = {
3732 { .modelname = "basic", .config = ALC260_BASIC },
3733 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3734 .config = ALC260_BASIC }, /* Sony VAIO */
3735 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3736 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
3737 { .modelname = "hp", .config = ALC260_HP },
3738 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3739 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3740 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
3741 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3742 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3743 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3744 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3745 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3746 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3747 { .modelname = "acer", .config = ALC260_ACER },
3748 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
3749 #ifdef CONFIG_SND_DEBUG
3750 { .modelname = "test", .config = ALC260_TEST },
3752 { .modelname = "auto", .config = ALC260_AUTO },
3756 static struct alc_config_preset alc260_presets[] = {
3758 .mixers = { alc260_base_output_mixer,
3760 alc260_pc_beep_mixer,
3761 alc260_capture_mixer },
3762 .init_verbs = { alc260_init_verbs },
3763 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3764 .dac_nids = alc260_dac_nids,
3765 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3766 .adc_nids = alc260_adc_nids,
3767 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3768 .channel_mode = alc260_modes,
3769 .input_mux = &alc260_capture_source,
3772 .mixers = { alc260_base_output_mixer,
3774 alc260_capture_alt_mixer },
3775 .init_verbs = { alc260_hp_init_verbs },
3776 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3777 .dac_nids = alc260_dac_nids,
3778 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3779 .adc_nids = alc260_hp_adc_nids,
3780 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3781 .channel_mode = alc260_modes,
3782 .input_mux = &alc260_capture_source,
3784 [ALC260_HP_3013] = {
3785 .mixers = { alc260_hp_3013_mixer,
3787 alc260_capture_alt_mixer },
3788 .init_verbs = { alc260_hp_3013_init_verbs },
3789 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3790 .dac_nids = alc260_dac_nids,
3791 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3792 .adc_nids = alc260_hp_adc_nids,
3793 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3794 .channel_mode = alc260_modes,
3795 .input_mux = &alc260_capture_source,
3797 [ALC260_FUJITSU_S702X] = {
3798 .mixers = { alc260_fujitsu_mixer,
3799 alc260_capture_mixer },
3800 .init_verbs = { alc260_fujitsu_init_verbs },
3801 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3802 .dac_nids = alc260_dac_nids,
3803 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3804 .adc_nids = alc260_dual_adc_nids,
3805 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3806 .channel_mode = alc260_modes,
3807 .input_mux = &alc260_fujitsu_capture_source,
3810 .mixers = { alc260_acer_mixer,
3811 alc260_capture_mixer },
3812 .init_verbs = { alc260_acer_init_verbs },
3813 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3814 .dac_nids = alc260_dac_nids,
3815 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3816 .adc_nids = alc260_dual_adc_nids,
3817 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3818 .channel_mode = alc260_modes,
3819 .input_mux = &alc260_acer_capture_source,
3821 #ifdef CONFIG_SND_DEBUG
3823 .mixers = { alc260_test_mixer,
3824 alc260_capture_mixer },
3825 .init_verbs = { alc260_test_init_verbs },
3826 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
3827 .dac_nids = alc260_test_dac_nids,
3828 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
3829 .adc_nids = alc260_test_adc_nids,
3830 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3831 .channel_mode = alc260_modes,
3832 .input_mux = &alc260_test_capture_source,
3837 static int patch_alc260(struct hda_codec *codec)
3839 struct alc_spec *spec;
3840 int err, board_config;
3842 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3848 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3849 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3850 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
3851 board_config = ALC260_AUTO;
3854 if (board_config == ALC260_AUTO) {
3855 /* automatic parse from the BIOS config */
3856 err = alc260_parse_auto_config(codec);
3861 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3862 board_config = ALC260_BASIC;
3866 if (board_config != ALC260_AUTO)
3867 setup_preset(spec, &alc260_presets[board_config]);
3869 spec->stream_name_analog = "ALC260 Analog";
3870 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3871 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3873 spec->stream_name_digital = "ALC260 Digital";
3874 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3875 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3877 codec->patch_ops = alc_patch_ops;
3878 if (board_config == ALC260_AUTO)
3879 spec->init_hook = alc260_auto_init;
3888 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3889 * configuration. Each pin widget can choose any input DACs and a mixer.
3890 * Each ADC is connected from a mixer of all inputs. This makes possible
3891 * 6-channel independent captures.
3893 * In addition, an independent DAC for the multi-playback (not used in this
3896 #define ALC882_DIGOUT_NID 0x06
3897 #define ALC882_DIGIN_NID 0x0a
3899 static struct hda_channel_mode alc882_ch_modes[1] = {
3903 static hda_nid_t alc882_dac_nids[4] = {
3904 /* front, rear, clfe, rear_surr */
3905 0x02, 0x03, 0x04, 0x05
3908 /* identical with ALC880 */
3909 #define alc882_adc_nids alc880_adc_nids
3910 #define alc882_adc_nids_alt alc880_adc_nids_alt
3913 /* FIXME: should be a matrix-type input source selection */
3915 static struct hda_input_mux alc882_capture_source = {
3919 { "Front Mic", 0x1 },
3925 #define alc882_mux_enum_info alc_mux_enum_info
3926 #define alc882_mux_enum_get alc_mux_enum_get
3928 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3930 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3931 struct alc_spec *spec = codec->spec;
3932 const struct hda_input_mux *imux = spec->input_mux;
3933 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3934 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
3935 hda_nid_t nid = capture_mixers[adc_idx];
3936 unsigned int *cur_val = &spec->cur_mux[adc_idx];
3937 unsigned int i, idx;
3939 idx = ucontrol->value.enumerated.item[0];
3940 if (idx >= imux->num_items)
3941 idx = imux->num_items - 1;
3942 if (*cur_val == idx && ! codec->in_resume)
3944 for (i = 0; i < imux->num_items; i++) {
3945 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
3946 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3947 v | (imux->items[i].index << 8));
3956 static struct hda_verb alc882_sixstack_ch6_init[] = {
3957 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
3958 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3959 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3960 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3967 static struct hda_verb alc882_sixstack_ch8_init[] = {
3968 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3969 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3970 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3971 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3975 static struct hda_channel_mode alc882_sixstack_modes[2] = {
3976 { 6, alc882_sixstack_ch6_init },
3977 { 8, alc882_sixstack_ch8_init },
3980 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3981 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3983 static struct snd_kcontrol_new alc882_base_mixer[] = {
3984 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3985 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3986 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3987 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3988 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3989 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3990 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3991 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3992 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3993 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3996 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4003 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4004 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4005 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4006 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4007 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4008 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4009 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4010 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4013 /* .name = "Capture Source", */
4014 .name = "Input Source",
4016 .info = alc882_mux_enum_info,
4017 .get = alc882_mux_enum_get,
4018 .put = alc882_mux_enum_put,
4023 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4026 .name = "Channel Mode",
4027 .info = alc_ch_mode_info,
4028 .get = alc_ch_mode_get,
4029 .put = alc_ch_mode_put,
4034 static struct hda_verb alc882_init_verbs[] = {
4035 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4042 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4044 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4045 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4046 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4048 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4049 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4050 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4052 /* Front Pin: output 0 (0x0c) */
4053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4055 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4056 /* Rear Pin: output 1 (0x0d) */
4057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4059 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4060 /* CLFE Pin: output 2 (0x0e) */
4061 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4062 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4063 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4064 /* Side Pin: output 3 (0x0f) */
4065 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4067 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4068 /* Mic (rear) pin: input vref at 80% */
4069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4070 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4071 /* Front Mic pin: input vref at 80% */
4072 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4073 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4074 /* Line In pin: input */
4075 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4077 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4078 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4079 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4080 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4081 /* CD pin widget for input */
4082 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4084 /* FIXME: use matrix-type input source selection */
4085 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4086 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4101 /* ADC1: mute amp left and right */
4102 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4103 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4104 /* ADC2: mute amp left and right */
4105 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4106 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4107 /* ADC3: mute amp left and right */
4108 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4109 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4115 * generic initialization of ADC, input mixers and output mixers
4117 static struct hda_verb alc882_auto_init_verbs[] = {
4119 * Unmute ADC0-2 and set the default input to mic-in
4121 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4123 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4125 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4128 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4130 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4133 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4141 * Set up output mixers (0x0c - 0x0f)
4143 /* set vol=0 to output mixers */
4144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4148 /* set up input amps for analog loopback */
4149 /* Amp Indices: DAC = 0, mixer = 1 */
4150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4152 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4153 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4154 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4156 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4157 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4158 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4159 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4161 /* FIXME: use matrix-type input source selection */
4162 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4163 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4164 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4165 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4169 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4171 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4182 /* capture mixer elements */
4183 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4184 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4185 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4190 /* The multiple "Capture Source" controls confuse alsamixer
4191 * So call somewhat different..
4192 * FIXME: the controls appear in the "playback" view!
4194 /* .name = "Capture Source", */
4195 .name = "Input Source",
4197 .info = alc882_mux_enum_info,
4198 .get = alc882_mux_enum_get,
4199 .put = alc882_mux_enum_put,
4204 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4205 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4206 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4207 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4208 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4209 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4210 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4213 /* The multiple "Capture Source" controls confuse alsamixer
4214 * So call somewhat different..
4215 * FIXME: the controls appear in the "playback" view!
4217 /* .name = "Capture Source", */
4218 .name = "Input Source",
4220 .info = alc882_mux_enum_info,
4221 .get = alc882_mux_enum_get,
4222 .put = alc882_mux_enum_put,
4227 /* pcm configuration: identiacal with ALC880 */
4228 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4229 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4230 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4231 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4234 * configuration and preset
4236 static struct hda_board_config alc882_cfg_tbl[] = {
4237 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4238 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4239 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
4240 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
4241 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
4242 { .modelname = "auto", .config = ALC882_AUTO },
4246 static struct alc_config_preset alc882_presets[] = {
4247 [ALC882_3ST_DIG] = {
4248 .mixers = { alc882_base_mixer },
4249 .init_verbs = { alc882_init_verbs },
4250 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4251 .dac_nids = alc882_dac_nids,
4252 .dig_out_nid = ALC882_DIGOUT_NID,
4253 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4254 .adc_nids = alc882_adc_nids,
4255 .dig_in_nid = ALC882_DIGIN_NID,
4256 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4257 .channel_mode = alc882_ch_modes,
4258 .input_mux = &alc882_capture_source,
4260 [ALC882_6ST_DIG] = {
4261 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4262 .init_verbs = { alc882_init_verbs },
4263 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4264 .dac_nids = alc882_dac_nids,
4265 .dig_out_nid = ALC882_DIGOUT_NID,
4266 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4267 .adc_nids = alc882_adc_nids,
4268 .dig_in_nid = ALC882_DIGIN_NID,
4269 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4270 .channel_mode = alc882_sixstack_modes,
4271 .input_mux = &alc882_capture_source,
4277 * BIOS auto configuration
4279 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4280 hda_nid_t nid, int pin_type,
4284 struct alc_spec *spec = codec->spec;
4287 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4290 idx = spec->multiout.dac_nids[dac_idx] - 2;
4292 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4293 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4294 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4298 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4300 struct alc_spec *spec = codec->spec;
4303 for (i = 0; i <= HDA_SIDE; i++) {
4304 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4306 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4310 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4312 struct alc_spec *spec = codec->spec;
4315 pin = spec->autocfg.hp_pin;
4316 if (pin) /* connect to front */
4317 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4320 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4321 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4323 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4325 struct alc_spec *spec = codec->spec;
4328 for (i = 0; i < AUTO_PIN_LAST; i++) {
4329 hda_nid_t nid = spec->autocfg.input_pins[i];
4330 if (alc882_is_input_pin(nid)) {
4331 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4332 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4333 if (nid != ALC882_PIN_CD_NID)
4334 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4340 /* almost identical with ALC880 parser... */
4341 static int alc882_parse_auto_config(struct hda_codec *codec)
4343 struct alc_spec *spec = codec->spec;
4344 int err = alc880_parse_auto_config(codec);
4349 /* hack - override the init verbs */
4350 spec->init_verbs[0] = alc882_auto_init_verbs;
4354 /* additional initialization for auto-configuration model */
4355 static void alc882_auto_init(struct hda_codec *codec)
4357 alc882_auto_init_multi_out(codec);
4358 alc882_auto_init_hp_out(codec);
4359 alc882_auto_init_analog_input(codec);
4363 * ALC882 Headphone poll in 3.5.1a or 3.5.2
4366 static int patch_alc882(struct hda_codec *codec)
4368 struct alc_spec *spec;
4369 int err, board_config;
4371 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4377 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4379 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4380 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
4381 board_config = ALC882_AUTO;
4384 if (board_config == ALC882_AUTO) {
4385 /* automatic parse from the BIOS config */
4386 err = alc882_parse_auto_config(codec);
4391 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4392 board_config = ALC882_3ST_DIG;
4396 if (board_config != ALC882_AUTO)
4397 setup_preset(spec, &alc882_presets[board_config]);
4399 spec->stream_name_analog = "ALC882 Analog";
4400 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4401 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4403 spec->stream_name_digital = "ALC882 Digital";
4404 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4405 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4407 if (! spec->adc_nids && spec->input_mux) {
4408 /* check whether NID 0x07 is valid */
4409 unsigned int wcap = get_wcaps(codec, 0x07);
4410 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4411 if (wcap != AC_WID_AUD_IN) {
4412 spec->adc_nids = alc882_adc_nids_alt;
4413 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4414 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4417 spec->adc_nids = alc882_adc_nids;
4418 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4419 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4424 codec->patch_ops = alc_patch_ops;
4425 if (board_config == ALC882_AUTO)
4426 spec->init_hook = alc882_auto_init;
4435 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
4436 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
4438 #define alc262_dac_nids alc260_dac_nids
4439 #define alc262_adc_nids alc882_adc_nids
4440 #define alc262_adc_nids_alt alc882_adc_nids_alt
4442 #define alc262_modes alc260_modes
4443 #define alc262_capture_source alc882_capture_source
4445 static struct snd_kcontrol_new alc262_base_mixer[] = {
4446 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4447 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4448 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4449 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4450 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4451 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4453 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4454 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
4455 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
4456 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
4457 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
4458 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
4459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4460 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4461 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
4465 #define alc262_capture_mixer alc882_capture_mixer
4466 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
4469 * generic initialization of ADC, input mixers and output mixers
4471 static struct hda_verb alc262_init_verbs[] = {
4473 * Unmute ADC0-2 and set the default input to mic-in
4475 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4477 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4478 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4479 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4482 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4484 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4487 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4491 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4492 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4495 * Set up output mixers (0x0c - 0x0e)
4497 /* set vol=0 to output mixers */
4498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4501 /* set up input amps for analog loopback */
4502 /* Amp Indices: DAC = 0, mixer = 1 */
4503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4511 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4512 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4514 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4515 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4517 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4519 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4521 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4523 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4524 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4526 /* FIXME: use matrix-type input source selection */
4527 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4528 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4529 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4530 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4531 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4532 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4535 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4536 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4549 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
4552 #define ALC_HP_EVENT 0x37
4554 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
4555 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
4556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4560 static struct hda_input_mux alc262_fujitsu_capture_source = {
4568 /* mute/unmute internal speaker according to the hp jack and mute state */
4569 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
4571 struct alc_spec *spec = codec->spec;
4574 if (force || ! spec->sense_updated) {
4575 unsigned int present;
4576 /* need to execute and sync at first */
4577 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
4578 present = snd_hda_codec_read(codec, 0x14, 0,
4579 AC_VERB_GET_PIN_SENSE, 0);
4580 spec->jack_present = (present & 0x80000000) != 0;
4581 spec->sense_updated = 1;
4583 if (spec->jack_present) {
4584 /* mute internal speaker */
4585 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4587 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4590 /* unmute internal speaker if necessary */
4591 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
4592 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4594 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
4595 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4600 /* unsolicited event for HP jack sensing */
4601 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
4604 if ((res >> 26) != ALC_HP_EVENT)
4606 alc262_fujitsu_automute(codec, 1);
4609 /* bind volumes of both NID 0x0c and 0x0d */
4610 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
4611 struct snd_ctl_elem_value *ucontrol)
4613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4614 long *valp = ucontrol->value.integer.value;
4617 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
4618 0x7f, valp[0] & 0x7f);
4619 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
4620 0x7f, valp[1] & 0x7f);
4621 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
4622 0x7f, valp[0] & 0x7f);
4623 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
4624 0x7f, valp[1] & 0x7f);
4628 /* bind hp and internal speaker mute (with plug check) */
4629 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
4630 struct snd_ctl_elem_value *ucontrol)
4632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4633 long *valp = ucontrol->value.integer.value;
4636 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
4637 0x80, valp[0] ? 0 : 0x80);
4638 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
4639 0x80, valp[1] ? 0 : 0x80);
4640 if (change || codec->in_resume)
4641 alc262_fujitsu_automute(codec, codec->in_resume);
4645 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
4647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4648 .name = "Master Playback Volume",
4649 .info = snd_hda_mixer_amp_volume_info,
4650 .get = snd_hda_mixer_amp_volume_get,
4651 .put = alc262_fujitsu_master_vol_put,
4652 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
4655 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4656 .name = "Master Playback Switch",
4657 .info = snd_hda_mixer_amp_switch_info,
4658 .get = snd_hda_mixer_amp_switch_get,
4659 .put = alc262_fujitsu_master_sw_put,
4660 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
4662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4664 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4666 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4670 /* add playback controls from the parsed DAC table */
4671 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4676 spec->multiout.num_dacs = 1; /* only use one dac */
4677 spec->multiout.dac_nids = spec->private_dac_nids;
4678 spec->multiout.dac_nids[0] = 2;
4680 nid = cfg->line_out_pins[0];
4682 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
4683 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4685 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
4686 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4690 nid = cfg->speaker_pins[0];
4693 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4694 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4696 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4697 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4700 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4701 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4707 /* spec->multiout.hp_nid = 2; */
4709 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4710 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4712 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4713 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4716 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4717 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4724 /* identical with ALC880 */
4725 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
4728 * generic initialization of ADC, input mixers and output mixers
4730 static struct hda_verb alc262_volume_init_verbs[] = {
4732 * Unmute ADC0-2 and set the default input to mic-in
4734 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4736 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4737 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4738 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4741 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4743 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4746 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4748 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4749 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4751 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4754 * Set up output mixers (0x0c - 0x0f)
4756 /* set vol=0 to output mixers */
4757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4761 /* set up input amps for analog loopback */
4762 /* Amp Indices: DAC = 0, mixer = 1 */
4763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4770 /* FIXME: use matrix-type input source selection */
4771 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4772 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4778 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4779 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4780 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4783 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4784 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4785 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4791 /* pcm configuration: identiacal with ALC880 */
4792 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
4793 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
4794 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
4795 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
4798 * BIOS auto configuration
4800 static int alc262_parse_auto_config(struct hda_codec *codec)
4802 struct alc_spec *spec = codec->spec;
4804 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4806 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4807 alc262_ignore)) < 0)
4809 if (! spec->autocfg.line_outs)
4810 return 0; /* can't find valid BIOS pin config */
4811 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4812 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4815 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4817 if (spec->autocfg.dig_out_pin)
4818 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
4819 if (spec->autocfg.dig_in_pin)
4820 spec->dig_in_nid = ALC262_DIGIN_NID;
4822 if (spec->kctl_alloc)
4823 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4825 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
4826 spec->input_mux = &spec->private_imux;
4831 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
4832 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
4833 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
4836 /* init callback for auto-configuration model -- overriding the default init */
4837 static void alc262_auto_init(struct hda_codec *codec)
4839 alc262_auto_init_multi_out(codec);
4840 alc262_auto_init_hp_out(codec);
4841 alc262_auto_init_analog_input(codec);
4845 * configuration and preset
4847 static struct hda_board_config alc262_cfg_tbl[] = {
4848 { .modelname = "basic", .config = ALC262_BASIC },
4849 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
4850 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
4851 { .modelname = "auto", .config = ALC262_AUTO },
4855 static struct alc_config_preset alc262_presets[] = {
4857 .mixers = { alc262_base_mixer },
4858 .init_verbs = { alc262_init_verbs },
4859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4860 .dac_nids = alc262_dac_nids,
4862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4863 .channel_mode = alc262_modes,
4864 .input_mux = &alc262_capture_source,
4866 [ALC262_FUJITSU] = {
4867 .mixers = { alc262_fujitsu_mixer },
4868 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
4869 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4870 .dac_nids = alc262_dac_nids,
4872 .dig_out_nid = ALC262_DIGOUT_NID,
4873 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4874 .channel_mode = alc262_modes,
4875 .input_mux = &alc262_fujitsu_capture_source,
4876 .unsol_event = alc262_fujitsu_unsol_event,
4880 static int patch_alc262(struct hda_codec *codec)
4882 struct alc_spec *spec;
4886 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4892 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
4895 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4896 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4897 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4898 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4902 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
4903 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
4904 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
4905 board_config = ALC262_AUTO;
4908 if (board_config == ALC262_AUTO) {
4909 /* automatic parse from the BIOS config */
4910 err = alc262_parse_auto_config(codec);
4915 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4916 board_config = ALC262_BASIC;
4920 if (board_config != ALC262_AUTO)
4921 setup_preset(spec, &alc262_presets[board_config]);
4923 spec->stream_name_analog = "ALC262 Analog";
4924 spec->stream_analog_playback = &alc262_pcm_analog_playback;
4925 spec->stream_analog_capture = &alc262_pcm_analog_capture;
4927 spec->stream_name_digital = "ALC262 Digital";
4928 spec->stream_digital_playback = &alc262_pcm_digital_playback;
4929 spec->stream_digital_capture = &alc262_pcm_digital_capture;
4931 if (! spec->adc_nids && spec->input_mux) {
4932 /* check whether NID 0x07 is valid */
4933 unsigned int wcap = get_wcaps(codec, 0x07);
4935 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4936 if (wcap != AC_WID_AUD_IN) {
4937 spec->adc_nids = alc262_adc_nids_alt;
4938 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
4939 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
4942 spec->adc_nids = alc262_adc_nids;
4943 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
4944 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
4949 codec->patch_ops = alc_patch_ops;
4950 if (board_config == ALC262_AUTO)
4951 spec->init_hook = alc262_auto_init;
4958 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4962 * set the path ways for 2 channel output
4963 * need to set the codec line out and mic 1 pin widgets to inputs
4965 static struct hda_verb alc861_threestack_ch2_init[] = {
4966 /* set pin widget 1Ah (line in) for input */
4967 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4968 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4969 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4971 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
4972 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
4973 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
4978 * need to set the codec line out and mic 1 pin widgets to outputs
4980 static struct hda_verb alc861_threestack_ch6_init[] = {
4981 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4982 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4983 /* set pin widget 18h (mic1) for output (CLFE)*/
4984 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4986 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
4987 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
4989 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
4990 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
4991 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
4995 static struct hda_channel_mode alc861_threestack_modes[2] = {
4996 { 2, alc861_threestack_ch2_init },
4997 { 6, alc861_threestack_ch6_init },
5002 static struct snd_kcontrol_new alc861_base_mixer[] = {
5003 /* output mixer control */
5004 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5005 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5006 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5007 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5008 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
5010 /*Input mixer control */
5011 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5012 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5013 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5014 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5015 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5016 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5018 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5019 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
5020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
5022 /* Capture mixer control */
5023 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5024 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5027 .name = "Capture Source",
5029 .info = alc_mux_enum_info,
5030 .get = alc_mux_enum_get,
5031 .put = alc_mux_enum_put,
5036 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
5037 /* output mixer control */
5038 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5039 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5040 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5041 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5042 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
5044 /* Input mixer control */
5045 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5046 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5047 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5048 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5049 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5050 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5052 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5053 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
5054 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
5056 /* Capture mixer control */
5057 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5058 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5061 .name = "Capture Source",
5063 .info = alc_mux_enum_info,
5064 .get = alc_mux_enum_get,
5065 .put = alc_mux_enum_put,
5068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5069 .name = "Channel Mode",
5070 .info = alc_ch_mode_info,
5071 .get = alc_ch_mode_get,
5072 .put = alc_ch_mode_put,
5073 .private_value = ARRAY_SIZE(alc861_threestack_modes),
5079 * generic initialization of ADC, input mixers and output mixers
5081 static struct hda_verb alc861_base_init_verbs[] = {
5083 * Unmute ADC0 and set the default input to mic-in
5085 /* port-A for surround (rear panel) */
5086 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5087 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
5088 /* port-B for mic-in (rear panel) with vref */
5089 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5090 /* port-C for line-in (rear panel) */
5091 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5092 /* port-D for Front */
5093 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5094 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5095 /* port-E for HP out (front panel) */
5096 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5097 /* route front PCM to HP */
5098 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5099 /* port-F for mic-in (front panel) with vref */
5100 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5101 /* port-G for CLFE (rear panel) */
5102 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5103 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
5104 /* port-H for side (rear panel) */
5105 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5106 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
5108 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5109 /* route front mic to ADC1*/
5110 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5111 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5113 /* Unmute DAC0~3 & spdif out*/
5114 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5115 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5116 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5117 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5120 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5121 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5122 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5123 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5124 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5126 /* Unmute Stereo Mixer 15 */
5127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5133 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5134 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5135 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5136 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5139 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5146 static struct hda_verb alc861_threestack_init_verbs[] = {
5148 * Unmute ADC0 and set the default input to mic-in
5150 /* port-A for surround (rear panel) */
5151 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5152 /* port-B for mic-in (rear panel) with vref */
5153 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5154 /* port-C for line-in (rear panel) */
5155 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5156 /* port-D for Front */
5157 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5158 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5159 /* port-E for HP out (front panel) */
5160 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5161 /* route front PCM to HP */
5162 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5163 /* port-F for mic-in (front panel) with vref */
5164 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5165 /* port-G for CLFE (rear panel) */
5166 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5167 /* port-H for side (rear panel) */
5168 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5170 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5171 /* route front mic to ADC1*/
5172 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5173 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5174 /* Unmute DAC0~3 & spdif out*/
5175 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5176 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5177 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5178 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5179 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5181 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5182 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5183 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5184 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5185 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5187 /* Unmute Stereo Mixer 15 */
5188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5193 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5195 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5196 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5197 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5199 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5202 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5206 * generic initialization of ADC, input mixers and output mixers
5208 static struct hda_verb alc861_auto_init_verbs[] = {
5210 * Unmute ADC0 and set the default input to mic-in
5212 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5215 /* Unmute DAC0~3 & spdif out*/
5216 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5217 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5218 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5219 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5222 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5223 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5224 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5225 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5226 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5228 /* Unmute Stereo Mixer 15 */
5229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5231 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5232 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
5234 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5235 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5236 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5237 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5238 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5239 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5240 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5243 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5245 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5246 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5247 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5248 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5249 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5252 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
5257 /* pcm configuration: identiacal with ALC880 */
5258 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
5259 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
5260 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
5261 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
5264 #define ALC861_DIGOUT_NID 0x07
5266 static struct hda_channel_mode alc861_8ch_modes[1] = {
5270 static hda_nid_t alc861_dac_nids[4] = {
5271 /* front, surround, clfe, side */
5272 0x03, 0x06, 0x05, 0x04
5275 static hda_nid_t alc861_adc_nids[1] = {
5280 static struct hda_input_mux alc861_capture_source = {
5284 { "Front Mic", 0x3 },
5291 /* fill in the dac_nids table from the parsed pin configuration */
5292 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5297 spec->multiout.dac_nids = spec->private_dac_nids;
5298 for (i = 0; i < cfg->line_outs; i++) {
5299 nid = cfg->line_out_pins[i];
5301 if (i >= ARRAY_SIZE(alc861_dac_nids))
5303 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
5306 spec->multiout.num_dacs = cfg->line_outs;
5310 /* add playback controls from the parsed DAC table */
5311 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
5312 const struct auto_pin_cfg *cfg)
5315 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
5319 for (i = 0; i < cfg->line_outs; i++) {
5320 nid = spec->multiout.dac_nids[i];
5325 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
5326 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
5328 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
5329 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5332 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
5333 if (nid == alc861_dac_nids[idx])
5335 sprintf(name, "%s Playback Switch", chname[idx]);
5336 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
5337 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5344 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
5352 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
5354 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5355 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5357 spec->multiout.hp_nid = nid;
5362 /* create playback/capture controls for input pins */
5363 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5365 struct hda_input_mux *imux = &spec->private_imux;
5366 int i, err, idx, idx1;
5368 for (i = 0; i < AUTO_PIN_LAST; i++) {
5369 switch(cfg->input_pins[i]) {
5394 err = new_analog_input(spec, cfg->input_pins[i],
5395 auto_pin_cfg_labels[i], idx, 0x15);
5399 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
5400 imux->items[imux->num_items].index = idx1;
5406 static struct snd_kcontrol_new alc861_capture_mixer[] = {
5407 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5408 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5411 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5412 /* The multiple "Capture Source" controls confuse alsamixer
5413 * So call somewhat different..
5414 *FIXME: the controls appear in the "playback" view!
5416 /* .name = "Capture Source", */
5417 .name = "Input Source",
5419 .info = alc_mux_enum_info,
5420 .get = alc_mux_enum_get,
5421 .put = alc_mux_enum_put,
5426 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
5427 int pin_type, int dac_idx)
5431 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
5432 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5436 static void alc861_auto_init_multi_out(struct hda_codec *codec)
5438 struct alc_spec *spec = codec->spec;
5441 for (i = 0; i < spec->autocfg.line_outs; i++) {
5442 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5444 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
5448 static void alc861_auto_init_hp_out(struct hda_codec *codec)
5450 struct alc_spec *spec = codec->spec;
5453 pin = spec->autocfg.hp_pin;
5454 if (pin) /* connect to front */
5455 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
5458 static void alc861_auto_init_analog_input(struct hda_codec *codec)
5460 struct alc_spec *spec = codec->spec;
5463 for (i = 0; i < AUTO_PIN_LAST; i++) {
5464 hda_nid_t nid = spec->autocfg.input_pins[i];
5465 if ((nid>=0x0c) && (nid <=0x11)) {
5466 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5467 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
5472 /* parse the BIOS configuration and set up the alc_spec */
5473 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
5474 static int alc861_parse_auto_config(struct hda_codec *codec)
5476 struct alc_spec *spec = codec->spec;
5478 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
5480 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5481 alc861_ignore)) < 0)
5483 if (! spec->autocfg.line_outs)
5484 return 0; /* can't find valid BIOS pin config */
5486 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
5487 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5488 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
5489 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5492 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5494 if (spec->autocfg.dig_out_pin)
5495 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
5497 if (spec->kctl_alloc)
5498 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5500 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
5502 spec->input_mux = &spec->private_imux;
5504 spec->adc_nids = alc861_adc_nids;
5505 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
5506 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
5512 /* additional initialization for auto-configuration model */
5513 static void alc861_auto_init(struct hda_codec *codec)
5515 alc861_auto_init_multi_out(codec);
5516 alc861_auto_init_hp_out(codec);
5517 alc861_auto_init_analog_input(codec);
5522 * configuration and preset
5524 static struct hda_board_config alc861_cfg_tbl[] = {
5525 { .modelname = "3stack", .config = ALC861_3ST },
5526 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
5527 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
5528 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
5529 { .modelname = "auto", .config = ALC861_AUTO },
5533 static struct alc_config_preset alc861_presets[] = {
5535 .mixers = { alc861_3ST_mixer },
5536 .init_verbs = { alc861_threestack_init_verbs },
5537 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5538 .dac_nids = alc861_dac_nids,
5539 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5540 .channel_mode = alc861_threestack_modes,
5541 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5542 .adc_nids = alc861_adc_nids,
5543 .input_mux = &alc861_capture_source,
5545 [ALC861_3ST_DIG] = {
5546 .mixers = { alc861_base_mixer },
5547 .init_verbs = { alc861_threestack_init_verbs },
5548 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5549 .dac_nids = alc861_dac_nids,
5550 .dig_out_nid = ALC861_DIGOUT_NID,
5551 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5552 .channel_mode = alc861_threestack_modes,
5553 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5554 .adc_nids = alc861_adc_nids,
5555 .input_mux = &alc861_capture_source,
5557 [ALC861_6ST_DIG] = {
5558 .mixers = { alc861_base_mixer },
5559 .init_verbs = { alc861_base_init_verbs },
5560 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5561 .dac_nids = alc861_dac_nids,
5562 .dig_out_nid = ALC861_DIGOUT_NID,
5563 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
5564 .channel_mode = alc861_8ch_modes,
5565 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5566 .adc_nids = alc861_adc_nids,
5567 .input_mux = &alc861_capture_source,
5572 static int patch_alc861(struct hda_codec *codec)
5574 struct alc_spec *spec;
5578 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5584 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
5585 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
5586 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
5587 board_config = ALC861_AUTO;
5590 if (board_config == ALC861_AUTO) {
5591 /* automatic parse from the BIOS config */
5592 err = alc861_parse_auto_config(codec);
5597 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
5598 board_config = ALC861_3ST_DIG;
5602 if (board_config != ALC861_AUTO)
5603 setup_preset(spec, &alc861_presets[board_config]);
5605 spec->stream_name_analog = "ALC861 Analog";
5606 spec->stream_analog_playback = &alc861_pcm_analog_playback;
5607 spec->stream_analog_capture = &alc861_pcm_analog_capture;
5609 spec->stream_name_digital = "ALC861 Digital";
5610 spec->stream_digital_playback = &alc861_pcm_digital_playback;
5611 spec->stream_digital_capture = &alc861_pcm_digital_capture;
5613 codec->patch_ops = alc_patch_ops;
5614 if (board_config == ALC861_AUTO)
5615 spec->init_hook = alc861_auto_init;
5623 struct hda_codec_preset snd_hda_preset_realtek[] = {
5624 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
5625 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
5626 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
5627 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
5628 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
5629 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
5630 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },