2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sound/driver.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include "hda_codec.h"
33 #include "hda_local.h"
36 /* ALC880 board config type */
56 #ifdef CONFIG_SND_DEBUG
60 ALC880_MODEL_LAST /* last tag */
70 #ifdef CONFIG_SND_DEBUG
74 ALC260_MODEL_LAST /* last tag */
82 ALC262_MODEL_LAST /* last tag */
103 #define GPIO_MASK 0x03
106 /* codec parameterization */
107 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
108 unsigned int num_mixers;
110 const struct hda_verb *init_verbs[5]; /* initialization verbs
111 * don't forget NULL termination!
113 unsigned int num_init_verbs;
115 char *stream_name_analog; /* analog PCM stream */
116 struct hda_pcm_stream *stream_analog_playback;
117 struct hda_pcm_stream *stream_analog_capture;
119 char *stream_name_digital; /* digital PCM stream */
120 struct hda_pcm_stream *stream_digital_playback;
121 struct hda_pcm_stream *stream_digital_capture;
124 struct hda_multi_out multiout; /* playback set-up
125 * max_channels, dacs must be set
126 * dig_out_nid and hp_nid are optional
130 unsigned int num_adc_nids;
132 hda_nid_t dig_in_nid; /* digital-in NID; optional */
135 unsigned int num_mux_defs;
136 const struct hda_input_mux *input_mux;
137 unsigned int cur_mux[3];
140 const struct hda_channel_mode *channel_mode;
141 int num_channel_mode;
143 /* PCM information */
144 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
146 /* dynamic controls, init_verbs and input_mux */
147 struct auto_pin_cfg autocfg;
148 unsigned int num_kctl_alloc, num_kctl_used;
149 struct snd_kcontrol_new *kctl_alloc;
150 struct hda_input_mux private_imux;
151 hda_nid_t private_dac_nids[5];
154 void (*init_hook)(struct hda_codec *codec);
155 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
157 /* for pin sensing */
158 unsigned int sense_updated: 1;
159 unsigned int jack_present: 1;
163 * configuration template - to be copied to the spec instance
165 struct alc_config_preset {
166 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
167 const struct hda_verb *init_verbs[5];
168 unsigned int num_dacs;
170 hda_nid_t dig_out_nid; /* optional */
171 hda_nid_t hp_nid; /* optional */
172 unsigned int num_adc_nids;
174 hda_nid_t dig_in_nid;
175 unsigned int num_channel_mode;
176 const struct hda_channel_mode *channel_mode;
177 unsigned int num_mux_defs;
178 const struct hda_input_mux *input_mux;
179 void (*unsol_event)(struct hda_codec *, unsigned int);
180 void (*init_hook)(struct hda_codec *);
187 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
189 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
190 struct alc_spec *spec = codec->spec;
191 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
192 if (mux_idx >= spec->num_mux_defs)
194 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
197 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
200 struct alc_spec *spec = codec->spec;
201 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
203 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
207 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
209 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
210 struct alc_spec *spec = codec->spec;
211 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
212 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
213 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
214 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
219 * channel mode setting
221 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
223 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
224 struct alc_spec *spec = codec->spec;
225 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
226 spec->num_channel_mode);
229 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
232 struct alc_spec *spec = codec->spec;
233 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
234 spec->num_channel_mode, spec->multiout.max_channels);
237 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
239 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
240 struct alc_spec *spec = codec->spec;
241 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
242 spec->num_channel_mode, &spec->multiout.max_channels);
246 * Control the mode of pin widget settings via the mixer. "pc" is used
247 * instead of "%" to avoid consequences of accidently treating the % as
248 * being part of a format specifier. Maximum allowed length of a value is
249 * 63 characters plus NULL terminator.
251 * Note: some retasking pin complexes seem to ignore requests for input
252 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
253 * are requested. Therefore order this list so that this behaviour will not
254 * cause problems when mixer clients move through the enum sequentially.
255 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
258 static char *alc_pin_mode_names[] = {
259 "Mic 50pc bias", "Mic 80pc bias",
260 "Line in", "Line out", "Headphone out",
262 static unsigned char alc_pin_mode_values[] = {
263 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
265 /* The control can present all 5 options, or it can limit the options based
266 * in the pin being assumed to be exclusively an input or an output pin. In
267 * addition, "input" pins may or may not process the mic bias option
268 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
269 * accept requests for bias as of chip versions up to March 2006) and/or
270 * wiring in the computer.
272 #define ALC_PIN_DIR_IN 0x00
273 #define ALC_PIN_DIR_OUT 0x01
274 #define ALC_PIN_DIR_INOUT 0x02
275 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
276 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
278 /* Info about the pin modes supported by the different pin direction modes.
279 * For each direction the minimum and maximum values are given.
281 static signed char alc_pin_mode_dir_info[5][2] = {
282 { 0, 2 }, /* ALC_PIN_DIR_IN */
283 { 3, 4 }, /* ALC_PIN_DIR_OUT */
284 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
285 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
286 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
288 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
289 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
290 #define alc_pin_mode_n_items(_dir) \
291 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
293 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
295 unsigned int item_num = uinfo->value.enumerated.item;
296 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
298 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
300 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
302 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
303 item_num = alc_pin_mode_min(dir);
304 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
308 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
312 hda_nid_t nid = kcontrol->private_value & 0xffff;
313 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
314 long *valp = ucontrol->value.integer.value;
315 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
317 /* Find enumerated value for current pinctl setting */
318 i = alc_pin_mode_min(dir);
319 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
321 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
325 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
329 hda_nid_t nid = kcontrol->private_value & 0xffff;
330 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
331 long val = *ucontrol->value.integer.value;
332 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
334 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
335 val = alc_pin_mode_min(dir);
337 change = pinctl != alc_pin_mode_values[val];
339 /* Set pin mode to that requested */
340 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
341 alc_pin_mode_values[val]);
343 /* Also enable the retasking pin's input/output as required
344 * for the requested pin mode. Enum values of 2 or less are
347 * Dynamically switching the input/output buffers probably
348 * reduces noise slightly (particularly on input) so we'll
349 * do it. However, having both input and output buffers
350 * enabled simultaneously doesn't seem to be problematic if
351 * this turns out to be necessary in the future.
354 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
356 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
359 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
361 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
368 #define ALC_PIN_MODE(xname, nid, dir) \
369 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
370 .info = alc_pin_mode_info, \
371 .get = alc_pin_mode_get, \
372 .put = alc_pin_mode_put, \
373 .private_value = nid | (dir<<16) }
375 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
376 * together using a mask with more than one bit set. This control is
377 * currently used only by the ALC260 test model. At this stage they are not
378 * needed for any "production" models.
380 #ifdef CONFIG_SND_DEBUG
381 static int alc_gpio_data_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
383 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
385 uinfo->value.integer.min = 0;
386 uinfo->value.integer.max = 1;
389 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
391 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
392 hda_nid_t nid = kcontrol->private_value & 0xffff;
393 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
394 long *valp = ucontrol->value.integer.value;
395 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
397 *valp = (val & mask) != 0;
400 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
404 hda_nid_t nid = kcontrol->private_value & 0xffff;
405 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
406 long val = *ucontrol->value.integer.value;
407 unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
409 /* Set/unset the masked GPIO bit(s) as needed */
410 change = (val==0?0:mask) != (gpio_data & mask);
415 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data);
419 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
420 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
421 .info = alc_gpio_data_info, \
422 .get = alc_gpio_data_get, \
423 .put = alc_gpio_data_put, \
424 .private_value = nid | (mask<<16) }
425 #endif /* CONFIG_SND_DEBUG */
427 /* A switch control to allow the enabling of the digital IO pins on the
428 * ALC260. This is incredibly simplistic; the intention of this control is
429 * to provide something in the test model allowing digital outputs to be
430 * identified if present. If models are found which can utilise these
431 * outputs a more complete mixer control can be devised for those models if
434 #ifdef CONFIG_SND_DEBUG
435 static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
437 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
439 uinfo->value.integer.min = 0;
440 uinfo->value.integer.max = 1;
443 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
446 hda_nid_t nid = kcontrol->private_value & 0xffff;
447 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
448 long *valp = ucontrol->value.integer.value;
449 unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
451 *valp = (val & mask) != 0;
454 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
457 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
458 hda_nid_t nid = kcontrol->private_value & 0xffff;
459 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
460 long val = *ucontrol->value.integer.value;
461 unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
463 /* Set/unset the masked control bit(s) as needed */
464 change = (val==0?0:mask) != (ctrl_data & mask);
469 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
473 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
474 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
475 .info = alc_spdif_ctrl_info, \
476 .get = alc_spdif_ctrl_get, \
477 .put = alc_spdif_ctrl_put, \
478 .private_value = nid | (mask<<16) }
479 #endif /* CONFIG_SND_DEBUG */
482 * set up from the preset table
484 static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
488 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
489 spec->mixers[spec->num_mixers++] = preset->mixers[i];
490 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
491 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
493 spec->channel_mode = preset->channel_mode;
494 spec->num_channel_mode = preset->num_channel_mode;
496 spec->multiout.max_channels = spec->channel_mode[0].channels;
498 spec->multiout.num_dacs = preset->num_dacs;
499 spec->multiout.dac_nids = preset->dac_nids;
500 spec->multiout.dig_out_nid = preset->dig_out_nid;
501 spec->multiout.hp_nid = preset->hp_nid;
503 spec->num_mux_defs = preset->num_mux_defs;
504 if (! spec->num_mux_defs)
505 spec->num_mux_defs = 1;
506 spec->input_mux = preset->input_mux;
508 spec->num_adc_nids = preset->num_adc_nids;
509 spec->adc_nids = preset->adc_nids;
510 spec->dig_in_nid = preset->dig_in_nid;
512 spec->unsol_event = preset->unsol_event;
513 spec->init_hook = preset->init_hook;
517 * ALC880 3-stack model
519 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
520 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
524 static hda_nid_t alc880_dac_nids[4] = {
525 /* front, rear, clfe, rear_surr */
526 0x02, 0x05, 0x04, 0x03
529 static hda_nid_t alc880_adc_nids[3] = {
534 /* The datasheet says the node 0x07 is connected from inputs,
535 * but it shows zero connection in the real implementation on some devices.
536 * Note: this is a 915GAV bug, fixed on 915GLV
538 static hda_nid_t alc880_adc_nids_alt[2] = {
543 #define ALC880_DIGOUT_NID 0x06
544 #define ALC880_DIGIN_NID 0x0a
546 static struct hda_input_mux alc880_capture_source = {
550 { "Front Mic", 0x3 },
556 /* channel source setting (2/6 channel selection for 3-stack) */
558 static struct hda_verb alc880_threestack_ch2_init[] = {
559 /* set line-in to input, mute it */
560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
562 /* set mic-in to input vref 80%, mute it */
563 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
564 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
569 static struct hda_verb alc880_threestack_ch6_init[] = {
570 /* set line-in to output, unmute it */
571 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
572 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
573 /* set mic-in to output, unmute it */
574 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
575 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
579 static struct hda_channel_mode alc880_threestack_modes[2] = {
580 { 2, alc880_threestack_ch2_init },
581 { 6, alc880_threestack_ch6_init },
584 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
585 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
586 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
587 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
588 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
589 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
590 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
591 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
592 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
593 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
594 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
595 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
596 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
598 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
599 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
601 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
602 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
605 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
606 .name = "Channel Mode",
607 .info = alc_ch_mode_info,
608 .get = alc_ch_mode_get,
609 .put = alc_ch_mode_put,
614 /* capture mixer elements */
615 static struct snd_kcontrol_new alc880_capture_mixer[] = {
616 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
617 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
618 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
619 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
620 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
621 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
624 /* The multiple "Capture Source" controls confuse alsamixer
625 * So call somewhat different..
626 * FIXME: the controls appear in the "playback" view!
628 /* .name = "Capture Source", */
629 .name = "Input Source",
631 .info = alc_mux_enum_info,
632 .get = alc_mux_enum_get,
633 .put = alc_mux_enum_put,
638 /* capture mixer elements (in case NID 0x07 not available) */
639 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
640 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
641 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
642 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
643 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
646 /* The multiple "Capture Source" controls confuse alsamixer
647 * So call somewhat different..
648 * FIXME: the controls appear in the "playback" view!
650 /* .name = "Capture Source", */
651 .name = "Input Source",
653 .info = alc_mux_enum_info,
654 .get = alc_mux_enum_get,
655 .put = alc_mux_enum_put,
663 * ALC880 5-stack model
665 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
666 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
667 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
670 /* additional mixers to alc880_three_stack_mixer */
671 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
672 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
673 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
677 /* channel source setting (6/8 channel selection for 5-stack) */
679 static struct hda_verb alc880_fivestack_ch6_init[] = {
680 /* set line-in to input, mute it */
681 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
682 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
687 static struct hda_verb alc880_fivestack_ch8_init[] = {
688 /* set line-in to output, unmute it */
689 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
690 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
694 static struct hda_channel_mode alc880_fivestack_modes[2] = {
695 { 6, alc880_fivestack_ch6_init },
696 { 8, alc880_fivestack_ch8_init },
701 * ALC880 6-stack model
703 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
704 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
705 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
708 static hda_nid_t alc880_6st_dac_nids[4] = {
709 /* front, rear, clfe, rear_surr */
710 0x02, 0x03, 0x04, 0x05
713 static struct hda_input_mux alc880_6stack_capture_source = {
717 { "Front Mic", 0x1 },
723 /* fixed 8-channels */
724 static struct hda_channel_mode alc880_sixstack_modes[1] = {
728 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
730 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
731 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
732 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
733 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
734 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
735 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
736 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
737 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
738 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
739 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
740 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
741 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
742 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
745 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
747 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
748 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
751 .name = "Channel Mode",
752 .info = alc_ch_mode_info,
753 .get = alc_ch_mode_get,
754 .put = alc_ch_mode_put,
763 * W810 has rear IO for:
766 * Center/LFE (DAC 04)
769 * The system also has a pair of internal speakers, and a headphone jack.
770 * These are both connected to Line2 on the codec, hence to DAC 02.
772 * There is a variable resistor to control the speaker or headphone
773 * volume. This is a hardware-only device without a software API.
775 * Plugging headphones in will disable the internal speakers. This is
776 * implemented in hardware, not via the driver using jack sense. In
777 * a similar fashion, plugging into the rear socket marked "front" will
778 * disable both the speakers and headphones.
780 * For input, there's a microphone jack, and an "audio in" jack.
781 * These may not do anything useful with this driver yet, because I
782 * haven't setup any initialization verbs for these yet...
785 static hda_nid_t alc880_w810_dac_nids[3] = {
786 /* front, rear/surround, clfe */
790 /* fixed 6 channels */
791 static struct hda_channel_mode alc880_w810_modes[1] = {
795 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
796 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
798 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
799 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
800 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
801 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
802 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
803 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
804 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
813 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
814 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
817 static hda_nid_t alc880_z71v_dac_nids[1] = {
820 #define ALC880_Z71V_HP_DAC 0x03
822 /* fixed 2 channels */
823 static struct hda_channel_mode alc880_2_jack_modes[1] = {
827 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
828 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
829 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
830 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
831 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
844 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
845 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
848 static hda_nid_t alc880_f1734_dac_nids[1] = {
851 #define ALC880_F1734_HP_DAC 0x02
853 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
856 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
857 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
870 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
871 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
872 * Mic = 0x18, Line = 0x1a
875 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
876 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
878 static struct snd_kcontrol_new alc880_asus_mixer[] = {
879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
882 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
885 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
886 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
895 .name = "Channel Mode",
896 .info = alc_ch_mode_info,
897 .get = alc_ch_mode_get,
898 .put = alc_ch_mode_put,
905 * ALC880 ASUS W1V model
907 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
908 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
909 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
912 /* additional mixers to alc880_asus_mixer */
913 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
914 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
915 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
919 /* additional mixers to alc880_asus_mixer */
920 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
921 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
922 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
927 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
929 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
932 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
935 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
936 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
939 /* The multiple "Capture Source" controls confuse alsamixer
940 * So call somewhat different..
941 * FIXME: the controls appear in the "playback" view!
943 /* .name = "Capture Source", */
944 .name = "Input Source",
946 .info = alc_mux_enum_info,
947 .get = alc_mux_enum_get,
948 .put = alc_mux_enum_put,
954 * build control elements
956 static int alc_build_controls(struct hda_codec *codec)
958 struct alc_spec *spec = codec->spec;
962 for (i = 0; i < spec->num_mixers; i++) {
963 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
968 if (spec->multiout.dig_out_nid) {
969 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
973 if (spec->dig_in_nid) {
974 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
983 * initialize the codec volumes, etc
987 * generic initialization of ADC, input mixers and output mixers
989 static struct hda_verb alc880_volume_init_verbs[] = {
991 * Unmute ADC0-2 and set the default input to mic-in
993 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
995 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
996 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
997 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1000 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1002 * Note: PASD motherboards uses the Line In 2 as the input for front panel
1005 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
1010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1013 * Set up output mixers (0x0c - 0x0f)
1015 /* set vol=0 to output mixers */
1016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1020 /* set up input amps for analog loopback */
1021 /* Amp Indices: DAC = 0, mixer = 1 */
1022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1024 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1025 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1026 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1027 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1028 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1029 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1035 * 3-stack pin configuration:
1036 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1038 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1040 * preset connection lists of input pins
1041 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1043 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1044 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1045 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1048 * Set pin mode and muting
1050 /* set front pin widgets 0x14 for output */
1051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1053 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1054 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1055 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1056 /* Mic2 (as headphone out) for HP output */
1057 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1058 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1059 /* Line In pin widget for input */
1060 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1061 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1062 /* Line2 (as front mic) pin widget for input and vref at 80% */
1063 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1064 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1065 /* CD pin widget for input */
1066 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1072 * 5-stack pin configuration:
1073 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1074 * line-in/side = 0x1a, f-mic = 0x1b
1076 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1078 * preset connection lists of input pins
1079 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1081 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1082 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1085 * Set pin mode and muting
1087 /* set pin widgets 0x14-0x17 for output */
1088 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1089 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1090 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1091 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1092 /* unmute pins for output (no gain on this amp) */
1093 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1095 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1096 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1098 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1101 /* Mic2 (as headphone out) for HP output */
1102 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1104 /* Line In pin widget for input */
1105 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1107 /* Line2 (as front mic) pin widget for input and vref at 80% */
1108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1110 /* CD pin widget for input */
1111 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1117 * W810 pin configuration:
1118 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1120 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1121 /* hphone/speaker input selector: front DAC */
1122 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1128 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1129 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1132 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1138 * Z71V pin configuration:
1139 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1141 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1142 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1143 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1145 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1148 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1149 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1150 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1156 * 6-stack pin configuration:
1157 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
1158 * line = 0x1a, HP = 0x1b
1160 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1161 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1164 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1166 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1167 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1168 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1169 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1170 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1173 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1174 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1175 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1179 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1180 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1187 * F1734 pin configuration:
1188 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1190 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1191 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1192 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1193 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1194 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1196 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1201 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1202 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1203 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1204 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1205 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1207 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1208 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1209 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1216 * ASUS pin configuration:
1217 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1219 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1220 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1221 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1222 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1223 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1226 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1229 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1231 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1232 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1234 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1236 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1237 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1240 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1241 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1242 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1247 /* Enable GPIO mask and set output */
1248 static struct hda_verb alc880_gpio1_init_verbs[] = {
1249 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1250 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1251 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1256 /* Enable GPIO mask and set output */
1257 static struct hda_verb alc880_gpio2_init_verbs[] = {
1258 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1259 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1260 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1265 /* Clevo m520g init */
1266 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1267 /* headphone output */
1268 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1276 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1277 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1278 /* Mic1 (rear panel) */
1279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1281 /* Mic2 (front panel) */
1282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1285 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1286 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 /* change to EAPD mode */
1288 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1289 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1294 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1295 /* Headphone output */
1296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1298 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1299 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1301 /* Line In pin widget for input */
1302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1303 /* CD pin widget for input */
1304 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1305 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1308 /* change to EAPD mode */
1309 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1310 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1316 * LG m1 express dual
1319 * Rear Line-In/Out (blue): 0x14
1320 * Build-in Mic-In: 0x15
1322 * HP-Out (green): 0x1b
1323 * Mic-In/Out (red): 0x19
1327 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1328 static hda_nid_t alc880_lg_dac_nids[3] = {
1332 /* seems analog CD is not working */
1333 static struct hda_input_mux alc880_lg_capture_source = {
1338 { "Internal Mic", 0x6 },
1342 /* 2,4,6 channel modes */
1343 static struct hda_verb alc880_lg_ch2_init[] = {
1344 /* set line-in and mic-in to input */
1345 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1346 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1350 static struct hda_verb alc880_lg_ch4_init[] = {
1351 /* set line-in to out and mic-in to input */
1352 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1353 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1357 static struct hda_verb alc880_lg_ch6_init[] = {
1358 /* set line-in and mic-in to output */
1359 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1360 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1364 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1365 { 2, alc880_lg_ch2_init },
1366 { 4, alc880_lg_ch4_init },
1367 { 6, alc880_lg_ch6_init },
1370 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1371 /* FIXME: it's not really "master" but front channels */
1372 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1373 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1374 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1375 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1376 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1377 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1378 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1379 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1384 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1385 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1388 .name = "Channel Mode",
1389 .info = alc_ch_mode_info,
1390 .get = alc_ch_mode_get,
1391 .put = alc_ch_mode_put,
1396 static struct hda_verb alc880_lg_init_verbs[] = {
1397 /* set capture source to mic-in */
1398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1399 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1401 /* mute all amp mixer inputs */
1402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
1404 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1405 /* line-in to input */
1406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1407 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1412 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1413 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1414 /* mic-in to input */
1415 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1416 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1419 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1420 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1421 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1423 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1427 /* toggle speaker-output according to the hp-jack state */
1428 static void alc880_lg_automute(struct hda_codec *codec)
1430 unsigned int present;
1432 present = snd_hda_codec_read(codec, 0x1b, 0,
1433 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1434 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1435 0x80, present ? 0x80 : 0);
1436 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1437 0x80, present ? 0x80 : 0);
1440 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1442 /* Looks like the unsol event is incompatible with the standard
1443 * definition. 4bit tag is placed at 28 bit!
1445 if ((res >> 28) == 0x01)
1446 alc880_lg_automute(codec);
1455 * Built-in Mic-In: 0x19 (?)
1460 /* seems analog CD is not working */
1461 static struct hda_input_mux alc880_lg_lw_capture_source = {
1465 { "Internal Mic", 0x1 },
1469 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1470 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1471 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1474 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1475 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1479 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1480 /* set capture source to mic-in */
1481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1483 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
1486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1490 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 /* mic-in to input */
1493 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1494 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1499 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1503 /* toggle speaker-output according to the hp-jack state */
1504 static void alc880_lg_lw_automute(struct hda_codec *codec)
1506 unsigned int present;
1508 present = snd_hda_codec_read(codec, 0x1b, 0,
1509 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1510 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1511 0x80, present ? 0x80 : 0);
1512 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1513 0x80, present ? 0x80 : 0);
1516 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1518 /* Looks like the unsol event is incompatible with the standard
1519 * definition. 4bit tag is placed at 28 bit!
1521 if ((res >> 28) == 0x01)
1522 alc880_lg_lw_automute(codec);
1529 static int alc_init(struct hda_codec *codec)
1531 struct alc_spec *spec = codec->spec;
1534 for (i = 0; i < spec->num_init_verbs; i++)
1535 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1537 if (spec->init_hook)
1538 spec->init_hook(codec);
1543 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
1545 struct alc_spec *spec = codec->spec;
1547 if (spec->unsol_event)
1548 spec->unsol_event(codec, res);
1555 static int alc_resume(struct hda_codec *codec)
1557 struct alc_spec *spec = codec->spec;
1561 for (i = 0; i < spec->num_mixers; i++)
1562 snd_hda_resume_ctls(codec, spec->mixers[i]);
1563 if (spec->multiout.dig_out_nid)
1564 snd_hda_resume_spdif_out(codec);
1565 if (spec->dig_in_nid)
1566 snd_hda_resume_spdif_in(codec);
1573 * Analog playback callbacks
1575 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1576 struct hda_codec *codec,
1577 struct snd_pcm_substream *substream)
1579 struct alc_spec *spec = codec->spec;
1580 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1583 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1584 struct hda_codec *codec,
1585 unsigned int stream_tag,
1586 unsigned int format,
1587 struct snd_pcm_substream *substream)
1589 struct alc_spec *spec = codec->spec;
1590 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1594 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1595 struct hda_codec *codec,
1596 struct snd_pcm_substream *substream)
1598 struct alc_spec *spec = codec->spec;
1599 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1605 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1606 struct hda_codec *codec,
1607 struct snd_pcm_substream *substream)
1609 struct alc_spec *spec = codec->spec;
1610 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1613 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1614 struct hda_codec *codec,
1615 struct snd_pcm_substream *substream)
1617 struct alc_spec *spec = codec->spec;
1618 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1624 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1625 struct hda_codec *codec,
1626 unsigned int stream_tag,
1627 unsigned int format,
1628 struct snd_pcm_substream *substream)
1630 struct alc_spec *spec = codec->spec;
1632 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1633 stream_tag, 0, format);
1637 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1638 struct hda_codec *codec,
1639 struct snd_pcm_substream *substream)
1641 struct alc_spec *spec = codec->spec;
1643 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1650 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1654 /* NID is set in alc_build_pcms */
1656 .open = alc880_playback_pcm_open,
1657 .prepare = alc880_playback_pcm_prepare,
1658 .cleanup = alc880_playback_pcm_cleanup
1662 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1666 /* NID is set in alc_build_pcms */
1668 .prepare = alc880_capture_pcm_prepare,
1669 .cleanup = alc880_capture_pcm_cleanup
1673 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1677 /* NID is set in alc_build_pcms */
1679 .open = alc880_dig_playback_pcm_open,
1680 .close = alc880_dig_playback_pcm_close
1684 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1688 /* NID is set in alc_build_pcms */
1691 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1692 static struct hda_pcm_stream alc_pcm_null_playback = {
1698 static int alc_build_pcms(struct hda_codec *codec)
1700 struct alc_spec *spec = codec->spec;
1701 struct hda_pcm *info = spec->pcm_rec;
1704 codec->num_pcms = 1;
1705 codec->pcm_info = info;
1707 info->name = spec->stream_name_analog;
1708 if (spec->stream_analog_playback) {
1709 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1710 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1711 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1713 if (spec->stream_analog_capture) {
1714 snd_assert(spec->adc_nids, return -EINVAL);
1715 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1716 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1719 if (spec->channel_mode) {
1720 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1721 for (i = 0; i < spec->num_channel_mode; i++) {
1722 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1723 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1728 /* If the use of more than one ADC is requested for the current
1729 * model, configure a second analog capture-only PCM.
1731 if (spec->num_adc_nids > 1) {
1734 info->name = spec->stream_name_analog;
1735 /* No playback stream for second PCM */
1736 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1737 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1738 if (spec->stream_analog_capture) {
1739 snd_assert(spec->adc_nids, return -EINVAL);
1740 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1741 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1745 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1748 info->name = spec->stream_name_digital;
1749 if (spec->multiout.dig_out_nid &&
1750 spec->stream_digital_playback) {
1751 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1752 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1754 if (spec->dig_in_nid &&
1755 spec->stream_digital_capture) {
1756 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1757 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1764 static void alc_free(struct hda_codec *codec)
1766 struct alc_spec *spec = codec->spec;
1772 if (spec->kctl_alloc) {
1773 for (i = 0; i < spec->num_kctl_used; i++)
1774 kfree(spec->kctl_alloc[i].name);
1775 kfree(spec->kctl_alloc);
1782 static struct hda_codec_ops alc_patch_ops = {
1783 .build_controls = alc_build_controls,
1784 .build_pcms = alc_build_pcms,
1787 .unsol_event = alc_unsol_event,
1789 .resume = alc_resume,
1795 * Test configuration for debugging
1797 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1800 #ifdef CONFIG_SND_DEBUG
1801 static hda_nid_t alc880_test_dac_nids[4] = {
1802 0x02, 0x03, 0x04, 0x05
1805 static struct hda_input_mux alc880_test_capture_source = {
1814 { "Surround", 0x6 },
1818 static struct hda_channel_mode alc880_test_modes[4] = {
1825 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1827 static char *texts[] = {
1828 "N/A", "Line Out", "HP Out",
1829 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1831 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1833 uinfo->value.enumerated.items = 8;
1834 if (uinfo->value.enumerated.item >= 8)
1835 uinfo->value.enumerated.item = 7;
1836 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1840 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1843 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1844 unsigned int pin_ctl, item = 0;
1846 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1847 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1848 if (pin_ctl & AC_PINCTL_OUT_EN) {
1849 if (pin_ctl & AC_PINCTL_HP_EN)
1853 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1854 switch (pin_ctl & AC_PINCTL_VREFEN) {
1855 case AC_PINCTL_VREF_HIZ: item = 3; break;
1856 case AC_PINCTL_VREF_50: item = 4; break;
1857 case AC_PINCTL_VREF_GRD: item = 5; break;
1858 case AC_PINCTL_VREF_80: item = 6; break;
1859 case AC_PINCTL_VREF_100: item = 7; break;
1862 ucontrol->value.enumerated.item[0] = item;
1866 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1869 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1870 static unsigned int ctls[] = {
1871 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1872 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1873 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1874 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1875 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1876 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1878 unsigned int old_ctl, new_ctl;
1880 old_ctl = snd_hda_codec_read(codec, nid, 0,
1881 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1882 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1883 if (old_ctl != new_ctl) {
1884 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1885 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1886 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1892 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1894 static char *texts[] = {
1895 "Front", "Surround", "CLFE", "Side"
1897 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1899 uinfo->value.enumerated.items = 4;
1900 if (uinfo->value.enumerated.item >= 4)
1901 uinfo->value.enumerated.item = 3;
1902 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1906 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1912 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1913 ucontrol->value.enumerated.item[0] = sel & 3;
1917 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1920 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1923 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1924 if (ucontrol->value.enumerated.item[0] != sel) {
1925 sel = ucontrol->value.enumerated.item[0] & 3;
1926 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1932 #define PIN_CTL_TEST(xname,nid) { \
1933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1935 .info = alc_test_pin_ctl_info, \
1936 .get = alc_test_pin_ctl_get, \
1937 .put = alc_test_pin_ctl_put, \
1938 .private_value = nid \
1941 #define PIN_SRC_TEST(xname,nid) { \
1942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1944 .info = alc_test_pin_src_info, \
1945 .get = alc_test_pin_src_get, \
1946 .put = alc_test_pin_src_put, \
1947 .private_value = nid \
1950 static struct snd_kcontrol_new alc880_test_mixer[] = {
1951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1952 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1953 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1954 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1955 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1956 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1957 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1958 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1959 PIN_CTL_TEST("Front Pin Mode", 0x14),
1960 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1961 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1962 PIN_CTL_TEST("Side Pin Mode", 0x17),
1963 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1964 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1965 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1966 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1967 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1968 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1969 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1970 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1971 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1972 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1973 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1974 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1975 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1976 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1977 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1978 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1983 .name = "Channel Mode",
1984 .info = alc_ch_mode_info,
1985 .get = alc_ch_mode_get,
1986 .put = alc_ch_mode_put,
1991 static struct hda_verb alc880_test_init_verbs[] = {
1992 /* Unmute inputs of 0x0c - 0x0f */
1993 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2001 /* Vol output for 0x0c-0x0f */
2002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2003 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2004 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2005 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2006 /* Set output pins 0x14-0x17 */
2007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2009 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2010 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2011 /* Unmute output pins 0x14-0x17 */
2012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2016 /* Set input pins 0x18-0x1c */
2017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2018 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2019 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2020 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2021 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2022 /* Mute input pins 0x18-0x1b */
2023 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2025 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2026 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2029 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2030 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2031 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2033 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2034 /* Analog input/passthru */
2035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2047 static struct hda_board_config alc880_cfg_tbl[] = {
2048 /* Back 3 jack, front 2 jack */
2049 { .modelname = "3stack", .config = ALC880_3ST },
2050 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
2051 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
2052 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
2053 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
2054 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
2055 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
2056 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
2057 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
2058 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
2059 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
2060 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
2061 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
2062 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
2063 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
2064 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
2065 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
2066 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
2067 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
2068 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
2069 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
2070 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
2071 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
2072 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
2073 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
2074 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
2075 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
2076 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
2077 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
2078 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
2079 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
2080 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
2081 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
2083 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
2085 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
2086 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
2087 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
2088 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
2090 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
2091 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
2092 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
2093 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
2094 /* Clevo m520G NB */
2095 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
2097 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
2098 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
2099 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
2100 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
2102 /* Back 5 jack, front 2 jack */
2103 { .modelname = "5stack", .config = ALC880_5ST },
2104 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
2105 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
2106 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
2107 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
2108 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
2110 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
2111 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
2112 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
2113 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
2114 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
2115 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
2116 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
2117 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
2118 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
2119 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
2120 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
2121 { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
2122 .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
2123 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
2124 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
2125 /* note subvendor = 0 below */
2126 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
2128 { .modelname = "w810", .config = ALC880_W810 },
2129 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
2131 { .modelname = "z71v", .config = ALC880_Z71V },
2132 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
2134 { .modelname = "6stack", .config = ALC880_6ST },
2135 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
2136 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
2137 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
2138 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
2140 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
2141 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
2142 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
2143 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
2144 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
2145 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
2146 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
2147 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
2148 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
2149 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
2150 { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
2151 { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
2153 { .modelname = "asus", .config = ALC880_ASUS },
2154 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
2155 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
2156 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
2157 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
2158 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
2159 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
2160 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
2161 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
2162 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
2163 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
2164 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
2165 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
2166 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
2168 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
2169 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
2171 { .modelname = "F1734", .config = ALC880_F1734 },
2172 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
2173 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
2175 { .modelname = "lg", .config = ALC880_LG },
2176 { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
2178 { .modelname = "lg-lw", .config = ALC880_LG_LW },
2179 { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
2181 #ifdef CONFIG_SND_DEBUG
2182 { .modelname = "test", .config = ALC880_TEST },
2184 { .modelname = "auto", .config = ALC880_AUTO },
2190 * ALC880 codec presets
2192 static struct alc_config_preset alc880_presets[] = {
2194 .mixers = { alc880_three_stack_mixer },
2195 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2196 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2197 .dac_nids = alc880_dac_nids,
2198 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2199 .channel_mode = alc880_threestack_modes,
2200 .input_mux = &alc880_capture_source,
2202 [ALC880_3ST_DIG] = {
2203 .mixers = { alc880_three_stack_mixer },
2204 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
2205 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2206 .dac_nids = alc880_dac_nids,
2207 .dig_out_nid = ALC880_DIGOUT_NID,
2208 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2209 .channel_mode = alc880_threestack_modes,
2210 .input_mux = &alc880_capture_source,
2212 [ALC880_TCL_S700] = {
2213 .mixers = { alc880_tcl_s700_mixer },
2214 .init_verbs = { alc880_volume_init_verbs,
2215 alc880_pin_tcl_S700_init_verbs,
2216 alc880_gpio2_init_verbs },
2217 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2218 .dac_nids = alc880_dac_nids,
2220 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2221 .channel_mode = alc880_2_jack_modes,
2222 .input_mux = &alc880_capture_source,
2225 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
2226 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2227 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2228 .dac_nids = alc880_dac_nids,
2229 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2230 .channel_mode = alc880_fivestack_modes,
2231 .input_mux = &alc880_capture_source,
2233 [ALC880_5ST_DIG] = {
2234 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
2235 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
2236 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2237 .dac_nids = alc880_dac_nids,
2238 .dig_out_nid = ALC880_DIGOUT_NID,
2239 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2240 .channel_mode = alc880_fivestack_modes,
2241 .input_mux = &alc880_capture_source,
2244 .mixers = { alc880_six_stack_mixer },
2245 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2246 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2247 .dac_nids = alc880_6st_dac_nids,
2248 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2249 .channel_mode = alc880_sixstack_modes,
2250 .input_mux = &alc880_6stack_capture_source,
2252 [ALC880_6ST_DIG] = {
2253 .mixers = { alc880_six_stack_mixer },
2254 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
2255 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2256 .dac_nids = alc880_6st_dac_nids,
2257 .dig_out_nid = ALC880_DIGOUT_NID,
2258 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2259 .channel_mode = alc880_sixstack_modes,
2260 .input_mux = &alc880_6stack_capture_source,
2263 .mixers = { alc880_w810_base_mixer },
2264 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
2265 alc880_gpio2_init_verbs },
2266 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2267 .dac_nids = alc880_w810_dac_nids,
2268 .dig_out_nid = ALC880_DIGOUT_NID,
2269 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2270 .channel_mode = alc880_w810_modes,
2271 .input_mux = &alc880_capture_source,
2274 .mixers = { alc880_z71v_mixer },
2275 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
2276 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2277 .dac_nids = alc880_z71v_dac_nids,
2278 .dig_out_nid = ALC880_DIGOUT_NID,
2280 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2281 .channel_mode = alc880_2_jack_modes,
2282 .input_mux = &alc880_capture_source,
2285 .mixers = { alc880_f1734_mixer },
2286 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
2287 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2288 .dac_nids = alc880_f1734_dac_nids,
2290 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2291 .channel_mode = alc880_2_jack_modes,
2292 .input_mux = &alc880_capture_source,
2295 .mixers = { alc880_asus_mixer },
2296 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2297 alc880_gpio1_init_verbs },
2298 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2299 .dac_nids = alc880_asus_dac_nids,
2300 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2301 .channel_mode = alc880_asus_modes,
2302 .input_mux = &alc880_capture_source,
2304 [ALC880_ASUS_DIG] = {
2305 .mixers = { alc880_asus_mixer },
2306 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2307 alc880_gpio1_init_verbs },
2308 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2309 .dac_nids = alc880_asus_dac_nids,
2310 .dig_out_nid = ALC880_DIGOUT_NID,
2311 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2312 .channel_mode = alc880_asus_modes,
2313 .input_mux = &alc880_capture_source,
2315 [ALC880_ASUS_DIG2] = {
2316 .mixers = { alc880_asus_mixer },
2317 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2318 alc880_gpio2_init_verbs }, /* use GPIO2 */
2319 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2320 .dac_nids = alc880_asus_dac_nids,
2321 .dig_out_nid = ALC880_DIGOUT_NID,
2322 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2323 .channel_mode = alc880_asus_modes,
2324 .input_mux = &alc880_capture_source,
2326 [ALC880_ASUS_W1V] = {
2327 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2328 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
2329 alc880_gpio1_init_verbs },
2330 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2331 .dac_nids = alc880_asus_dac_nids,
2332 .dig_out_nid = ALC880_DIGOUT_NID,
2333 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2334 .channel_mode = alc880_asus_modes,
2335 .input_mux = &alc880_capture_source,
2337 [ALC880_UNIWILL_DIG] = {
2338 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2339 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
2340 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2341 .dac_nids = alc880_asus_dac_nids,
2342 .dig_out_nid = ALC880_DIGOUT_NID,
2343 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2344 .channel_mode = alc880_asus_modes,
2345 .input_mux = &alc880_capture_source,
2348 .mixers = { alc880_three_stack_mixer },
2349 .init_verbs = { alc880_volume_init_verbs,
2350 alc880_pin_clevo_init_verbs },
2351 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2352 .dac_nids = alc880_dac_nids,
2354 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2355 .channel_mode = alc880_threestack_modes,
2356 .input_mux = &alc880_capture_source,
2359 .mixers = { alc880_lg_mixer },
2360 .init_verbs = { alc880_volume_init_verbs,
2361 alc880_lg_init_verbs },
2362 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2363 .dac_nids = alc880_lg_dac_nids,
2364 .dig_out_nid = ALC880_DIGOUT_NID,
2365 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2366 .channel_mode = alc880_lg_ch_modes,
2367 .input_mux = &alc880_lg_capture_source,
2368 .unsol_event = alc880_lg_unsol_event,
2369 .init_hook = alc880_lg_automute,
2372 .mixers = { alc880_lg_lw_mixer },
2373 .init_verbs = { alc880_volume_init_verbs,
2374 alc880_lg_lw_init_verbs },
2376 .dac_nids = alc880_dac_nids,
2377 .dig_out_nid = ALC880_DIGOUT_NID,
2378 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2379 .channel_mode = alc880_2_jack_modes,
2380 .input_mux = &alc880_lg_lw_capture_source,
2381 .unsol_event = alc880_lg_lw_unsol_event,
2382 .init_hook = alc880_lg_lw_automute,
2384 #ifdef CONFIG_SND_DEBUG
2386 .mixers = { alc880_test_mixer },
2387 .init_verbs = { alc880_test_init_verbs },
2388 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2389 .dac_nids = alc880_test_dac_nids,
2390 .dig_out_nid = ALC880_DIGOUT_NID,
2391 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2392 .channel_mode = alc880_test_modes,
2393 .input_mux = &alc880_test_capture_source,
2399 * Automatic parse of I/O pins from the BIOS configuration
2402 #define NUM_CONTROL_ALLOC 32
2403 #define NUM_VERB_ALLOC 32
2407 ALC_CTL_WIDGET_MUTE,
2410 static struct snd_kcontrol_new alc880_control_templates[] = {
2411 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2412 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2413 HDA_BIND_MUTE(NULL, 0, 0, 0),
2416 /* add dynamic controls */
2417 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2419 struct snd_kcontrol_new *knew;
2421 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2422 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2424 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2427 if (spec->kctl_alloc) {
2428 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2429 kfree(spec->kctl_alloc);
2431 spec->kctl_alloc = knew;
2432 spec->num_kctl_alloc = num;
2435 knew = &spec->kctl_alloc[spec->num_kctl_used];
2436 *knew = alc880_control_templates[type];
2437 knew->name = kstrdup(name, GFP_KERNEL);
2440 knew->private_value = val;
2441 spec->num_kctl_used++;
2445 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2446 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2447 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2448 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2449 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2450 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2451 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2452 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2453 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2454 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2455 #define ALC880_PIN_CD_NID 0x1c
2457 /* fill in the dac_nids table from the parsed pin configuration */
2458 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2464 memset(assigned, 0, sizeof(assigned));
2465 spec->multiout.dac_nids = spec->private_dac_nids;
2467 /* check the pins hardwired to audio widget */
2468 for (i = 0; i < cfg->line_outs; i++) {
2469 nid = cfg->line_out_pins[i];
2470 if (alc880_is_fixed_pin(nid)) {
2471 int idx = alc880_fixed_pin_idx(nid);
2472 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2476 /* left pins can be connect to any audio widget */
2477 for (i = 0; i < cfg->line_outs; i++) {
2478 nid = cfg->line_out_pins[i];
2479 if (alc880_is_fixed_pin(nid))
2481 /* search for an empty channel */
2482 for (j = 0; j < cfg->line_outs; j++) {
2483 if (! assigned[j]) {
2484 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2490 spec->multiout.num_dacs = cfg->line_outs;
2494 /* add playback controls from the parsed DAC table */
2495 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2496 const struct auto_pin_cfg *cfg)
2499 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2503 for (i = 0; i < cfg->line_outs; i++) {
2504 if (! spec->multiout.dac_nids[i])
2506 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2509 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2510 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2512 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2513 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2515 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2516 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2518 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2519 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2522 sprintf(name, "%s Playback Volume", chname[i]);
2523 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2524 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2526 sprintf(name, "%s Playback Switch", chname[i]);
2527 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2528 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2535 /* add playback controls for speaker and HP outputs */
2536 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2546 if (alc880_is_fixed_pin(pin)) {
2547 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2548 /* specify the DAC as the extra output */
2549 if (! spec->multiout.hp_nid)
2550 spec->multiout.hp_nid = nid;
2552 spec->multiout.extra_out_nid[0] = nid;
2553 /* control HP volume/switch on the output mixer amp */
2554 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2555 sprintf(name, "%s Playback Volume", pfx);
2556 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2557 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2559 sprintf(name, "%s Playback Switch", pfx);
2560 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2561 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2563 } else if (alc880_is_multi_pin(pin)) {
2564 /* set manual connection */
2565 /* we have only a switch on HP-out PIN */
2566 sprintf(name, "%s Playback Switch", pfx);
2567 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2568 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2574 /* create input playback/capture controls for the given pin */
2575 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2576 int idx, hda_nid_t mix_nid)
2581 sprintf(name, "%s Playback Volume", ctlname);
2582 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2583 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2585 sprintf(name, "%s Playback Switch", ctlname);
2586 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2587 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2592 /* create playback/capture controls for input pins */
2593 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2594 const struct auto_pin_cfg *cfg)
2596 struct hda_input_mux *imux = &spec->private_imux;
2599 for (i = 0; i < AUTO_PIN_LAST; i++) {
2600 if (alc880_is_input_pin(cfg->input_pins[i])) {
2601 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2602 err = new_analog_input(spec, cfg->input_pins[i],
2603 auto_pin_cfg_labels[i],
2607 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2608 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2615 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2616 hda_nid_t nid, int pin_type,
2620 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2621 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2622 /* need the manual connection? */
2623 if (alc880_is_multi_pin(nid)) {
2624 struct alc_spec *spec = codec->spec;
2625 int idx = alc880_multi_pin_idx(nid);
2626 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2627 AC_VERB_SET_CONNECT_SEL,
2628 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2632 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2634 struct alc_spec *spec = codec->spec;
2637 for (i = 0; i < spec->autocfg.line_outs; i++) {
2638 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2639 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2643 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2645 struct alc_spec *spec = codec->spec;
2648 pin = spec->autocfg.speaker_pins[0];
2649 if (pin) /* connect to front */
2650 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2651 pin = spec->autocfg.hp_pin;
2652 if (pin) /* connect to front */
2653 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2656 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2658 struct alc_spec *spec = codec->spec;
2661 for (i = 0; i < AUTO_PIN_LAST; i++) {
2662 hda_nid_t nid = spec->autocfg.input_pins[i];
2663 if (alc880_is_input_pin(nid)) {
2664 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2665 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2666 if (nid != ALC880_PIN_CD_NID)
2667 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2673 /* parse the BIOS configuration and set up the alc_spec */
2674 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2675 static int alc880_parse_auto_config(struct hda_codec *codec)
2677 struct alc_spec *spec = codec->spec;
2679 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2681 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2682 alc880_ignore)) < 0)
2684 if (! spec->autocfg.line_outs)
2685 return 0; /* can't find valid BIOS pin config */
2687 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2688 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2689 (err = alc880_auto_create_extra_out(spec,
2690 spec->autocfg.speaker_pins[0],
2692 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
2693 "Headphone")) < 0 ||
2694 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2697 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2699 if (spec->autocfg.dig_out_pin)
2700 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2701 if (spec->autocfg.dig_in_pin)
2702 spec->dig_in_nid = ALC880_DIGIN_NID;
2704 if (spec->kctl_alloc)
2705 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2707 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2709 spec->num_mux_defs = 1;
2710 spec->input_mux = &spec->private_imux;
2715 /* additional initialization for auto-configuration model */
2716 static void alc880_auto_init(struct hda_codec *codec)
2718 alc880_auto_init_multi_out(codec);
2719 alc880_auto_init_extra_out(codec);
2720 alc880_auto_init_analog_input(codec);
2724 * OK, here we have finally the patch for ALC880
2727 static int patch_alc880(struct hda_codec *codec)
2729 struct alc_spec *spec;
2733 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2739 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2740 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2741 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2742 board_config = ALC880_AUTO;
2745 if (board_config == ALC880_AUTO) {
2746 /* automatic parse from the BIOS config */
2747 err = alc880_parse_auto_config(codec);
2752 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2753 board_config = ALC880_3ST;
2757 if (board_config != ALC880_AUTO)
2758 setup_preset(spec, &alc880_presets[board_config]);
2760 spec->stream_name_analog = "ALC880 Analog";
2761 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2762 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2764 spec->stream_name_digital = "ALC880 Digital";
2765 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2766 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2768 if (! spec->adc_nids && spec->input_mux) {
2769 /* check whether NID 0x07 is valid */
2770 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2771 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2772 if (wcap != AC_WID_AUD_IN) {
2773 spec->adc_nids = alc880_adc_nids_alt;
2774 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2775 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2778 spec->adc_nids = alc880_adc_nids;
2779 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2780 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2785 codec->patch_ops = alc_patch_ops;
2786 if (board_config == ALC880_AUTO)
2787 spec->init_hook = alc880_auto_init;
2797 static hda_nid_t alc260_dac_nids[1] = {
2802 static hda_nid_t alc260_adc_nids[1] = {
2807 static hda_nid_t alc260_adc_nids_alt[1] = {
2812 static hda_nid_t alc260_hp_adc_nids[2] = {
2817 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
2818 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
2820 static hda_nid_t alc260_dual_adc_nids[2] = {
2825 #define ALC260_DIGOUT_NID 0x03
2826 #define ALC260_DIGIN_NID 0x06
2828 static struct hda_input_mux alc260_capture_source = {
2832 { "Front Mic", 0x1 },
2838 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2839 * headphone jack and the internal CD lines since these are the only pins at
2840 * which audio can appear. For flexibility, also allow the option of
2841 * recording the mixer output on the second ADC (ADC0 doesn't have a
2842 * connection to the mixer output).
2844 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
2848 { "Mic/Line", 0x0 },
2850 { "Headphone", 0x2 },
2856 { "Mic/Line", 0x0 },
2858 { "Headphone", 0x2 },
2865 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
2866 * the Fujitsu S702x, but jacks are marked differently.
2868 static struct hda_input_mux alc260_acer_capture_sources[2] = {
2875 { "Headphone", 0x5 },
2884 { "Headphone", 0x6 },
2890 * This is just place-holder, so there's something for alc_build_pcms to look
2891 * at when it calculates the maximum number of channels. ALC260 has no mixer
2892 * element which allows changing the channel mode, so the verb list is
2895 static struct hda_channel_mode alc260_modes[1] = {
2900 /* Mixer combinations
2902 * basic: base_output + input + pc_beep + capture
2903 * HP: base_output + input + capture_alt
2904 * HP_3013: hp_3013 + input + capture
2905 * fujitsu: fujitsu + capture
2906 * acer: acer + capture
2909 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
2910 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2911 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2912 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2913 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2914 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2915 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2919 static struct snd_kcontrol_new alc260_input_mixer[] = {
2920 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2921 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2922 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2923 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2925 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2926 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2927 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2931 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2932 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2933 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2937 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2938 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2939 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2940 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2941 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2942 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2944 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2945 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
2949 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
2950 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
2952 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
2953 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2954 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
2955 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
2956 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2957 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2958 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2959 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
2960 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
2961 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2962 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2963 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2964 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
2968 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
2969 * versions of the ALC260 don't act on requests to enable mic bias from NID
2970 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
2971 * datasheet doesn't mention this restriction. At this stage it's not clear
2972 * whether this behaviour is intentional or is a hardware bug in chip
2973 * revisions available in early 2006. Therefore for now allow the
2974 * "Headphone Jack Mode" control to span all choices, but if it turns out
2975 * that the lack of mic bias for this NID is intentional we could change the
2976 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
2978 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
2979 * don't appear to make the mic bias available from the "line" jack, even
2980 * though the NID used for this jack (0x14) can supply it. The theory is
2981 * that perhaps Acer have included blocking capacitors between the ALC260
2982 * and the output jack. If this turns out to be the case for all such
2983 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
2984 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
2986 static struct snd_kcontrol_new alc260_acer_mixer[] = {
2987 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2988 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
2989 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
2990 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2991 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2993 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2994 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
2995 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2996 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2997 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
2998 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2999 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3003 /* capture mixer elements */
3004 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3005 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3006 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3007 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3008 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3011 /* The multiple "Capture Source" controls confuse alsamixer
3012 * So call somewhat different..
3013 * FIXME: the controls appear in the "playback" view!
3015 /* .name = "Capture Source", */
3016 .name = "Input Source",
3018 .info = alc_mux_enum_info,
3019 .get = alc_mux_enum_get,
3020 .put = alc_mux_enum_put,
3025 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3026 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3027 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3030 /* The multiple "Capture Source" controls confuse alsamixer
3031 * So call somewhat different..
3032 * FIXME: the controls appear in the "playback" view!
3034 /* .name = "Capture Source", */
3035 .name = "Input Source",
3037 .info = alc_mux_enum_info,
3038 .get = alc_mux_enum_get,
3039 .put = alc_mux_enum_put,
3045 * initialization verbs
3047 static struct hda_verb alc260_init_verbs[] = {
3048 /* Line In pin widget for input */
3049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3050 /* CD pin widget for input */
3051 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3052 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3053 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3054 /* Mic2 (front panel) pin widget for input and vref at 80% */
3055 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3056 /* LINE-2 is used for line-out in rear */
3057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3058 /* select line-out */
3059 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3061 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3063 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3065 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3066 /* mute capture amp left and right */
3067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3068 /* set connection select to line in (default select for this ADC) */
3069 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3070 /* mute capture amp left and right */
3071 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3072 /* set connection select to line in (default select for this ADC) */
3073 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3074 /* set vol=0 Line-Out mixer amp left and right */
3075 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3076 /* unmute pin widget amp left and right (no gain on this amp) */
3077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3078 /* set vol=0 HP mixer amp left and right */
3079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3080 /* unmute pin widget amp left and right (no gain on this amp) */
3081 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3082 /* set vol=0 Mono mixer amp left and right */
3083 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3084 /* unmute pin widget amp left and right (no gain on this amp) */
3085 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3086 /* unmute LINE-2 out pin */
3087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3088 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3094 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3095 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3096 /* mute Front out path */
3097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3099 /* mute Headphone out path */
3100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3101 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3102 /* mute Mono out path */
3103 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3104 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3108 static struct hda_verb alc260_hp_init_verbs[] = {
3109 /* Headphone and output */
3110 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3112 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3113 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3114 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3115 /* Mic2 (front panel) pin widget for input and vref at 80% */
3116 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3117 /* Line In pin widget for input */
3118 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3119 /* Line-2 pin widget for output */
3120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3121 /* CD pin widget for input */
3122 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3123 /* unmute amp left and right */
3124 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3125 /* set connection select to line in (default select for this ADC) */
3126 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3127 /* unmute Line-Out mixer amp left and right (volume = 0) */
3128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3129 /* mute pin widget amp left and right (no gain on this amp) */
3130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3131 /* unmute HP mixer amp left and right (volume = 0) */
3132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3133 /* mute pin widget amp left and right (no gain on this amp) */
3134 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3135 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3138 /* unmute Line In */
3139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3142 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3143 /* Unmute Front out path */
3144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3146 /* Unmute Headphone out path */
3147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3149 /* Unmute Mono out path */
3150 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3151 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3155 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3156 /* Line out and output */
3157 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3159 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3160 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3161 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3162 /* Mic2 (front panel) pin widget for input and vref at 80% */
3163 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3164 /* Line In pin widget for input */
3165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3166 /* Headphone pin widget for output */
3167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3168 /* CD pin widget for input */
3169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3170 /* unmute amp left and right */
3171 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3172 /* set connection select to line in (default select for this ADC) */
3173 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3174 /* unmute Line-Out mixer amp left and right (volume = 0) */
3175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3176 /* mute pin widget amp left and right (no gain on this amp) */
3177 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3178 /* unmute HP mixer amp left and right (volume = 0) */
3179 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3180 /* mute pin widget amp left and right (no gain on this amp) */
3181 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3182 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
3184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3185 /* unmute Line In */
3186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
3188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3189 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3190 /* Unmute Front out path */
3191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3192 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3193 /* Unmute Headphone out path */
3194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3196 /* Unmute Mono out path */
3197 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3198 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3202 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3203 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3204 * audio = 0x16, internal speaker = 0x10.
3206 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3207 /* Disable all GPIOs */
3208 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3209 /* Internal speaker is connected to headphone pin */
3210 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3211 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3213 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3214 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3215 /* Ensure all other unused pins are disabled and muted. */
3216 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3217 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3218 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3219 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3220 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3221 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3225 /* Disable digital (SPDIF) pins */
3226 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3227 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3229 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3230 * when acting as an output.
3232 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3234 /* Start with output sum widgets muted and their output gains at min */
3235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3236 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3240 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3241 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3242 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3243 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3245 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3246 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3247 /* Unmute Line1 pin widget output buffer since it starts as an output.
3248 * If the pin mode is changed by the user the pin mode control will
3249 * take care of enabling the pin's input/output buffers as needed.
3250 * Therefore there's no need to enable the input buffer at this
3253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3254 /* Unmute input buffer of pin widget used for Line-in (no equiv
3257 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3259 /* Mute capture amp left and right */
3260 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3261 /* Set ADC connection select to match default mixer setting - line
3264 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3266 /* Do the same for the second ADC: mute capture input amp and
3267 * set ADC connection to line in (on mic1 pin)
3269 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3270 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3272 /* Mute all inputs to mixer widget (even unconnected ones) */
3273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3274 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3275 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3276 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3285 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3286 * similar laptops (adapted from Fujitsu init verbs).
3288 static struct hda_verb alc260_acer_init_verbs[] = {
3289 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3290 * the headphone jack. Turn this on and rely on the standard mute
3291 * methods whenever the user wants to turn these outputs off.
3293 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3294 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3295 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3296 /* Internal speaker/Headphone jack is connected to Line-out pin */
3297 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3298 /* Internal microphone/Mic jack is connected to Mic1 pin */
3299 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3300 /* Line In jack is connected to Line1 pin */
3301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3302 /* Ensure all other unused pins are disabled and muted. */
3303 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3304 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3305 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3306 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3307 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3308 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3311 /* Disable digital (SPDIF) pins */
3312 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3313 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3315 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3316 * bus when acting as outputs.
3318 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3319 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3321 /* Start with output sum widgets muted and their output gains at min */
3322 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3323 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3325 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3326 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3328 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3329 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3330 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3332 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
3333 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3334 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
3335 * inputs. If the pin mode is changed by the user the pin mode control
3336 * will take care of enabling the pin's input/output buffers as needed.
3337 * Therefore there's no need to enable the input buffer at this
3340 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3343 /* Mute capture amp left and right */
3344 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3345 /* Set ADC connection select to match default mixer setting - mic
3348 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3350 /* Do similar with the second ADC: mute capture input amp and
3351 * set ADC connection to mic to match ALSA's default state.
3353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3354 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3356 /* Mute all inputs to mixer widget (even unconnected ones) */
3357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3358 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3359 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3360 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3361 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3362 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3369 /* Test configuration for debugging, modelled after the ALC880 test
3372 #ifdef CONFIG_SND_DEBUG
3373 static hda_nid_t alc260_test_dac_nids[1] = {
3376 static hda_nid_t alc260_test_adc_nids[2] = {
3379 /* For testing the ALC260, each input MUX needs its own definition since
3380 * the signal assignments are different. This assumes that the first ADC
3383 static struct hda_input_mux alc260_test_capture_sources[2] = {
3387 { "MIC1 pin", 0x0 },
3388 { "MIC2 pin", 0x1 },
3389 { "LINE1 pin", 0x2 },
3390 { "LINE2 pin", 0x3 },
3392 { "LINE-OUT pin", 0x5 },
3393 { "HP-OUT pin", 0x6 },
3399 { "MIC1 pin", 0x0 },
3400 { "MIC2 pin", 0x1 },
3401 { "LINE1 pin", 0x2 },
3402 { "LINE2 pin", 0x3 },
3405 { "LINE-OUT pin", 0x6 },
3406 { "HP-OUT pin", 0x7 },
3410 static struct snd_kcontrol_new alc260_test_mixer[] = {
3411 /* Output driver widgets */
3412 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3413 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3414 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3415 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
3416 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3417 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
3419 /* Modes for retasking pin widgets
3420 * Note: the ALC260 doesn't seem to act on requests to enable mic
3421 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
3422 * mention this restriction. At this stage it's not clear whether
3423 * this behaviour is intentional or is a hardware bug in chip
3424 * revisions available at least up until early 2006. Therefore for
3425 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
3426 * choices, but if it turns out that the lack of mic bias for these
3427 * NIDs is intentional we could change their modes from
3428 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3430 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
3431 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
3432 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
3433 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
3434 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
3435 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
3437 /* Loopback mixer controls */
3438 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
3439 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
3440 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
3441 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
3442 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
3443 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
3444 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
3445 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
3446 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3447 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3448 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3449 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3450 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
3451 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
3452 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
3453 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
3455 /* Controls for GPIO pins, assuming they are configured as outputs */
3456 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
3457 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
3458 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
3459 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
3461 /* Switches to allow the digital IO pins to be enabled. The datasheet
3462 * is ambigious as to which NID is which; testing on laptops which
3463 * make this output available should provide clarification.
3465 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
3466 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
3470 static struct hda_verb alc260_test_init_verbs[] = {
3471 /* Enable all GPIOs as outputs with an initial value of 0 */
3472 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
3473 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3474 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
3476 /* Enable retasking pins as output, initially without power amp */
3477 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3478 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3481 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3484 /* Disable digital (SPDIF) pins initially, but users can enable
3485 * them via a mixer switch. In the case of SPDIF-out, this initverb
3486 * payload also sets the generation to 0, output to be in "consumer"
3487 * PCM format, copyright asserted, no pre-emphasis and no validity
3490 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3491 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3493 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
3494 * OUT1 sum bus when acting as an output.
3496 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3497 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
3498 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3499 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
3501 /* Start with output sum widgets muted and their output gains at min */
3502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3510 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3512 /* Unmute retasking pin widget output buffers since the default
3513 * state appears to be output. As the pin mode is changed by the
3514 * user the pin mode control will take care of enabling the pin's
3515 * input/output buffers as needed.
3517 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3522 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 /* Also unmute the mono-out pin widget */
3524 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3526 /* Mute capture amp left and right */
3527 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3528 /* Set ADC connection select to match default mixer setting (mic1
3531 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3533 /* Do the same for the second ADC: mute capture input amp and
3534 * set ADC connection to mic1 pin
3536 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3537 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3539 /* Mute all inputs to mixer widget (even unconnected ones) */
3540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3553 static struct hda_pcm_stream alc260_pcm_analog_playback = {
3559 static struct hda_pcm_stream alc260_pcm_analog_capture = {
3565 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
3566 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
3569 * for BIOS auto-configuration
3572 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3576 unsigned long vol_val, sw_val;
3580 if (nid >= 0x0f && nid < 0x11) {
3581 nid_vol = nid - 0x7;
3582 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3583 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3584 } else if (nid == 0x11) {
3585 nid_vol = nid - 0x7;
3586 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
3587 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
3588 } else if (nid >= 0x12 && nid <= 0x15) {
3590 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
3591 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3595 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3596 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
3598 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3599 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3604 /* add playback controls from the parsed DAC table */
3605 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3606 const struct auto_pin_cfg *cfg)
3611 spec->multiout.num_dacs = 1;
3612 spec->multiout.dac_nids = spec->private_dac_nids;
3613 spec->multiout.dac_nids[0] = 0x02;
3615 nid = cfg->line_out_pins[0];
3617 err = alc260_add_playback_controls(spec, nid, "Front");
3622 nid = cfg->speaker_pins[0];
3624 err = alc260_add_playback_controls(spec, nid, "Speaker");
3631 err = alc260_add_playback_controls(spec, nid, "Headphone");
3638 /* create playback/capture controls for input pins */
3639 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3640 const struct auto_pin_cfg *cfg)
3642 struct hda_input_mux *imux = &spec->private_imux;
3645 for (i = 0; i < AUTO_PIN_LAST; i++) {
3646 if (cfg->input_pins[i] >= 0x12) {
3647 idx = cfg->input_pins[i] - 0x12;
3648 err = new_analog_input(spec, cfg->input_pins[i],
3649 auto_pin_cfg_labels[i], idx, 0x07);
3652 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3653 imux->items[imux->num_items].index = idx;
3656 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3657 idx = cfg->input_pins[i] - 0x09;
3658 err = new_analog_input(spec, cfg->input_pins[i],
3659 auto_pin_cfg_labels[i], idx, 0x07);
3662 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3663 imux->items[imux->num_items].index = idx;
3670 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3671 hda_nid_t nid, int pin_type,
3675 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3676 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3677 /* need the manual connection? */
3679 int idx = nid - 0x12;
3680 snd_hda_codec_write(codec, idx + 0x0b, 0,
3681 AC_VERB_SET_CONNECT_SEL, sel_idx);
3686 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3688 struct alc_spec *spec = codec->spec;
3691 nid = spec->autocfg.line_out_pins[0];
3693 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3695 nid = spec->autocfg.speaker_pins[0];
3697 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3699 nid = spec->autocfg.hp_pin;
3701 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3704 #define ALC260_PIN_CD_NID 0x16
3705 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3707 struct alc_spec *spec = codec->spec;
3710 for (i = 0; i < AUTO_PIN_LAST; i++) {
3711 hda_nid_t nid = spec->autocfg.input_pins[i];
3713 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3714 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3715 if (nid != ALC260_PIN_CD_NID)
3716 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3723 * generic initialization of ADC, input mixers and output mixers
3725 static struct hda_verb alc260_volume_init_verbs[] = {
3727 * Unmute ADC0-1 and set the default input to mic-in
3729 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3730 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3731 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3732 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3734 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3736 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3739 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3741 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3742 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3743 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3747 * Set up output mixers (0x08 - 0x0a)
3749 /* set vol=0 to output mixers */
3750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3751 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3752 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3753 /* set up input amps for analog loopback */
3754 /* Amp Indices: DAC = 0, mixer = 1 */
3755 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3756 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3759 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3760 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3765 static int alc260_parse_auto_config(struct hda_codec *codec)
3767 struct alc_spec *spec = codec->spec;
3770 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3772 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3773 alc260_ignore)) < 0)
3775 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3777 if (! spec->kctl_alloc)
3778 return 0; /* can't find valid BIOS pin config */
3779 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3782 spec->multiout.max_channels = 2;
3784 if (spec->autocfg.dig_out_pin)
3785 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3786 if (spec->kctl_alloc)
3787 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3789 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3791 spec->num_mux_defs = 1;
3792 spec->input_mux = &spec->private_imux;
3794 /* check whether NID 0x04 is valid */
3795 wcap = get_wcaps(codec, 0x04);
3796 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3797 if (wcap != AC_WID_AUD_IN) {
3798 spec->adc_nids = alc260_adc_nids_alt;
3799 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3800 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3802 spec->adc_nids = alc260_adc_nids;
3803 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3804 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3811 /* additional initialization for auto-configuration model */
3812 static void alc260_auto_init(struct hda_codec *codec)
3814 alc260_auto_init_multi_out(codec);
3815 alc260_auto_init_analog_input(codec);
3819 * ALC260 configurations
3821 static struct hda_board_config alc260_cfg_tbl[] = {
3822 { .modelname = "basic", .config = ALC260_BASIC },
3823 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3824 .config = ALC260_BASIC }, /* Sony VAIO */
3825 { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
3826 .config = ALC260_BASIC }, /* CTL Travel Master U553W */
3827 { .modelname = "hp", .config = ALC260_HP },
3828 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3829 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3830 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
3831 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3832 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3833 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3834 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3835 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3836 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3837 { .modelname = "acer", .config = ALC260_ACER },
3838 { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
3839 #ifdef CONFIG_SND_DEBUG
3840 { .modelname = "test", .config = ALC260_TEST },
3842 { .modelname = "auto", .config = ALC260_AUTO },
3846 static struct alc_config_preset alc260_presets[] = {
3848 .mixers = { alc260_base_output_mixer,
3850 alc260_pc_beep_mixer,
3851 alc260_capture_mixer },
3852 .init_verbs = { alc260_init_verbs },
3853 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3854 .dac_nids = alc260_dac_nids,
3855 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3856 .adc_nids = alc260_adc_nids,
3857 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3858 .channel_mode = alc260_modes,
3859 .input_mux = &alc260_capture_source,
3862 .mixers = { alc260_base_output_mixer,
3864 alc260_capture_alt_mixer },
3865 .init_verbs = { alc260_hp_init_verbs },
3866 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3867 .dac_nids = alc260_dac_nids,
3868 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3869 .adc_nids = alc260_hp_adc_nids,
3870 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3871 .channel_mode = alc260_modes,
3872 .input_mux = &alc260_capture_source,
3874 [ALC260_HP_3013] = {
3875 .mixers = { alc260_hp_3013_mixer,
3877 alc260_capture_alt_mixer },
3878 .init_verbs = { alc260_hp_3013_init_verbs },
3879 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3880 .dac_nids = alc260_dac_nids,
3881 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3882 .adc_nids = alc260_hp_adc_nids,
3883 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3884 .channel_mode = alc260_modes,
3885 .input_mux = &alc260_capture_source,
3887 [ALC260_FUJITSU_S702X] = {
3888 .mixers = { alc260_fujitsu_mixer,
3889 alc260_capture_mixer },
3890 .init_verbs = { alc260_fujitsu_init_verbs },
3891 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3892 .dac_nids = alc260_dac_nids,
3893 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3894 .adc_nids = alc260_dual_adc_nids,
3895 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3896 .channel_mode = alc260_modes,
3897 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
3898 .input_mux = alc260_fujitsu_capture_sources,
3901 .mixers = { alc260_acer_mixer,
3902 alc260_capture_mixer },
3903 .init_verbs = { alc260_acer_init_verbs },
3904 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3905 .dac_nids = alc260_dac_nids,
3906 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
3907 .adc_nids = alc260_dual_adc_nids,
3908 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3909 .channel_mode = alc260_modes,
3910 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
3911 .input_mux = alc260_acer_capture_sources,
3913 #ifdef CONFIG_SND_DEBUG
3915 .mixers = { alc260_test_mixer,
3916 alc260_capture_mixer },
3917 .init_verbs = { alc260_test_init_verbs },
3918 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
3919 .dac_nids = alc260_test_dac_nids,
3920 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
3921 .adc_nids = alc260_test_adc_nids,
3922 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3923 .channel_mode = alc260_modes,
3924 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
3925 .input_mux = alc260_test_capture_sources,
3930 static int patch_alc260(struct hda_codec *codec)
3932 struct alc_spec *spec;
3933 int err, board_config;
3935 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3941 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3942 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3943 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
3944 board_config = ALC260_AUTO;
3947 if (board_config == ALC260_AUTO) {
3948 /* automatic parse from the BIOS config */
3949 err = alc260_parse_auto_config(codec);
3954 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3955 board_config = ALC260_BASIC;
3959 if (board_config != ALC260_AUTO)
3960 setup_preset(spec, &alc260_presets[board_config]);
3962 spec->stream_name_analog = "ALC260 Analog";
3963 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3964 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3966 spec->stream_name_digital = "ALC260 Digital";
3967 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3968 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3970 codec->patch_ops = alc_patch_ops;
3971 if (board_config == ALC260_AUTO)
3972 spec->init_hook = alc260_auto_init;
3981 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3982 * configuration. Each pin widget can choose any input DACs and a mixer.
3983 * Each ADC is connected from a mixer of all inputs. This makes possible
3984 * 6-channel independent captures.
3986 * In addition, an independent DAC for the multi-playback (not used in this
3989 #define ALC882_DIGOUT_NID 0x06
3990 #define ALC882_DIGIN_NID 0x0a
3992 static struct hda_channel_mode alc882_ch_modes[1] = {
3996 static hda_nid_t alc882_dac_nids[4] = {
3997 /* front, rear, clfe, rear_surr */
3998 0x02, 0x03, 0x04, 0x05
4001 /* identical with ALC880 */
4002 #define alc882_adc_nids alc880_adc_nids
4003 #define alc882_adc_nids_alt alc880_adc_nids_alt
4006 /* FIXME: should be a matrix-type input source selection */
4008 static struct hda_input_mux alc882_capture_source = {
4012 { "Front Mic", 0x1 },
4017 #define alc882_mux_enum_info alc_mux_enum_info
4018 #define alc882_mux_enum_get alc_mux_enum_get
4020 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4022 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4023 struct alc_spec *spec = codec->spec;
4024 const struct hda_input_mux *imux = spec->input_mux;
4025 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4026 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4027 hda_nid_t nid = capture_mixers[adc_idx];
4028 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4029 unsigned int i, idx;
4031 idx = ucontrol->value.enumerated.item[0];
4032 if (idx >= imux->num_items)
4033 idx = imux->num_items - 1;
4034 if (*cur_val == idx && ! codec->in_resume)
4036 for (i = 0; i < imux->num_items; i++) {
4037 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
4038 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4039 v | (imux->items[i].index << 8));
4048 static struct hda_verb alc882_sixstack_ch6_init[] = {
4049 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4050 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4051 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4052 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4059 static struct hda_verb alc882_sixstack_ch8_init[] = {
4060 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4061 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4062 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4063 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4067 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4068 { 6, alc882_sixstack_ch6_init },
4069 { 8, alc882_sixstack_ch8_init },
4072 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4073 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4075 static struct snd_kcontrol_new alc882_base_mixer[] = {
4076 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4077 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4078 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4079 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4080 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4081 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4082 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4083 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4084 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4085 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4086 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4087 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4088 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4089 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4090 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4093 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4094 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4095 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4096 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4097 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4098 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4099 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4100 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4101 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4102 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4105 /* .name = "Capture Source", */
4106 .name = "Input Source",
4108 .info = alc882_mux_enum_info,
4109 .get = alc882_mux_enum_get,
4110 .put = alc882_mux_enum_put,
4115 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4118 .name = "Channel Mode",
4119 .info = alc_ch_mode_info,
4120 .get = alc_ch_mode_get,
4121 .put = alc_ch_mode_put,
4126 static struct hda_verb alc882_init_verbs[] = {
4127 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4132 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4137 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4140 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4141 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4144 /* Front Pin: output 0 (0x0c) */
4145 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4146 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4147 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4148 /* Rear Pin: output 1 (0x0d) */
4149 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4152 /* CLFE Pin: output 2 (0x0e) */
4153 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4154 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4155 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
4156 /* Side Pin: output 3 (0x0f) */
4157 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4158 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4159 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
4160 /* Mic (rear) pin: input vref at 80% */
4161 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4162 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4163 /* Front Mic pin: input vref at 80% */
4164 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4165 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4166 /* Line In pin: input */
4167 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4168 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4169 /* Line-2 In: Headphone output (output 0 - 0x0c) */
4170 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4171 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4172 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
4173 /* CD pin widget for input */
4174 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4176 /* FIXME: use matrix-type input source selection */
4177 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4178 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4193 /* ADC1: mute amp left and right */
4194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4195 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4196 /* ADC2: mute amp left and right */
4197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4199 /* ADC3: mute amp left and right */
4200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4201 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4207 * generic initialization of ADC, input mixers and output mixers
4209 static struct hda_verb alc882_auto_init_verbs[] = {
4211 * Unmute ADC0-2 and set the default input to mic-in
4213 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4215 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4216 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4217 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4218 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4220 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4222 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4225 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4233 * Set up output mixers (0x0c - 0x0f)
4235 /* set vol=0 to output mixers */
4236 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4237 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4238 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4239 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4240 /* set up input amps for analog loopback */
4241 /* Amp Indices: DAC = 0, mixer = 1 */
4242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4246 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4247 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4248 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4249 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4250 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4251 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4253 /* FIXME: use matrix-type input source selection */
4254 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4255 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4258 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4259 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4263 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4264 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4274 /* capture mixer elements */
4275 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
4276 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4277 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4278 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
4279 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
4281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4282 /* The multiple "Capture Source" controls confuse alsamixer
4283 * So call somewhat different..
4284 * FIXME: the controls appear in the "playback" view!
4286 /* .name = "Capture Source", */
4287 .name = "Input Source",
4289 .info = alc882_mux_enum_info,
4290 .get = alc882_mux_enum_get,
4291 .put = alc882_mux_enum_put,
4296 static struct snd_kcontrol_new alc882_capture_mixer[] = {
4297 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
4298 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
4299 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
4300 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
4301 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
4302 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
4304 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4305 /* The multiple "Capture Source" controls confuse alsamixer
4306 * So call somewhat different..
4307 * FIXME: the controls appear in the "playback" view!
4309 /* .name = "Capture Source", */
4310 .name = "Input Source",
4312 .info = alc882_mux_enum_info,
4313 .get = alc882_mux_enum_get,
4314 .put = alc882_mux_enum_put,
4319 /* pcm configuration: identiacal with ALC880 */
4320 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
4321 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
4322 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
4323 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
4326 * configuration and preset
4328 static struct hda_board_config alc882_cfg_tbl[] = {
4329 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
4330 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
4331 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
4332 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
4333 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
4334 { .modelname = "auto", .config = ALC882_AUTO },
4338 static struct alc_config_preset alc882_presets[] = {
4339 [ALC882_3ST_DIG] = {
4340 .mixers = { alc882_base_mixer },
4341 .init_verbs = { alc882_init_verbs },
4342 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4343 .dac_nids = alc882_dac_nids,
4344 .dig_out_nid = ALC882_DIGOUT_NID,
4345 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4346 .adc_nids = alc882_adc_nids,
4347 .dig_in_nid = ALC882_DIGIN_NID,
4348 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
4349 .channel_mode = alc882_ch_modes,
4350 .input_mux = &alc882_capture_source,
4352 [ALC882_6ST_DIG] = {
4353 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
4354 .init_verbs = { alc882_init_verbs },
4355 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
4356 .dac_nids = alc882_dac_nids,
4357 .dig_out_nid = ALC882_DIGOUT_NID,
4358 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
4359 .adc_nids = alc882_adc_nids,
4360 .dig_in_nid = ALC882_DIGIN_NID,
4361 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
4362 .channel_mode = alc882_sixstack_modes,
4363 .input_mux = &alc882_capture_source,
4369 * BIOS auto configuration
4371 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4372 hda_nid_t nid, int pin_type,
4376 struct alc_spec *spec = codec->spec;
4379 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4382 idx = spec->multiout.dac_nids[dac_idx] - 2;
4384 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4385 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4386 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4390 static void alc882_auto_init_multi_out(struct hda_codec *codec)
4392 struct alc_spec *spec = codec->spec;
4395 for (i = 0; i <= HDA_SIDE; i++) {
4396 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4398 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
4402 static void alc882_auto_init_hp_out(struct hda_codec *codec)
4404 struct alc_spec *spec = codec->spec;
4407 pin = spec->autocfg.hp_pin;
4408 if (pin) /* connect to front */
4409 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
4412 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
4413 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
4415 static void alc882_auto_init_analog_input(struct hda_codec *codec)
4417 struct alc_spec *spec = codec->spec;
4420 for (i = 0; i < AUTO_PIN_LAST; i++) {
4421 hda_nid_t nid = spec->autocfg.input_pins[i];
4422 if (alc882_is_input_pin(nid)) {
4423 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4424 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4425 if (nid != ALC882_PIN_CD_NID)
4426 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4432 /* almost identical with ALC880 parser... */
4433 static int alc882_parse_auto_config(struct hda_codec *codec)
4435 struct alc_spec *spec = codec->spec;
4436 int err = alc880_parse_auto_config(codec);
4441 /* hack - override the init verbs */
4442 spec->init_verbs[0] = alc882_auto_init_verbs;
4446 /* additional initialization for auto-configuration model */
4447 static void alc882_auto_init(struct hda_codec *codec)
4449 alc882_auto_init_multi_out(codec);
4450 alc882_auto_init_hp_out(codec);
4451 alc882_auto_init_analog_input(codec);
4455 * ALC882 Headphone poll in 3.5.1a or 3.5.2
4458 static int patch_alc882(struct hda_codec *codec)
4460 struct alc_spec *spec;
4461 int err, board_config;
4463 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4469 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
4471 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
4472 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
4473 board_config = ALC882_AUTO;
4476 if (board_config == ALC882_AUTO) {
4477 /* automatic parse from the BIOS config */
4478 err = alc882_parse_auto_config(codec);
4483 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4484 board_config = ALC882_3ST_DIG;
4488 if (board_config != ALC882_AUTO)
4489 setup_preset(spec, &alc882_presets[board_config]);
4491 spec->stream_name_analog = "ALC882 Analog";
4492 spec->stream_analog_playback = &alc882_pcm_analog_playback;
4493 spec->stream_analog_capture = &alc882_pcm_analog_capture;
4495 spec->stream_name_digital = "ALC882 Digital";
4496 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4497 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4499 if (! spec->adc_nids && spec->input_mux) {
4500 /* check whether NID 0x07 is valid */
4501 unsigned int wcap = get_wcaps(codec, 0x07);
4502 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4503 if (wcap != AC_WID_AUD_IN) {
4504 spec->adc_nids = alc882_adc_nids_alt;
4505 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4506 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
4509 spec->adc_nids = alc882_adc_nids;
4510 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
4511 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
4516 codec->patch_ops = alc_patch_ops;
4517 if (board_config == ALC882_AUTO)
4518 spec->init_hook = alc882_auto_init;
4527 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
4528 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
4530 #define alc262_dac_nids alc260_dac_nids
4531 #define alc262_adc_nids alc882_adc_nids
4532 #define alc262_adc_nids_alt alc882_adc_nids_alt
4534 #define alc262_modes alc260_modes
4535 #define alc262_capture_source alc882_capture_source
4537 static struct snd_kcontrol_new alc262_base_mixer[] = {
4538 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4539 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4540 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4541 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4542 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4543 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4546 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
4547 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
4548 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
4549 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
4550 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
4551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4552 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4553 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
4557 #define alc262_capture_mixer alc882_capture_mixer
4558 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
4561 * generic initialization of ADC, input mixers and output mixers
4563 static struct hda_verb alc262_init_verbs[] = {
4565 * Unmute ADC0-2 and set the default input to mic-in
4567 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4569 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4570 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4571 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4574 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4576 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4579 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4580 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4581 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4582 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4583 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4584 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4587 * Set up output mixers (0x0c - 0x0e)
4589 /* set vol=0 to output mixers */
4590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4593 /* set up input amps for analog loopback */
4594 /* Amp Indices: DAC = 0, mixer = 1 */
4595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4597 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4600 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4604 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4606 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4607 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4609 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4611 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4613 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4615 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4616 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4618 /* FIXME: use matrix-type input source selection */
4619 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4620 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4621 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4622 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4623 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4624 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4628 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4629 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4631 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4632 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4634 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4641 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
4644 #define ALC_HP_EVENT 0x37
4646 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
4647 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
4648 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4652 static struct hda_input_mux alc262_fujitsu_capture_source = {
4660 /* mute/unmute internal speaker according to the hp jack and mute state */
4661 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
4663 struct alc_spec *spec = codec->spec;
4666 if (force || ! spec->sense_updated) {
4667 unsigned int present;
4668 /* need to execute and sync at first */
4669 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
4670 present = snd_hda_codec_read(codec, 0x14, 0,
4671 AC_VERB_GET_PIN_SENSE, 0);
4672 spec->jack_present = (present & 0x80000000) != 0;
4673 spec->sense_updated = 1;
4675 if (spec->jack_present) {
4676 /* mute internal speaker */
4677 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4679 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4682 /* unmute internal speaker if necessary */
4683 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
4684 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
4686 mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
4687 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
4692 /* unsolicited event for HP jack sensing */
4693 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
4696 if ((res >> 26) != ALC_HP_EVENT)
4698 alc262_fujitsu_automute(codec, 1);
4701 /* bind volumes of both NID 0x0c and 0x0d */
4702 static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
4703 struct snd_ctl_elem_value *ucontrol)
4705 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4706 long *valp = ucontrol->value.integer.value;
4709 change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
4710 0x7f, valp[0] & 0x7f);
4711 change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
4712 0x7f, valp[1] & 0x7f);
4713 snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
4714 0x7f, valp[0] & 0x7f);
4715 snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
4716 0x7f, valp[1] & 0x7f);
4720 /* bind hp and internal speaker mute (with plug check) */
4721 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
4722 struct snd_ctl_elem_value *ucontrol)
4724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4725 long *valp = ucontrol->value.integer.value;
4728 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
4729 0x80, valp[0] ? 0 : 0x80);
4730 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
4731 0x80, valp[1] ? 0 : 0x80);
4732 if (change || codec->in_resume)
4733 alc262_fujitsu_automute(codec, codec->in_resume);
4737 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
4739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4740 .name = "Master Playback Volume",
4741 .info = snd_hda_mixer_amp_volume_info,
4742 .get = snd_hda_mixer_amp_volume_get,
4743 .put = alc262_fujitsu_master_vol_put,
4744 .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
4747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4748 .name = "Master Playback Switch",
4749 .info = snd_hda_mixer_amp_switch_info,
4750 .get = snd_hda_mixer_amp_switch_get,
4751 .put = alc262_fujitsu_master_sw_put,
4752 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
4754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4756 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4757 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4758 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4762 /* add playback controls from the parsed DAC table */
4763 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4768 spec->multiout.num_dacs = 1; /* only use one dac */
4769 spec->multiout.dac_nids = spec->private_dac_nids;
4770 spec->multiout.dac_nids[0] = 2;
4772 nid = cfg->line_out_pins[0];
4774 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
4775 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4777 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
4778 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4782 nid = cfg->speaker_pins[0];
4785 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4786 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4788 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4789 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4792 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4793 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4799 /* spec->multiout.hp_nid = 2; */
4801 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4802 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4804 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4805 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4808 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4809 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4816 /* identical with ALC880 */
4817 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
4820 * generic initialization of ADC, input mixers and output mixers
4822 static struct hda_verb alc262_volume_init_verbs[] = {
4824 * Unmute ADC0-2 and set the default input to mic-in
4826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4829 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4831 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4833 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4835 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4838 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4846 * Set up output mixers (0x0c - 0x0f)
4848 /* set vol=0 to output mixers */
4849 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4850 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4853 /* set up input amps for analog loopback */
4854 /* Amp Indices: DAC = 0, mixer = 1 */
4855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4857 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4859 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4862 /* FIXME: use matrix-type input source selection */
4863 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4864 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4866 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4868 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4883 /* pcm configuration: identiacal with ALC880 */
4884 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
4885 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
4886 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
4887 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
4890 * BIOS auto configuration
4892 static int alc262_parse_auto_config(struct hda_codec *codec)
4894 struct alc_spec *spec = codec->spec;
4896 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4898 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4899 alc262_ignore)) < 0)
4901 if (! spec->autocfg.line_outs)
4902 return 0; /* can't find valid BIOS pin config */
4903 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4904 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4907 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4909 if (spec->autocfg.dig_out_pin)
4910 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
4911 if (spec->autocfg.dig_in_pin)
4912 spec->dig_in_nid = ALC262_DIGIN_NID;
4914 if (spec->kctl_alloc)
4915 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4917 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
4918 spec->num_mux_defs = 1;
4919 spec->input_mux = &spec->private_imux;
4924 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
4925 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
4926 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
4929 /* init callback for auto-configuration model -- overriding the default init */
4930 static void alc262_auto_init(struct hda_codec *codec)
4932 alc262_auto_init_multi_out(codec);
4933 alc262_auto_init_hp_out(codec);
4934 alc262_auto_init_analog_input(codec);
4938 * configuration and preset
4940 static struct hda_board_config alc262_cfg_tbl[] = {
4941 { .modelname = "basic", .config = ALC262_BASIC },
4942 { .modelname = "fujitsu", .config = ALC262_FUJITSU },
4943 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
4944 { .modelname = "auto", .config = ALC262_AUTO },
4948 static struct alc_config_preset alc262_presets[] = {
4950 .mixers = { alc262_base_mixer },
4951 .init_verbs = { alc262_init_verbs },
4952 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4953 .dac_nids = alc262_dac_nids,
4955 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4956 .channel_mode = alc262_modes,
4957 .input_mux = &alc262_capture_source,
4959 [ALC262_FUJITSU] = {
4960 .mixers = { alc262_fujitsu_mixer },
4961 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
4962 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4963 .dac_nids = alc262_dac_nids,
4965 .dig_out_nid = ALC262_DIGOUT_NID,
4966 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4967 .channel_mode = alc262_modes,
4968 .input_mux = &alc262_fujitsu_capture_source,
4969 .unsol_event = alc262_fujitsu_unsol_event,
4973 static int patch_alc262(struct hda_codec *codec)
4975 struct alc_spec *spec;
4979 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4985 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
4988 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4989 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4990 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4991 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4995 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
4996 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
4997 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
4998 board_config = ALC262_AUTO;
5001 if (board_config == ALC262_AUTO) {
5002 /* automatic parse from the BIOS config */
5003 err = alc262_parse_auto_config(codec);
5008 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
5009 board_config = ALC262_BASIC;
5013 if (board_config != ALC262_AUTO)
5014 setup_preset(spec, &alc262_presets[board_config]);
5016 spec->stream_name_analog = "ALC262 Analog";
5017 spec->stream_analog_playback = &alc262_pcm_analog_playback;
5018 spec->stream_analog_capture = &alc262_pcm_analog_capture;
5020 spec->stream_name_digital = "ALC262 Digital";
5021 spec->stream_digital_playback = &alc262_pcm_digital_playback;
5022 spec->stream_digital_capture = &alc262_pcm_digital_capture;
5024 if (! spec->adc_nids && spec->input_mux) {
5025 /* check whether NID 0x07 is valid */
5026 unsigned int wcap = get_wcaps(codec, 0x07);
5028 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5029 if (wcap != AC_WID_AUD_IN) {
5030 spec->adc_nids = alc262_adc_nids_alt;
5031 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
5032 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
5035 spec->adc_nids = alc262_adc_nids;
5036 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
5037 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
5042 codec->patch_ops = alc_patch_ops;
5043 if (board_config == ALC262_AUTO)
5044 spec->init_hook = alc262_auto_init;
5051 * ALC861 channel source setting (2/6 channel selection for 3-stack)
5055 * set the path ways for 2 channel output
5056 * need to set the codec line out and mic 1 pin widgets to inputs
5058 static struct hda_verb alc861_threestack_ch2_init[] = {
5059 /* set pin widget 1Ah (line in) for input */
5060 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5061 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
5062 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5064 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
5065 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
5066 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
5071 * need to set the codec line out and mic 1 pin widgets to outputs
5073 static struct hda_verb alc861_threestack_ch6_init[] = {
5074 /* set pin widget 1Ah (line in) for output (Back Surround)*/
5075 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5076 /* set pin widget 18h (mic1) for output (CLFE)*/
5077 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5079 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
5080 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
5082 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
5083 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
5084 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
5088 static struct hda_channel_mode alc861_threestack_modes[2] = {
5089 { 2, alc861_threestack_ch2_init },
5090 { 6, alc861_threestack_ch6_init },
5095 static struct snd_kcontrol_new alc861_base_mixer[] = {
5096 /* output mixer control */
5097 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5098 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5099 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5100 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5101 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
5103 /*Input mixer control */
5104 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5105 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5106 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5107 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5108 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5109 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5111 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
5113 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
5115 /* Capture mixer control */
5116 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5117 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5120 .name = "Capture Source",
5122 .info = alc_mux_enum_info,
5123 .get = alc_mux_enum_get,
5124 .put = alc_mux_enum_put,
5129 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
5130 /* output mixer control */
5131 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
5132 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
5133 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
5134 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
5135 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
5137 /* Input mixer control */
5138 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
5139 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
5140 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
5141 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
5142 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
5143 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
5144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
5145 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
5146 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
5147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
5149 /* Capture mixer control */
5150 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5151 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5154 .name = "Capture Source",
5156 .info = alc_mux_enum_info,
5157 .get = alc_mux_enum_get,
5158 .put = alc_mux_enum_put,
5161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5162 .name = "Channel Mode",
5163 .info = alc_ch_mode_info,
5164 .get = alc_ch_mode_get,
5165 .put = alc_ch_mode_put,
5166 .private_value = ARRAY_SIZE(alc861_threestack_modes),
5172 * generic initialization of ADC, input mixers and output mixers
5174 static struct hda_verb alc861_base_init_verbs[] = {
5176 * Unmute ADC0 and set the default input to mic-in
5178 /* port-A for surround (rear panel) */
5179 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5180 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
5181 /* port-B for mic-in (rear panel) with vref */
5182 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5183 /* port-C for line-in (rear panel) */
5184 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5185 /* port-D for Front */
5186 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5187 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5188 /* port-E for HP out (front panel) */
5189 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5190 /* route front PCM to HP */
5191 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5192 /* port-F for mic-in (front panel) with vref */
5193 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5194 /* port-G for CLFE (rear panel) */
5195 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5196 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
5197 /* port-H for side (rear panel) */
5198 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5199 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
5201 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5202 /* route front mic to ADC1*/
5203 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5206 /* Unmute DAC0~3 & spdif out*/
5207 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5208 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5209 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5210 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5213 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5214 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5215 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5216 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5217 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5219 /* Unmute Stereo Mixer 15 */
5220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5225 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5226 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5227 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5228 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5239 static struct hda_verb alc861_threestack_init_verbs[] = {
5241 * Unmute ADC0 and set the default input to mic-in
5243 /* port-A for surround (rear panel) */
5244 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5245 /* port-B for mic-in (rear panel) with vref */
5246 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5247 /* port-C for line-in (rear panel) */
5248 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5249 /* port-D for Front */
5250 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
5251 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
5252 /* port-E for HP out (front panel) */
5253 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
5254 /* route front PCM to HP */
5255 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
5256 /* port-F for mic-in (front panel) with vref */
5257 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
5258 /* port-G for CLFE (rear panel) */
5259 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5260 /* port-H for side (rear panel) */
5261 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5263 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
5264 /* route front mic to ADC1*/
5265 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5267 /* Unmute DAC0~3 & spdif out*/
5268 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5269 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5270 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5271 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5274 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5275 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5276 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5277 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5278 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5280 /* Unmute Stereo Mixer 15 */
5281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5284 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
5286 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5287 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5288 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5289 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5290 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5292 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5293 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
5295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5299 * generic initialization of ADC, input mixers and output mixers
5301 static struct hda_verb alc861_auto_init_verbs[] = {
5303 * Unmute ADC0 and set the default input to mic-in
5305 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5308 /* Unmute DAC0~3 & spdif out*/
5309 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5310 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5311 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5312 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5315 /* Unmute Mixer 14 (mic) 1c (Line in)*/
5316 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5317 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5318 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5319 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5321 /* Unmute Stereo Mixer 15 */
5322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
5327 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5328 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5329 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5330 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5336 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5337 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5339 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5340 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5342 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5343 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
5345 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
5350 /* pcm configuration: identiacal with ALC880 */
5351 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
5352 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
5353 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
5354 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
5357 #define ALC861_DIGOUT_NID 0x07
5359 static struct hda_channel_mode alc861_8ch_modes[1] = {
5363 static hda_nid_t alc861_dac_nids[4] = {
5364 /* front, surround, clfe, side */
5365 0x03, 0x06, 0x05, 0x04
5368 static hda_nid_t alc861_adc_nids[1] = {
5373 static struct hda_input_mux alc861_capture_source = {
5377 { "Front Mic", 0x3 },
5384 /* fill in the dac_nids table from the parsed pin configuration */
5385 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5390 spec->multiout.dac_nids = spec->private_dac_nids;
5391 for (i = 0; i < cfg->line_outs; i++) {
5392 nid = cfg->line_out_pins[i];
5394 if (i >= ARRAY_SIZE(alc861_dac_nids))
5396 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
5399 spec->multiout.num_dacs = cfg->line_outs;
5403 /* add playback controls from the parsed DAC table */
5404 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
5405 const struct auto_pin_cfg *cfg)
5408 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
5412 for (i = 0; i < cfg->line_outs; i++) {
5413 nid = spec->multiout.dac_nids[i];
5418 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
5419 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
5421 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
5422 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
5425 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
5426 if (nid == alc861_dac_nids[idx])
5428 sprintf(name, "%s Playback Switch", chname[idx]);
5429 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
5430 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5437 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
5445 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
5447 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
5448 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
5450 spec->multiout.hp_nid = nid;
5455 /* create playback/capture controls for input pins */
5456 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
5458 struct hda_input_mux *imux = &spec->private_imux;
5459 int i, err, idx, idx1;
5461 for (i = 0; i < AUTO_PIN_LAST; i++) {
5462 switch(cfg->input_pins[i]) {
5487 err = new_analog_input(spec, cfg->input_pins[i],
5488 auto_pin_cfg_labels[i], idx, 0x15);
5492 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
5493 imux->items[imux->num_items].index = idx1;
5499 static struct snd_kcontrol_new alc861_capture_mixer[] = {
5500 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5501 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5505 /* The multiple "Capture Source" controls confuse alsamixer
5506 * So call somewhat different..
5507 *FIXME: the controls appear in the "playback" view!
5509 /* .name = "Capture Source", */
5510 .name = "Input Source",
5512 .info = alc_mux_enum_info,
5513 .get = alc_mux_enum_get,
5514 .put = alc_mux_enum_put,
5519 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
5520 int pin_type, int dac_idx)
5524 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
5525 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
5529 static void alc861_auto_init_multi_out(struct hda_codec *codec)
5531 struct alc_spec *spec = codec->spec;
5534 for (i = 0; i < spec->autocfg.line_outs; i++) {
5535 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5537 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
5541 static void alc861_auto_init_hp_out(struct hda_codec *codec)
5543 struct alc_spec *spec = codec->spec;
5546 pin = spec->autocfg.hp_pin;
5547 if (pin) /* connect to front */
5548 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
5551 static void alc861_auto_init_analog_input(struct hda_codec *codec)
5553 struct alc_spec *spec = codec->spec;
5556 for (i = 0; i < AUTO_PIN_LAST; i++) {
5557 hda_nid_t nid = spec->autocfg.input_pins[i];
5558 if ((nid>=0x0c) && (nid <=0x11)) {
5559 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5560 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
5565 /* parse the BIOS configuration and set up the alc_spec */
5566 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
5567 static int alc861_parse_auto_config(struct hda_codec *codec)
5569 struct alc_spec *spec = codec->spec;
5571 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
5573 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5574 alc861_ignore)) < 0)
5576 if (! spec->autocfg.line_outs)
5577 return 0; /* can't find valid BIOS pin config */
5579 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
5580 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
5581 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
5582 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
5585 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5587 if (spec->autocfg.dig_out_pin)
5588 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
5590 if (spec->kctl_alloc)
5591 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5593 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
5595 spec->num_mux_defs = 1;
5596 spec->input_mux = &spec->private_imux;
5598 spec->adc_nids = alc861_adc_nids;
5599 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
5600 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
5606 /* additional initialization for auto-configuration model */
5607 static void alc861_auto_init(struct hda_codec *codec)
5609 alc861_auto_init_multi_out(codec);
5610 alc861_auto_init_hp_out(codec);
5611 alc861_auto_init_analog_input(codec);
5616 * configuration and preset
5618 static struct hda_board_config alc861_cfg_tbl[] = {
5619 { .modelname = "3stack", .config = ALC861_3ST },
5620 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
5621 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
5622 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
5623 { .modelname = "auto", .config = ALC861_AUTO },
5627 static struct alc_config_preset alc861_presets[] = {
5629 .mixers = { alc861_3ST_mixer },
5630 .init_verbs = { alc861_threestack_init_verbs },
5631 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5632 .dac_nids = alc861_dac_nids,
5633 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5634 .channel_mode = alc861_threestack_modes,
5635 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5636 .adc_nids = alc861_adc_nids,
5637 .input_mux = &alc861_capture_source,
5639 [ALC861_3ST_DIG] = {
5640 .mixers = { alc861_base_mixer },
5641 .init_verbs = { alc861_threestack_init_verbs },
5642 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5643 .dac_nids = alc861_dac_nids,
5644 .dig_out_nid = ALC861_DIGOUT_NID,
5645 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
5646 .channel_mode = alc861_threestack_modes,
5647 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5648 .adc_nids = alc861_adc_nids,
5649 .input_mux = &alc861_capture_source,
5651 [ALC861_6ST_DIG] = {
5652 .mixers = { alc861_base_mixer },
5653 .init_verbs = { alc861_base_init_verbs },
5654 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
5655 .dac_nids = alc861_dac_nids,
5656 .dig_out_nid = ALC861_DIGOUT_NID,
5657 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
5658 .channel_mode = alc861_8ch_modes,
5659 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
5660 .adc_nids = alc861_adc_nids,
5661 .input_mux = &alc861_capture_source,
5666 static int patch_alc861(struct hda_codec *codec)
5668 struct alc_spec *spec;
5672 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
5678 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
5679 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
5680 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
5681 board_config = ALC861_AUTO;
5684 if (board_config == ALC861_AUTO) {
5685 /* automatic parse from the BIOS config */
5686 err = alc861_parse_auto_config(codec);
5691 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
5692 board_config = ALC861_3ST_DIG;
5696 if (board_config != ALC861_AUTO)
5697 setup_preset(spec, &alc861_presets[board_config]);
5699 spec->stream_name_analog = "ALC861 Analog";
5700 spec->stream_analog_playback = &alc861_pcm_analog_playback;
5701 spec->stream_analog_capture = &alc861_pcm_analog_capture;
5703 spec->stream_name_digital = "ALC861 Digital";
5704 spec->stream_digital_playback = &alc861_pcm_digital_playback;
5705 spec->stream_digital_capture = &alc861_pcm_digital_capture;
5707 codec->patch_ops = alc_patch_ops;
5708 if (board_config == ALC861_AUTO)
5709 spec->init_hook = alc861_auto_init;
5717 struct hda_codec_preset snd_hda_preset_realtek[] = {
5718 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
5719 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
5720 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
5721 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
5722 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
5723 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
5724 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },