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 */
83 ALC262_MODEL_LAST /* last tag */
116 #define GPIO_MASK 0x03
119 /* codec parameterization */
120 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
121 unsigned int num_mixers;
123 const struct hda_verb *init_verbs[5]; /* initialization verbs
127 unsigned int num_init_verbs;
129 char *stream_name_analog; /* analog PCM stream */
130 struct hda_pcm_stream *stream_analog_playback;
131 struct hda_pcm_stream *stream_analog_capture;
133 char *stream_name_digital; /* digital PCM stream */
134 struct hda_pcm_stream *stream_digital_playback;
135 struct hda_pcm_stream *stream_digital_capture;
138 struct hda_multi_out multiout; /* playback set-up
139 * max_channels, dacs must be set
140 * dig_out_nid and hp_nid are optional
144 unsigned int num_adc_nids;
146 hda_nid_t dig_in_nid; /* digital-in NID; optional */
149 unsigned int num_mux_defs;
150 const struct hda_input_mux *input_mux;
151 unsigned int cur_mux[3];
154 const struct hda_channel_mode *channel_mode;
155 int num_channel_mode;
157 /* PCM information */
158 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
160 /* dynamic controls, init_verbs and input_mux */
161 struct auto_pin_cfg autocfg;
162 unsigned int num_kctl_alloc, num_kctl_used;
163 struct snd_kcontrol_new *kctl_alloc;
164 struct hda_input_mux private_imux;
165 hda_nid_t private_dac_nids[5];
168 void (*init_hook)(struct hda_codec *codec);
169 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
171 /* for pin sensing */
172 unsigned int sense_updated: 1;
173 unsigned int jack_present: 1;
177 * configuration template - to be copied to the spec instance
179 struct alc_config_preset {
180 struct snd_kcontrol_new *mixers[5]; /* should be identical size
183 const struct hda_verb *init_verbs[5];
184 unsigned int num_dacs;
186 hda_nid_t dig_out_nid; /* optional */
187 hda_nid_t hp_nid; /* optional */
188 unsigned int num_adc_nids;
190 hda_nid_t dig_in_nid;
191 unsigned int num_channel_mode;
192 const struct hda_channel_mode *channel_mode;
193 unsigned int num_mux_defs;
194 const struct hda_input_mux *input_mux;
195 void (*unsol_event)(struct hda_codec *, unsigned int);
196 void (*init_hook)(struct hda_codec *);
203 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
204 struct snd_ctl_elem_info *uinfo)
206 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
207 struct alc_spec *spec = codec->spec;
208 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
209 if (mux_idx >= spec->num_mux_defs)
211 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
214 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
215 struct snd_ctl_elem_value *ucontrol)
217 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
218 struct alc_spec *spec = codec->spec;
219 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
221 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
225 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
226 struct snd_ctl_elem_value *ucontrol)
228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
229 struct alc_spec *spec = codec->spec;
230 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
231 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
232 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
233 spec->adc_nids[adc_idx],
234 &spec->cur_mux[adc_idx]);
239 * channel mode setting
241 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
242 struct snd_ctl_elem_info *uinfo)
244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
245 struct alc_spec *spec = codec->spec;
246 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
247 spec->num_channel_mode);
250 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
251 struct snd_ctl_elem_value *ucontrol)
253 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
254 struct alc_spec *spec = codec->spec;
255 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
256 spec->num_channel_mode,
257 spec->multiout.max_channels);
260 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
261 struct snd_ctl_elem_value *ucontrol)
263 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
264 struct alc_spec *spec = codec->spec;
265 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
266 spec->num_channel_mode,
267 &spec->multiout.max_channels);
271 * Control the mode of pin widget settings via the mixer. "pc" is used
272 * instead of "%" to avoid consequences of accidently treating the % as
273 * being part of a format specifier. Maximum allowed length of a value is
274 * 63 characters plus NULL terminator.
276 * Note: some retasking pin complexes seem to ignore requests for input
277 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
278 * are requested. Therefore order this list so that this behaviour will not
279 * cause problems when mixer clients move through the enum sequentially.
280 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
283 static char *alc_pin_mode_names[] = {
284 "Mic 50pc bias", "Mic 80pc bias",
285 "Line in", "Line out", "Headphone out",
287 static unsigned char alc_pin_mode_values[] = {
288 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
290 /* The control can present all 5 options, or it can limit the options based
291 * in the pin being assumed to be exclusively an input or an output pin. In
292 * addition, "input" pins may or may not process the mic bias option
293 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
294 * accept requests for bias as of chip versions up to March 2006) and/or
295 * wiring in the computer.
297 #define ALC_PIN_DIR_IN 0x00
298 #define ALC_PIN_DIR_OUT 0x01
299 #define ALC_PIN_DIR_INOUT 0x02
300 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
301 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
303 /* Info about the pin modes supported by the different pin direction modes.
304 * For each direction the minimum and maximum values are given.
306 static signed char alc_pin_mode_dir_info[5][2] = {
307 { 0, 2 }, /* ALC_PIN_DIR_IN */
308 { 3, 4 }, /* ALC_PIN_DIR_OUT */
309 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
310 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
311 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
313 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
314 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
315 #define alc_pin_mode_n_items(_dir) \
316 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
318 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
319 struct snd_ctl_elem_info *uinfo)
321 unsigned int item_num = uinfo->value.enumerated.item;
322 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
324 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
326 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
328 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
329 item_num = alc_pin_mode_min(dir);
330 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
334 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
335 struct snd_ctl_elem_value *ucontrol)
338 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
339 hda_nid_t nid = kcontrol->private_value & 0xffff;
340 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
341 long *valp = ucontrol->value.integer.value;
342 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
343 AC_VERB_GET_PIN_WIDGET_CONTROL,
346 /* Find enumerated value for current pinctl setting */
347 i = alc_pin_mode_min(dir);
348 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
350 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
354 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
355 struct snd_ctl_elem_value *ucontrol)
358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
359 hda_nid_t nid = kcontrol->private_value & 0xffff;
360 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
361 long val = *ucontrol->value.integer.value;
362 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
363 AC_VERB_GET_PIN_WIDGET_CONTROL,
366 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
367 val = alc_pin_mode_min(dir);
369 change = pinctl != alc_pin_mode_values[val];
371 /* Set pin mode to that requested */
372 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
373 alc_pin_mode_values[val]);
375 /* Also enable the retasking pin's input/output as required
376 * for the requested pin mode. Enum values of 2 or less are
379 * Dynamically switching the input/output buffers probably
380 * reduces noise slightly (particularly on input) so we'll
381 * do it. However, having both input and output buffers
382 * enabled simultaneously doesn't seem to be problematic if
383 * this turns out to be necessary in the future.
386 snd_hda_codec_write(codec, nid, 0,
387 AC_VERB_SET_AMP_GAIN_MUTE,
389 snd_hda_codec_write(codec, nid, 0,
390 AC_VERB_SET_AMP_GAIN_MUTE,
393 snd_hda_codec_write(codec, nid, 0,
394 AC_VERB_SET_AMP_GAIN_MUTE,
396 snd_hda_codec_write(codec, nid, 0,
397 AC_VERB_SET_AMP_GAIN_MUTE,
404 #define ALC_PIN_MODE(xname, nid, dir) \
405 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
406 .info = alc_pin_mode_info, \
407 .get = alc_pin_mode_get, \
408 .put = alc_pin_mode_put, \
409 .private_value = nid | (dir<<16) }
411 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
412 * together using a mask with more than one bit set. This control is
413 * currently used only by the ALC260 test model. At this stage they are not
414 * needed for any "production" models.
416 #ifdef CONFIG_SND_DEBUG
417 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_info *uinfo)
420 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
422 uinfo->value.integer.min = 0;
423 uinfo->value.integer.max = 1;
426 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
427 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,
434 AC_VERB_GET_GPIO_DATA, 0x00);
436 *valp = (val & mask) != 0;
439 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_value *ucontrol)
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 hda_nid_t nid = kcontrol->private_value & 0xffff;
445 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
446 long val = *ucontrol->value.integer.value;
447 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
448 AC_VERB_GET_GPIO_DATA,
451 /* Set/unset the masked GPIO bit(s) as needed */
452 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
457 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
461 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
462 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
463 .info = alc_gpio_data_info, \
464 .get = alc_gpio_data_get, \
465 .put = alc_gpio_data_put, \
466 .private_value = nid | (mask<<16) }
467 #endif /* CONFIG_SND_DEBUG */
469 /* A switch control to allow the enabling of the digital IO pins on the
470 * ALC260. This is incredibly simplistic; the intention of this control is
471 * to provide something in the test model allowing digital outputs to be
472 * identified if present. If models are found which can utilise these
473 * outputs a more complete mixer control can be devised for those models if
476 #ifdef CONFIG_SND_DEBUG
477 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_info *uinfo)
480 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
482 uinfo->value.integer.min = 0;
483 uinfo->value.integer.max = 1;
486 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
490 hda_nid_t nid = kcontrol->private_value & 0xffff;
491 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
492 long *valp = ucontrol->value.integer.value;
493 unsigned int val = snd_hda_codec_read(codec, nid, 0,
494 AC_VERB_GET_DIGI_CONVERT, 0x00);
496 *valp = (val & mask) != 0;
499 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
504 hda_nid_t nid = kcontrol->private_value & 0xffff;
505 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
506 long val = *ucontrol->value.integer.value;
507 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
508 AC_VERB_GET_DIGI_CONVERT,
511 /* Set/unset the masked control bit(s) as needed */
512 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
517 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
522 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
523 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
524 .info = alc_spdif_ctrl_info, \
525 .get = alc_spdif_ctrl_get, \
526 .put = alc_spdif_ctrl_put, \
527 .private_value = nid | (mask<<16) }
528 #endif /* CONFIG_SND_DEBUG */
531 * set up from the preset table
533 static void setup_preset(struct alc_spec *spec,
534 const struct alc_config_preset *preset)
538 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
539 spec->mixers[spec->num_mixers++] = preset->mixers[i];
540 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
542 spec->init_verbs[spec->num_init_verbs++] =
543 preset->init_verbs[i];
545 spec->channel_mode = preset->channel_mode;
546 spec->num_channel_mode = preset->num_channel_mode;
548 spec->multiout.max_channels = spec->channel_mode[0].channels;
550 spec->multiout.num_dacs = preset->num_dacs;
551 spec->multiout.dac_nids = preset->dac_nids;
552 spec->multiout.dig_out_nid = preset->dig_out_nid;
553 spec->multiout.hp_nid = preset->hp_nid;
555 spec->num_mux_defs = preset->num_mux_defs;
556 if (! spec->num_mux_defs)
557 spec->num_mux_defs = 1;
558 spec->input_mux = preset->input_mux;
560 spec->num_adc_nids = preset->num_adc_nids;
561 spec->adc_nids = preset->adc_nids;
562 spec->dig_in_nid = preset->dig_in_nid;
564 spec->unsol_event = preset->unsol_event;
565 spec->init_hook = preset->init_hook;
569 * ALC880 3-stack model
571 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
572 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
573 * F-Mic = 0x1b, HP = 0x19
576 static hda_nid_t alc880_dac_nids[4] = {
577 /* front, rear, clfe, rear_surr */
578 0x02, 0x05, 0x04, 0x03
581 static hda_nid_t alc880_adc_nids[3] = {
586 /* The datasheet says the node 0x07 is connected from inputs,
587 * but it shows zero connection in the real implementation on some devices.
588 * Note: this is a 915GAV bug, fixed on 915GLV
590 static hda_nid_t alc880_adc_nids_alt[2] = {
595 #define ALC880_DIGOUT_NID 0x06
596 #define ALC880_DIGIN_NID 0x0a
598 static struct hda_input_mux alc880_capture_source = {
602 { "Front Mic", 0x3 },
608 /* channel source setting (2/6 channel selection for 3-stack) */
610 static struct hda_verb alc880_threestack_ch2_init[] = {
611 /* set line-in to input, mute it */
612 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
613 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
614 /* set mic-in to input vref 80%, mute it */
615 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
616 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
621 static struct hda_verb alc880_threestack_ch6_init[] = {
622 /* set line-in to output, unmute it */
623 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
624 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
625 /* set mic-in to output, unmute it */
626 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
627 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
631 static struct hda_channel_mode alc880_threestack_modes[2] = {
632 { 2, alc880_threestack_ch2_init },
633 { 6, alc880_threestack_ch6_init },
636 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
637 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
639 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
640 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
641 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
642 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
643 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
644 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
647 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
648 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
653 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
654 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
657 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
658 .name = "Channel Mode",
659 .info = alc_ch_mode_info,
660 .get = alc_ch_mode_get,
661 .put = alc_ch_mode_put,
666 /* capture mixer elements */
667 static struct snd_kcontrol_new alc880_capture_mixer[] = {
668 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
669 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
670 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
671 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
672 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
673 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
676 /* The multiple "Capture Source" controls confuse alsamixer
677 * So call somewhat different..
678 * FIXME: the controls appear in the "playback" view!
680 /* .name = "Capture Source", */
681 .name = "Input Source",
683 .info = alc_mux_enum_info,
684 .get = alc_mux_enum_get,
685 .put = alc_mux_enum_put,
690 /* capture mixer elements (in case NID 0x07 not available) */
691 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
692 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
693 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
694 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
695 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
698 /* The multiple "Capture Source" controls confuse alsamixer
699 * So call somewhat different..
700 * FIXME: the controls appear in the "playback" view!
702 /* .name = "Capture Source", */
703 .name = "Input Source",
705 .info = alc_mux_enum_info,
706 .get = alc_mux_enum_get,
707 .put = alc_mux_enum_put,
715 * ALC880 5-stack model
717 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
719 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
720 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
723 /* additional mixers to alc880_three_stack_mixer */
724 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
725 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
726 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
730 /* channel source setting (6/8 channel selection for 5-stack) */
732 static struct hda_verb alc880_fivestack_ch6_init[] = {
733 /* set line-in to input, mute it */
734 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
735 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
740 static struct hda_verb alc880_fivestack_ch8_init[] = {
741 /* set line-in to output, unmute it */
742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
747 static struct hda_channel_mode alc880_fivestack_modes[2] = {
748 { 6, alc880_fivestack_ch6_init },
749 { 8, alc880_fivestack_ch8_init },
754 * ALC880 6-stack model
756 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
758 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
759 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
762 static hda_nid_t alc880_6st_dac_nids[4] = {
763 /* front, rear, clfe, rear_surr */
764 0x02, 0x03, 0x04, 0x05
767 static struct hda_input_mux alc880_6stack_capture_source = {
771 { "Front Mic", 0x1 },
777 /* fixed 8-channels */
778 static struct hda_channel_mode alc880_sixstack_modes[1] = {
782 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
783 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
784 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
785 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
786 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
787 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
788 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
789 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
790 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
791 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
792 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
801 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
802 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
805 .name = "Channel Mode",
806 .info = alc_ch_mode_info,
807 .get = alc_ch_mode_get,
808 .put = alc_ch_mode_put,
817 * W810 has rear IO for:
820 * Center/LFE (DAC 04)
823 * The system also has a pair of internal speakers, and a headphone jack.
824 * These are both connected to Line2 on the codec, hence to DAC 02.
826 * There is a variable resistor to control the speaker or headphone
827 * volume. This is a hardware-only device without a software API.
829 * Plugging headphones in will disable the internal speakers. This is
830 * implemented in hardware, not via the driver using jack sense. In
831 * a similar fashion, plugging into the rear socket marked "front" will
832 * disable both the speakers and headphones.
834 * For input, there's a microphone jack, and an "audio in" jack.
835 * These may not do anything useful with this driver yet, because I
836 * haven't setup any initialization verbs for these yet...
839 static hda_nid_t alc880_w810_dac_nids[3] = {
840 /* front, rear/surround, clfe */
844 /* fixed 6 channels */
845 static struct hda_channel_mode alc880_w810_modes[1] = {
849 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
850 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
852 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
853 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
854 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
855 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
856 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
857 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
858 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
867 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
868 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
872 static hda_nid_t alc880_z71v_dac_nids[1] = {
875 #define ALC880_Z71V_HP_DAC 0x03
877 /* fixed 2 channels */
878 static struct hda_channel_mode alc880_2_jack_modes[1] = {
882 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
884 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
885 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
886 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
899 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
900 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
903 static hda_nid_t alc880_f1734_dac_nids[1] = {
906 #define ALC880_F1734_HP_DAC 0x02
908 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
909 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
910 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
911 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
912 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
915 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
916 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
925 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
926 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
927 * Mic = 0x18, Line = 0x1a
930 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
931 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
933 static struct snd_kcontrol_new alc880_asus_mixer[] = {
934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
936 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
937 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
942 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
943 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
944 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
945 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
950 .name = "Channel Mode",
951 .info = alc_ch_mode_info,
952 .get = alc_ch_mode_get,
953 .put = alc_ch_mode_put,
960 * ALC880 ASUS W1V model
962 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
963 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
964 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
967 /* additional mixers to alc880_asus_mixer */
968 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
969 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
970 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
974 /* additional mixers to alc880_asus_mixer */
975 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
976 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
977 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
982 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
984 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
987 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
990 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
991 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
994 /* The multiple "Capture Source" controls confuse alsamixer
995 * So call somewhat different..
996 * FIXME: the controls appear in the "playback" view!
998 /* .name = "Capture Source", */
999 .name = "Input Source",
1001 .info = alc_mux_enum_info,
1002 .get = alc_mux_enum_get,
1003 .put = alc_mux_enum_put,
1009 * build control elements
1011 static int alc_build_controls(struct hda_codec *codec)
1013 struct alc_spec *spec = codec->spec;
1017 for (i = 0; i < spec->num_mixers; i++) {
1018 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1023 if (spec->multiout.dig_out_nid) {
1024 err = snd_hda_create_spdif_out_ctls(codec,
1025 spec->multiout.dig_out_nid);
1029 if (spec->dig_in_nid) {
1030 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1039 * initialize the codec volumes, etc
1043 * generic initialization of ADC, input mixers and output mixers
1045 static struct hda_verb alc880_volume_init_verbs[] = {
1047 * Unmute ADC0-2 and set the default input to mic-in
1049 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1051 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1052 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1053 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1054 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1056 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1058 * Note: PASD motherboards uses the Line In 2 as the input for front
1061 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1069 * Set up output mixers (0x0c - 0x0f)
1071 /* set vol=0 to output mixers */
1072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1075 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1076 /* set up input amps for analog loopback */
1077 /* Amp Indices: DAC = 0, mixer = 1 */
1078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1085 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1091 * 3-stack pin configuration:
1092 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1094 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1096 * preset connection lists of input pins
1097 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1099 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1100 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1101 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1104 * Set pin mode and muting
1106 /* set front pin widgets 0x14 for output */
1107 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1108 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1109 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1110 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1111 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1112 /* Mic2 (as headphone out) for HP output */
1113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1115 /* Line In pin widget for input */
1116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1118 /* Line2 (as front mic) pin widget for input and vref at 80% */
1119 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1120 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1121 /* CD pin widget for input */
1122 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1128 * 5-stack pin configuration:
1129 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1130 * line-in/side = 0x1a, f-mic = 0x1b
1132 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1134 * preset connection lists of input pins
1135 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1137 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1138 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1141 * Set pin mode and muting
1143 /* set pin widgets 0x14-0x17 for output */
1144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1146 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1147 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1148 /* unmute pins for output (no gain on this amp) */
1149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1151 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1152 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1154 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1155 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1156 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1157 /* Mic2 (as headphone out) for HP output */
1158 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1159 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1160 /* Line In pin widget for input */
1161 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1162 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1163 /* Line2 (as front mic) pin widget for input and vref at 80% */
1164 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1165 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1166 /* CD pin widget for input */
1167 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1173 * W810 pin configuration:
1174 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1176 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1177 /* hphone/speaker input selector: front DAC */
1178 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1185 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1187 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1188 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1194 * Z71V pin configuration:
1195 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1197 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1206 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1212 * 6-stack pin configuration:
1213 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1214 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1216 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1217 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1223 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1224 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1225 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1226 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1228 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1230 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1243 * F1734 pin configuration:
1244 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1246 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1247 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1248 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1249 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1250 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1259 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1260 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1261 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1262 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1265 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1272 * ASUS pin configuration:
1273 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1275 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1276 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1277 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1278 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1279 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1282 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1284 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1285 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1288 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1291 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1292 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1294 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1295 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1296 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1297 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1298 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1303 /* Enable GPIO mask and set output */
1304 static struct hda_verb alc880_gpio1_init_verbs[] = {
1305 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1306 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1307 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1312 /* Enable GPIO mask and set output */
1313 static struct hda_verb alc880_gpio2_init_verbs[] = {
1314 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1315 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1316 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1321 /* Clevo m520g init */
1322 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1323 /* headphone output */
1324 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1330 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1332 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1333 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1334 /* Mic1 (rear panel) */
1335 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1336 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1337 /* Mic2 (front panel) */
1338 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1341 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1342 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1343 /* change to EAPD mode */
1344 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1345 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1350 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1351 /* Headphone output */
1352 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1355 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1357 /* Line In pin widget for input */
1358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1359 /* CD pin widget for input */
1360 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1361 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1364 /* change to EAPD mode */
1365 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1366 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1372 * LG m1 express dual
1375 * Rear Line-In/Out (blue): 0x14
1376 * Build-in Mic-In: 0x15
1378 * HP-Out (green): 0x1b
1379 * Mic-In/Out (red): 0x19
1383 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1384 static hda_nid_t alc880_lg_dac_nids[3] = {
1388 /* seems analog CD is not working */
1389 static struct hda_input_mux alc880_lg_capture_source = {
1394 { "Internal Mic", 0x6 },
1398 /* 2,4,6 channel modes */
1399 static struct hda_verb alc880_lg_ch2_init[] = {
1400 /* set line-in and mic-in to input */
1401 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1402 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1406 static struct hda_verb alc880_lg_ch4_init[] = {
1407 /* set line-in to out and mic-in to input */
1408 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1409 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1413 static struct hda_verb alc880_lg_ch6_init[] = {
1414 /* set line-in and mic-in to output */
1415 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1416 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1420 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1421 { 2, alc880_lg_ch2_init },
1422 { 4, alc880_lg_ch4_init },
1423 { 6, alc880_lg_ch6_init },
1426 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1427 /* FIXME: it's not really "master" but front channels */
1428 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1429 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1430 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1431 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1432 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1433 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1434 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1435 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1436 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1437 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1438 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1439 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1440 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1441 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1444 .name = "Channel Mode",
1445 .info = alc_ch_mode_info,
1446 .get = alc_ch_mode_get,
1447 .put = alc_ch_mode_put,
1452 static struct hda_verb alc880_lg_init_verbs[] = {
1453 /* set capture source to mic-in */
1454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1457 /* mute all amp mixer inputs */
1458 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1459 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1460 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1461 /* line-in to input */
1462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1469 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 /* mic-in to input */
1471 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1475 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1483 /* toggle speaker-output according to the hp-jack state */
1484 static void alc880_lg_automute(struct hda_codec *codec)
1486 unsigned int present;
1488 present = snd_hda_codec_read(codec, 0x1b, 0,
1489 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1490 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1491 0x80, present ? 0x80 : 0);
1492 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1493 0x80, present ? 0x80 : 0);
1496 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1498 /* Looks like the unsol event is incompatible with the standard
1499 * definition. 4bit tag is placed at 28 bit!
1501 if ((res >> 28) == 0x01)
1502 alc880_lg_automute(codec);
1511 * Built-in Mic-In: 0x19 (?)
1516 /* seems analog CD is not working */
1517 static struct hda_input_mux alc880_lg_lw_capture_source = {
1521 { "Internal Mic", 0x1 },
1525 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1526 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1527 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1530 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1531 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1535 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1536 /* set capture source to mic-in */
1537 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1543 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1545 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1547 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1548 /* mic-in to input */
1549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1555 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1559 /* toggle speaker-output according to the hp-jack state */
1560 static void alc880_lg_lw_automute(struct hda_codec *codec)
1562 unsigned int present;
1564 present = snd_hda_codec_read(codec, 0x1b, 0,
1565 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1566 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1567 0x80, present ? 0x80 : 0);
1568 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1569 0x80, present ? 0x80 : 0);
1572 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1574 /* Looks like the unsol event is incompatible with the standard
1575 * definition. 4bit tag is placed at 28 bit!
1577 if ((res >> 28) == 0x01)
1578 alc880_lg_lw_automute(codec);
1585 static int alc_init(struct hda_codec *codec)
1587 struct alc_spec *spec = codec->spec;
1590 for (i = 0; i < spec->num_init_verbs; i++)
1591 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1593 if (spec->init_hook)
1594 spec->init_hook(codec);
1599 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1601 struct alc_spec *spec = codec->spec;
1603 if (spec->unsol_event)
1604 spec->unsol_event(codec, res);
1611 static int alc_resume(struct hda_codec *codec)
1613 struct alc_spec *spec = codec->spec;
1617 for (i = 0; i < spec->num_mixers; i++)
1618 snd_hda_resume_ctls(codec, spec->mixers[i]);
1619 if (spec->multiout.dig_out_nid)
1620 snd_hda_resume_spdif_out(codec);
1621 if (spec->dig_in_nid)
1622 snd_hda_resume_spdif_in(codec);
1629 * Analog playback callbacks
1631 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1632 struct hda_codec *codec,
1633 struct snd_pcm_substream *substream)
1635 struct alc_spec *spec = codec->spec;
1636 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1639 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1640 struct hda_codec *codec,
1641 unsigned int stream_tag,
1642 unsigned int format,
1643 struct snd_pcm_substream *substream)
1645 struct alc_spec *spec = codec->spec;
1646 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
1647 stream_tag, format, substream);
1650 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1651 struct hda_codec *codec,
1652 struct snd_pcm_substream *substream)
1654 struct alc_spec *spec = codec->spec;
1655 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1661 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1662 struct hda_codec *codec,
1663 struct snd_pcm_substream *substream)
1665 struct alc_spec *spec = codec->spec;
1666 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1669 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1670 struct hda_codec *codec,
1671 struct snd_pcm_substream *substream)
1673 struct alc_spec *spec = codec->spec;
1674 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1680 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1681 struct hda_codec *codec,
1682 unsigned int stream_tag,
1683 unsigned int format,
1684 struct snd_pcm_substream *substream)
1686 struct alc_spec *spec = codec->spec;
1688 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1689 stream_tag, 0, format);
1693 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1694 struct hda_codec *codec,
1695 struct snd_pcm_substream *substream)
1697 struct alc_spec *spec = codec->spec;
1699 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1707 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1711 /* NID is set in alc_build_pcms */
1713 .open = alc880_playback_pcm_open,
1714 .prepare = alc880_playback_pcm_prepare,
1715 .cleanup = alc880_playback_pcm_cleanup
1719 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1723 /* NID is set in alc_build_pcms */
1725 .prepare = alc880_capture_pcm_prepare,
1726 .cleanup = alc880_capture_pcm_cleanup
1730 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1734 /* NID is set in alc_build_pcms */
1736 .open = alc880_dig_playback_pcm_open,
1737 .close = alc880_dig_playback_pcm_close
1741 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1745 /* NID is set in alc_build_pcms */
1748 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1749 static struct hda_pcm_stream alc_pcm_null_playback = {
1755 static int alc_build_pcms(struct hda_codec *codec)
1757 struct alc_spec *spec = codec->spec;
1758 struct hda_pcm *info = spec->pcm_rec;
1761 codec->num_pcms = 1;
1762 codec->pcm_info = info;
1764 info->name = spec->stream_name_analog;
1765 if (spec->stream_analog_playback) {
1766 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1767 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1768 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1770 if (spec->stream_analog_capture) {
1771 snd_assert(spec->adc_nids, return -EINVAL);
1772 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1773 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1776 if (spec->channel_mode) {
1777 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1778 for (i = 0; i < spec->num_channel_mode; i++) {
1779 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1780 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1785 /* If the use of more than one ADC is requested for the current
1786 * model, configure a second analog capture-only PCM.
1788 if (spec->num_adc_nids > 1) {
1791 info->name = spec->stream_name_analog;
1792 /* No playback stream for second PCM */
1793 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1794 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1795 if (spec->stream_analog_capture) {
1796 snd_assert(spec->adc_nids, return -EINVAL);
1797 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1798 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1802 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1805 info->name = spec->stream_name_digital;
1806 if (spec->multiout.dig_out_nid &&
1807 spec->stream_digital_playback) {
1808 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1809 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1811 if (spec->dig_in_nid &&
1812 spec->stream_digital_capture) {
1813 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1814 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1821 static void alc_free(struct hda_codec *codec)
1823 struct alc_spec *spec = codec->spec;
1829 if (spec->kctl_alloc) {
1830 for (i = 0; i < spec->num_kctl_used; i++)
1831 kfree(spec->kctl_alloc[i].name);
1832 kfree(spec->kctl_alloc);
1839 static struct hda_codec_ops alc_patch_ops = {
1840 .build_controls = alc_build_controls,
1841 .build_pcms = alc_build_pcms,
1844 .unsol_event = alc_unsol_event,
1846 .resume = alc_resume,
1852 * Test configuration for debugging
1854 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1857 #ifdef CONFIG_SND_DEBUG
1858 static hda_nid_t alc880_test_dac_nids[4] = {
1859 0x02, 0x03, 0x04, 0x05
1862 static struct hda_input_mux alc880_test_capture_source = {
1871 { "Surround", 0x6 },
1875 static struct hda_channel_mode alc880_test_modes[4] = {
1882 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1883 struct snd_ctl_elem_info *uinfo)
1885 static char *texts[] = {
1886 "N/A", "Line Out", "HP Out",
1887 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1889 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1891 uinfo->value.enumerated.items = 8;
1892 if (uinfo->value.enumerated.item >= 8)
1893 uinfo->value.enumerated.item = 7;
1894 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1898 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1899 struct snd_ctl_elem_value *ucontrol)
1901 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1902 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1903 unsigned int pin_ctl, item = 0;
1905 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1906 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1907 if (pin_ctl & AC_PINCTL_OUT_EN) {
1908 if (pin_ctl & AC_PINCTL_HP_EN)
1912 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1913 switch (pin_ctl & AC_PINCTL_VREFEN) {
1914 case AC_PINCTL_VREF_HIZ: item = 3; break;
1915 case AC_PINCTL_VREF_50: item = 4; break;
1916 case AC_PINCTL_VREF_GRD: item = 5; break;
1917 case AC_PINCTL_VREF_80: item = 6; break;
1918 case AC_PINCTL_VREF_100: item = 7; break;
1921 ucontrol->value.enumerated.item[0] = item;
1925 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1926 struct snd_ctl_elem_value *ucontrol)
1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1929 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1930 static unsigned int ctls[] = {
1931 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1932 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1933 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1934 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1935 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1936 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1938 unsigned int old_ctl, new_ctl;
1940 old_ctl = snd_hda_codec_read(codec, nid, 0,
1941 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1942 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1943 if (old_ctl != new_ctl) {
1944 snd_hda_codec_write(codec, nid, 0,
1945 AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1946 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1947 (ucontrol->value.enumerated.item[0] >= 3 ?
1954 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1955 struct snd_ctl_elem_info *uinfo)
1957 static char *texts[] = {
1958 "Front", "Surround", "CLFE", "Side"
1960 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1962 uinfo->value.enumerated.items = 4;
1963 if (uinfo->value.enumerated.item >= 4)
1964 uinfo->value.enumerated.item = 3;
1965 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1969 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1970 struct snd_ctl_elem_value *ucontrol)
1972 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1973 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1976 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1977 ucontrol->value.enumerated.item[0] = sel & 3;
1981 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
1984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1985 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1988 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1989 if (ucontrol->value.enumerated.item[0] != sel) {
1990 sel = ucontrol->value.enumerated.item[0] & 3;
1991 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1997 #define PIN_CTL_TEST(xname,nid) { \
1998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2000 .info = alc_test_pin_ctl_info, \
2001 .get = alc_test_pin_ctl_get, \
2002 .put = alc_test_pin_ctl_put, \
2003 .private_value = nid \
2006 #define PIN_SRC_TEST(xname,nid) { \
2007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2009 .info = alc_test_pin_src_info, \
2010 .get = alc_test_pin_src_get, \
2011 .put = alc_test_pin_src_put, \
2012 .private_value = nid \
2015 static struct snd_kcontrol_new alc880_test_mixer[] = {
2016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2017 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2018 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2019 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2020 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2021 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2022 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2023 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2024 PIN_CTL_TEST("Front Pin Mode", 0x14),
2025 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2026 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2027 PIN_CTL_TEST("Side Pin Mode", 0x17),
2028 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2029 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2030 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2031 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2032 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2033 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2034 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2035 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2036 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2037 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2038 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2039 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2040 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2041 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2042 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2043 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2044 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2045 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2048 .name = "Channel Mode",
2049 .info = alc_ch_mode_info,
2050 .get = alc_ch_mode_get,
2051 .put = alc_ch_mode_put,
2056 static struct hda_verb alc880_test_init_verbs[] = {
2057 /* Unmute inputs of 0x0c - 0x0f */
2058 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2060 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2061 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2062 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2065 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2066 /* Vol output for 0x0c-0x0f */
2067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2068 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2069 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2070 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2071 /* Set output pins 0x14-0x17 */
2072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2074 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2075 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2076 /* Unmute output pins 0x14-0x17 */
2077 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2079 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2081 /* Set input pins 0x18-0x1c */
2082 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2083 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2085 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2086 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2087 /* Mute input pins 0x18-0x1b */
2088 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2089 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2091 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2094 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2096 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2097 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2098 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2099 /* Analog input/passthru */
2100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2112 static struct hda_board_config alc880_cfg_tbl[] = {
2113 /* Back 3 jack, front 2 jack */
2114 { .modelname = "3stack", .config = ALC880_3ST },
2115 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2116 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2117 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2118 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2119 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2120 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2121 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2122 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2123 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2124 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2125 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2126 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2127 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2128 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2129 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2130 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2131 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2132 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2133 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2134 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2135 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2136 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2137 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2138 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2139 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2140 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2141 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2142 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2143 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2144 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2145 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2146 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2148 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2150 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2151 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2152 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2153 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2155 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2156 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2157 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2158 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2159 /* Clevo m520G NB */
2160 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
2162 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2163 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2164 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2165 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2167 /* Back 5 jack, front 2 jack */
2168 { .modelname = "5stack", .config = ALC880_5ST },
2169 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2170 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2171 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2172 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2173 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2175 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2176 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2177 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2178 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2179 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2180 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2181 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2182 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2183 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2184 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2185 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2186 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2187 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2188 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2189 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2190 /* note subvendor = 0 below */
2191 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2193 { .modelname = "w810", .config = ALC880_W810 },
2194 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2196 { .modelname = "z71v", .config = ALC880_Z71V },
2197 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2199 { .modelname = "6stack", .config = ALC880_6ST },
2200 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2201 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2202 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2203 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2205 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2206 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2207 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2208 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2209 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2210 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2211 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2212 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2213 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2214 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2215 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2216 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2218 { .modelname = "asus", .config = ALC880_ASUS },
2219 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2220 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2221 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2222 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2223 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2224 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2225 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2226 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2227 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2228 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2229 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2230 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2231 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2233 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2234 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2236 { .modelname = "F1734", .config = ALC880_F1734 },
2237 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2238 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2240 { .modelname = "lg", .config = ALC880_LG },
2241 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2242 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
2244 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2245 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2247 #ifdef CONFIG_SND_DEBUG
2248 { .modelname = "test", .config = ALC880_TEST },
2250 { .modelname = "auto", .config = ALC880_AUTO },
2256 * ALC880 codec presets
2258 static struct alc_config_preset alc880_presets[] = {
2260 .mixers = { alc880_three_stack_mixer },
2261 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2262 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2263 .dac_nids = alc880_dac_nids,
2264 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2265 .channel_mode = alc880_threestack_modes,
2266 .input_mux = &alc880_capture_source,
2268 [ALC880_3ST_DIG] = {
2269 .mixers = { alc880_three_stack_mixer },
2270 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2271 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2272 .dac_nids = alc880_dac_nids,
2273 .dig_out_nid = ALC880_DIGOUT_NID,
2274 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2275 .channel_mode = alc880_threestack_modes,
2276 .input_mux = &alc880_capture_source,
2278 [ALC880_TCL_S700] = {
2279 .mixers = { alc880_tcl_s700_mixer },
2280 .init_verbs = { alc880_volume_init_verbs,
2281 alc880_pin_tcl_S700_init_verbs,
2282 alc880_gpio2_init_verbs },
2283 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2284 .dac_nids = alc880_dac_nids,
2286 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2287 .channel_mode = alc880_2_jack_modes,
2288 .input_mux = &alc880_capture_source,
2291 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2292 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2293 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2294 .dac_nids = alc880_dac_nids,
2295 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2296 .channel_mode = alc880_fivestack_modes,
2297 .input_mux = &alc880_capture_source,
2299 [ALC880_5ST_DIG] = {
2300 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2301 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2302 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2303 .dac_nids = alc880_dac_nids,
2304 .dig_out_nid = ALC880_DIGOUT_NID,
2305 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2306 .channel_mode = alc880_fivestack_modes,
2307 .input_mux = &alc880_capture_source,
2310 .mixers = { alc880_six_stack_mixer },
2311 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2312 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2313 .dac_nids = alc880_6st_dac_nids,
2314 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2315 .channel_mode = alc880_sixstack_modes,
2316 .input_mux = &alc880_6stack_capture_source,
2318 [ALC880_6ST_DIG] = {
2319 .mixers = { alc880_six_stack_mixer },
2320 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2321 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2322 .dac_nids = alc880_6st_dac_nids,
2323 .dig_out_nid = ALC880_DIGOUT_NID,
2324 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2325 .channel_mode = alc880_sixstack_modes,
2326 .input_mux = &alc880_6stack_capture_source,
2329 .mixers = { alc880_w810_base_mixer },
2330 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2331 alc880_gpio2_init_verbs },
2332 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2333 .dac_nids = alc880_w810_dac_nids,
2334 .dig_out_nid = ALC880_DIGOUT_NID,
2335 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2336 .channel_mode = alc880_w810_modes,
2337 .input_mux = &alc880_capture_source,
2340 .mixers = { alc880_z71v_mixer },
2341 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2342 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2343 .dac_nids = alc880_z71v_dac_nids,
2344 .dig_out_nid = ALC880_DIGOUT_NID,
2346 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2347 .channel_mode = alc880_2_jack_modes,
2348 .input_mux = &alc880_capture_source,
2351 .mixers = { alc880_f1734_mixer },
2352 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2353 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2354 .dac_nids = alc880_f1734_dac_nids,
2356 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2357 .channel_mode = alc880_2_jack_modes,
2358 .input_mux = &alc880_capture_source,
2361 .mixers = { alc880_asus_mixer },
2362 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2363 alc880_gpio1_init_verbs },
2364 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2365 .dac_nids = alc880_asus_dac_nids,
2366 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2367 .channel_mode = alc880_asus_modes,
2368 .input_mux = &alc880_capture_source,
2370 [ALC880_ASUS_DIG] = {
2371 .mixers = { alc880_asus_mixer },
2372 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2373 alc880_gpio1_init_verbs },
2374 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2375 .dac_nids = alc880_asus_dac_nids,
2376 .dig_out_nid = ALC880_DIGOUT_NID,
2377 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2378 .channel_mode = alc880_asus_modes,
2379 .input_mux = &alc880_capture_source,
2381 [ALC880_ASUS_DIG2] = {
2382 .mixers = { alc880_asus_mixer },
2383 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2384 alc880_gpio2_init_verbs }, /* use GPIO2 */
2385 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2386 .dac_nids = alc880_asus_dac_nids,
2387 .dig_out_nid = ALC880_DIGOUT_NID,
2388 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2389 .channel_mode = alc880_asus_modes,
2390 .input_mux = &alc880_capture_source,
2392 [ALC880_ASUS_W1V] = {
2393 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2394 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2395 alc880_gpio1_init_verbs },
2396 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2397 .dac_nids = alc880_asus_dac_nids,
2398 .dig_out_nid = ALC880_DIGOUT_NID,
2399 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2400 .channel_mode = alc880_asus_modes,
2401 .input_mux = &alc880_capture_source,
2403 [ALC880_UNIWILL_DIG] = {
2404 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2405 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2406 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2407 .dac_nids = alc880_asus_dac_nids,
2408 .dig_out_nid = ALC880_DIGOUT_NID,
2409 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2410 .channel_mode = alc880_asus_modes,
2411 .input_mux = &alc880_capture_source,
2414 .mixers = { alc880_three_stack_mixer },
2415 .init_verbs = { alc880_volume_init_verbs,
2416 alc880_pin_clevo_init_verbs },
2417 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2418 .dac_nids = alc880_dac_nids,
2420 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2421 .channel_mode = alc880_threestack_modes,
2422 .input_mux = &alc880_capture_source,
2425 .mixers = { alc880_lg_mixer },
2426 .init_verbs = { alc880_volume_init_verbs,
2427 alc880_lg_init_verbs },
2428 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2429 .dac_nids = alc880_lg_dac_nids,
2430 .dig_out_nid = ALC880_DIGOUT_NID,
2431 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2432 .channel_mode = alc880_lg_ch_modes,
2433 .input_mux = &alc880_lg_capture_source,
2434 .unsol_event = alc880_lg_unsol_event,
2435 .init_hook = alc880_lg_automute,
2438 .mixers = { alc880_lg_lw_mixer },
2439 .init_verbs = { alc880_volume_init_verbs,
2440 alc880_lg_lw_init_verbs },
2442 .dac_nids = alc880_dac_nids,
2443 .dig_out_nid = ALC880_DIGOUT_NID,
2444 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2445 .channel_mode = alc880_2_jack_modes,
2446 .input_mux = &alc880_lg_lw_capture_source,
2447 .unsol_event = alc880_lg_lw_unsol_event,
2448 .init_hook = alc880_lg_lw_automute,
2450 #ifdef CONFIG_SND_DEBUG
2452 .mixers = { alc880_test_mixer },
2453 .init_verbs = { alc880_test_init_verbs },
2454 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2455 .dac_nids = alc880_test_dac_nids,
2456 .dig_out_nid = ALC880_DIGOUT_NID,
2457 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2458 .channel_mode = alc880_test_modes,
2459 .input_mux = &alc880_test_capture_source,
2465 * Automatic parse of I/O pins from the BIOS configuration
2468 #define NUM_CONTROL_ALLOC 32
2469 #define NUM_VERB_ALLOC 32
2473 ALC_CTL_WIDGET_MUTE,
2476 static struct snd_kcontrol_new alc880_control_templates[] = {
2477 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2478 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2479 HDA_BIND_MUTE(NULL, 0, 0, 0),
2482 /* add dynamic controls */
2483 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2485 struct snd_kcontrol_new *knew;
2487 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2488 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2490 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2493 if (spec->kctl_alloc) {
2494 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2495 kfree(spec->kctl_alloc);
2497 spec->kctl_alloc = knew;
2498 spec->num_kctl_alloc = num;
2501 knew = &spec->kctl_alloc[spec->num_kctl_used];
2502 *knew = alc880_control_templates[type];
2503 knew->name = kstrdup(name, GFP_KERNEL);
2506 knew->private_value = val;
2507 spec->num_kctl_used++;
2511 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2512 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2513 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2514 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2515 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2516 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2517 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2518 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2519 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2520 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2521 #define ALC880_PIN_CD_NID 0x1c
2523 /* fill in the dac_nids table from the parsed pin configuration */
2524 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2530 memset(assigned, 0, sizeof(assigned));
2531 spec->multiout.dac_nids = spec->private_dac_nids;
2533 /* check the pins hardwired to audio widget */
2534 for (i = 0; i < cfg->line_outs; i++) {
2535 nid = cfg->line_out_pins[i];
2536 if (alc880_is_fixed_pin(nid)) {
2537 int idx = alc880_fixed_pin_idx(nid);
2538 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2542 /* left pins can be connect to any audio widget */
2543 for (i = 0; i < cfg->line_outs; i++) {
2544 nid = cfg->line_out_pins[i];
2545 if (alc880_is_fixed_pin(nid))
2547 /* search for an empty channel */
2548 for (j = 0; j < cfg->line_outs; j++) {
2549 if (! assigned[j]) {
2550 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2556 spec->multiout.num_dacs = cfg->line_outs;
2560 /* add playback controls from the parsed DAC table */
2561 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2562 const struct auto_pin_cfg *cfg)
2565 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2569 for (i = 0; i < cfg->line_outs; i++) {
2570 if (! spec->multiout.dac_nids[i])
2572 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2575 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2576 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2578 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2579 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2581 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2582 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2584 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2585 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2588 sprintf(name, "%s Playback Volume", chname[i]);
2589 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2590 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2592 sprintf(name, "%s Playback Switch", chname[i]);
2593 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2594 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2601 /* add playback controls for speaker and HP outputs */
2602 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2612 if (alc880_is_fixed_pin(pin)) {
2613 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2614 /* specify the DAC as the extra output */
2615 if (! spec->multiout.hp_nid)
2616 spec->multiout.hp_nid = nid;
2618 spec->multiout.extra_out_nid[0] = nid;
2619 /* control HP volume/switch on the output mixer amp */
2620 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2621 sprintf(name, "%s Playback Volume", pfx);
2622 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2623 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2625 sprintf(name, "%s Playback Switch", pfx);
2626 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2627 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2629 } else if (alc880_is_multi_pin(pin)) {
2630 /* set manual connection */
2631 /* we have only a switch on HP-out PIN */
2632 sprintf(name, "%s Playback Switch", pfx);
2633 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2634 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2640 /* create input playback/capture controls for the given pin */
2641 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2642 int idx, hda_nid_t mix_nid)
2647 sprintf(name, "%s Playback Volume", ctlname);
2648 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2649 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2651 sprintf(name, "%s Playback Switch", ctlname);
2652 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2653 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2658 /* create playback/capture controls for input pins */
2659 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2660 const struct auto_pin_cfg *cfg)
2662 struct hda_input_mux *imux = &spec->private_imux;
2665 for (i = 0; i < AUTO_PIN_LAST; i++) {
2666 if (alc880_is_input_pin(cfg->input_pins[i])) {
2667 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2668 err = new_analog_input(spec, cfg->input_pins[i],
2669 auto_pin_cfg_labels[i],
2673 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2674 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2681 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2682 hda_nid_t nid, int pin_type,
2686 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2687 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2688 /* need the manual connection? */
2689 if (alc880_is_multi_pin(nid)) {
2690 struct alc_spec *spec = codec->spec;
2691 int idx = alc880_multi_pin_idx(nid);
2692 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2693 AC_VERB_SET_CONNECT_SEL,
2694 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2698 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2700 struct alc_spec *spec = codec->spec;
2703 for (i = 0; i < spec->autocfg.line_outs; i++) {
2704 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2705 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2709 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2711 struct alc_spec *spec = codec->spec;
2714 pin = spec->autocfg.speaker_pins[0];
2715 if (pin) /* connect to front */
2716 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2717 pin = spec->autocfg.hp_pin;
2718 if (pin) /* connect to front */
2719 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2722 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2724 struct alc_spec *spec = codec->spec;
2727 for (i = 0; i < AUTO_PIN_LAST; i++) {
2728 hda_nid_t nid = spec->autocfg.input_pins[i];
2729 if (alc880_is_input_pin(nid)) {
2730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2731 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2732 if (nid != ALC880_PIN_CD_NID)
2733 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2739 /* parse the BIOS configuration and set up the alc_spec */
2740 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2741 static int alc880_parse_auto_config(struct hda_codec *codec)
2743 struct alc_spec *spec = codec->spec;
2745 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2747 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2748 alc880_ignore)) < 0)
2750 if (! spec->autocfg.line_outs)
2751 return 0; /* can't find valid BIOS pin config */
2753 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2754 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2755 (err = alc880_auto_create_extra_out(spec,
2756 spec->autocfg.speaker_pins[0],
2758 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2759 "Headphone")) < 0 ||
2760 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2763 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2765 if (spec->autocfg.dig_out_pin)
2766 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2767 if (spec->autocfg.dig_in_pin)
2768 spec->dig_in_nid = ALC880_DIGIN_NID;
2770 if (spec->kctl_alloc)
2771 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2773 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2775 spec->num_mux_defs = 1;
2776 spec->input_mux = &spec->private_imux;
2781 /* additional initialization for auto-configuration model */
2782 static void alc880_auto_init(struct hda_codec *codec)
2784 alc880_auto_init_multi_out(codec);
2785 alc880_auto_init_extra_out(codec);
2786 alc880_auto_init_analog_input(codec);
2790 * OK, here we have finally the patch for ALC880
2793 static int patch_alc880(struct hda_codec *codec)
2795 struct alc_spec *spec;
2799 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2805 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2806 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2807 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
2808 "trying auto-probe from BIOS...\n");
2809 board_config = ALC880_AUTO;
2812 if (board_config == ALC880_AUTO) {
2813 /* automatic parse from the BIOS config */
2814 err = alc880_parse_auto_config(codec);
2820 "hda_codec: Cannot set up configuration "
2821 "from BIOS. Using 3-stack mode...\n");
2822 board_config = ALC880_3ST;
2826 if (board_config != ALC880_AUTO)
2827 setup_preset(spec, &alc880_presets[board_config]);
2829 spec->stream_name_analog = "ALC880 Analog";
2830 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2831 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2833 spec->stream_name_digital = "ALC880 Digital";
2834 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2835 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2837 if (! spec->adc_nids && spec->input_mux) {
2838 /* check whether NID 0x07 is valid */
2839 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2840 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2841 if (wcap != AC_WID_AUD_IN) {
2842 spec->adc_nids = alc880_adc_nids_alt;
2843 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2844 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2847 spec->adc_nids = alc880_adc_nids;
2848 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2849 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2854 codec->patch_ops = alc_patch_ops;
2855 if (board_config == ALC880_AUTO)
2856 spec->init_hook = alc880_auto_init;
2866 static hda_nid_t alc260_dac_nids[1] = {
2871 static hda_nid_t alc260_adc_nids[1] = {
2876 static hda_nid_t alc260_adc_nids_alt[1] = {
2881 static hda_nid_t alc260_hp_adc_nids[2] = {
2886 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2887 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2889 static hda_nid_t alc260_dual_adc_nids[2] = {
2894 #define ALC260_DIGOUT_NID 0x03
2895 #define ALC260_DIGIN_NID 0x06
2897 static struct hda_input_mux alc260_capture_source = {
2901 { "Front Mic", 0x1 },
2907 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2908 * headphone jack and the internal CD lines since these are the only pins at
2909 * which audio can appear. For flexibility, also allow the option of
2910 * recording the mixer output on the second ADC (ADC0 doesn't have a
2911 * connection to the mixer output).
2913 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2917 { "Mic/Line", 0x0 },
2919 { "Headphone", 0x2 },
2925 { "Mic/Line", 0x0 },
2927 { "Headphone", 0x2 },
2934 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2935 * the Fujitsu S702x, but jacks are marked differently.
2937 static struct hda_input_mux alc260_acer_capture_sources[2] = {
2944 { "Headphone", 0x5 },
2953 { "Headphone", 0x6 },
2959 * This is just place-holder, so there's something for alc_build_pcms to look
2960 * at when it calculates the maximum number of channels. ALC260 has no mixer
2961 * element which allows changing the channel mode, so the verb list is
2964 static struct hda_channel_mode alc260_modes[1] = {
2969 /* Mixer combinations
2971 * basic: base_output + input + pc_beep + capture
2972 * HP: base_output + input + capture_alt
2973 * HP_3013: hp_3013 + input + capture
2974 * fujitsu: fujitsu + capture
2975 * acer: acer + capture
2978 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
2979 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2980 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2981 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2982 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2983 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2984 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2988 static struct snd_kcontrol_new alc260_input_mixer[] = {
2989 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2990 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2992 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2994 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3000 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3001 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3002 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3006 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3007 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3008 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3009 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3010 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3013 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3014 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3018 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3019 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3021 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3022 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3023 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3024 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3025 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3026 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3027 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3028 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3029 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3030 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3031 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3032 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3033 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3037 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3038 * versions of the ALC260 don't act on requests to enable mic bias from NID
3039 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3040 * datasheet doesn't mention this restriction. At this stage it's not clear
3041 * whether this behaviour is intentional or is a hardware bug in chip
3042 * revisions available in early 2006. Therefore for now allow the
3043 * "Headphone Jack Mode" control to span all choices, but if it turns out
3044 * that the lack of mic bias for this NID is intentional we could change the
3045 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3047 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3048 * don't appear to make the mic bias available from the "line" jack, even
3049 * though the NID used for this jack (0x14) can supply it. The theory is
3050 * that perhaps Acer have included blocking capacitors between the ALC260
3051 * and the output jack. If this turns out to be the case for all such
3052 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3053 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3055 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3056 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3057 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3058 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3059 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3060 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3062 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3063 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3064 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3065 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3066 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3067 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3068 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3072 /* capture mixer elements */
3073 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3074 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3075 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3076 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3077 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3080 /* The multiple "Capture Source" controls confuse alsamixer
3081 * So call somewhat different..
3082 * FIXME: the controls appear in the "playback" view!
3084 /* .name = "Capture Source", */
3085 .name = "Input Source",
3087 .info = alc_mux_enum_info,
3088 .get = alc_mux_enum_get,
3089 .put = alc_mux_enum_put,
3094 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3095 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3096 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3099 /* The multiple "Capture Source" controls confuse alsamixer
3100 * So call somewhat different..
3101 * FIXME: the controls appear in the "playback" view!
3103 /* .name = "Capture Source", */
3104 .name = "Input Source",
3106 .info = alc_mux_enum_info,
3107 .get = alc_mux_enum_get,
3108 .put = alc_mux_enum_put,
3114 * initialization verbs
3116 static struct hda_verb alc260_init_verbs[] = {
3117 /* Line In pin widget for input */
3118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3119 /* CD pin widget for input */
3120 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3121 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3122 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3123 /* Mic2 (front panel) pin widget for input and vref at 80% */
3124 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3125 /* LINE-2 is used for line-out in rear */
3126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3127 /* select line-out */
3128 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3130 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3132 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3134 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3135 /* mute capture amp left and right */
3136 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3137 /* set connection select to line in (default select for this ADC) */
3138 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3139 /* mute capture amp left and right */
3140 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3141 /* set connection select to line in (default select for this ADC) */
3142 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3143 /* set vol=0 Line-Out mixer amp left and right */
3144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3145 /* unmute pin widget amp left and right (no gain on this amp) */
3146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3147 /* set vol=0 HP mixer amp left and right */
3148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3149 /* unmute pin widget amp left and right (no gain on this amp) */
3150 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3151 /* set vol=0 Mono mixer amp left and right */
3152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3153 /* unmute pin widget amp left and right (no gain on this amp) */
3154 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3155 /* unmute LINE-2 out pin */
3156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3157 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3163 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3164 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3165 /* mute Front out path */
3166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3168 /* mute Headphone out path */
3169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3171 /* mute Mono out path */
3172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3173 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3177 #if 0 /* should be identical with alc260_init_verbs? */
3178 static struct hda_verb alc260_hp_init_verbs[] = {
3179 /* Headphone and output */
3180 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3182 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3183 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3184 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3185 /* Mic2 (front panel) pin widget for input and vref at 80% */
3186 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3187 /* Line In pin widget for input */
3188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3189 /* Line-2 pin widget for output */
3190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3191 /* CD pin widget for input */
3192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3193 /* unmute amp left and right */
3194 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3195 /* set connection select to line in (default select for this ADC) */
3196 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3197 /* unmute Line-Out mixer amp left and right (volume = 0) */
3198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3199 /* mute pin widget amp left and right (no gain on this amp) */
3200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3201 /* unmute HP mixer amp left and right (volume = 0) */
3202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3203 /* mute pin widget amp left and right (no gain on this amp) */