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 */
54 #ifdef CONFIG_SND_DEBUG
58 ALC880_MODEL_LAST /* last tag */
67 #ifdef CONFIG_SND_DEBUG
71 ALC260_MODEL_LAST /* last tag */
78 ALC262_MODEL_LAST /* last tag */
99 #define GPIO_MASK 0x03
102 /* codec parameterization */
103 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
104 unsigned int num_mixers;
106 const struct hda_verb *init_verbs[5]; /* initialization verbs
107 * don't forget NULL termination!
109 unsigned int num_init_verbs;
111 char *stream_name_analog; /* analog PCM stream */
112 struct hda_pcm_stream *stream_analog_playback;
113 struct hda_pcm_stream *stream_analog_capture;
115 char *stream_name_digital; /* digital PCM stream */
116 struct hda_pcm_stream *stream_digital_playback;
117 struct hda_pcm_stream *stream_digital_capture;
120 struct hda_multi_out multiout; /* playback set-up
121 * max_channels, dacs must be set
122 * dig_out_nid and hp_nid are optional
126 unsigned int num_adc_nids;
128 hda_nid_t dig_in_nid; /* digital-in NID; optional */
131 const struct hda_input_mux *input_mux;
132 unsigned int cur_mux[3];
135 const struct hda_channel_mode *channel_mode;
136 int num_channel_mode;
138 /* PCM information */
139 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
141 /* dynamic controls, init_verbs and input_mux */
142 struct auto_pin_cfg autocfg;
143 unsigned int num_kctl_alloc, num_kctl_used;
144 struct snd_kcontrol_new *kctl_alloc;
145 struct hda_input_mux private_imux;
146 hda_nid_t private_dac_nids[5];
150 * configuration template - to be copied to the spec instance
152 struct alc_config_preset {
153 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
154 const struct hda_verb *init_verbs[5];
155 unsigned int num_dacs;
157 hda_nid_t dig_out_nid; /* optional */
158 hda_nid_t hp_nid; /* optional */
159 unsigned int num_adc_nids;
161 hda_nid_t dig_in_nid;
162 unsigned int num_channel_mode;
163 const struct hda_channel_mode *channel_mode;
164 const struct hda_input_mux *input_mux;
171 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
173 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
174 struct alc_spec *spec = codec->spec;
175 return snd_hda_input_mux_info(spec->input_mux, uinfo);
178 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
180 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
181 struct alc_spec *spec = codec->spec;
182 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
184 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
188 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
191 struct alc_spec *spec = codec->spec;
192 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
193 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
194 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
199 * channel mode setting
201 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
203 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
204 struct alc_spec *spec = codec->spec;
205 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
206 spec->num_channel_mode);
209 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
211 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
212 struct alc_spec *spec = codec->spec;
213 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
214 spec->num_channel_mode, spec->multiout.max_channels);
217 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
219 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
220 struct alc_spec *spec = codec->spec;
221 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
222 spec->num_channel_mode, &spec->multiout.max_channels);
226 * Control the mode of pin widget settings via the mixer. "pc" is used
227 * instead of "%" to avoid consequences of accidently treating the % as
228 * being part of a format specifier. Maximum allowed length of a value is
229 * 63 characters plus NULL terminator.
231 * Note: some retasking pin complexes seem to ignore requests for input
232 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
233 * are requested. Therefore order this list so that this behaviour will not
234 * cause problems when mixer clients move through the enum sequentially.
235 * NIDs 0x0f and 0x10 have been observed to have this behaviour.
237 static char *alc_pin_mode_names[] = {
238 "Mic 50pc bias", "Mic 80pc bias",
239 "Line in", "Line out", "Headphone out",
241 static unsigned char alc_pin_mode_values[] = {
242 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
244 /* The control can present all 5 options, or it can limit the options based
245 * in the pin being assumed to be exclusively an input or an output pin.
247 #define ALC_PIN_DIR_IN 0x00
248 #define ALC_PIN_DIR_OUT 0x01
249 #define ALC_PIN_DIR_INOUT 0x02
251 /* Info about the pin modes supported by the three different pin directions.
252 * For each direction the minimum and maximum values are given.
254 static signed char alc_pin_mode_dir_info[3][2] = {
255 { 0, 2 }, /* ALC_PIN_DIR_IN */
256 { 3, 4 }, /* ALC_PIN_DIR_OUT */
257 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
259 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
260 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
261 #define alc_pin_mode_n_items(_dir) \
262 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
264 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
266 unsigned int item_num = uinfo->value.enumerated.item;
267 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
269 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
271 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
273 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
274 item_num = alc_pin_mode_min(dir);
275 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
279 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
283 hda_nid_t nid = kcontrol->private_value & 0xffff;
284 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
285 long *valp = ucontrol->value.integer.value;
286 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
288 /* Find enumerated value for current pinctl setting */
289 i = alc_pin_mode_min(dir);
290 while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
292 *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
296 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
299 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
300 hda_nid_t nid = kcontrol->private_value & 0xffff;
301 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
302 long val = *ucontrol->value.integer.value;
303 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
305 if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
306 val = alc_pin_mode_min(dir);
308 change = pinctl != alc_pin_mode_values[val];
310 /* Set pin mode to that requested */
311 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
312 alc_pin_mode_values[val]);
314 /* Also enable the retasking pin's input/output as required
315 * for the requested pin mode. Enum values of 2 or less are
318 * Dynamically switching the input/output buffers probably
319 * reduces noise slightly, particularly on input. However,
320 * havingboth input and output buffers enabled
321 * simultaneously doesn't seem to be problematic.
324 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
326 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
329 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
331 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
338 #define ALC_PIN_MODE(xname, nid, dir) \
339 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
340 .info = alc_pin_mode_info, \
341 .get = alc_pin_mode_get, \
342 .put = alc_pin_mode_put, \
343 .private_value = nid | (dir<<16) }
346 * set up from the preset table
348 static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
352 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
353 spec->mixers[spec->num_mixers++] = preset->mixers[i];
354 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
355 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
357 spec->channel_mode = preset->channel_mode;
358 spec->num_channel_mode = preset->num_channel_mode;
360 spec->multiout.max_channels = spec->channel_mode[0].channels;
362 spec->multiout.num_dacs = preset->num_dacs;
363 spec->multiout.dac_nids = preset->dac_nids;
364 spec->multiout.dig_out_nid = preset->dig_out_nid;
365 spec->multiout.hp_nid = preset->hp_nid;
367 spec->input_mux = preset->input_mux;
369 spec->num_adc_nids = preset->num_adc_nids;
370 spec->adc_nids = preset->adc_nids;
371 spec->dig_in_nid = preset->dig_in_nid;
375 * ALC880 3-stack model
377 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
378 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
382 static hda_nid_t alc880_dac_nids[4] = {
383 /* front, rear, clfe, rear_surr */
384 0x02, 0x05, 0x04, 0x03
387 static hda_nid_t alc880_adc_nids[3] = {
392 /* The datasheet says the node 0x07 is connected from inputs,
393 * but it shows zero connection in the real implementation on some devices.
394 * Note: this is a 915GAV bug, fixed on 915GLV
396 static hda_nid_t alc880_adc_nids_alt[2] = {
401 #define ALC880_DIGOUT_NID 0x06
402 #define ALC880_DIGIN_NID 0x0a
404 static struct hda_input_mux alc880_capture_source = {
408 { "Front Mic", 0x3 },
414 /* channel source setting (2/6 channel selection for 3-stack) */
416 static struct hda_verb alc880_threestack_ch2_init[] = {
417 /* set line-in to input, mute it */
418 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
419 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
420 /* set mic-in to input vref 80%, mute it */
421 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
422 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
427 static struct hda_verb alc880_threestack_ch6_init[] = {
428 /* set line-in to output, unmute it */
429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
431 /* set mic-in to output, unmute it */
432 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
433 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
437 static struct hda_channel_mode alc880_threestack_modes[2] = {
438 { 2, alc880_threestack_ch2_init },
439 { 6, alc880_threestack_ch6_init },
442 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
443 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
444 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
445 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
446 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
449 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
450 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
451 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
452 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
453 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
454 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
455 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
456 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
457 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
458 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
459 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
460 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
461 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
463 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
464 .name = "Channel Mode",
465 .info = alc_ch_mode_info,
466 .get = alc_ch_mode_get,
467 .put = alc_ch_mode_put,
472 /* capture mixer elements */
473 static struct snd_kcontrol_new alc880_capture_mixer[] = {
474 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
475 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
476 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
477 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
478 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
479 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
482 /* The multiple "Capture Source" controls confuse alsamixer
483 * So call somewhat different..
484 * FIXME: the controls appear in the "playback" view!
486 /* .name = "Capture Source", */
487 .name = "Input Source",
489 .info = alc_mux_enum_info,
490 .get = alc_mux_enum_get,
491 .put = alc_mux_enum_put,
496 /* capture mixer elements (in case NID 0x07 not available) */
497 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
498 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
499 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
500 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
501 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
504 /* The multiple "Capture Source" controls confuse alsamixer
505 * So call somewhat different..
506 * FIXME: the controls appear in the "playback" view!
508 /* .name = "Capture Source", */
509 .name = "Input Source",
511 .info = alc_mux_enum_info,
512 .get = alc_mux_enum_get,
513 .put = alc_mux_enum_put,
521 * ALC880 5-stack model
523 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
524 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
525 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
528 /* additional mixers to alc880_three_stack_mixer */
529 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
530 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
531 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
535 /* channel source setting (6/8 channel selection for 5-stack) */
537 static struct hda_verb alc880_fivestack_ch6_init[] = {
538 /* set line-in to input, mute it */
539 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
540 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
545 static struct hda_verb alc880_fivestack_ch8_init[] = {
546 /* set line-in to output, unmute it */
547 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
548 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
552 static struct hda_channel_mode alc880_fivestack_modes[2] = {
553 { 6, alc880_fivestack_ch6_init },
554 { 8, alc880_fivestack_ch8_init },
559 * ALC880 6-stack model
561 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
562 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
563 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
566 static hda_nid_t alc880_6st_dac_nids[4] = {
567 /* front, rear, clfe, rear_surr */
568 0x02, 0x03, 0x04, 0x05
571 static struct hda_input_mux alc880_6stack_capture_source = {
575 { "Front Mic", 0x1 },
581 /* fixed 8-channels */
582 static struct hda_channel_mode alc880_sixstack_modes[1] = {
586 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
587 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
588 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
589 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
590 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
591 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
592 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
593 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
594 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
595 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
596 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
602 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
603 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
605 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
606 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
609 .name = "Channel Mode",
610 .info = alc_ch_mode_info,
611 .get = alc_ch_mode_get,
612 .put = alc_ch_mode_put,
621 * W810 has rear IO for:
624 * Center/LFE (DAC 04)
627 * The system also has a pair of internal speakers, and a headphone jack.
628 * These are both connected to Line2 on the codec, hence to DAC 02.
630 * There is a variable resistor to control the speaker or headphone
631 * volume. This is a hardware-only device without a software API.
633 * Plugging headphones in will disable the internal speakers. This is
634 * implemented in hardware, not via the driver using jack sense. In
635 * a similar fashion, plugging into the rear socket marked "front" will
636 * disable both the speakers and headphones.
638 * For input, there's a microphone jack, and an "audio in" jack.
639 * These may not do anything useful with this driver yet, because I
640 * haven't setup any initialization verbs for these yet...
643 static hda_nid_t alc880_w810_dac_nids[3] = {
644 /* front, rear/surround, clfe */
648 /* fixed 6 channels */
649 static struct hda_channel_mode alc880_w810_modes[1] = {
653 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
654 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
655 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
656 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
658 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
661 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
662 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
671 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
672 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
675 static hda_nid_t alc880_z71v_dac_nids[1] = {
678 #define ALC880_Z71V_HP_DAC 0x03
680 /* fixed 2 channels */
681 static struct hda_channel_mode alc880_2_jack_modes[1] = {
685 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
686 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
687 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
688 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
689 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
690 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
691 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
702 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
703 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
706 static hda_nid_t alc880_f1734_dac_nids[1] = {
709 #define ALC880_F1734_HP_DAC 0x02
711 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
712 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
713 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
714 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
715 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
717 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
728 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
729 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
730 * Mic = 0x18, Line = 0x1a
733 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
734 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
736 static struct snd_kcontrol_new alc880_asus_mixer[] = {
737 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
738 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
739 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
740 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
741 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
742 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
743 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
744 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
745 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
746 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
747 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
748 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
749 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
750 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
752 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
753 .name = "Channel Mode",
754 .info = alc_ch_mode_info,
755 .get = alc_ch_mode_get,
756 .put = alc_ch_mode_put,
763 * ALC880 ASUS W1V model
765 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
766 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
767 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
770 /* additional mixers to alc880_asus_mixer */
771 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
772 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
773 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
777 /* additional mixers to alc880_asus_mixer */
778 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
779 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
780 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
785 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
786 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
787 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
788 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
789 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
790 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
793 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
794 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
797 /* The multiple "Capture Source" controls confuse alsamixer
798 * So call somewhat different..
799 * FIXME: the controls appear in the "playback" view!
801 /* .name = "Capture Source", */
802 .name = "Input Source",
804 .info = alc_mux_enum_info,
805 .get = alc_mux_enum_get,
806 .put = alc_mux_enum_put,
812 * build control elements
814 static int alc_build_controls(struct hda_codec *codec)
816 struct alc_spec *spec = codec->spec;
820 for (i = 0; i < spec->num_mixers; i++) {
821 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
826 if (spec->multiout.dig_out_nid) {
827 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
831 if (spec->dig_in_nid) {
832 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
841 * initialize the codec volumes, etc
845 * generic initialization of ADC, input mixers and output mixers
847 static struct hda_verb alc880_volume_init_verbs[] = {
849 * Unmute ADC0-2 and set the default input to mic-in
851 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
853 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
855 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
858 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
860 * Note: PASD motherboards uses the Line In 2 as the input for front panel
863 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
871 * Set up output mixers (0x0c - 0x0f)
873 /* set vol=0 to output mixers */
874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
875 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
876 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
877 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
878 /* set up input amps for analog loopback */
879 /* Amp Indices: DAC = 0, mixer = 1 */
880 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
885 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
893 * 3-stack pin configuration:
894 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
896 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
898 * preset connection lists of input pins
899 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
901 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
902 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
903 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
906 * Set pin mode and muting
908 /* set front pin widgets 0x14 for output */
909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
911 /* Mic1 (rear panel) pin widget for input and vref at 80% */
912 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
913 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
914 /* Mic2 (as headphone out) for HP output */
915 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
916 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
917 /* Line In pin widget for input */
918 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
919 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
920 /* Line2 (as front mic) pin widget for input and vref at 80% */
921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
923 /* CD pin widget for input */
924 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
930 * 5-stack pin configuration:
931 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
932 * line-in/side = 0x1a, f-mic = 0x1b
934 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
936 * preset connection lists of input pins
937 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
939 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
940 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
943 * Set pin mode and muting
945 /* set pin widgets 0x14-0x17 for output */
946 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
947 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
948 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
949 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
950 /* unmute pins for output (no gain on this amp) */
951 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
952 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
954 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
956 /* Mic1 (rear panel) pin widget for input and vref at 80% */
957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
959 /* Mic2 (as headphone out) for HP output */
960 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
961 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
962 /* Line In pin widget for input */
963 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
964 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
965 /* Line2 (as front mic) pin widget for input and vref at 80% */
966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
967 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
968 /* CD pin widget for input */
969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
975 * W810 pin configuration:
976 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
978 static struct hda_verb alc880_pin_w810_init_verbs[] = {
979 /* hphone/speaker input selector: front DAC */
980 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
986 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
996 * Z71V pin configuration:
997 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
999 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1005 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1006 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1007 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1008 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1014 * 6-stack pin configuration:
1015 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
1016 * line = 0x1a, HP = 0x1b
1018 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1019 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1021 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1023 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1024 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1025 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1026 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1027 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1028 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1030 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1031 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1032 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1033 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1034 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1035 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1037 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1038 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1045 * F1734 pin configuration:
1046 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1048 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1049 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1050 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1051 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1052 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1054 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1059 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1061 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1063 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1064 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1065 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1066 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1067 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1074 * ASUS pin configuration:
1075 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1077 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1078 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1079 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1080 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1081 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1087 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1088 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1089 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1092 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1093 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1094 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1095 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1096 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1097 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1100 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1105 /* Enable GPIO mask and set output */
1106 static struct hda_verb alc880_gpio1_init_verbs[] = {
1107 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1108 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1109 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1114 /* Enable GPIO mask and set output */
1115 static struct hda_verb alc880_gpio2_init_verbs[] = {
1116 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1117 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1118 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1123 /* Clevo m520g init */
1124 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1125 /* headphone output */
1126 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1129 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1131 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1132 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1134 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1135 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1136 /* Mic1 (rear panel) */
1137 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1138 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1139 /* Mic2 (front panel) */
1140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1143 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1144 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1145 /* change to EAPD mode */
1146 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1147 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1152 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1153 /* Headphone output */
1154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1157 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1159 /* Line In pin widget for input */
1160 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1161 /* CD pin widget for input */
1162 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1163 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1164 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1166 /* change to EAPD mode */
1167 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1168 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1176 static int alc_init(struct hda_codec *codec)
1178 struct alc_spec *spec = codec->spec;
1181 for (i = 0; i < spec->num_init_verbs; i++)
1182 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1190 static int alc_resume(struct hda_codec *codec)
1192 struct alc_spec *spec = codec->spec;
1196 for (i = 0; i < spec->num_mixers; i++)
1197 snd_hda_resume_ctls(codec, spec->mixers[i]);
1198 if (spec->multiout.dig_out_nid)
1199 snd_hda_resume_spdif_out(codec);
1200 if (spec->dig_in_nid)
1201 snd_hda_resume_spdif_in(codec);
1208 * Analog playback callbacks
1210 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1211 struct hda_codec *codec,
1212 struct snd_pcm_substream *substream)
1214 struct alc_spec *spec = codec->spec;
1215 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1218 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1219 struct hda_codec *codec,
1220 unsigned int stream_tag,
1221 unsigned int format,
1222 struct snd_pcm_substream *substream)
1224 struct alc_spec *spec = codec->spec;
1225 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1229 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1230 struct hda_codec *codec,
1231 struct snd_pcm_substream *substream)
1233 struct alc_spec *spec = codec->spec;
1234 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1240 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1241 struct hda_codec *codec,
1242 struct snd_pcm_substream *substream)
1244 struct alc_spec *spec = codec->spec;
1245 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1248 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1249 struct hda_codec *codec,
1250 struct snd_pcm_substream *substream)
1252 struct alc_spec *spec = codec->spec;
1253 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1259 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1260 struct hda_codec *codec,
1261 unsigned int stream_tag,
1262 unsigned int format,
1263 struct snd_pcm_substream *substream)
1265 struct alc_spec *spec = codec->spec;
1267 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1268 stream_tag, 0, format);
1272 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1273 struct hda_codec *codec,
1274 struct snd_pcm_substream *substream)
1276 struct alc_spec *spec = codec->spec;
1278 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1285 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1289 /* NID is set in alc_build_pcms */
1291 .open = alc880_playback_pcm_open,
1292 .prepare = alc880_playback_pcm_prepare,
1293 .cleanup = alc880_playback_pcm_cleanup
1297 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1301 /* NID is set in alc_build_pcms */
1303 .prepare = alc880_capture_pcm_prepare,
1304 .cleanup = alc880_capture_pcm_cleanup
1308 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1312 /* NID is set in alc_build_pcms */
1314 .open = alc880_dig_playback_pcm_open,
1315 .close = alc880_dig_playback_pcm_close
1319 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1323 /* NID is set in alc_build_pcms */
1326 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
1327 static struct hda_pcm_stream alc_pcm_null_playback = {
1333 static int alc_build_pcms(struct hda_codec *codec)
1335 struct alc_spec *spec = codec->spec;
1336 struct hda_pcm *info = spec->pcm_rec;
1339 codec->num_pcms = 1;
1340 codec->pcm_info = info;
1342 info->name = spec->stream_name_analog;
1343 if (spec->stream_analog_playback) {
1344 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1345 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1346 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1348 if (spec->stream_analog_capture) {
1349 snd_assert(spec->adc_nids, return -EINVAL);
1350 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1351 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1354 if (spec->channel_mode) {
1355 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1356 for (i = 0; i < spec->num_channel_mode; i++) {
1357 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1358 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1363 /* If the use of more than one ADC is requested for the current
1364 * model, configure a second analog capture-only PCM.
1366 if (spec->num_adc_nids > 1) {
1369 info->name = spec->stream_name_analog;
1370 /* No playback stream for second PCM */
1371 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
1372 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
1373 if (spec->stream_analog_capture) {
1374 snd_assert(spec->adc_nids, return -EINVAL);
1375 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1376 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
1380 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1383 info->name = spec->stream_name_digital;
1384 if (spec->multiout.dig_out_nid &&
1385 spec->stream_digital_playback) {
1386 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1387 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1389 if (spec->dig_in_nid &&
1390 spec->stream_digital_capture) {
1391 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1392 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1399 static void alc_free(struct hda_codec *codec)
1401 struct alc_spec *spec = codec->spec;
1407 if (spec->kctl_alloc) {
1408 for (i = 0; i < spec->num_kctl_used; i++)
1409 kfree(spec->kctl_alloc[i].name);
1410 kfree(spec->kctl_alloc);
1417 static struct hda_codec_ops alc_patch_ops = {
1418 .build_controls = alc_build_controls,
1419 .build_pcms = alc_build_pcms,
1423 .resume = alc_resume,
1429 * Test configuration for debugging
1431 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1434 #ifdef CONFIG_SND_DEBUG
1435 static hda_nid_t alc880_test_dac_nids[4] = {
1436 0x02, 0x03, 0x04, 0x05
1439 static struct hda_input_mux alc880_test_capture_source = {
1450 static struct hda_channel_mode alc880_test_modes[4] = {
1457 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1459 static char *texts[] = {
1460 "N/A", "Line Out", "HP Out",
1461 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1463 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1465 uinfo->value.enumerated.items = 8;
1466 if (uinfo->value.enumerated.item >= 8)
1467 uinfo->value.enumerated.item = 7;
1468 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1472 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1475 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1476 unsigned int pin_ctl, item = 0;
1478 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1479 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1480 if (pin_ctl & AC_PINCTL_OUT_EN) {
1481 if (pin_ctl & AC_PINCTL_HP_EN)
1485 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1486 switch (pin_ctl & AC_PINCTL_VREFEN) {
1487 case AC_PINCTL_VREF_HIZ: item = 3; break;
1488 case AC_PINCTL_VREF_50: item = 4; break;
1489 case AC_PINCTL_VREF_GRD: item = 5; break;
1490 case AC_PINCTL_VREF_80: item = 6; break;
1491 case AC_PINCTL_VREF_100: item = 7; break;
1494 ucontrol->value.enumerated.item[0] = item;
1498 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1500 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1501 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1502 static unsigned int ctls[] = {
1503 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1504 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1505 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1506 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1507 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1508 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1510 unsigned int old_ctl, new_ctl;
1512 old_ctl = snd_hda_codec_read(codec, nid, 0,
1513 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1514 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1515 if (old_ctl != new_ctl) {
1516 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1517 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1518 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1524 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1526 static char *texts[] = {
1527 "Front", "Surround", "CLFE", "Side"
1529 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1531 uinfo->value.enumerated.items = 4;
1532 if (uinfo->value.enumerated.item >= 4)
1533 uinfo->value.enumerated.item = 3;
1534 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1538 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1541 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1544 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1545 ucontrol->value.enumerated.item[0] = sel & 3;
1549 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1552 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1555 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1556 if (ucontrol->value.enumerated.item[0] != sel) {
1557 sel = ucontrol->value.enumerated.item[0] & 3;
1558 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1564 #define PIN_CTL_TEST(xname,nid) { \
1565 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1567 .info = alc_test_pin_ctl_info, \
1568 .get = alc_test_pin_ctl_get, \
1569 .put = alc_test_pin_ctl_put, \
1570 .private_value = nid \
1573 #define PIN_SRC_TEST(xname,nid) { \
1574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1576 .info = alc_test_pin_src_info, \
1577 .get = alc_test_pin_src_get, \
1578 .put = alc_test_pin_src_put, \
1579 .private_value = nid \
1582 static struct snd_kcontrol_new alc880_test_mixer[] = {
1583 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1584 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1585 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1586 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1587 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1588 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1589 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1590 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1591 PIN_CTL_TEST("Front Pin Mode", 0x14),
1592 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1593 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1594 PIN_CTL_TEST("Side Pin Mode", 0x17),
1595 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1596 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1597 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1598 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1599 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1600 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1601 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1602 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1603 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1604 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1605 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1606 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1607 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1608 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1609 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1610 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1611 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1612 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1615 .name = "Channel Mode",
1616 .info = alc_ch_mode_info,
1617 .get = alc_ch_mode_get,
1618 .put = alc_ch_mode_put,
1623 static struct hda_verb alc880_test_init_verbs[] = {
1624 /* Unmute inputs of 0x0c - 0x0f */
1625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1626 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1628 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1630 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1631 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1632 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1633 /* Vol output for 0x0c-0x0f */
1634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1635 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1638 /* Set output pins 0x14-0x17 */
1639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1641 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1642 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1643 /* Unmute output pins 0x14-0x17 */
1644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1646 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1647 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1648 /* Set input pins 0x18-0x1c */
1649 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1650 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1651 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1652 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1653 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1654 /* Mute input pins 0x18-0x1b */
1655 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1656 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1657 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1661 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1662 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1663 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1664 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1665 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1666 /* Analog input/passthru */
1667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1668 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1669 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1679 static struct hda_board_config alc880_cfg_tbl[] = {
1680 /* Back 3 jack, front 2 jack */
1681 { .modelname = "3stack", .config = ALC880_3ST },
1682 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1683 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1684 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1685 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1686 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1687 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1688 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1689 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1690 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1691 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1692 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1693 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1694 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1695 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1696 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1697 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1698 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1699 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1700 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1701 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1702 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1703 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1704 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1705 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1706 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1707 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1708 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1709 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1710 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1711 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1712 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1713 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
1715 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
1717 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1718 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1719 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
1720 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
1722 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1723 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
1724 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
1725 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
1726 /* Clevo m520G NB */
1727 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
1729 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1730 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1731 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1732 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
1734 /* Back 5 jack, front 2 jack */
1735 { .modelname = "5stack", .config = ALC880_5ST },
1736 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1737 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1738 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1739 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
1740 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
1742 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1743 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
1744 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1745 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1746 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1747 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1748 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1749 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1750 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1751 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1752 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1753 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
1754 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1755 /* note subvendor = 0 below */
1756 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1758 { .modelname = "w810", .config = ALC880_W810 },
1759 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
1761 { .modelname = "z71v", .config = ALC880_Z71V },
1762 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1764 { .modelname = "6stack", .config = ALC880_6ST },
1765 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
1766 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
1767 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
1768 { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
1770 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
1771 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1772 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1773 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1774 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1775 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
1776 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
1777 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
1778 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
1779 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
1781 { .modelname = "asus", .config = ALC880_ASUS },
1782 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1783 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1784 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1785 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1786 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
1787 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1788 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1789 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1790 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1791 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1792 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1793 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
1795 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1796 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1798 { .modelname = "F1734", .config = ALC880_F1734 },
1799 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1800 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
1802 #ifdef CONFIG_SND_DEBUG
1803 { .modelname = "test", .config = ALC880_TEST },
1805 { .modelname = "auto", .config = ALC880_AUTO },
1811 * ALC880 codec presets
1813 static struct alc_config_preset alc880_presets[] = {
1815 .mixers = { alc880_three_stack_mixer },
1816 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1817 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1818 .dac_nids = alc880_dac_nids,
1819 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1820 .channel_mode = alc880_threestack_modes,
1821 .input_mux = &alc880_capture_source,
1823 [ALC880_3ST_DIG] = {
1824 .mixers = { alc880_three_stack_mixer },
1825 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1826 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1827 .dac_nids = alc880_dac_nids,
1828 .dig_out_nid = ALC880_DIGOUT_NID,
1829 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1830 .channel_mode = alc880_threestack_modes,
1831 .input_mux = &alc880_capture_source,
1833 [ALC880_TCL_S700] = {
1834 .mixers = { alc880_tcl_s700_mixer },
1835 .init_verbs = { alc880_volume_init_verbs,
1836 alc880_pin_tcl_S700_init_verbs,
1837 alc880_gpio2_init_verbs },
1838 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1839 .dac_nids = alc880_dac_nids,
1841 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1842 .channel_mode = alc880_2_jack_modes,
1843 .input_mux = &alc880_capture_source,
1846 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1847 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1848 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1849 .dac_nids = alc880_dac_nids,
1850 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1851 .channel_mode = alc880_fivestack_modes,
1852 .input_mux = &alc880_capture_source,
1854 [ALC880_5ST_DIG] = {
1855 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1856 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1857 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1858 .dac_nids = alc880_dac_nids,
1859 .dig_out_nid = ALC880_DIGOUT_NID,
1860 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1861 .channel_mode = alc880_fivestack_modes,
1862 .input_mux = &alc880_capture_source,
1865 .mixers = { alc880_six_stack_mixer },
1866 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1867 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1868 .dac_nids = alc880_6st_dac_nids,
1869 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1870 .channel_mode = alc880_sixstack_modes,
1871 .input_mux = &alc880_6stack_capture_source,
1873 [ALC880_6ST_DIG] = {
1874 .mixers = { alc880_six_stack_mixer },
1875 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1876 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1877 .dac_nids = alc880_6st_dac_nids,
1878 .dig_out_nid = ALC880_DIGOUT_NID,
1879 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1880 .channel_mode = alc880_sixstack_modes,
1881 .input_mux = &alc880_6stack_capture_source,
1884 .mixers = { alc880_w810_base_mixer },
1885 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1886 alc880_gpio2_init_verbs },
1887 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1888 .dac_nids = alc880_w810_dac_nids,
1889 .dig_out_nid = ALC880_DIGOUT_NID,
1890 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1891 .channel_mode = alc880_w810_modes,
1892 .input_mux = &alc880_capture_source,
1895 .mixers = { alc880_z71v_mixer },
1896 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
1897 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1898 .dac_nids = alc880_z71v_dac_nids,
1899 .dig_out_nid = ALC880_DIGOUT_NID,
1901 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1902 .channel_mode = alc880_2_jack_modes,
1903 .input_mux = &alc880_capture_source,
1906 .mixers = { alc880_f1734_mixer },
1907 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1908 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1909 .dac_nids = alc880_f1734_dac_nids,
1911 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1912 .channel_mode = alc880_2_jack_modes,
1913 .input_mux = &alc880_capture_source,
1916 .mixers = { alc880_asus_mixer },
1917 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1918 alc880_gpio1_init_verbs },
1919 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1920 .dac_nids = alc880_asus_dac_nids,
1921 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1922 .channel_mode = alc880_asus_modes,
1923 .input_mux = &alc880_capture_source,
1925 [ALC880_ASUS_DIG] = {
1926 .mixers = { alc880_asus_mixer },
1927 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1928 alc880_gpio1_init_verbs },
1929 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1930 .dac_nids = alc880_asus_dac_nids,
1931 .dig_out_nid = ALC880_DIGOUT_NID,
1932 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1933 .channel_mode = alc880_asus_modes,
1934 .input_mux = &alc880_capture_source,
1936 [ALC880_ASUS_DIG2] = {
1937 .mixers = { alc880_asus_mixer },
1938 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1939 alc880_gpio2_init_verbs }, /* use GPIO2 */
1940 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1941 .dac_nids = alc880_asus_dac_nids,
1942 .dig_out_nid = ALC880_DIGOUT_NID,
1943 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1944 .channel_mode = alc880_asus_modes,
1945 .input_mux = &alc880_capture_source,
1947 [ALC880_ASUS_W1V] = {
1948 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1949 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1950 alc880_gpio1_init_verbs },
1951 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1952 .dac_nids = alc880_asus_dac_nids,
1953 .dig_out_nid = ALC880_DIGOUT_NID,
1954 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1955 .channel_mode = alc880_asus_modes,
1956 .input_mux = &alc880_capture_source,
1958 [ALC880_UNIWILL_DIG] = {
1959 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
1960 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1961 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1962 .dac_nids = alc880_asus_dac_nids,
1963 .dig_out_nid = ALC880_DIGOUT_NID,
1964 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1965 .channel_mode = alc880_asus_modes,
1966 .input_mux = &alc880_capture_source,
1969 .mixers = { alc880_three_stack_mixer },
1970 .init_verbs = { alc880_volume_init_verbs,
1971 alc880_pin_clevo_init_verbs },
1972 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1973 .dac_nids = alc880_dac_nids,
1975 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1976 .channel_mode = alc880_threestack_modes,
1977 .input_mux = &alc880_capture_source,
1979 #ifdef CONFIG_SND_DEBUG
1981 .mixers = { alc880_test_mixer },
1982 .init_verbs = { alc880_test_init_verbs },
1983 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1984 .dac_nids = alc880_test_dac_nids,
1985 .dig_out_nid = ALC880_DIGOUT_NID,
1986 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1987 .channel_mode = alc880_test_modes,
1988 .input_mux = &alc880_test_capture_source,
1994 * Automatic parse of I/O pins from the BIOS configuration
1997 #define NUM_CONTROL_ALLOC 32
1998 #define NUM_VERB_ALLOC 32
2002 ALC_CTL_WIDGET_MUTE,
2005 static struct snd_kcontrol_new alc880_control_templates[] = {
2006 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2007 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2008 HDA_BIND_MUTE(NULL, 0, 0, 0),
2011 /* add dynamic controls */
2012 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
2014 struct snd_kcontrol_new *knew;
2016 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2017 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2019 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2022 if (spec->kctl_alloc) {
2023 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2024 kfree(spec->kctl_alloc);
2026 spec->kctl_alloc = knew;
2027 spec->num_kctl_alloc = num;
2030 knew = &spec->kctl_alloc[spec->num_kctl_used];
2031 *knew = alc880_control_templates[type];
2032 knew->name = kstrdup(name, GFP_KERNEL);
2035 knew->private_value = val;
2036 spec->num_kctl_used++;
2040 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2041 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2042 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2043 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2044 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2045 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2046 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2047 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2048 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2049 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2050 #define ALC880_PIN_CD_NID 0x1c
2052 /* fill in the dac_nids table from the parsed pin configuration */
2053 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
2059 memset(assigned, 0, sizeof(assigned));
2060 spec->multiout.dac_nids = spec->private_dac_nids;
2062 /* check the pins hardwired to audio widget */
2063 for (i = 0; i < cfg->line_outs; i++) {
2064 nid = cfg->line_out_pins[i];
2065 if (alc880_is_fixed_pin(nid)) {
2066 int idx = alc880_fixed_pin_idx(nid);
2067 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
2071 /* left pins can be connect to any audio widget */
2072 for (i = 0; i < cfg->line_outs; i++) {
2073 nid = cfg->line_out_pins[i];
2074 if (alc880_is_fixed_pin(nid))
2076 /* search for an empty channel */
2077 for (j = 0; j < cfg->line_outs; j++) {
2078 if (! assigned[j]) {
2079 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
2085 spec->multiout.num_dacs = cfg->line_outs;
2089 /* add playback controls from the parsed DAC table */
2090 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2091 const struct auto_pin_cfg *cfg)
2094 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
2098 for (i = 0; i < cfg->line_outs; i++) {
2099 if (! spec->multiout.dac_nids[i])
2101 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2104 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2105 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2107 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2108 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2110 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2111 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2113 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2114 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2117 sprintf(name, "%s Playback Volume", chname[i]);
2118 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2119 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2121 sprintf(name, "%s Playback Switch", chname[i]);
2122 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2123 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2130 /* add playback controls for speaker and HP outputs */
2131 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2141 if (alc880_is_fixed_pin(pin)) {
2142 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2143 if (! spec->multiout.dac_nids[0]) {
2144 /* use this as the primary output */
2145 spec->multiout.dac_nids[0] = nid;
2146 if (! spec->multiout.num_dacs)
2147 spec->multiout.num_dacs = 1;
2149 /* specify the DAC as the extra output */
2150 spec->multiout.hp_nid = nid;
2151 /* control HP volume/switch on the output mixer amp */
2152 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2153 sprintf(name, "%s Playback Volume", pfx);
2154 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2155 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2157 sprintf(name, "%s Playback Switch", pfx);
2158 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2159 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2161 } else if (alc880_is_multi_pin(pin)) {
2162 /* set manual connection */
2163 if (! spec->multiout.dac_nids[0]) {
2164 /* use this as the primary output */
2165 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
2166 if (! spec->multiout.num_dacs)
2167 spec->multiout.num_dacs = 1;
2169 /* we have only a switch on HP-out PIN */
2170 sprintf(name, "%s Playback Switch", pfx);
2171 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2172 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2178 /* create input playback/capture controls for the given pin */
2179 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2180 int idx, hda_nid_t mix_nid)
2185 sprintf(name, "%s Playback Volume", ctlname);
2186 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2187 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2189 sprintf(name, "%s Playback Switch", ctlname);
2190 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2191 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2196 /* create playback/capture controls for input pins */
2197 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2198 const struct auto_pin_cfg *cfg)
2200 struct hda_input_mux *imux = &spec->private_imux;
2203 for (i = 0; i < AUTO_PIN_LAST; i++) {
2204 if (alc880_is_input_pin(cfg->input_pins[i])) {
2205 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2206 err = new_analog_input(spec, cfg->input_pins[i],
2207 auto_pin_cfg_labels[i],
2211 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2212 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2219 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2220 hda_nid_t nid, int pin_type,
2224 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2225 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2226 /* need the manual connection? */
2227 if (alc880_is_multi_pin(nid)) {
2228 struct alc_spec *spec = codec->spec;
2229 int idx = alc880_multi_pin_idx(nid);
2230 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2231 AC_VERB_SET_CONNECT_SEL,
2232 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2236 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2238 struct alc_spec *spec = codec->spec;
2241 for (i = 0; i < spec->autocfg.line_outs; i++) {
2242 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2243 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2247 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2249 struct alc_spec *spec = codec->spec;
2252 pin = spec->autocfg.speaker_pin;
2253 if (pin) /* connect to front */
2254 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2255 pin = spec->autocfg.hp_pin;
2256 if (pin) /* connect to front */
2257 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2260 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2262 struct alc_spec *spec = codec->spec;
2265 for (i = 0; i < AUTO_PIN_LAST; i++) {
2266 hda_nid_t nid = spec->autocfg.input_pins[i];
2267 if (alc880_is_input_pin(nid)) {
2268 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2269 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2270 if (nid != ALC880_PIN_CD_NID)
2271 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2277 /* parse the BIOS configuration and set up the alc_spec */
2278 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2279 static int alc880_parse_auto_config(struct hda_codec *codec)
2281 struct alc_spec *spec = codec->spec;
2283 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2285 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2286 alc880_ignore)) < 0)
2288 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
2289 ! spec->autocfg.hp_pin)
2290 return 0; /* can't find valid BIOS pin config */
2292 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2293 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2294 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2296 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2297 "Headphone")) < 0 ||
2298 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2301 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2303 if (spec->autocfg.dig_out_pin)
2304 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2305 if (spec->autocfg.dig_in_pin)
2306 spec->dig_in_nid = ALC880_DIGIN_NID;
2308 if (spec->kctl_alloc)
2309 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2311 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2313 spec->input_mux = &spec->private_imux;
2318 /* init callback for auto-configuration model -- overriding the default init */
2319 static int alc880_auto_init(struct hda_codec *codec)
2322 alc880_auto_init_multi_out(codec);
2323 alc880_auto_init_extra_out(codec);
2324 alc880_auto_init_analog_input(codec);
2329 * OK, here we have finally the patch for ALC880
2332 static int patch_alc880(struct hda_codec *codec)
2334 struct alc_spec *spec;
2338 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2344 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2345 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2346 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2347 board_config = ALC880_AUTO;
2350 if (board_config == ALC880_AUTO) {
2351 /* automatic parse from the BIOS config */
2352 err = alc880_parse_auto_config(codec);
2357 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2358 board_config = ALC880_3ST;
2362 if (board_config != ALC880_AUTO)
2363 setup_preset(spec, &alc880_presets[board_config]);
2365 spec->stream_name_analog = "ALC880 Analog";
2366 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2367 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2369 spec->stream_name_digital = "ALC880 Digital";
2370 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2371 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2373 if (! spec->adc_nids && spec->input_mux) {
2374 /* check whether NID 0x07 is valid */
2375 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2376 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2377 if (wcap != AC_WID_AUD_IN) {
2378 spec->adc_nids = alc880_adc_nids_alt;
2379 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2380 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2383 spec->adc_nids = alc880_adc_nids;
2384 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2385 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2390 codec->patch_ops = alc_patch_ops;
2391 if (board_config == ALC880_AUTO)
2392 codec->patch_ops.init = alc880_auto_init;
2402 static hda_nid_t alc260_dac_nids[1] = {
2407 static hda_nid_t alc260_adc_nids[1] = {
2412 static hda_nid_t alc260_adc_nids_alt[1] = {
2417 static hda_nid_t alc260_hp_adc_nids[2] = {
2422 static hda_nid_t alc260_fujitsu_adc_nids[2] = {
2427 #define ALC260_DIGOUT_NID 0x03
2428 #define ALC260_DIGIN_NID 0x06
2430 static struct hda_input_mux alc260_capture_source = {
2434 { "Front Mic", 0x1 },
2440 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
2441 * headphone jack and the internal CD lines.
2443 static struct hda_input_mux alc260_fujitsu_capture_source = {
2446 { "Mic/Line", 0x0 },
2448 { "Headphone", 0x2 },
2453 * This is just place-holder, so there's something for alc_build_pcms to look
2454 * at when it calculates the maximum number of channels. ALC260 has no mixer
2455 * element which allows changing the channel mode, so the verb list is
2458 static struct hda_channel_mode alc260_modes[1] = {
2463 /* Mixer combinations
2465 * basic: base_output + input + pc_beep + capture
2466 * HP: base_output + input + capture_alt
2467 * HP_3013: hp_3013 + input + capture
2468 * fujitsu: fujitsu + capture
2471 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
2472 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2473 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2474 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2475 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2476 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2477 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2481 static struct snd_kcontrol_new alc260_input_mixer[] = {
2482 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2483 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2484 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2485 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2487 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2488 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2493 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2494 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2495 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2499 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2500 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2501 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2502 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2503 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2504 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2506 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2507 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
2511 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
2512 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2513 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
2514 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
2515 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2516 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2517 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2518 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
2519 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
2520 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2521 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2522 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2523 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
2527 /* capture mixer elements */
2528 static struct snd_kcontrol_new alc260_capture_mixer[] = {
2529 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2530 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2531 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
2532 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
2534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2535 /* The multiple "Capture Source" controls confuse alsamixer
2536 * So call somewhat different..
2537 * FIXME: the controls appear in the "playback" view!
2539 /* .name = "Capture Source", */
2540 .name = "Input Source",
2542 .info = alc_mux_enum_info,
2543 .get = alc_mux_enum_get,
2544 .put = alc_mux_enum_put,
2549 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
2550 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2551 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2554 /* The multiple "Capture Source" controls confuse alsamixer
2555 * So call somewhat different..
2556 * FIXME: the controls appear in the "playback" view!
2558 /* .name = "Capture Source", */
2559 .name = "Input Source",
2561 .info = alc_mux_enum_info,
2562 .get = alc_mux_enum_get,
2563 .put = alc_mux_enum_put,
2569 * initialization verbs
2571 static struct hda_verb alc260_init_verbs[] = {
2572 /* Line In pin widget for input */
2573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2574 /* CD pin widget for input */
2575 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2576 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2577 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2578 /* Mic2 (front panel) pin widget for input and vref at 80% */
2579 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2580 /* LINE-2 is used for line-out in rear */
2581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2582 /* select line-out */
2583 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
2585 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2587 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2589 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2590 /* mute capture amp left and right */
2591 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2592 /* set connection select to line in (default select for this ADC) */
2593 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2594 /* mute capture amp left and right */
2595 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2596 /* set connection select to line in (default select for this ADC) */
2597 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
2598 /* set vol=0 Line-Out mixer amp left and right */
2599 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2600 /* unmute pin widget amp left and right (no gain on this amp) */
2601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2602 /* set vol=0 HP mixer amp left and right */
2603 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2604 /* unmute pin widget amp left and right (no gain on this amp) */
2605 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2606 /* set vol=0 Mono mixer amp left and right */
2607 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2608 /* unmute pin widget amp left and right (no gain on this amp) */
2609 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2610 /* unmute LINE-2 out pin */
2611 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2612 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2619 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2620 /* mute Front out path */
2621 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2622 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2623 /* mute Headphone out path */
2624 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2625 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2626 /* mute Mono out path */
2627 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2628 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2632 static struct hda_verb alc260_hp_init_verbs[] = {
2633 /* Headphone and output */
2634 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2636 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2637 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2639 /* Mic2 (front panel) pin widget for input and vref at 80% */
2640 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2641 /* Line In pin widget for input */
2642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2643 /* Line-2 pin widget for output */
2644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2645 /* CD pin widget for input */
2646 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2647 /* unmute amp left and right */
2648 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2649 /* set connection select to line in (default select for this ADC) */
2650 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2651 /* unmute Line-Out mixer amp left and right (volume = 0) */
2652 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2653 /* mute pin widget amp left and right (no gain on this amp) */
2654 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2655 /* unmute HP mixer amp left and right (volume = 0) */
2656 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2657 /* mute pin widget amp left and right (no gain on this amp) */
2658 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2659 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2662 /* unmute Line In */
2663 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2666 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2667 /* Unmute Front out path */
2668 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2669 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2670 /* Unmute Headphone out path */
2671 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2672 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2673 /* Unmute Mono out path */
2674 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2675 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2679 static struct hda_verb alc260_hp_3013_init_verbs[] = {
2680 /* Line out and output */
2681 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2683 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2684 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2685 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2686 /* Mic2 (front panel) pin widget for input and vref at 80% */
2687 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2688 /* Line In pin widget for input */
2689 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2690 /* Headphone pin widget for output */
2691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2692 /* CD pin widget for input */
2693 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2694 /* unmute amp left and right */
2695 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2696 /* set connection select to line in (default select for this ADC) */
2697 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2698 /* unmute Line-Out mixer amp left and right (volume = 0) */
2699 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2700 /* mute pin widget amp left and right (no gain on this amp) */
2701 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2702 /* unmute HP mixer amp left and right (volume = 0) */
2703 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2704 /* mute pin widget amp left and right (no gain on this amp) */
2705 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2706 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2709 /* unmute Line In */
2710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2713 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2714 /* Unmute Front out path */
2715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2717 /* Unmute Headphone out path */
2718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2720 /* Unmute Mono out path */
2721 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2722 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2726 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2729 static struct hda_verb alc260_fujitsu_init_verbs[] = {
2730 /* Disable all GPIOs */
2731 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2732 /* Internal speaker is connected to headphone pin */
2733 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2734 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2735 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2736 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2737 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2738 /* Ensure all other unused pins are disabled and muted.
2739 * Note: trying to set widget 0x15 to anything blocks all audio
2740 * output for some reason, so just leave that at the default.
2742 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2743 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2744 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2745 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2746 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2747 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2748 /* Disable digital (SPDIF) pins */
2749 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2750 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2752 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
2753 * when acting as an output.
2755 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
2757 /* Start with output sum widgets muted and their output gains at min */
2758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2760 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2762 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2763 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2765 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2766 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2768 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2769 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 /* Unmute Line1 pin widget output buffer since it starts as an output.
2771 * If the pin mode is changed by the user the pin mode control will
2772 * take care of enabling the pin's input/output buffers as needed.
2773 * Therefore there's no need to enable the input buffer at this
2776 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777 /* Unmute input buffer of pin widget used for Line-in (no equiv
2780 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2782 /* Mute capture amp left and right */
2783 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2784 /* Set ADC connection select to match default mixer setting - line
2787 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2789 /* Do the same for the second ADC: mute capture input amp and
2790 * set ADC connection to line in
2792 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2793 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
2795 /* Mute all inputs to mixer widget (even unconnected ones) */
2796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
2808 /* Test configuration for debugging, modelled after the ALC880 test
2811 #ifdef CONFIG_SND_DEBUG
2812 static hda_nid_t alc260_test_dac_nids[1] = {
2815 static hda_nid_t alc260_test_adc_nids[2] = {
2818 /* This is a bit messy since the two input muxes in the ALC260 have slight
2819 * variations in their signal assignments. The ideal way to deal with this
2820 * is to extend alc_spec.input_mux to allow a different input MUX for each
2821 * ADC. For the purposes of the test model it's sufficient to just list
2822 * both options for affected signal indices. The separate input mux
2823 * functionality only needs to be considered if a model comes along which
2824 * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
2827 static struct hda_input_mux alc260_test_capture_source = {
2830 { "MIC1 pin", 0x0 },
2831 { "MIC2 pin", 0x1 },
2832 { "LINE1 pin", 0x2 },
2833 { "LINE2 pin", 0x3 },
2835 { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
2836 { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
2837 { "HP-OUT pin (cap2 only)", 0x7 },
2840 static struct snd_kcontrol_new alc260_test_mixer[] = {
2841 /* Output driver widgets */
2842 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2843 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2844 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2845 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
2846 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2847 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
2849 /* Modes for retasking pin widgets */
2850 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
2851 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
2852 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
2853 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
2854 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
2855 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
2857 /* Loopback mixer controls */
2858 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
2859 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
2860 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
2861 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
2862 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
2863 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
2864 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
2865 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
2866 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2867 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2868 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2869 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2870 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
2871 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
2872 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
2873 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
2876 static struct hda_verb alc260_test_init_verbs[] = {
2877 /* Disable all GPIOs */
2878 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2879 /* Enable retasking pins as output, initially without power amp */
2880 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2881 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2883 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2884 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2885 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2887 /* Disable digital (SPDIF) pins for now */
2888 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2889 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2891 /* Ensure mic1, mic2, line1 and line2 pin widget take input from the
2892 * OUT1 sum bus when acting as an output.
2894 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
2895 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
2896 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
2897 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
2899 /* Start with output sum widgets muted and their output gains at min */
2900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2903 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2906 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2907 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2910 /* Unmute retasking pin widget output buffers since the default
2911 * state appears to be output. As the pin mode is changed by the
2912 * user the pin mode control will take care of enabling the pin's
2913 * input/output buffers as needed.
2915 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2916 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2918 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 /* Also unmute the mono-out pin widget */
2922 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 /* Mute capture amp left and right */
2925 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2926 /* Set ADC connection select to match default mixer setting - line
2929 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2931 /* Do the same for the second ADC: mute capture input amp and
2932 * set ADC connection to line in
2934 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2935 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
2937 /* Mute all inputs to mixer widget (even unconnected ones) */
2938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2944 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
2951 static struct hda_pcm_stream alc260_pcm_analog_playback = {
2957 static struct hda_pcm_stream alc260_pcm_analog_capture = {
2963 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
2964 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
2967 * for BIOS auto-configuration
2970 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
2974 unsigned long vol_val, sw_val;
2978 if (nid >= 0x0f && nid < 0x11) {
2979 nid_vol = nid - 0x7;
2980 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2981 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2982 } else if (nid == 0x11) {
2983 nid_vol = nid - 0x7;
2984 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
2985 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
2986 } else if (nid >= 0x12 && nid <= 0x15) {
2988 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2989 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2993 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
2994 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
2996 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
2997 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
3002 /* add playback controls from the parsed DAC table */
3003 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3004 const struct auto_pin_cfg *cfg)
3009 spec->multiout.num_dacs = 1;
3010 spec->multiout.dac_nids = spec->private_dac_nids;
3011 spec->multiout.dac_nids[0] = 0x02;
3013 nid = cfg->line_out_pins[0];
3015 err = alc260_add_playback_controls(spec, nid, "Front");
3020 nid = cfg->speaker_pin;
3022 err = alc260_add_playback_controls(spec, nid, "Speaker");
3029 err = alc260_add_playback_controls(spec, nid, "Headphone");
3036 /* create playback/capture controls for input pins */
3037 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3038 const struct auto_pin_cfg *cfg)
3040 struct hda_input_mux *imux = &spec->private_imux;
3043 for (i = 0; i < AUTO_PIN_LAST; i++) {
3044 if (cfg->input_pins[i] >= 0x12) {
3045 idx = cfg->input_pins[i] - 0x12;
3046 err = new_analog_input(spec, cfg->input_pins[i],
3047 auto_pin_cfg_labels[i], idx, 0x07);
3050 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3051 imux->items[imux->num_items].index = idx;
3054 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
3055 idx = cfg->input_pins[i] - 0x09;
3056 err = new_analog_input(spec, cfg->input_pins[i],
3057 auto_pin_cfg_labels[i], idx, 0x07);
3060 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3061 imux->items[imux->num_items].index = idx;
3068 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
3069 hda_nid_t nid, int pin_type,
3073 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3074 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3075 /* need the manual connection? */
3077 int idx = nid - 0x12;
3078 snd_hda_codec_write(codec, idx + 0x0b, 0,
3079 AC_VERB_SET_CONNECT_SEL, sel_idx);
3084 static void alc260_auto_init_multi_out(struct hda_codec *codec)
3086 struct alc_spec *spec = codec->spec;
3089 nid = spec->autocfg.line_out_pins[0];
3091 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3093 nid = spec->autocfg.speaker_pin;
3095 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3097 nid = spec->autocfg.hp_pin;
3099 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
3102 #define ALC260_PIN_CD_NID 0x16
3103 static void alc260_auto_init_analog_input(struct hda_codec *codec)
3105 struct alc_spec *spec = codec->spec;
3108 for (i = 0; i < AUTO_PIN_LAST; i++) {
3109 hda_nid_t nid = spec->autocfg.input_pins[i];
3111 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3112 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3113 if (nid != ALC260_PIN_CD_NID)
3114 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3121 * generic initialization of ADC, input mixers and output mixers
3123 static struct hda_verb alc260_volume_init_verbs[] = {
3125 * Unmute ADC0-1 and set the default input to mic-in
3127 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3128 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3129 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3130 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3132 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3134 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3137 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3145 * Set up output mixers (0x08 - 0x0a)
3147 /* set vol=0 to output mixers */
3148 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3150 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3151 /* set up input amps for analog loopback */
3152 /* Amp Indices: DAC = 0, mixer = 1 */
3153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3154 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3157 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3163 static int alc260_parse_auto_config(struct hda_codec *codec)
3165 struct alc_spec *spec = codec->spec;
3168 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
3170 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3171 alc260_ignore)) < 0)
3173 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
3175 if (! spec->kctl_alloc)
3176 return 0; /* can't find valid BIOS pin config */
3177 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3180 spec->multiout.max_channels = 2;
3182 if (spec->autocfg.dig_out_pin)
3183 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
3184 if (spec->kctl_alloc)
3185 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3187 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
3189 spec->input_mux = &spec->private_imux;
3191 /* check whether NID 0x04 is valid */
3192 wcap = get_wcaps(codec, 0x04);
3193 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3194 if (wcap != AC_WID_AUD_IN) {
3195 spec->adc_nids = alc260_adc_nids_alt;
3196 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
3197 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
3199 spec->adc_nids = alc260_adc_nids;
3200 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
3201 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
3208 /* init callback for auto-configuration model -- overriding the default init */
3209 static int alc260_auto_init(struct hda_codec *codec)
3212 alc260_auto_init_multi_out(codec);
3213 alc260_auto_init_analog_input(codec);
3218 * ALC260 configurations
3220 static struct hda_board_config alc260_cfg_tbl[] = {
3221 { .modelname = "basic", .config = ALC260_BASIC },
3222 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
3223 .config = ALC260_BASIC }, /* Sony VAIO */
3224 { .modelname = "hp", .config = ALC260_HP },
3225 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
3226 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
3227 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
3228 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
3229 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
3230 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
3231 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
3232 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
3233 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
3234 #ifdef CONFIG_SND_DEBUG
3235 { .modelname = "test", .config = ALC260_TEST },
3237 { .modelname = "auto", .config = ALC260_AUTO },
3241 static struct alc_config_preset alc260_presets[] = {
3243 .mixers = { alc260_base_output_mixer,
3245 alc260_pc_beep_mixer,
3246 alc260_capture_mixer },
3247 .init_verbs = { alc260_init_verbs },
3248 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3249 .dac_nids = alc260_dac_nids,
3250 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3251 .adc_nids = alc260_adc_nids,
3252 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3253 .channel_mode = alc260_modes,
3254 .input_mux = &alc260_capture_source,
3257 .mixers = { alc260_base_output_mixer,
3259 alc260_capture_alt_mixer },
3260 .init_verbs = { alc260_hp_init_verbs },
3261 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3262 .dac_nids = alc260_dac_nids,
3263 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3264 .adc_nids = alc260_hp_adc_nids,
3265 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3266 .channel_mode = alc260_modes,
3267 .input_mux = &alc260_capture_source,
3269 [ALC260_HP_3013] = {
3270 .mixers = { alc260_hp_3013_mixer,
3272 alc260_capture_alt_mixer },
3273 .init_verbs = { alc260_hp_3013_init_verbs },
3274 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3275 .dac_nids = alc260_dac_nids,
3276 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
3277 .adc_nids = alc260_hp_adc_nids,
3278 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3279 .channel_mode = alc260_modes,
3280 .input_mux = &alc260_capture_source,
3282 [ALC260_FUJITSU_S702X] = {
3283 .mixers = { alc260_fujitsu_mixer,
3284 alc260_capture_mixer },
3285 .init_verbs = { alc260_fujitsu_init_verbs },
3286 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3287 .dac_nids = alc260_dac_nids,
3288 .num_adc_nids = ARRAY_SIZE(alc260_fujitsu_adc_nids),
3289 .adc_nids = alc260_fujitsu_adc_nids,
3290 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3291 .channel_mode = alc260_modes,
3292 .input_mux = &alc260_fujitsu_capture_source,
3294 #ifdef CONFIG_SND_DEBUG
3296 .mixers = { alc260_test_mixer,
3297 alc260_capture_mixer },
3298 .init_verbs = { alc260_test_init_verbs },
3299 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
3300 .dac_nids = alc260_test_dac_nids,
3301 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
3302 .adc_nids = alc260_test_adc_nids,
3303 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3304 .channel_mode = alc260_modes,
3305 .input_mux = &alc260_test_capture_source,
3310 static int patch_alc260(struct hda_codec *codec)
3312 struct alc_spec *spec;
3313 int err, board_config;
3315 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3321 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3322 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3323 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
3324 board_config = ALC260_AUTO;
3327 if (board_config == ALC260_AUTO) {
3328 /* automatic parse from the BIOS config */
3329 err = alc260_parse_auto_config(codec);
3334 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3335 board_config = ALC260_BASIC;
3339 if (board_config != ALC260_AUTO)
3340 setup_preset(spec, &alc260_presets[board_config]);
3342 spec->stream_name_analog = "ALC260 Analog";
3343 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3344 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3346 spec->stream_name_digital = "ALC260 Digital";
3347 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3348 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3350 codec->patch_ops = alc_patch_ops;
3351 if (board_config == ALC260_AUTO)
3352 codec->patch_ops.init = alc260_auto_init;
3361 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3362 * configuration. Each pin widget can choose any input DACs and a mixer.
3363 * Each ADC is connected from a mixer of all inputs. This makes possible
3364 * 6-channel independent captures.
3366 * In addition, an independent DAC for the multi-playback (not used in this
3369 #define ALC882_DIGOUT_NID 0x06
3370 #define ALC882_DIGIN_NID 0x0a
3372 static struct hda_channel_mode alc882_ch_modes[1] = {
3376 static hda_nid_t alc882_dac_nids[4] = {
3377 /* front, rear, clfe, rear_surr */
3378 0x02, 0x03, 0x04, 0x05
3381 /* identical with ALC880 */
3382 #define alc882_adc_nids alc880_adc_nids
3383 #define alc882_adc_nids_alt alc880_adc_nids_alt
3386 /* FIXME: should be a matrix-type input source selection */
3388 static struct hda_input_mux alc882_capture_source = {
3392 { "Front Mic", 0x1 },
3398 #define alc882_mux_enum_info alc_mux_enum_info
3399 #define alc882_mux_enum_get alc_mux_enum_get
3401 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3404 struct alc_spec *spec = codec->spec;
3405 const struct hda_input_mux *imux = spec->input_mux;
3406 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3407 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
3408 hda_nid_t nid = capture_mixers[adc_idx];
3409 unsigned int *cur_val = &spec->cur_mux[adc_idx];
3410 unsigned int i, idx;
3412 idx = ucontrol->value.enumerated.item[0];
3413 if (idx >= imux->num_items)
3414 idx = imux->num_items - 1;
3415 if (*cur_val == idx && ! codec->in_resume)
3417 for (i = 0; i < imux->num_items; i++) {
3418 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
3419 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3420 v | (imux->items[i].index << 8));
3429 static struct hda_verb alc882_sixstack_ch6_init[] = {
3430 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
3431 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3432 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3433 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3440 static struct hda_verb alc882_sixstack_ch8_init[] = {
3441 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3442 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3443 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3444 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3448 static struct hda_channel_mode alc882_sixstack_modes[2] = {
3449 { 6, alc882_sixstack_ch6_init },
3450 { 8, alc882_sixstack_ch8_init },
3453 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3454 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3456 static struct snd_kcontrol_new alc882_base_mixer[] = {
3457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3458 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3459 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3460 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3461 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3462 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3463 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3464 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3465 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3466 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3467 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3468 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3469 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3470 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3471 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3474 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3475 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3476 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
3477 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
3478 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3479 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3480 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3481 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3482 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3483 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3485 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3486 /* .name = "Capture Source", */
3487 .name = "Input Source",
3489 .info = alc882_mux_enum_info,
3490 .get = alc882_mux_enum_get,
3491 .put = alc882_mux_enum_put,
3496 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
3498 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3499 .name = "Channel Mode",
3500 .info = alc_ch_mode_info,
3501 .get = alc_ch_mode_get,
3502 .put = alc_ch_mode_put,
3507 static struct hda_verb alc882_init_verbs[] = {
3508 /* Front mixer: unmute input/output amp left and right (volume = 0) */
3509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3515 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3517 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3519 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3522 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3525 /* Front Pin: output 0 (0x0c) */
3526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3528 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
3529 /* Rear Pin: output 1 (0x0d) */
3530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3532 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
3533 /* CLFE Pin: output 2 (0x0e) */
3534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3536 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
3537 /* Side Pin: output 3 (0x0f) */
3538 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3539 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3540 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
3541 /* Mic (rear) pin: input vref at 80% */
3542 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3544 /* Front Mic pin: input vref at 80% */
3545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3547 /* Line In pin: input */
3548 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3549 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3550 /* Line-2 In: Headphone output (output 0 - 0x0c) */
3551 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3552 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3554 /* CD pin widget for input */
3555 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3557 /* FIXME: use matrix-type input source selection */
3558 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3559 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3574 /* ADC1: mute amp left and right */
3575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3576 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3577 /* ADC2: mute amp left and right */
3578 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3579 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3580 /* ADC3: mute amp left and right */
3581 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3582 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3588 * generic initialization of ADC, input mixers and output mixers
3590 static struct hda_verb alc882_auto_init_verbs[] = {
3592 * Unmute ADC0-2 and set the default input to mic-in
3594 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3595 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3596 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3597 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3598 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3599 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3601 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3603 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3606 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3607 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3614 * Set up output mixers (0x0c - 0x0f)
3616 /* set vol=0 to output mixers */
3617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3618 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3620 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3621 /* set up input amps for analog loopback */
3622 /* Amp Indices: DAC = 0, mixer = 1 */
3623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3630 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3631 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3632 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3634 /* FIXME: use matrix-type input source selection */
3635 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3636 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3637 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3638 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3639 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3640 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3642 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3644 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3645 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3655 /* capture mixer elements */
3656 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
3657 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3658 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3659 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
3660 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
3662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3663 /* The multiple "Capture Source" controls confuse alsamixer
3664 * So call somewhat different..
3665 * FIXME: the controls appear in the "playback" view!
3667 /* .name = "Capture Source", */
3668 .name = "Input Source",
3670 .info = alc882_mux_enum_info,
3671 .get = alc882_mux_enum_get,
3672 .put = alc882_mux_enum_put,
3677 static struct snd_kcontrol_new alc882_capture_mixer[] = {
3678 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3679 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3680 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3681 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3682 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3683 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3685 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3686 /* The multiple "Capture Source" controls confuse alsamixer
3687 * So call somewhat different..
3688 * FIXME: the controls appear in the "playback" view!
3690 /* .name = "Capture Source", */
3691 .name = "Input Source",
3693 .info = alc882_mux_enum_info,
3694 .get = alc882_mux_enum_get,
3695 .put = alc882_mux_enum_put,
3700 /* pcm configuration: identiacal with ALC880 */
3701 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
3702 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
3703 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
3704 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
3707 * configuration and preset
3709 static struct hda_board_config alc882_cfg_tbl[] = {
3710 { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
3711 { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
3712 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
3713 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
3714 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
3715 { .modelname = "auto", .config = ALC882_AUTO },
3719 static struct alc_config_preset alc882_presets[] = {
3720 [ALC882_3ST_DIG] = {
3721 .mixers = { alc882_base_mixer },
3722 .init_verbs = { alc882_init_verbs },
3723 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3724 .dac_nids = alc882_dac_nids,
3725 .dig_out_nid = ALC882_DIGOUT_NID,
3726 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3727 .adc_nids = alc882_adc_nids,
3728 .dig_in_nid = ALC882_DIGIN_NID,
3729 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3730 .channel_mode = alc882_ch_modes,
3731 .input_mux = &alc882_capture_source,
3733 [ALC882_6ST_DIG] = {
3734 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
3735 .init_verbs = { alc882_init_verbs },
3736 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3737 .dac_nids = alc882_dac_nids,
3738 .dig_out_nid = ALC882_DIGOUT_NID,
3739 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3740 .adc_nids = alc882_adc_nids,
3741 .dig_in_nid = ALC882_DIGIN_NID,
3742 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
3743 .channel_mode = alc882_sixstack_modes,
3744 .input_mux = &alc882_capture_source,
3750 * BIOS auto configuration
3752 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
3753 hda_nid_t nid, int pin_type,
3757 struct alc_spec *spec = codec->spec;
3760 if (spec->multiout.dac_nids[dac_idx] == 0x25)
3763 idx = spec->multiout.dac_nids[dac_idx] - 2;
3765 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3766 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3767 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
3771 static void alc882_auto_init_multi_out(struct hda_codec *codec)
3773 struct alc_spec *spec = codec->spec;
3776 for (i = 0; i <= HDA_SIDE; i++) {
3777 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3779 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
3783 static void alc882_auto_init_hp_out(struct hda_codec *codec)
3785 struct alc_spec *spec = codec->spec;
3788 pin = spec->autocfg.hp_pin;
3789 if (pin) /* connect to front */
3790 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
3793 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
3794 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
3796 static void alc882_auto_init_analog_input(struct hda_codec *codec)
3798 struct alc_spec *spec = codec->spec;
3801 for (i = 0; i < AUTO_PIN_LAST; i++) {
3802 hda_nid_t nid = spec->autocfg.input_pins[i];
3803 if (alc882_is_input_pin(nid)) {
3804 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3805 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3806 if (nid != ALC882_PIN_CD_NID)
3807 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3813 /* almost identical with ALC880 parser... */
3814 static int alc882_parse_auto_config(struct hda_codec *codec)
3816 struct alc_spec *spec = codec->spec;
3817 int err = alc880_parse_auto_config(codec);
3822 /* hack - override the init verbs */
3823 spec->init_verbs[0] = alc882_auto_init_verbs;
3827 /* init callback for auto-configuration model -- overriding the default init */
3828 static int alc882_auto_init(struct hda_codec *codec)
3831 alc882_auto_init_multi_out(codec);
3832 alc882_auto_init_hp_out(codec);
3833 alc882_auto_init_analog_input(codec);
3838 * ALC882 Headphone poll in 3.5.1a or 3.5.2
3841 static int patch_alc882(struct hda_codec *codec)
3843 struct alc_spec *spec;
3844 int err, board_config;
3846 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3852 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
3854 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
3855 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
3856 board_config = ALC882_AUTO;
3859 if (board_config == ALC882_AUTO) {
3860 /* automatic parse from the BIOS config */
3861 err = alc882_parse_auto_config(codec);
3866 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3867 board_config = ALC882_3ST_DIG;
3871 if (board_config != ALC882_AUTO)
3872 setup_preset(spec, &alc882_presets[board_config]);
3874 spec->stream_name_analog = "ALC882 Analog";
3875 spec->stream_analog_playback = &alc882_pcm_analog_playback;
3876 spec->stream_analog_capture = &alc882_pcm_analog_capture;
3878 spec->stream_name_digital = "ALC882 Digital";
3879 spec->stream_digital_playback = &alc882_pcm_digital_playback;
3880 spec->stream_digital_capture = &alc882_pcm_digital_capture;
3882 if (! spec->adc_nids && spec->input_mux) {
3883 /* check whether NID 0x07 is valid */
3884 unsigned int wcap = get_wcaps(codec, 0x07);
3885 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3886 if (wcap != AC_WID_AUD_IN) {
3887 spec->adc_nids = alc882_adc_nids_alt;
3888 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
3889 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
3892 spec->adc_nids = alc882_adc_nids;
3893 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
3894 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
3899 codec->patch_ops = alc_patch_ops;
3900 if (board_config == ALC882_AUTO)
3901 codec->patch_ops.init = alc882_auto_init;
3910 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
3911 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
3913 #define alc262_dac_nids alc260_dac_nids
3914 #define alc262_adc_nids alc882_adc_nids
3915 #define alc262_adc_nids_alt alc882_adc_nids_alt
3917 #define alc262_modes alc260_modes
3918 #define alc262_capture_source alc882_capture_source
3920 static struct snd_kcontrol_new alc262_base_mixer[] = {
3921 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3922 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3923 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3924 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3925 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3926 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3931 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
3932 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
3933 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
3934 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3935 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3936 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
3937 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3938 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3941 .name = "Capture Source",
3943 .info = alc882_mux_enum_info,
3944 .get = alc882_mux_enum_get,
3945 .put = alc882_mux_enum_put,
3950 #define alc262_capture_mixer alc882_capture_mixer
3951 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
3954 * generic initialization of ADC, input mixers and output mixers
3956 static struct hda_verb alc262_init_verbs[] = {
3958 * Unmute ADC0-2 and set the default input to mic-in
3960 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3962 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3963 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3964 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3965 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3967 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3969 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3972 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3977 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3980 * Set up output mixers (0x0c - 0x0e)
3982 /* set vol=0 to output mixers */
3983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3984 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3985 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3986 /* set up input amps for analog loopback */
3987 /* Amp Indices: DAC = 0, mixer = 1 */
3988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3997 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3998 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3999 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4000 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4004 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4005 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4006 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4008 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
4009 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4011 /* FIXME: use matrix-type input source selection */
4012 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4013 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4016 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4017 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4019 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4020 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4021 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4022 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4025 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4032 /* add playback controls from the parsed DAC table */
4033 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4038 spec->multiout.num_dacs = 1; /* only use one dac */
4039 spec->multiout.dac_nids = spec->private_dac_nids;
4040 spec->multiout.dac_nids[0] = 2;
4042 nid = cfg->line_out_pins[0];
4044 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
4045 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4047 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
4048 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4052 nid = cfg->speaker_pin;
4055 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4056 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4058 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4059 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4062 if (! cfg->line_out_pins[0])
4063 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
4064 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4066 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
4067 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4073 /* spec->multiout.hp_nid = 2; */
4075 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4076 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
4078 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4079 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4082 if (! cfg->line_out_pins[0])
4083 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
4084 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
4086 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4087 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4094 /* identical with ALC880 */
4095 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
4098 * generic initialization of ADC, input mixers and output mixers
4100 static struct hda_verb alc262_volume_init_verbs[] = {
4102 * Unmute ADC0-2 and set the default input to mic-in
4104 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
4105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4106 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4108 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
4109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4111 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4113 * Note: PASD motherboards uses the Line In 2 as the input for front panel
4116 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
4124 * Set up output mixers (0x0c - 0x0f)
4126 /* set vol=0 to output mixers */
4127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4128 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4131 /* set up input amps for analog loopback */
4132 /* Amp Indices: DAC = 0, mixer = 1 */
4133 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4134 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4137 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4140 /* FIXME: use matrix-type input source selection */
4141 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
4142 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
4143 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4148 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4149 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4150 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4151 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
4155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
4156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
4161 /* pcm configuration: identiacal with ALC880 */
4162 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
4163 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
4164 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
4165 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
4168 * BIOS auto configuration
4170 static int alc262_parse_auto_config(struct hda_codec *codec)
4172 struct alc_spec *spec = codec->spec;
4174 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
4176 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4177 alc262_ignore)) < 0)
4179 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
4180 ! spec->autocfg.hp_pin)
4181 return 0; /* can't find valid BIOS pin config */
4182 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4183 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4186 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4188 if (spec->autocfg.dig_out_pin)
4189 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
4190 if (spec->autocfg.dig_in_pin)
4191 spec->dig_in_nid = ALC262_DIGIN_NID;
4193 if (spec->kctl_alloc)
4194 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4196 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
4197 spec->input_mux = &spec->private_imux;
4202 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
4203 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
4204 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
4207 /* init callback for auto-configuration model -- overriding the default init */
4208 static int alc262_auto_init(struct hda_codec *codec)
4211 alc262_auto_init_multi_out(codec);
4212 alc262_auto_init_hp_out(codec);
4213 alc262_auto_init_analog_input(codec);
4218 * configuration and preset
4220 static struct hda_board_config alc262_cfg_tbl[] = {
4221 { .modelname = "basic", .config = ALC262_BASIC },
4222 { .modelname = "auto", .config = ALC262_AUTO },
4226 static struct alc_config_preset alc262_presets[] = {
4228 .mixers = { alc262_base_mixer },
4229 .init_verbs = { alc262_init_verbs },
4230 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
4231 .dac_nids = alc262_dac_nids,
4233 .num_channel_mode = ARRAY_SIZE(alc262_modes),
4234 .channel_mode = alc262_modes,
4235 .input_mux = &alc262_capture_source,
4239 static int patch_alc262(struct hda_codec *codec)
4241 struct alc_spec *spec;
4245 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4251 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
4254 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4255 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
4256 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
4257 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
4261 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
4262 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
4263 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
4264 board_config = ALC262_AUTO;
4267 if (board_config == ALC262_AUTO) {
4268 /* automatic parse from the BIOS config */
4269 err = alc262_parse_auto_config(codec);
4274 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4275 board_config = ALC262_BASIC;
4279 if (board_config != ALC262_AUTO)
4280 setup_preset(spec, &alc262_presets[board_config]);
4282 spec->stream_name_analog = "ALC262 Analog";
4283 spec->stream_analog_playback = &alc262_pcm_analog_playback;
4284 spec->stream_analog_capture = &alc262_pcm_analog_capture;
4286 spec->stream_name_digital = "ALC262 Digital";
4287 spec->stream_digital_playback = &alc262_pcm_digital_playback;
4288 spec->stream_digital_capture = &alc262_pcm_digital_capture;
4290 if (! spec->adc_nids && spec->input_mux) {
4291 /* check whether NID 0x07 is valid */
4292 unsigned int wcap = get_wcaps(codec, 0x07);
4294 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4295 if (wcap != AC_WID_AUD_IN) {
4296 spec->adc_nids = alc262_adc_nids_alt;
4297 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
4298 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
4301 spec->adc_nids = alc262_adc_nids;
4302 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
4303 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
4308 codec->patch_ops = alc_patch_ops;
4309 if (board_config == ALC262_AUTO)
4310 codec->patch_ops.init = alc262_auto_init;
4317 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4321 * set the path ways for 2 channel output
4322 * need to set the codec line out and mic 1 pin widgets to inputs
4324 static struct hda_verb alc861_threestack_ch2_init[] = {
4325 /* set pin widget 1Ah (line in) for input */
4326 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4327 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4328 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4330 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
4331 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
4332 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
4337 * need to set the codec line out and mic 1 pin widgets to outputs
4339 static struct hda_verb alc861_threestack_ch6_init[] = {
4340 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4341 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4342 /* set pin widget 18h (mic1) for output (CLFE)*/
4343 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4345 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
4346 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
4348 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
4349 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
4350 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
4354 static struct hda_channel_mode alc861_threestack_modes[2] = {
4355 { 2, alc861_threestack_ch2_init },
4356 { 6, alc861_threestack_ch6_init },
4361 static struct snd_kcontrol_new alc861_base_mixer[] = {
4362 /* output mixer control */
4363 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4364 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4365 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4366 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4367 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
4369 /*Input mixer control */
4370 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4371 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4372 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4373 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4374 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4375 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4377 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4378 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4379 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4381 /* Capture mixer control */
4382 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4383 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4386 .name = "Capture Source",
4388 .info = alc_mux_enum_info,
4389 .get = alc_mux_enum_get,
4390 .put = alc_mux_enum_put,
4395 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
4396 /* output mixer control */
4397 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4398 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4399 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4400 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4401 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
4403 /* Input mixer control */
4404 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4405 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4406 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4407 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4408 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4409 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4410 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4411 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4412 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4413 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4415 /* Capture mixer control */
4416 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4417 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4420 .name = "Capture Source",
4422 .info = alc_mux_enum_info,
4423 .get = alc_mux_enum_get,
4424 .put = alc_mux_enum_put,
4427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4428 .name = "Channel Mode",
4429 .info = alc_ch_mode_info,
4430 .get = alc_ch_mode_get,
4431 .put = alc_ch_mode_put,
4432 .private_value = ARRAY_SIZE(alc861_threestack_modes),
4438 * generic initialization of ADC, input mixers and output mixers
4440 static struct hda_verb alc861_base_init_verbs[] = {
4442 * Unmute ADC0 and set the default input to mic-in
4444 /* port-A for surround (rear panel) */
4445 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4446 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
4447 /* port-B for mic-in (rear panel) with vref */
4448 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4449 /* port-C for line-in (rear panel) */
4450 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4451 /* port-D for Front */
4452 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4453 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4454 /* port-E for HP out (front panel) */
4455 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4456 /* route front PCM to HP */
4457 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4458 /* port-F for mic-in (front panel) with vref */
4459 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4460 /* port-G for CLFE (rear panel) */
4461 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4462 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
4463 /* port-H for side (rear panel) */
4464 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4465 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
4467 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4468 /* route front mic to ADC1*/
4469 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4470 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4472 /* Unmute DAC0~3 & spdif out*/
4473 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4474 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4475 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4476 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4479 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4480 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4481 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4482 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4483 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4485 /* Unmute Stereo Mixer 15 */
4486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4494 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4496 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4498 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4500 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4505 static struct hda_verb alc861_threestack_init_verbs[] = {
4507 * Unmute ADC0 and set the default input to mic-in
4509 /* port-A for surround (rear panel) */
4510 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4511 /* port-B for mic-in (rear panel) with vref */
4512 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4513 /* port-C for line-in (rear panel) */
4514 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4515 /* port-D for Front */
4516 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4517 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4518 /* port-E for HP out (front panel) */
4519 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4520 /* route front PCM to HP */
4521 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4522 /* port-F for mic-in (front panel) with vref */
4523 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4524 /* port-G for CLFE (rear panel) */
4525 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4526 /* port-H for side (rear panel) */
4527 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4529 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4530 /* route front mic to ADC1*/
4531 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4533 /* Unmute DAC0~3 & spdif out*/
4534 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4535 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4536 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4537 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4540 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4541 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4542 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4543 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4544 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4546 /* Unmute Stereo Mixer 15 */
4547 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4550 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4552 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4553 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4554 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4555 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4556 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4558 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4565 * generic initialization of ADC, input mixers and output mixers
4567 static struct hda_verb alc861_auto_init_verbs[] = {
4569 * Unmute ADC0 and set the default input to mic-in
4571 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4574 /* Unmute DAC0~3 & spdif out*/
4575 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4576 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4577 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4578 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4581 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4582 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4583 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4584 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4585 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4587 /* Unmute Stereo Mixer 15 */
4588 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
4593 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4595 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4596 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4598 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4606 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4607 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4608 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4609 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4611 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
4616 /* pcm configuration: identiacal with ALC880 */
4617 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
4618 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
4619 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
4620 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
4623 #define ALC861_DIGOUT_NID 0x07
4625 static struct hda_channel_mode alc861_8ch_modes[1] = {
4629 static hda_nid_t alc861_dac_nids[4] = {
4630 /* front, surround, clfe, side */
4631 0x03, 0x06, 0x05, 0x04
4634 static hda_nid_t alc861_adc_nids[1] = {
4639 static struct hda_input_mux alc861_capture_source = {
4643 { "Front Mic", 0x3 },
4650 /* fill in the dac_nids table from the parsed pin configuration */
4651 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4656 spec->multiout.dac_nids = spec->private_dac_nids;
4657 for (i = 0; i < cfg->line_outs; i++) {
4658 nid = cfg->line_out_pins[i];
4660 if (i >= ARRAY_SIZE(alc861_dac_nids))
4662 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
4665 spec->multiout.num_dacs = cfg->line_outs;
4669 /* add playback controls from the parsed DAC table */
4670 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
4671 const struct auto_pin_cfg *cfg)
4674 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
4678 for (i = 0; i < cfg->line_outs; i++) {
4679 nid = spec->multiout.dac_nids[i];
4684 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
4685 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
4687 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
4688 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4691 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
4692 if (nid == alc861_dac_nids[idx])
4694 sprintf(name, "%s Playback Switch", chname[idx]);
4695 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4696 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4703 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
4711 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
4713 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4714 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4716 spec->multiout.hp_nid = nid;
4721 /* create playback/capture controls for input pins */
4722 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4724 struct hda_input_mux *imux = &spec->private_imux;
4725 int i, err, idx, idx1;
4727 for (i = 0; i < AUTO_PIN_LAST; i++) {
4728 switch(cfg->input_pins[i]) {
4753 err = new_analog_input(spec, cfg->input_pins[i],
4754 auto_pin_cfg_labels[i], idx, 0x15);
4758 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
4759 imux->items[imux->num_items].index = idx1;
4765 static struct snd_kcontrol_new alc861_capture_mixer[] = {
4766 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4767 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4771 /* The multiple "Capture Source" controls confuse alsamixer
4772 * So call somewhat different..
4773 *FIXME: the controls appear in the "playback" view!
4775 /* .name = "Capture Source", */
4776 .name = "Input Source",
4778 .info = alc_mux_enum_info,
4779 .get = alc_mux_enum_get,
4780 .put = alc_mux_enum_put,
4785 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
4786 int pin_type, int dac_idx)
4790 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4791 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4795 static void alc861_auto_init_multi_out(struct hda_codec *codec)
4797 struct alc_spec *spec = codec->spec;
4800 for (i = 0; i < spec->autocfg.line_outs; i++) {
4801 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4803 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
4807 static void alc861_auto_init_hp_out(struct hda_codec *codec)
4809 struct alc_spec *spec = codec->spec;
4812 pin = spec->autocfg.hp_pin;
4813 if (pin) /* connect to front */
4814 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
4817 static void alc861_auto_init_analog_input(struct hda_codec *codec)
4819 struct alc_spec *spec = codec->spec;
4822 for (i = 0; i < AUTO_PIN_LAST; i++) {
4823 hda_nid_t nid = spec->autocfg.input_pins[i];
4824 if ((nid>=0x0c) && (nid <=0x11)) {
4825 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4826 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4831 /* parse the BIOS configuration and set up the alc_spec */
4832 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
4833 static int alc861_parse_auto_config(struct hda_codec *codec)
4835 struct alc_spec *spec = codec->spec;
4837 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
4839 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4840 alc861_ignore)) < 0)
4842 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
4843 ! spec->autocfg.hp_pin)
4844 return 0; /* can't find valid BIOS pin config */
4846 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
4847 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4848 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
4849 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4852 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4854 if (spec->autocfg.dig_out_pin)
4855 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
4857 if (spec->kctl_alloc)
4858 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4860 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
4862 spec->input_mux = &spec->private_imux;
4864 spec->adc_nids = alc861_adc_nids;
4865 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
4866 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
4872 /* init callback for auto-configuration model -- overriding the default init */
4873 static int alc861_auto_init(struct hda_codec *codec)
4876 alc861_auto_init_multi_out(codec);
4877 alc861_auto_init_hp_out(codec);
4878 alc861_auto_init_analog_input(codec);
4885 * configuration and preset
4887 static struct hda_board_config alc861_cfg_tbl[] = {
4888 { .modelname = "3stack", .config = ALC861_3ST },
4889 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
4890 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
4891 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
4892 { .modelname = "auto", .config = ALC861_AUTO },
4896 static struct alc_config_preset alc861_presets[] = {
4898 .mixers = { alc861_3ST_mixer },
4899 .init_verbs = { alc861_threestack_init_verbs },
4900 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4901 .dac_nids = alc861_dac_nids,
4902 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4903 .channel_mode = alc861_threestack_modes,
4904 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4905 .adc_nids = alc861_adc_nids,
4906 .input_mux = &alc861_capture_source,
4908 [ALC861_3ST_DIG] = {
4909 .mixers = { alc861_base_mixer },
4910 .init_verbs = { alc861_threestack_init_verbs },
4911 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4912 .dac_nids = alc861_dac_nids,
4913 .dig_out_nid = ALC861_DIGOUT_NID,
4914 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4915 .channel_mode = alc861_threestack_modes,
4916 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4917 .adc_nids = alc861_adc_nids,
4918 .input_mux = &alc861_capture_source,
4920 [ALC861_6ST_DIG] = {
4921 .mixers = { alc861_base_mixer },
4922 .init_verbs = { alc861_base_init_verbs },
4923 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4924 .dac_nids = alc861_dac_nids,
4925 .dig_out_nid = ALC861_DIGOUT_NID,
4926 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
4927 .channel_mode = alc861_8ch_modes,
4928 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4929 .adc_nids = alc861_adc_nids,
4930 .input_mux = &alc861_capture_source,
4935 static int patch_alc861(struct hda_codec *codec)
4937 struct alc_spec *spec;
4941 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4947 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
4948 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
4949 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
4950 board_config = ALC861_AUTO;
4953 if (board_config == ALC861_AUTO) {
4954 /* automatic parse from the BIOS config */
4955 err = alc861_parse_auto_config(codec);
4960 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4961 board_config = ALC861_3ST_DIG;
4965 if (board_config != ALC861_AUTO)
4966 setup_preset(spec, &alc861_presets[board_config]);
4968 spec->stream_name_analog = "ALC861 Analog";
4969 spec->stream_analog_playback = &alc861_pcm_analog_playback;
4970 spec->stream_analog_capture = &alc861_pcm_analog_capture;
4972 spec->stream_name_digital = "ALC861 Digital";
4973 spec->stream_digital_playback = &alc861_pcm_digital_playback;
4974 spec->stream_digital_capture = &alc861_pcm_digital_capture;
4976 codec->patch_ops = alc_patch_ops;
4977 if (board_config == ALC861_AUTO)
4978 codec->patch_ops.init = alc861_auto_init;
4986 struct hda_codec_preset snd_hda_preset_realtek[] = {
4987 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
4988 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
4989 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
4990 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4991 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
4992 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
4993 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },