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>
10 * This driver is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This driver is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <sound/driver.h>
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
35 /* ALC880 board config type */
53 #ifdef CONFIG_SND_DEBUG
57 ALC880_MODEL_LAST /* last tag */
67 ALC260_MODEL_LAST /* last tag */
74 ALC262_MODEL_LAST /* last tag */
95 #define GPIO_MASK 0x03
98 /* codec parameterization */
99 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
100 unsigned int num_mixers;
102 const struct hda_verb *init_verbs[5]; /* initialization verbs
103 * don't forget NULL termination!
105 unsigned int num_init_verbs;
107 char *stream_name_analog; /* analog PCM stream */
108 struct hda_pcm_stream *stream_analog_playback;
109 struct hda_pcm_stream *stream_analog_capture;
111 char *stream_name_digital; /* digital PCM stream */
112 struct hda_pcm_stream *stream_digital_playback;
113 struct hda_pcm_stream *stream_digital_capture;
116 struct hda_multi_out multiout; /* playback set-up
117 * max_channels, dacs must be set
118 * dig_out_nid and hp_nid are optional
122 unsigned int num_adc_nids;
124 hda_nid_t dig_in_nid; /* digital-in NID; optional */
127 const struct hda_input_mux *input_mux;
128 unsigned int cur_mux[3];
131 const struct hda_channel_mode *channel_mode;
132 int num_channel_mode;
134 /* PCM information */
135 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
137 /* dynamic controls, init_verbs and input_mux */
138 struct auto_pin_cfg autocfg;
139 unsigned int num_kctl_alloc, num_kctl_used;
140 struct snd_kcontrol_new *kctl_alloc;
141 struct hda_input_mux private_imux;
142 hda_nid_t private_dac_nids[5];
146 * configuration template - to be copied to the spec instance
148 struct alc_config_preset {
149 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
150 const struct hda_verb *init_verbs[5];
151 unsigned int num_dacs;
153 hda_nid_t dig_out_nid; /* optional */
154 hda_nid_t hp_nid; /* optional */
155 unsigned int num_adc_nids;
157 hda_nid_t dig_in_nid;
158 unsigned int num_channel_mode;
159 const struct hda_channel_mode *channel_mode;
160 const struct hda_input_mux *input_mux;
167 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
169 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
170 struct alc_spec *spec = codec->spec;
171 return snd_hda_input_mux_info(spec->input_mux, uinfo);
174 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
177 struct alc_spec *spec = codec->spec;
178 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
180 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
184 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
187 struct alc_spec *spec = codec->spec;
188 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
189 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
190 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
195 * channel mode setting
197 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
200 struct alc_spec *spec = codec->spec;
201 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
202 spec->num_channel_mode);
205 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
207 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
208 struct alc_spec *spec = codec->spec;
209 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
210 spec->num_channel_mode, spec->multiout.max_channels);
213 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
216 struct alc_spec *spec = codec->spec;
217 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
218 spec->num_channel_mode, &spec->multiout.max_channels);
223 * Control of pin widget settings via the mixer. Only boolean settings are
224 * supported, so VrefEn can't be controlled using these functions as they
227 static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
229 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
231 uinfo->value.integer.min = 0;
232 uinfo->value.integer.max = 1;
236 static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
239 hda_nid_t nid = kcontrol->private_value & 0xffff;
240 long mask = (kcontrol->private_value >> 16) & 0xff;
241 long *valp = ucontrol->value.integer.value;
244 if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask)
249 static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
252 hda_nid_t nid = kcontrol->private_value & 0xffff;
253 long mask = (kcontrol->private_value >> 16) & 0xff;
254 long *valp = ucontrol->value.integer.value;
255 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
256 int change = ((pinctl & mask)!=0) != *valp;
259 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
260 *valp?(pinctl|mask):(pinctl&~mask));
264 #define ALC_PINCTL_SWITCH(xname, nid, mask) \
265 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
266 .info = alc_pinctl_switch_info, \
267 .get = alc_pinctl_switch_get, \
268 .put = alc_pinctl_switch_put, \
269 .private_value = (nid) | (mask<<16) }
273 * set up from the preset table
275 static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
279 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
280 spec->mixers[spec->num_mixers++] = preset->mixers[i];
281 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
282 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
284 spec->channel_mode = preset->channel_mode;
285 spec->num_channel_mode = preset->num_channel_mode;
287 spec->multiout.max_channels = spec->channel_mode[0].channels;
289 spec->multiout.num_dacs = preset->num_dacs;
290 spec->multiout.dac_nids = preset->dac_nids;
291 spec->multiout.dig_out_nid = preset->dig_out_nid;
292 spec->multiout.hp_nid = preset->hp_nid;
294 spec->input_mux = preset->input_mux;
296 spec->num_adc_nids = preset->num_adc_nids;
297 spec->adc_nids = preset->adc_nids;
298 spec->dig_in_nid = preset->dig_in_nid;
302 * ALC880 3-stack model
304 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
305 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
309 static hda_nid_t alc880_dac_nids[4] = {
310 /* front, rear, clfe, rear_surr */
311 0x02, 0x05, 0x04, 0x03
314 static hda_nid_t alc880_adc_nids[3] = {
319 /* The datasheet says the node 0x07 is connected from inputs,
320 * but it shows zero connection in the real implementation on some devices.
321 * Note: this is a 915GAV bug, fixed on 915GLV
323 static hda_nid_t alc880_adc_nids_alt[2] = {
328 #define ALC880_DIGOUT_NID 0x06
329 #define ALC880_DIGIN_NID 0x0a
331 static struct hda_input_mux alc880_capture_source = {
335 { "Front Mic", 0x3 },
341 /* channel source setting (2/6 channel selection for 3-stack) */
343 static struct hda_verb alc880_threestack_ch2_init[] = {
344 /* set line-in to input, mute it */
345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
347 /* set mic-in to input vref 80%, mute it */
348 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
349 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
354 static struct hda_verb alc880_threestack_ch6_init[] = {
355 /* set line-in to output, unmute it */
356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
358 /* set mic-in to output, unmute it */
359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
364 static struct hda_channel_mode alc880_threestack_modes[2] = {
365 { 2, alc880_threestack_ch2_init },
366 { 6, alc880_threestack_ch6_init },
369 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
370 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
371 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
372 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
373 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
386 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
387 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
388 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
391 .name = "Channel Mode",
392 .info = alc_ch_mode_info,
393 .get = alc_ch_mode_get,
394 .put = alc_ch_mode_put,
399 /* capture mixer elements */
400 static struct snd_kcontrol_new alc880_capture_mixer[] = {
401 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
402 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
403 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
404 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
405 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
406 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
409 /* The multiple "Capture Source" controls confuse alsamixer
410 * So call somewhat different..
411 * FIXME: the controls appear in the "playback" view!
413 /* .name = "Capture Source", */
414 .name = "Input Source",
416 .info = alc_mux_enum_info,
417 .get = alc_mux_enum_get,
418 .put = alc_mux_enum_put,
423 /* capture mixer elements (in case NID 0x07 not available) */
424 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
425 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
426 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
427 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
428 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
431 /* The multiple "Capture Source" controls confuse alsamixer
432 * So call somewhat different..
433 * FIXME: the controls appear in the "playback" view!
435 /* .name = "Capture Source", */
436 .name = "Input Source",
438 .info = alc_mux_enum_info,
439 .get = alc_mux_enum_get,
440 .put = alc_mux_enum_put,
448 * ALC880 5-stack model
450 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
451 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
452 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
455 /* additional mixers to alc880_three_stack_mixer */
456 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
457 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
458 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
462 /* channel source setting (6/8 channel selection for 5-stack) */
464 static struct hda_verb alc880_fivestack_ch6_init[] = {
465 /* set line-in to input, mute it */
466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
472 static struct hda_verb alc880_fivestack_ch8_init[] = {
473 /* set line-in to output, unmute it */
474 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
475 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
479 static struct hda_channel_mode alc880_fivestack_modes[2] = {
480 { 6, alc880_fivestack_ch6_init },
481 { 8, alc880_fivestack_ch8_init },
486 * ALC880 6-stack model
488 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
489 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
490 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
493 static hda_nid_t alc880_6st_dac_nids[4] = {
494 /* front, rear, clfe, rear_surr */
495 0x02, 0x03, 0x04, 0x05
498 static struct hda_input_mux alc880_6stack_capture_source = {
502 { "Front Mic", 0x1 },
508 /* fixed 8-channels */
509 static struct hda_channel_mode alc880_sixstack_modes[1] = {
513 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
515 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
516 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
517 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
518 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
519 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
520 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
521 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
522 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
523 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
526 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
527 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
530 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
532 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
533 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
536 .name = "Channel Mode",
537 .info = alc_ch_mode_info,
538 .get = alc_ch_mode_get,
539 .put = alc_ch_mode_put,
548 * W810 has rear IO for:
551 * Center/LFE (DAC 04)
554 * The system also has a pair of internal speakers, and a headphone jack.
555 * These are both connected to Line2 on the codec, hence to DAC 02.
557 * There is a variable resistor to control the speaker or headphone
558 * volume. This is a hardware-only device without a software API.
560 * Plugging headphones in will disable the internal speakers. This is
561 * implemented in hardware, not via the driver using jack sense. In
562 * a similar fashion, plugging into the rear socket marked "front" will
563 * disable both the speakers and headphones.
565 * For input, there's a microphone jack, and an "audio in" jack.
566 * These may not do anything useful with this driver yet, because I
567 * haven't setup any initialization verbs for these yet...
570 static hda_nid_t alc880_w810_dac_nids[3] = {
571 /* front, rear/surround, clfe */
575 /* fixed 6 channels */
576 static struct hda_channel_mode alc880_w810_modes[1] = {
580 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
581 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
584 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
585 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
586 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
587 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
588 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
589 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
598 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
599 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
602 static hda_nid_t alc880_z71v_dac_nids[1] = {
605 #define ALC880_Z71V_HP_DAC 0x03
607 /* fixed 2 channels */
608 static struct hda_channel_mode alc880_2_jack_modes[1] = {
612 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
613 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
616 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
629 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
630 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
633 static hda_nid_t alc880_f1734_dac_nids[1] = {
636 #define ALC880_F1734_HP_DAC 0x02
638 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
640 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
641 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
642 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
655 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
656 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
657 * Mic = 0x18, Line = 0x1a
660 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
661 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
663 static struct snd_kcontrol_new alc880_asus_mixer[] = {
664 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
665 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
667 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
670 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
671 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
674 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
675 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
680 .name = "Channel Mode",
681 .info = alc_ch_mode_info,
682 .get = alc_ch_mode_get,
683 .put = alc_ch_mode_put,
690 * ALC880 ASUS W1V model
692 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
693 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
694 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
697 /* additional mixers to alc880_asus_mixer */
698 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
699 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
700 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
704 /* additional mixers to alc880_asus_mixer */
705 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
706 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
707 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
712 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
714 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
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),
720 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
721 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
724 /* The multiple "Capture Source" controls confuse alsamixer
725 * So call somewhat different..
726 * FIXME: the controls appear in the "playback" view!
728 /* .name = "Capture Source", */
729 .name = "Input Source",
731 .info = alc_mux_enum_info,
732 .get = alc_mux_enum_get,
733 .put = alc_mux_enum_put,
739 * build control elements
741 static int alc_build_controls(struct hda_codec *codec)
743 struct alc_spec *spec = codec->spec;
747 for (i = 0; i < spec->num_mixers; i++) {
748 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
753 if (spec->multiout.dig_out_nid) {
754 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
758 if (spec->dig_in_nid) {
759 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
768 * initialize the codec volumes, etc
772 * generic initialization of ADC, input mixers and output mixers
774 static struct hda_verb alc880_volume_init_verbs[] = {
776 * Unmute ADC0-2 and set the default input to mic-in
778 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
780 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
782 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
785 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
787 * Note: PASD motherboards uses the Line In 2 as the input for front panel
790 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
798 * Set up output mixers (0x0c - 0x0f)
800 /* set vol=0 to output mixers */
801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
805 /* set up input amps for analog loopback */
806 /* Amp Indices: DAC = 0, mixer = 1 */
807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
820 * 3-stack pin configuration:
821 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
823 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
825 * preset connection lists of input pins
826 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
828 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
829 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
830 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
833 * Set pin mode and muting
835 /* set front pin widgets 0x14 for output */
836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
838 /* Mic1 (rear panel) pin widget for input and vref at 80% */
839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
841 /* Mic2 (as headphone out) for HP output */
842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
844 /* Line In pin widget for input */
845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
846 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
847 /* Line2 (as front mic) pin widget for input and vref at 80% */
848 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
849 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
850 /* CD pin widget for input */
851 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
857 * 5-stack pin configuration:
858 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
859 * line-in/side = 0x1a, f-mic = 0x1b
861 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
863 * preset connection lists of input pins
864 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
867 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
870 * Set pin mode and muting
872 /* set pin widgets 0x14-0x17 for output */
873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
875 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
876 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
877 /* unmute pins for output (no gain on this amp) */
878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
883 /* Mic1 (rear panel) pin widget for input and vref at 80% */
884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
886 /* Mic2 (as headphone out) for HP output */
887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
889 /* Line In pin widget for input */
890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
892 /* Line2 (as front mic) pin widget for input and vref at 80% */
893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
895 /* CD pin widget for input */
896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
902 * W810 pin configuration:
903 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
905 static struct hda_verb alc880_pin_w810_init_verbs[] = {
906 /* hphone/speaker input selector: front DAC */
907 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
923 * Z71V pin configuration:
924 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
926 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
927 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
941 * 6-stack pin configuration:
942 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
943 * line = 0x1a, HP = 0x1b
945 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
946 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
954 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
972 * F1734 pin configuration:
973 * HP = 0x14, speaker-out = 0x15, mic = 0x18
975 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
976 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
977 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
978 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
979 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
982 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
986 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
988 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
989 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
990 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
992 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
993 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
994 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1001 * ASUS pin configuration:
1002 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1004 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1005 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1006 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1007 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1014 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1016 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1021 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1025 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1026 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1032 /* Enable GPIO mask and set output */
1033 static struct hda_verb alc880_gpio1_init_verbs[] = {
1034 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
1035 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1036 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1041 /* Enable GPIO mask and set output */
1042 static struct hda_verb alc880_gpio2_init_verbs[] = {
1043 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1044 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1045 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1050 /* Clevo m520g init */
1051 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1052 /* headphone output */
1053 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1058 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1061 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1062 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1063 /* Mic1 (rear panel) */
1064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1066 /* Mic2 (front panel) */
1067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1072 /* change to EAPD mode */
1073 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1074 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1079 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1080 /* Headphone output */
1081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1084 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1086 /* Line In pin widget for input */
1087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1088 /* CD pin widget for input */
1089 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1090 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1093 /* change to EAPD mode */
1094 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1095 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1103 static int alc_init(struct hda_codec *codec)
1105 struct alc_spec *spec = codec->spec;
1108 for (i = 0; i < spec->num_init_verbs; i++)
1109 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1117 static int alc_resume(struct hda_codec *codec)
1119 struct alc_spec *spec = codec->spec;
1123 for (i = 0; i < spec->num_mixers; i++)
1124 snd_hda_resume_ctls(codec, spec->mixers[i]);
1125 if (spec->multiout.dig_out_nid)
1126 snd_hda_resume_spdif_out(codec);
1127 if (spec->dig_in_nid)
1128 snd_hda_resume_spdif_in(codec);
1135 * Analog playback callbacks
1137 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1138 struct hda_codec *codec,
1139 struct snd_pcm_substream *substream)
1141 struct alc_spec *spec = codec->spec;
1142 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1145 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1146 struct hda_codec *codec,
1147 unsigned int stream_tag,
1148 unsigned int format,
1149 struct snd_pcm_substream *substream)
1151 struct alc_spec *spec = codec->spec;
1152 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1156 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1157 struct hda_codec *codec,
1158 struct snd_pcm_substream *substream)
1160 struct alc_spec *spec = codec->spec;
1161 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1167 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1168 struct hda_codec *codec,
1169 struct snd_pcm_substream *substream)
1171 struct alc_spec *spec = codec->spec;
1172 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1175 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1176 struct hda_codec *codec,
1177 struct snd_pcm_substream *substream)
1179 struct alc_spec *spec = codec->spec;
1180 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1186 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1187 struct hda_codec *codec,
1188 unsigned int stream_tag,
1189 unsigned int format,
1190 struct snd_pcm_substream *substream)
1192 struct alc_spec *spec = codec->spec;
1194 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1195 stream_tag, 0, format);
1199 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1200 struct hda_codec *codec,
1201 struct snd_pcm_substream *substream)
1203 struct alc_spec *spec = codec->spec;
1205 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1212 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1216 /* NID is set in alc_build_pcms */
1218 .open = alc880_playback_pcm_open,
1219 .prepare = alc880_playback_pcm_prepare,
1220 .cleanup = alc880_playback_pcm_cleanup
1224 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1228 /* NID is set in alc_build_pcms */
1230 .prepare = alc880_capture_pcm_prepare,
1231 .cleanup = alc880_capture_pcm_cleanup
1235 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1239 /* NID is set in alc_build_pcms */
1241 .open = alc880_dig_playback_pcm_open,
1242 .close = alc880_dig_playback_pcm_close
1246 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1250 /* NID is set in alc_build_pcms */
1253 static int alc_build_pcms(struct hda_codec *codec)
1255 struct alc_spec *spec = codec->spec;
1256 struct hda_pcm *info = spec->pcm_rec;
1259 codec->num_pcms = 1;
1260 codec->pcm_info = info;
1262 info->name = spec->stream_name_analog;
1263 if (spec->stream_analog_playback) {
1264 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1265 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1266 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1268 if (spec->stream_analog_capture) {
1269 snd_assert(spec->adc_nids, return -EINVAL);
1270 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1271 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1274 if (spec->channel_mode) {
1275 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1276 for (i = 0; i < spec->num_channel_mode; i++) {
1277 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1278 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1283 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1286 info->name = spec->stream_name_digital;
1287 if (spec->multiout.dig_out_nid &&
1288 spec->stream_digital_playback) {
1289 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1290 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1292 if (spec->dig_in_nid &&
1293 spec->stream_digital_capture) {
1294 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1295 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1302 static void alc_free(struct hda_codec *codec)
1304 struct alc_spec *spec = codec->spec;
1310 if (spec->kctl_alloc) {
1311 for (i = 0; i < spec->num_kctl_used; i++)
1312 kfree(spec->kctl_alloc[i].name);
1313 kfree(spec->kctl_alloc);
1320 static struct hda_codec_ops alc_patch_ops = {
1321 .build_controls = alc_build_controls,
1322 .build_pcms = alc_build_pcms,
1326 .resume = alc_resume,
1332 * Test configuration for debugging
1334 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1337 #ifdef CONFIG_SND_DEBUG
1338 static hda_nid_t alc880_test_dac_nids[4] = {
1339 0x02, 0x03, 0x04, 0x05
1342 static struct hda_input_mux alc880_test_capture_source = {
1353 static struct hda_channel_mode alc880_test_modes[4] = {
1360 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1362 static char *texts[] = {
1363 "N/A", "Line Out", "HP Out",
1364 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1366 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1368 uinfo->value.enumerated.items = 8;
1369 if (uinfo->value.enumerated.item >= 8)
1370 uinfo->value.enumerated.item = 7;
1371 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1375 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1378 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1379 unsigned int pin_ctl, item = 0;
1381 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1382 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1383 if (pin_ctl & AC_PINCTL_OUT_EN) {
1384 if (pin_ctl & AC_PINCTL_HP_EN)
1388 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1389 switch (pin_ctl & AC_PINCTL_VREFEN) {
1390 case AC_PINCTL_VREF_HIZ: item = 3; break;
1391 case AC_PINCTL_VREF_50: item = 4; break;
1392 case AC_PINCTL_VREF_GRD: item = 5; break;
1393 case AC_PINCTL_VREF_80: item = 6; break;
1394 case AC_PINCTL_VREF_100: item = 7; break;
1397 ucontrol->value.enumerated.item[0] = item;
1401 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1404 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1405 static unsigned int ctls[] = {
1406 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1407 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1408 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1409 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1410 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1411 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1413 unsigned int old_ctl, new_ctl;
1415 old_ctl = snd_hda_codec_read(codec, nid, 0,
1416 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1417 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1418 if (old_ctl != new_ctl) {
1419 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1420 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1421 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1427 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1429 static char *texts[] = {
1430 "Front", "Surround", "CLFE", "Side"
1432 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1434 uinfo->value.enumerated.items = 4;
1435 if (uinfo->value.enumerated.item >= 4)
1436 uinfo->value.enumerated.item = 3;
1437 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1441 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1444 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1447 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1448 ucontrol->value.enumerated.item[0] = sel & 3;
1452 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1455 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1458 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1459 if (ucontrol->value.enumerated.item[0] != sel) {
1460 sel = ucontrol->value.enumerated.item[0] & 3;
1461 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1467 #define PIN_CTL_TEST(xname,nid) { \
1468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1470 .info = alc_test_pin_ctl_info, \
1471 .get = alc_test_pin_ctl_get, \
1472 .put = alc_test_pin_ctl_put, \
1473 .private_value = nid \
1476 #define PIN_SRC_TEST(xname,nid) { \
1477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1479 .info = alc_test_pin_src_info, \
1480 .get = alc_test_pin_src_get, \
1481 .put = alc_test_pin_src_put, \
1482 .private_value = nid \
1485 static struct snd_kcontrol_new alc880_test_mixer[] = {
1486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1487 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1488 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1489 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1492 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1493 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1494 PIN_CTL_TEST("Front Pin Mode", 0x14),
1495 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1496 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1497 PIN_CTL_TEST("Side Pin Mode", 0x17),
1498 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1499 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1500 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1501 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1502 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1503 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1504 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1505 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1506 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1507 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1508 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1509 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1510 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1511 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1512 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1513 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1514 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1515 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1518 .name = "Channel Mode",
1519 .info = alc_ch_mode_info,
1520 .get = alc_ch_mode_get,
1521 .put = alc_ch_mode_put,
1526 static struct hda_verb alc880_test_init_verbs[] = {
1527 /* Unmute inputs of 0x0c - 0x0f */
1528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1536 /* Vol output for 0x0c-0x0f */
1537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1541 /* Set output pins 0x14-0x17 */
1542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1546 /* Unmute output pins 0x14-0x17 */
1547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1549 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1551 /* Set input pins 0x18-0x1c */
1552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1557 /* Mute input pins 0x18-0x1b */
1558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1564 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1569 /* Analog input/passthru */
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1582 static struct hda_board_config alc880_cfg_tbl[] = {
1583 /* Back 3 jack, front 2 jack */
1584 { .modelname = "3stack", .config = ALC880_3ST },
1585 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1586 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1587 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1588 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1589 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1590 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1591 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1592 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1593 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1594 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1595 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1596 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1597 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1598 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1599 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1600 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1601 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1602 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1603 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1604 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1605 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1606 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1607 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1608 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1609 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1610 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1611 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1612 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1613 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1614 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1615 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1616 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
1618 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
1620 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1621 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1622 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
1623 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
1625 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1626 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
1627 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
1628 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
1629 /* Clevo m520G NB */
1630 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
1632 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1633 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1634 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1635 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
1637 /* Back 5 jack, front 2 jack */
1638 { .modelname = "5stack", .config = ALC880_5ST },
1639 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1640 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1641 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1642 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
1643 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
1645 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1646 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
1647 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1648 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1649 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1650 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1651 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1652 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1653 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1654 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1655 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1656 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
1657 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1658 /* note subvendor = 0 below */
1659 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1661 { .modelname = "w810", .config = ALC880_W810 },
1662 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
1664 { .modelname = "z71v", .config = ALC880_Z71V },
1665 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1667 { .modelname = "6stack", .config = ALC880_6ST },
1668 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
1669 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
1670 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
1672 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
1673 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1674 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1675 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1676 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1677 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
1678 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
1679 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
1680 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
1682 { .modelname = "asus", .config = ALC880_ASUS },
1683 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1684 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1685 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1686 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1687 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
1688 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1689 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1690 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1691 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1692 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1693 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1694 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
1696 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1697 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1699 { .modelname = "F1734", .config = ALC880_F1734 },
1700 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1701 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
1703 #ifdef CONFIG_SND_DEBUG
1704 { .modelname = "test", .config = ALC880_TEST },
1706 { .modelname = "auto", .config = ALC880_AUTO },
1712 * ALC880 codec presets
1714 static struct alc_config_preset alc880_presets[] = {
1716 .mixers = { alc880_three_stack_mixer },
1717 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1718 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1719 .dac_nids = alc880_dac_nids,
1720 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1721 .channel_mode = alc880_threestack_modes,
1722 .input_mux = &alc880_capture_source,
1724 [ALC880_3ST_DIG] = {
1725 .mixers = { alc880_three_stack_mixer },
1726 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1727 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1728 .dac_nids = alc880_dac_nids,
1729 .dig_out_nid = ALC880_DIGOUT_NID,
1730 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1731 .channel_mode = alc880_threestack_modes,
1732 .input_mux = &alc880_capture_source,
1734 [ALC880_TCL_S700] = {
1735 .mixers = { alc880_tcl_s700_mixer },
1736 .init_verbs = { alc880_volume_init_verbs,
1737 alc880_pin_tcl_S700_init_verbs,
1738 alc880_gpio2_init_verbs },
1739 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1740 .dac_nids = alc880_dac_nids,
1742 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1743 .channel_mode = alc880_2_jack_modes,
1744 .input_mux = &alc880_capture_source,
1747 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1748 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1749 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1750 .dac_nids = alc880_dac_nids,
1751 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1752 .channel_mode = alc880_fivestack_modes,
1753 .input_mux = &alc880_capture_source,
1755 [ALC880_5ST_DIG] = {
1756 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1757 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1758 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1759 .dac_nids = alc880_dac_nids,
1760 .dig_out_nid = ALC880_DIGOUT_NID,
1761 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1762 .channel_mode = alc880_fivestack_modes,
1763 .input_mux = &alc880_capture_source,
1766 .mixers = { alc880_six_stack_mixer },
1767 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1768 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1769 .dac_nids = alc880_6st_dac_nids,
1770 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1771 .channel_mode = alc880_sixstack_modes,
1772 .input_mux = &alc880_6stack_capture_source,
1774 [ALC880_6ST_DIG] = {
1775 .mixers = { alc880_six_stack_mixer },
1776 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1777 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1778 .dac_nids = alc880_6st_dac_nids,
1779 .dig_out_nid = ALC880_DIGOUT_NID,
1780 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1781 .channel_mode = alc880_sixstack_modes,
1782 .input_mux = &alc880_6stack_capture_source,
1785 .mixers = { alc880_w810_base_mixer },
1786 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1787 alc880_gpio2_init_verbs },
1788 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1789 .dac_nids = alc880_w810_dac_nids,
1790 .dig_out_nid = ALC880_DIGOUT_NID,
1791 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1792 .channel_mode = alc880_w810_modes,
1793 .input_mux = &alc880_capture_source,
1796 .mixers = { alc880_z71v_mixer },
1797 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
1798 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1799 .dac_nids = alc880_z71v_dac_nids,
1800 .dig_out_nid = ALC880_DIGOUT_NID,
1802 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1803 .channel_mode = alc880_2_jack_modes,
1804 .input_mux = &alc880_capture_source,
1807 .mixers = { alc880_f1734_mixer },
1808 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1809 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1810 .dac_nids = alc880_f1734_dac_nids,
1812 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1813 .channel_mode = alc880_2_jack_modes,
1814 .input_mux = &alc880_capture_source,
1817 .mixers = { alc880_asus_mixer },
1818 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1819 alc880_gpio1_init_verbs },
1820 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1821 .dac_nids = alc880_asus_dac_nids,
1822 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1823 .channel_mode = alc880_asus_modes,
1824 .input_mux = &alc880_capture_source,
1826 [ALC880_ASUS_DIG] = {
1827 .mixers = { alc880_asus_mixer },
1828 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1829 alc880_gpio1_init_verbs },
1830 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1831 .dac_nids = alc880_asus_dac_nids,
1832 .dig_out_nid = ALC880_DIGOUT_NID,
1833 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1834 .channel_mode = alc880_asus_modes,
1835 .input_mux = &alc880_capture_source,
1837 [ALC880_ASUS_DIG2] = {
1838 .mixers = { alc880_asus_mixer },
1839 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1840 alc880_gpio2_init_verbs }, /* use GPIO2 */
1841 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1842 .dac_nids = alc880_asus_dac_nids,
1843 .dig_out_nid = ALC880_DIGOUT_NID,
1844 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1845 .channel_mode = alc880_asus_modes,
1846 .input_mux = &alc880_capture_source,
1848 [ALC880_ASUS_W1V] = {
1849 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1850 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1851 alc880_gpio1_init_verbs },
1852 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1853 .dac_nids = alc880_asus_dac_nids,
1854 .dig_out_nid = ALC880_DIGOUT_NID,
1855 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1856 .channel_mode = alc880_asus_modes,
1857 .input_mux = &alc880_capture_source,
1859 [ALC880_UNIWILL_DIG] = {
1860 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
1861 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1862 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1863 .dac_nids = alc880_asus_dac_nids,
1864 .dig_out_nid = ALC880_DIGOUT_NID,
1865 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1866 .channel_mode = alc880_asus_modes,
1867 .input_mux = &alc880_capture_source,
1870 .mixers = { alc880_three_stack_mixer },
1871 .init_verbs = { alc880_volume_init_verbs,
1872 alc880_pin_clevo_init_verbs },
1873 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1874 .dac_nids = alc880_dac_nids,
1876 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1877 .channel_mode = alc880_threestack_modes,
1878 .input_mux = &alc880_capture_source,
1880 #ifdef CONFIG_SND_DEBUG
1882 .mixers = { alc880_test_mixer },
1883 .init_verbs = { alc880_test_init_verbs },
1884 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1885 .dac_nids = alc880_test_dac_nids,
1886 .dig_out_nid = ALC880_DIGOUT_NID,
1887 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1888 .channel_mode = alc880_test_modes,
1889 .input_mux = &alc880_test_capture_source,
1895 * Automatic parse of I/O pins from the BIOS configuration
1898 #define NUM_CONTROL_ALLOC 32
1899 #define NUM_VERB_ALLOC 32
1903 ALC_CTL_WIDGET_MUTE,
1906 static struct snd_kcontrol_new alc880_control_templates[] = {
1907 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1908 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1909 HDA_BIND_MUTE(NULL, 0, 0, 0),
1912 /* add dynamic controls */
1913 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1915 struct snd_kcontrol_new *knew;
1917 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1918 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1920 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1923 if (spec->kctl_alloc) {
1924 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1925 kfree(spec->kctl_alloc);
1927 spec->kctl_alloc = knew;
1928 spec->num_kctl_alloc = num;
1931 knew = &spec->kctl_alloc[spec->num_kctl_used];
1932 *knew = alc880_control_templates[type];
1933 knew->name = kstrdup(name, GFP_KERNEL);
1936 knew->private_value = val;
1937 spec->num_kctl_used++;
1941 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1942 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1943 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1944 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1945 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
1946 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
1947 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
1948 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
1949 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1950 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
1951 #define ALC880_PIN_CD_NID 0x1c
1953 /* fill in the dac_nids table from the parsed pin configuration */
1954 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1960 memset(assigned, 0, sizeof(assigned));
1961 spec->multiout.dac_nids = spec->private_dac_nids;
1963 /* check the pins hardwired to audio widget */
1964 for (i = 0; i < cfg->line_outs; i++) {
1965 nid = cfg->line_out_pins[i];
1966 if (alc880_is_fixed_pin(nid)) {
1967 int idx = alc880_fixed_pin_idx(nid);
1968 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
1972 /* left pins can be connect to any audio widget */
1973 for (i = 0; i < cfg->line_outs; i++) {
1974 nid = cfg->line_out_pins[i];
1975 if (alc880_is_fixed_pin(nid))
1977 /* search for an empty channel */
1978 for (j = 0; j < cfg->line_outs; j++) {
1979 if (! assigned[j]) {
1980 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1986 spec->multiout.num_dacs = cfg->line_outs;
1990 /* add playback controls from the parsed DAC table */
1991 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
1992 const struct auto_pin_cfg *cfg)
1995 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1999 for (i = 0; i < cfg->line_outs; i++) {
2000 if (! spec->multiout.dac_nids[i])
2002 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2005 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
2006 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
2008 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
2009 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
2011 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
2012 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
2014 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
2015 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
2018 sprintf(name, "%s Playback Volume", chname[i]);
2019 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2020 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2022 sprintf(name, "%s Playback Switch", chname[i]);
2023 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2024 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2031 /* add playback controls for speaker and HP outputs */
2032 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2042 if (alc880_is_fixed_pin(pin)) {
2043 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2044 if (! spec->multiout.dac_nids[0]) {
2045 /* use this as the primary output */
2046 spec->multiout.dac_nids[0] = nid;
2047 if (! spec->multiout.num_dacs)
2048 spec->multiout.num_dacs = 1;
2050 /* specify the DAC as the extra output */
2051 spec->multiout.hp_nid = nid;
2052 /* control HP volume/switch on the output mixer amp */
2053 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2054 sprintf(name, "%s Playback Volume", pfx);
2055 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2056 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
2058 sprintf(name, "%s Playback Switch", pfx);
2059 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2060 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
2062 } else if (alc880_is_multi_pin(pin)) {
2063 /* set manual connection */
2064 if (! spec->multiout.dac_nids[0]) {
2065 /* use this as the primary output */
2066 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
2067 if (! spec->multiout.num_dacs)
2068 spec->multiout.num_dacs = 1;
2070 /* we have only a switch on HP-out PIN */
2071 sprintf(name, "%s Playback Switch", pfx);
2072 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2073 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
2079 /* create input playback/capture controls for the given pin */
2080 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
2081 int idx, hda_nid_t mix_nid)
2086 sprintf(name, "%s Playback Volume", ctlname);
2087 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2088 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2090 sprintf(name, "%s Playback Switch", ctlname);
2091 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2092 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
2097 /* create playback/capture controls for input pins */
2098 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2099 const struct auto_pin_cfg *cfg)
2101 struct hda_input_mux *imux = &spec->private_imux;
2104 for (i = 0; i < AUTO_PIN_LAST; i++) {
2105 if (alc880_is_input_pin(cfg->input_pins[i])) {
2106 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2107 err = new_analog_input(spec, cfg->input_pins[i],
2108 auto_pin_cfg_labels[i],
2112 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2113 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2120 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2121 hda_nid_t nid, int pin_type,
2125 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2126 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2127 /* need the manual connection? */
2128 if (alc880_is_multi_pin(nid)) {
2129 struct alc_spec *spec = codec->spec;
2130 int idx = alc880_multi_pin_idx(nid);
2131 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
2132 AC_VERB_SET_CONNECT_SEL,
2133 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2137 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2139 struct alc_spec *spec = codec->spec;
2142 for (i = 0; i < spec->autocfg.line_outs; i++) {
2143 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2144 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2148 static void alc880_auto_init_extra_out(struct hda_codec *codec)
2150 struct alc_spec *spec = codec->spec;
2153 pin = spec->autocfg.speaker_pin;
2154 if (pin) /* connect to front */
2155 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
2156 pin = spec->autocfg.hp_pin;
2157 if (pin) /* connect to front */
2158 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2161 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2163 struct alc_spec *spec = codec->spec;
2166 for (i = 0; i < AUTO_PIN_LAST; i++) {
2167 hda_nid_t nid = spec->autocfg.input_pins[i];
2168 if (alc880_is_input_pin(nid)) {
2169 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2170 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2171 if (nid != ALC880_PIN_CD_NID)
2172 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2178 /* parse the BIOS configuration and set up the alc_spec */
2179 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2180 static int alc880_parse_auto_config(struct hda_codec *codec)
2182 struct alc_spec *spec = codec->spec;
2184 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
2186 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2187 alc880_ignore)) < 0)
2189 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
2190 ! spec->autocfg.hp_pin)
2191 return 0; /* can't find valid BIOS pin config */
2193 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
2194 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2195 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2197 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
2198 "Headphone")) < 0 ||
2199 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2202 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2204 if (spec->autocfg.dig_out_pin)
2205 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2206 if (spec->autocfg.dig_in_pin)
2207 spec->dig_in_nid = ALC880_DIGIN_NID;
2209 if (spec->kctl_alloc)
2210 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2212 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2214 spec->input_mux = &spec->private_imux;
2219 /* init callback for auto-configuration model -- overriding the default init */
2220 static int alc880_auto_init(struct hda_codec *codec)
2223 alc880_auto_init_multi_out(codec);
2224 alc880_auto_init_extra_out(codec);
2225 alc880_auto_init_analog_input(codec);
2230 * OK, here we have finally the patch for ALC880
2233 static int patch_alc880(struct hda_codec *codec)
2235 struct alc_spec *spec;
2239 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2245 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2246 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2247 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2248 board_config = ALC880_AUTO;
2251 if (board_config == ALC880_AUTO) {
2252 /* automatic parse from the BIOS config */
2253 err = alc880_parse_auto_config(codec);
2258 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2259 board_config = ALC880_3ST;
2263 if (board_config != ALC880_AUTO)
2264 setup_preset(spec, &alc880_presets[board_config]);
2266 spec->stream_name_analog = "ALC880 Analog";
2267 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2268 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2270 spec->stream_name_digital = "ALC880 Digital";
2271 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2272 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2274 if (! spec->adc_nids && spec->input_mux) {
2275 /* check whether NID 0x07 is valid */
2276 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
2277 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2278 if (wcap != AC_WID_AUD_IN) {
2279 spec->adc_nids = alc880_adc_nids_alt;
2280 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2281 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2284 spec->adc_nids = alc880_adc_nids;
2285 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2286 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2291 codec->patch_ops = alc_patch_ops;
2292 if (board_config == ALC880_AUTO)
2293 codec->patch_ops.init = alc880_auto_init;
2303 static hda_nid_t alc260_dac_nids[1] = {
2308 static hda_nid_t alc260_adc_nids[1] = {
2313 static hda_nid_t alc260_adc_nids_alt[1] = {
2318 static hda_nid_t alc260_hp_adc_nids[2] = {
2323 #define ALC260_DIGOUT_NID 0x03
2324 #define ALC260_DIGIN_NID 0x06
2326 static struct hda_input_mux alc260_capture_source = {
2330 { "Front Mic", 0x1 },
2336 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
2337 * and the internal CD lines.
2339 static struct hda_input_mux alc260_fujitsu_capture_source = {
2342 { "Mic/Line", 0x0 },
2348 * This is just place-holder, so there's something for alc_build_pcms to look
2349 * at when it calculates the maximum number of channels. ALC260 has no mixer
2350 * element which allows changing the channel mode, so the verb list is
2353 static struct hda_channel_mode alc260_modes[1] = {
2358 /* Mixer combinations
2360 * basic: base_output + input + pc_beep + capture
2361 * HP: base_output + input + capture_alt
2362 * HP_3013: hp_3013 + input + capture
2363 * fujitsu: fujitsu + capture
2366 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
2367 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2368 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2369 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2370 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2371 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2372 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
2376 static struct snd_kcontrol_new alc260_input_mixer[] = {
2377 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2378 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2379 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2380 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2382 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2388 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
2389 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2390 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2394 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
2395 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2396 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2397 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
2398 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
2399 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2400 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
2401 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2402 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
2406 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
2407 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2408 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
2409 ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP),
2410 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2411 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2412 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
2413 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
2414 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
2415 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
2416 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2417 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
2421 /* capture mixer elements */
2422 static struct snd_kcontrol_new alc260_capture_mixer[] = {
2423 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2424 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2425 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
2426 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
2428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2429 /* The multiple "Capture Source" controls confuse alsamixer
2430 * So call somewhat different..
2431 * FIXME: the controls appear in the "playback" view!
2433 /* .name = "Capture Source", */
2434 .name = "Input Source",
2436 .info = alc_mux_enum_info,
2437 .get = alc_mux_enum_get,
2438 .put = alc_mux_enum_put,
2443 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
2444 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2445 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2447 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2448 /* The multiple "Capture Source" controls confuse alsamixer
2449 * So call somewhat different..
2450 * FIXME: the controls appear in the "playback" view!
2452 /* .name = "Capture Source", */
2453 .name = "Input Source",
2455 .info = alc_mux_enum_info,
2456 .get = alc_mux_enum_get,
2457 .put = alc_mux_enum_put,
2463 * initialization verbs
2465 static struct hda_verb alc260_init_verbs[] = {
2466 /* Line In pin widget for input */
2467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2468 /* CD pin widget for input */
2469 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2470 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2471 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2472 /* Mic2 (front panel) pin widget for input and vref at 80% */
2473 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2474 /* LINE-2 is used for line-out in rear */
2475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2476 /* select line-out */
2477 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2479 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2481 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2483 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2484 /* mute capture amp left and right */
2485 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2486 /* set connection select to line in (default select for this ADC) */
2487 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2488 /* mute capture amp left and right */
2489 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2490 /* set connection select to line in (default select for this ADC) */
2491 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
2492 /* set vol=0 Line-Out mixer amp left and right */
2493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2494 /* unmute pin widget amp left and right (no gain on this amp) */
2495 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2496 /* set vol=0 HP mixer amp left and right */
2497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2498 /* unmute pin widget amp left and right (no gain on this amp) */
2499 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 /* set vol=0 Mono mixer amp left and right */
2501 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2502 /* unmute pin widget amp left and right (no gain on this amp) */
2503 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2504 /* unmute LINE-2 out pin */
2505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2506 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2513 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2514 /* mute Front out path */
2515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2517 /* mute Headphone out path */
2518 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2520 /* mute Mono out path */
2521 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2526 static struct hda_verb alc260_hp_init_verbs[] = {
2527 /* Headphone and output */
2528 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2530 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2531 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2532 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2533 /* Mic2 (front panel) pin widget for input and vref at 80% */
2534 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2535 /* Line In pin widget for input */
2536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2537 /* Line-2 pin widget for output */
2538 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2539 /* CD pin widget for input */
2540 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2541 /* unmute amp left and right */
2542 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2543 /* set connection select to line in (default select for this ADC) */
2544 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2545 /* unmute Line-Out mixer amp left and right (volume = 0) */
2546 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2547 /* mute pin widget amp left and right (no gain on this amp) */
2548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2549 /* unmute HP mixer amp left and right (volume = 0) */
2550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2551 /* mute pin widget amp left and right (no gain on this amp) */
2552 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2553 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2556 /* unmute Line In */
2557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2560 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2561 /* Unmute Front out path */
2562 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2563 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2564 /* Unmute Headphone out path */
2565 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2567 /* Unmute Mono out path */
2568 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2569 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2573 static struct hda_verb alc260_hp_3013_init_verbs[] = {
2574 /* Line out and output */
2575 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2577 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
2578 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2579 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2580 /* Mic2 (front panel) pin widget for input and vref at 80% */
2581 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
2582 /* Line In pin widget for input */
2583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2584 /* Headphone pin widget for output */
2585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
2586 /* CD pin widget for input */
2587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
2588 /* unmute amp left and right */
2589 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
2590 /* set connection select to line in (default select for this ADC) */
2591 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2592 /* unmute Line-Out mixer amp left and right (volume = 0) */
2593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2594 /* mute pin widget amp left and right (no gain on this amp) */
2595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2596 /* unmute HP mixer amp left and right (volume = 0) */
2597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
2598 /* mute pin widget amp left and right (no gain on this amp) */
2599 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
2600 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
2603 /* unmute Line In */
2604 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
2606 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2607 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2608 /* Unmute Front out path */
2609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2611 /* Unmute Headphone out path */
2612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2614 /* Unmute Mono out path */
2615 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2616 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2620 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
2623 static struct hda_verb alc260_fujitsu_init_verbs[] = {
2624 /* Disable all GPIOs */
2625 {0x01, AC_VERB_SET_GPIO_MASK, 0},
2626 /* Internal speaker is connected to headphone pin */
2627 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2628 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
2629 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2630 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
2631 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2632 /* Ensure all other unused pins are disabled and muted.
2633 * Note: trying to set widget 0x15 to anything blocks all audio
2634 * output for some reason, so just leave that at the default.
2636 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2638 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2639 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2640 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2641 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2642 /* Disable digital (SPDIF) pins */
2643 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
2644 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
2646 /* Start with mixer outputs muted */
2647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2649 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2651 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
2652 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2653 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
2654 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2655 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
2656 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2658 /* Mute capture amp left and right */
2659 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2660 /* Set ADC connection select to line in (on mic1 pin) */
2661 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2663 /* Mute all inputs to mixer widget (even unconnected ones) */
2664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
2665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
2666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
2667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
2668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
2669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
2676 static struct hda_pcm_stream alc260_pcm_analog_playback = {
2682 static struct hda_pcm_stream alc260_pcm_analog_capture = {
2688 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
2689 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
2692 * for BIOS auto-configuration
2695 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
2699 unsigned long vol_val, sw_val;
2703 if (nid >= 0x0f && nid < 0x11) {
2704 nid_vol = nid - 0x7;
2705 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2706 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2707 } else if (nid == 0x11) {
2708 nid_vol = nid - 0x7;
2709 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
2710 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
2711 } else if (nid >= 0x12 && nid <= 0x15) {
2713 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
2714 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
2718 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
2719 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
2721 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
2722 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
2727 /* add playback controls from the parsed DAC table */
2728 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
2729 const struct auto_pin_cfg *cfg)
2734 spec->multiout.num_dacs = 1;
2735 spec->multiout.dac_nids = spec->private_dac_nids;
2736 spec->multiout.dac_nids[0] = 0x02;
2738 nid = cfg->line_out_pins[0];
2740 err = alc260_add_playback_controls(spec, nid, "Front");
2745 nid = cfg->speaker_pin;
2747 err = alc260_add_playback_controls(spec, nid, "Speaker");
2754 err = alc260_add_playback_controls(spec, nid, "Headphone");
2761 /* create playback/capture controls for input pins */
2762 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
2763 const struct auto_pin_cfg *cfg)
2765 struct hda_input_mux *imux = &spec->private_imux;
2768 for (i = 0; i < AUTO_PIN_LAST; i++) {
2769 if (cfg->input_pins[i] >= 0x12) {
2770 idx = cfg->input_pins[i] - 0x12;
2771 err = new_analog_input(spec, cfg->input_pins[i],
2772 auto_pin_cfg_labels[i], idx, 0x07);
2775 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2776 imux->items[imux->num_items].index = idx;
2779 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
2780 idx = cfg->input_pins[i] - 0x09;
2781 err = new_analog_input(spec, cfg->input_pins[i],
2782 auto_pin_cfg_labels[i], idx, 0x07);
2785 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2786 imux->items[imux->num_items].index = idx;
2793 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
2794 hda_nid_t nid, int pin_type,
2798 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
2800 /* need the manual connection? */
2802 int idx = nid - 0x12;
2803 snd_hda_codec_write(codec, idx + 0x0b, 0,
2804 AC_VERB_SET_CONNECT_SEL, sel_idx);
2809 static void alc260_auto_init_multi_out(struct hda_codec *codec)
2811 struct alc_spec *spec = codec->spec;
2814 nid = spec->autocfg.line_out_pins[0];
2816 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2818 nid = spec->autocfg.speaker_pin;
2820 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2822 nid = spec->autocfg.hp_pin;
2824 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
2827 #define ALC260_PIN_CD_NID 0x16
2828 static void alc260_auto_init_analog_input(struct hda_codec *codec)
2830 struct alc_spec *spec = codec->spec;
2833 for (i = 0; i < AUTO_PIN_LAST; i++) {
2834 hda_nid_t nid = spec->autocfg.input_pins[i];
2836 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2837 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2838 if (nid != ALC260_PIN_CD_NID)
2839 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2846 * generic initialization of ADC, input mixers and output mixers
2848 static struct hda_verb alc260_volume_init_verbs[] = {
2850 * Unmute ADC0-1 and set the default input to mic-in
2852 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
2853 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2854 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
2855 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2857 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2859 * Note: PASD motherboards uses the Line In 2 as the input for front panel
2862 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2863 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
2867 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2870 * Set up output mixers (0x08 - 0x0a)
2872 /* set vol=0 to output mixers */
2873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2874 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2875 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2876 /* set up input amps for analog loopback */
2877 /* Amp Indices: DAC = 0, mixer = 1 */
2878 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2880 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2881 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2882 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2883 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2888 static int alc260_parse_auto_config(struct hda_codec *codec)
2890 struct alc_spec *spec = codec->spec;
2893 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
2895 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2896 alc260_ignore)) < 0)
2898 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
2900 if (! spec->kctl_alloc)
2901 return 0; /* can't find valid BIOS pin config */
2902 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2905 spec->multiout.max_channels = 2;
2907 if (spec->autocfg.dig_out_pin)
2908 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
2909 if (spec->kctl_alloc)
2910 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2912 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
2914 spec->input_mux = &spec->private_imux;
2916 /* check whether NID 0x04 is valid */
2917 wcap = get_wcaps(codec, 0x04);
2918 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2919 if (wcap != AC_WID_AUD_IN) {
2920 spec->adc_nids = alc260_adc_nids_alt;
2921 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
2922 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
2924 spec->adc_nids = alc260_adc_nids;
2925 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2926 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
2933 /* init callback for auto-configuration model -- overriding the default init */
2934 static int alc260_auto_init(struct hda_codec *codec)
2937 alc260_auto_init_multi_out(codec);
2938 alc260_auto_init_analog_input(codec);
2943 * ALC260 configurations
2945 static struct hda_board_config alc260_cfg_tbl[] = {
2946 { .modelname = "basic", .config = ALC260_BASIC },
2947 { .modelname = "hp", .config = ALC260_HP },
2948 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
2949 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
2950 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
2951 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
2952 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
2953 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
2954 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
2955 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
2956 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
2957 { .modelname = "auto", .config = ALC260_AUTO },
2961 static struct alc_config_preset alc260_presets[] = {
2963 .mixers = { alc260_base_output_mixer,
2965 alc260_pc_beep_mixer,
2966 alc260_capture_mixer },
2967 .init_verbs = { alc260_init_verbs },
2968 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2969 .dac_nids = alc260_dac_nids,
2970 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
2971 .adc_nids = alc260_adc_nids,
2972 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2973 .channel_mode = alc260_modes,
2974 .input_mux = &alc260_capture_source,
2977 .mixers = { alc260_base_output_mixer,
2979 alc260_capture_alt_mixer },
2980 .init_verbs = { alc260_hp_init_verbs },
2981 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2982 .dac_nids = alc260_dac_nids,
2983 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
2984 .adc_nids = alc260_hp_adc_nids,
2985 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2986 .channel_mode = alc260_modes,
2987 .input_mux = &alc260_capture_source,
2989 [ALC260_HP_3013] = {
2990 .mixers = { alc260_hp_3013_mixer,
2992 alc260_capture_alt_mixer },
2993 .init_verbs = { alc260_hp_3013_init_verbs },
2994 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
2995 .dac_nids = alc260_dac_nids,
2996 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
2997 .adc_nids = alc260_hp_adc_nids,
2998 .num_channel_mode = ARRAY_SIZE(alc260_modes),
2999 .channel_mode = alc260_modes,
3000 .input_mux = &alc260_capture_source,
3002 [ALC260_FUJITSU_S702X] = {
3003 .mixers = { alc260_fujitsu_mixer,
3004 alc260_capture_mixer },
3005 .init_verbs = { alc260_fujitsu_init_verbs },
3006 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
3007 .dac_nids = alc260_dac_nids,
3008 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
3009 .adc_nids = alc260_adc_nids,
3010 .num_channel_mode = ARRAY_SIZE(alc260_modes),
3011 .channel_mode = alc260_modes,
3012 .input_mux = &alc260_fujitsu_capture_source,
3016 static int patch_alc260(struct hda_codec *codec)
3018 struct alc_spec *spec;
3019 int err, board_config;
3021 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3027 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
3028 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
3029 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
3030 board_config = ALC260_AUTO;
3033 if (board_config == ALC260_AUTO) {
3034 /* automatic parse from the BIOS config */
3035 err = alc260_parse_auto_config(codec);
3040 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3041 board_config = ALC260_BASIC;
3045 if (board_config != ALC260_AUTO)
3046 setup_preset(spec, &alc260_presets[board_config]);
3048 spec->stream_name_analog = "ALC260 Analog";
3049 spec->stream_analog_playback = &alc260_pcm_analog_playback;
3050 spec->stream_analog_capture = &alc260_pcm_analog_capture;
3052 spec->stream_name_digital = "ALC260 Digital";
3053 spec->stream_digital_playback = &alc260_pcm_digital_playback;
3054 spec->stream_digital_capture = &alc260_pcm_digital_capture;
3056 codec->patch_ops = alc_patch_ops;
3057 if (board_config == ALC260_AUTO)
3058 codec->patch_ops.init = alc260_auto_init;
3067 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
3068 * configuration. Each pin widget can choose any input DACs and a mixer.
3069 * Each ADC is connected from a mixer of all inputs. This makes possible
3070 * 6-channel independent captures.
3072 * In addition, an independent DAC for the multi-playback (not used in this
3075 #define ALC882_DIGOUT_NID 0x06
3076 #define ALC882_DIGIN_NID 0x0a
3078 static struct hda_channel_mode alc882_ch_modes[1] = {
3082 static hda_nid_t alc882_dac_nids[4] = {
3083 /* front, rear, clfe, rear_surr */
3084 0x02, 0x03, 0x04, 0x05
3087 /* identical with ALC880 */
3088 #define alc882_adc_nids alc880_adc_nids
3089 #define alc882_adc_nids_alt alc880_adc_nids_alt
3092 /* FIXME: should be a matrix-type input source selection */
3094 static struct hda_input_mux alc882_capture_source = {
3098 { "Front Mic", 0x1 },
3104 #define alc882_mux_enum_info alc_mux_enum_info
3105 #define alc882_mux_enum_get alc_mux_enum_get
3107 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3109 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3110 struct alc_spec *spec = codec->spec;
3111 const struct hda_input_mux *imux = spec->input_mux;
3112 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
3113 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
3114 hda_nid_t nid = capture_mixers[adc_idx];
3115 unsigned int *cur_val = &spec->cur_mux[adc_idx];
3116 unsigned int i, idx;
3118 idx = ucontrol->value.enumerated.item[0];
3119 if (idx >= imux->num_items)
3120 idx = imux->num_items - 1;
3121 if (*cur_val == idx && ! codec->in_resume)
3123 for (i = 0; i < imux->num_items; i++) {
3124 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
3125 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3126 v | (imux->items[i].index << 8));
3135 static struct hda_verb alc882_sixstack_ch6_init[] = {
3136 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
3137 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3138 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3139 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3146 static struct hda_verb alc882_sixstack_ch8_init[] = {
3147 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3148 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3149 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3150 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
3154 static struct hda_channel_mode alc882_sixstack_modes[2] = {
3155 { 6, alc882_sixstack_ch6_init },
3156 { 8, alc882_sixstack_ch8_init },
3159 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
3160 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
3162 static struct snd_kcontrol_new alc882_base_mixer[] = {
3163 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3164 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3166 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3167 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3168 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3169 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3170 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3171 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3172 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
3174 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3175 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3176 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3177 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3180 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3182 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
3183 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
3184 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3185 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3186 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3187 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3188 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3189 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3191 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3192 /* .name = "Capture Source", */
3193 .name = "Input Source",
3195 .info = alc882_mux_enum_info,
3196 .get = alc882_mux_enum_get,
3197 .put = alc882_mux_enum_put,
3202 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
3204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3205 .name = "Channel Mode",
3206 .info = alc_ch_mode_info,
3207 .get = alc_ch_mode_get,
3208 .put = alc_ch_mode_put,
3213 static struct hda_verb alc882_init_verbs[] = {
3214 /* Front mixer: unmute input/output amp left and right (volume = 0) */
3215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3225 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3227 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3228 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3229 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3231 /* Front Pin: output 0 (0x0c) */
3232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3233 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3234 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
3235 /* Rear Pin: output 1 (0x0d) */
3236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
3239 /* CLFE Pin: output 2 (0x0e) */
3240 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3242 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
3243 /* Side Pin: output 3 (0x0f) */
3244 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3246 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
3247 /* Mic (rear) pin: input vref at 80% */
3248 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3250 /* Front Mic pin: input vref at 80% */
3251 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3253 /* Line In pin: input */
3254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3256 /* Line-2 In: Headphone output (output 0 - 0x0c) */
3257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3258 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3259 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3260 /* CD pin widget for input */
3261 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3263 /* FIXME: use matrix-type input source selection */
3264 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3265 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3272 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3273 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3277 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3278 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3280 /* ADC1: mute amp left and right */
3281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3282 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3283 /* ADC2: mute amp left and right */
3284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3285 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3286 /* ADC3: mute amp left and right */
3287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3288 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3294 * generic initialization of ADC, input mixers and output mixers
3296 static struct hda_verb alc882_auto_init_verbs[] = {
3298 * Unmute ADC0-2 and set the default input to mic-in
3300 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3302 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3304 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3307 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3309 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3312 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3320 * Set up output mixers (0x0c - 0x0f)
3322 /* set vol=0 to output mixers */
3323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3327 /* set up input amps for analog loopback */
3328 /* Amp Indices: DAC = 0, mixer = 1 */
3329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3337 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3338 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3340 /* FIXME: use matrix-type input source selection */
3341 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3342 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3361 /* capture mixer elements */
3362 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
3363 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3364 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3365 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
3366 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
3368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3369 /* The multiple "Capture Source" controls confuse alsamixer
3370 * So call somewhat different..
3371 * FIXME: the controls appear in the "playback" view!
3373 /* .name = "Capture Source", */
3374 .name = "Input Source",
3376 .info = alc882_mux_enum_info,
3377 .get = alc882_mux_enum_get,
3378 .put = alc882_mux_enum_put,
3383 static struct snd_kcontrol_new alc882_capture_mixer[] = {
3384 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
3385 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
3386 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
3387 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
3388 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
3389 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
3391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3392 /* The multiple "Capture Source" controls confuse alsamixer
3393 * So call somewhat different..
3394 * FIXME: the controls appear in the "playback" view!
3396 /* .name = "Capture Source", */
3397 .name = "Input Source",
3399 .info = alc882_mux_enum_info,
3400 .get = alc882_mux_enum_get,
3401 .put = alc882_mux_enum_put,
3406 /* pcm configuration: identiacal with ALC880 */
3407 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
3408 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
3409 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
3410 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
3413 * configuration and preset
3415 static struct hda_board_config alc882_cfg_tbl[] = {
3416 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
3417 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
3418 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
3419 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
3420 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
3421 { .modelname = "auto", .config = ALC861_AUTO },
3425 static struct alc_config_preset alc882_presets[] = {
3426 [ALC882_3ST_DIG] = {
3427 .mixers = { alc882_base_mixer },
3428 .init_verbs = { alc882_init_verbs },
3429 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3430 .dac_nids = alc882_dac_nids,
3431 .dig_out_nid = ALC882_DIGOUT_NID,
3432 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3433 .adc_nids = alc882_adc_nids,
3434 .dig_in_nid = ALC882_DIGIN_NID,
3435 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
3436 .channel_mode = alc882_ch_modes,
3437 .input_mux = &alc882_capture_source,
3439 [ALC882_6ST_DIG] = {
3440 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
3441 .init_verbs = { alc882_init_verbs },
3442 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
3443 .dac_nids = alc882_dac_nids,
3444 .dig_out_nid = ALC882_DIGOUT_NID,
3445 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
3446 .adc_nids = alc882_adc_nids,
3447 .dig_in_nid = ALC882_DIGIN_NID,
3448 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
3449 .channel_mode = alc882_sixstack_modes,
3450 .input_mux = &alc882_capture_source,
3456 * BIOS auto configuration
3458 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
3459 hda_nid_t nid, int pin_type,
3463 struct alc_spec *spec = codec->spec;
3466 if (spec->multiout.dac_nids[dac_idx] == 0x25)
3469 idx = spec->multiout.dac_nids[dac_idx] - 2;
3471 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
3472 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
3473 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
3477 static void alc882_auto_init_multi_out(struct hda_codec *codec)
3479 struct alc_spec *spec = codec->spec;
3482 for (i = 0; i <= HDA_SIDE; i++) {
3483 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3485 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
3489 static void alc882_auto_init_hp_out(struct hda_codec *codec)
3491 struct alc_spec *spec = codec->spec;
3494 pin = spec->autocfg.hp_pin;
3495 if (pin) /* connect to front */
3496 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
3499 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
3500 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
3502 static void alc882_auto_init_analog_input(struct hda_codec *codec)
3504 struct alc_spec *spec = codec->spec;
3507 for (i = 0; i < AUTO_PIN_LAST; i++) {
3508 hda_nid_t nid = spec->autocfg.input_pins[i];
3509 if (alc882_is_input_pin(nid)) {
3510 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3511 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
3512 if (nid != ALC882_PIN_CD_NID)
3513 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3519 /* almost identical with ALC880 parser... */
3520 static int alc882_parse_auto_config(struct hda_codec *codec)
3522 struct alc_spec *spec = codec->spec;
3523 int err = alc880_parse_auto_config(codec);
3528 /* hack - override the init verbs */
3529 spec->init_verbs[0] = alc882_auto_init_verbs;
3533 /* init callback for auto-configuration model -- overriding the default init */
3534 static int alc882_auto_init(struct hda_codec *codec)
3537 alc882_auto_init_multi_out(codec);
3538 alc882_auto_init_hp_out(codec);
3539 alc882_auto_init_analog_input(codec);
3544 * ALC882 Headphone poll in 3.5.1a or 3.5.2
3547 static int patch_alc882(struct hda_codec *codec)
3549 struct alc_spec *spec;
3550 int err, board_config;
3552 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3558 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
3560 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
3561 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
3562 board_config = ALC882_AUTO;
3565 if (board_config == ALC882_AUTO) {
3566 /* automatic parse from the BIOS config */
3567 err = alc882_parse_auto_config(codec);
3572 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3573 board_config = ALC882_3ST_DIG;
3577 if (board_config != ALC882_AUTO)
3578 setup_preset(spec, &alc882_presets[board_config]);
3580 spec->stream_name_analog = "ALC882 Analog";
3581 spec->stream_analog_playback = &alc882_pcm_analog_playback;
3582 spec->stream_analog_capture = &alc882_pcm_analog_capture;
3584 spec->stream_name_digital = "ALC882 Digital";
3585 spec->stream_digital_playback = &alc882_pcm_digital_playback;
3586 spec->stream_digital_capture = &alc882_pcm_digital_capture;
3588 if (! spec->adc_nids && spec->input_mux) {
3589 /* check whether NID 0x07 is valid */
3590 unsigned int wcap = get_wcaps(codec, 0x07);
3591 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3592 if (wcap != AC_WID_AUD_IN) {
3593 spec->adc_nids = alc882_adc_nids_alt;
3594 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
3595 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
3598 spec->adc_nids = alc882_adc_nids;
3599 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
3600 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
3605 codec->patch_ops = alc_patch_ops;
3606 if (board_config == ALC882_AUTO)
3607 codec->patch_ops.init = alc882_auto_init;
3616 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
3617 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
3619 #define alc262_dac_nids alc260_dac_nids
3620 #define alc262_adc_nids alc882_adc_nids
3621 #define alc262_adc_nids_alt alc882_adc_nids_alt
3623 #define alc262_modes alc260_modes
3624 #define alc262_capture_source alc882_capture_source
3626 static struct snd_kcontrol_new alc262_base_mixer[] = {
3627 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3628 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
3629 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
3630 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
3631 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3632 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3634 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3635 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3636 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3637 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
3638 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
3639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
3640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3641 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3642 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
3643 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
3644 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
3646 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3647 .name = "Capture Source",
3649 .info = alc882_mux_enum_info,
3650 .get = alc882_mux_enum_get,
3651 .put = alc882_mux_enum_put,
3656 #define alc262_capture_mixer alc882_capture_mixer
3657 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
3660 * generic initialization of ADC, input mixers and output mixers
3662 static struct hda_verb alc262_init_verbs[] = {
3664 * Unmute ADC0-2 and set the default input to mic-in
3666 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3668 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3669 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3670 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3671 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3673 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3675 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3678 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3686 * Set up output mixers (0x0c - 0x0e)
3688 /* set vol=0 to output mixers */
3689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3690 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3691 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3692 /* set up input amps for analog loopback */
3693 /* Amp Indices: DAC = 0, mixer = 1 */
3694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3695 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3697 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3698 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3699 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3702 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3703 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3704 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3705 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3711 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3714 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
3715 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
3717 /* FIXME: use matrix-type input source selection */
3718 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3719 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3721 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3722 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3723 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3728 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3738 /* add playback controls from the parsed DAC table */
3739 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
3744 spec->multiout.num_dacs = 1; /* only use one dac */
3745 spec->multiout.dac_nids = spec->private_dac_nids;
3746 spec->multiout.dac_nids[0] = 2;
3748 nid = cfg->line_out_pins[0];
3750 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
3751 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3753 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
3754 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3758 nid = cfg->speaker_pin;
3761 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
3762 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
3764 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
3765 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
3768 if (! cfg->line_out_pins[0])
3769 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
3770 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3772 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
3773 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3779 /* spec->multiout.hp_nid = 2; */
3781 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
3782 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
3784 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
3785 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
3788 if (! cfg->line_out_pins[0])
3789 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
3790 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
3792 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
3793 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
3800 /* identical with ALC880 */
3801 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
3804 * generic initialization of ADC, input mixers and output mixers
3806 static struct hda_verb alc262_volume_init_verbs[] = {
3808 * Unmute ADC0-2 and set the default input to mic-in
3810 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3811 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3812 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3814 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3817 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3819 * Note: PASD motherboards uses the Line In 2 as the input for front panel
3822 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
3823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
3826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
3827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3830 * Set up output mixers (0x0c - 0x0f)
3832 /* set vol=0 to output mixers */
3833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3837 /* set up input amps for analog loopback */
3838 /* Amp Indices: DAC = 0, mixer = 1 */
3839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3846 /* FIXME: use matrix-type input source selection */
3847 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
3848 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
3849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3850 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3851 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3855 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3856 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
3861 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
3862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
3867 /* pcm configuration: identiacal with ALC880 */
3868 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
3869 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
3870 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
3871 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
3874 * BIOS auto configuration
3876 static int alc262_parse_auto_config(struct hda_codec *codec)
3878 struct alc_spec *spec = codec->spec;
3880 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
3882 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3883 alc262_ignore)) < 0)
3885 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
3886 ! spec->autocfg.hp_pin)
3887 return 0; /* can't find valid BIOS pin config */
3888 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
3889 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
3892 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3894 if (spec->autocfg.dig_out_pin)
3895 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
3896 if (spec->autocfg.dig_in_pin)
3897 spec->dig_in_nid = ALC262_DIGIN_NID;
3899 if (spec->kctl_alloc)
3900 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3902 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
3903 spec->input_mux = &spec->private_imux;
3908 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
3909 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
3910 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
3913 /* init callback for auto-configuration model -- overriding the default init */
3914 static int alc262_auto_init(struct hda_codec *codec)
3917 alc262_auto_init_multi_out(codec);
3918 alc262_auto_init_hp_out(codec);
3919 alc262_auto_init_analog_input(codec);
3924 * configuration and preset
3926 static struct hda_board_config alc262_cfg_tbl[] = {
3927 { .modelname = "basic", .config = ALC262_BASIC },
3928 { .modelname = "auto", .config = ALC262_AUTO },
3932 static struct alc_config_preset alc262_presets[] = {
3934 .mixers = { alc262_base_mixer },
3935 .init_verbs = { alc262_init_verbs },
3936 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
3937 .dac_nids = alc262_dac_nids,
3939 .num_channel_mode = ARRAY_SIZE(alc262_modes),
3940 .channel_mode = alc262_modes,
3941 .input_mux = &alc262_capture_source,
3945 static int patch_alc262(struct hda_codec *codec)
3947 struct alc_spec *spec;
3951 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
3957 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
3960 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
3961 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
3962 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
3963 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
3967 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
3968 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
3969 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
3970 board_config = ALC262_AUTO;
3973 if (board_config == ALC262_AUTO) {
3974 /* automatic parse from the BIOS config */
3975 err = alc262_parse_auto_config(codec);
3980 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
3981 board_config = ALC262_BASIC;
3985 if (board_config != ALC262_AUTO)
3986 setup_preset(spec, &alc262_presets[board_config]);
3988 spec->stream_name_analog = "ALC262 Analog";
3989 spec->stream_analog_playback = &alc262_pcm_analog_playback;
3990 spec->stream_analog_capture = &alc262_pcm_analog_capture;
3992 spec->stream_name_digital = "ALC262 Digital";
3993 spec->stream_digital_playback = &alc262_pcm_digital_playback;
3994 spec->stream_digital_capture = &alc262_pcm_digital_capture;
3996 if (! spec->adc_nids && spec->input_mux) {
3997 /* check whether NID 0x07 is valid */
3998 unsigned int wcap = get_wcaps(codec, 0x07);
4000 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4001 if (wcap != AC_WID_AUD_IN) {
4002 spec->adc_nids = alc262_adc_nids_alt;
4003 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
4004 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
4007 spec->adc_nids = alc262_adc_nids;
4008 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
4009 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
4014 codec->patch_ops = alc_patch_ops;
4015 if (board_config == ALC262_AUTO)
4016 codec->patch_ops.init = alc262_auto_init;
4023 * ALC861 channel source setting (2/6 channel selection for 3-stack)
4027 * set the path ways for 2 channel output
4028 * need to set the codec line out and mic 1 pin widgets to inputs
4030 static struct hda_verb alc861_threestack_ch2_init[] = {
4031 /* set pin widget 1Ah (line in) for input */
4032 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4033 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
4034 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4036 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
4037 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
4038 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
4043 * need to set the codec line out and mic 1 pin widgets to outputs
4045 static struct hda_verb alc861_threestack_ch6_init[] = {
4046 /* set pin widget 1Ah (line in) for output (Back Surround)*/
4047 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4048 /* set pin widget 18h (mic1) for output (CLFE)*/
4049 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4051 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
4052 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
4054 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
4055 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
4056 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
4060 static struct hda_channel_mode alc861_threestack_modes[2] = {
4061 { 2, alc861_threestack_ch2_init },
4062 { 6, alc861_threestack_ch6_init },
4067 static struct snd_kcontrol_new alc861_base_mixer[] = {
4068 /* output mixer control */
4069 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4070 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4071 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4072 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4073 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
4075 /*Input mixer control */
4076 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4077 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4078 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4079 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4080 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4081 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4082 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4083 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4084 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4087 /* Capture mixer control */
4088 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4089 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4091 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4092 .name = "Capture Source",
4094 .info = alc_mux_enum_info,
4095 .get = alc_mux_enum_get,
4096 .put = alc_mux_enum_put,
4101 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
4102 /* output mixer control */
4103 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
4104 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
4105 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
4106 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
4107 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
4109 /* Input mixer control */
4110 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
4111 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
4112 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
4113 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
4114 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
4115 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
4116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
4117 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
4118 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
4119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
4121 /* Capture mixer control */
4122 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4123 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4126 .name = "Capture Source",
4128 .info = alc_mux_enum_info,
4129 .get = alc_mux_enum_get,
4130 .put = alc_mux_enum_put,
4133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4134 .name = "Channel Mode",
4135 .info = alc_ch_mode_info,
4136 .get = alc_ch_mode_get,
4137 .put = alc_ch_mode_put,
4138 .private_value = ARRAY_SIZE(alc861_threestack_modes),
4144 * generic initialization of ADC, input mixers and output mixers
4146 static struct hda_verb alc861_base_init_verbs[] = {
4148 * Unmute ADC0 and set the default input to mic-in
4150 /* port-A for surround (rear panel) */
4151 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4152 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
4153 /* port-B for mic-in (rear panel) with vref */
4154 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4155 /* port-C for line-in (rear panel) */
4156 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4157 /* port-D for Front */
4158 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4159 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4160 /* port-E for HP out (front panel) */
4161 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4162 /* route front PCM to HP */
4163 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4164 /* port-F for mic-in (front panel) with vref */
4165 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4166 /* port-G for CLFE (rear panel) */
4167 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4168 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
4169 /* port-H for side (rear panel) */
4170 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4171 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
4173 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4174 /* route front mic to ADC1*/
4175 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4176 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4178 /* Unmute DAC0~3 & spdif out*/
4179 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4181 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4182 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4185 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4186 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4187 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4188 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4189 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4191 /* Unmute Stereo Mixer 15 */
4192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4198 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4199 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4200 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4202 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4204 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4211 static struct hda_verb alc861_threestack_init_verbs[] = {
4213 * Unmute ADC0 and set the default input to mic-in
4215 /* port-A for surround (rear panel) */
4216 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4217 /* port-B for mic-in (rear panel) with vref */
4218 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4219 /* port-C for line-in (rear panel) */
4220 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4221 /* port-D for Front */
4222 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
4223 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
4224 /* port-E for HP out (front panel) */
4225 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
4226 /* route front PCM to HP */
4227 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
4228 /* port-F for mic-in (front panel) with vref */
4229 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
4230 /* port-G for CLFE (rear panel) */
4231 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4232 /* port-H for side (rear panel) */
4233 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4235 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
4236 /* route front mic to ADC1*/
4237 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4238 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4239 /* Unmute DAC0~3 & spdif out*/
4240 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4243 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4246 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4247 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4248 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4249 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4250 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4252 /* Unmute Stereo Mixer 15 */
4253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
4258 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4260 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4262 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
4267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4271 * generic initialization of ADC, input mixers and output mixers
4273 static struct hda_verb alc861_auto_init_verbs[] = {
4275 * Unmute ADC0 and set the default input to mic-in
4277 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
4278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4280 /* Unmute DAC0~3 & spdif out*/
4281 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4282 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4283 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4284 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4287 /* Unmute Mixer 14 (mic) 1c (Line in)*/
4288 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4289 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4290 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4291 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4293 /* Unmute Stereo Mixer 15 */
4294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
4299 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4300 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4301 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4302 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4303 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4304 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4305 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4306 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4309 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4311 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4312 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4313 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4314 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
4315 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
4317 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
4322 /* pcm configuration: identiacal with ALC880 */
4323 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
4324 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
4325 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
4326 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
4329 #define ALC861_DIGOUT_NID 0x07
4331 static struct hda_channel_mode alc861_8ch_modes[1] = {
4335 static hda_nid_t alc861_dac_nids[4] = {
4336 /* front, surround, clfe, side */
4337 0x03, 0x06, 0x05, 0x04
4340 static hda_nid_t alc861_adc_nids[1] = {
4345 static struct hda_input_mux alc861_capture_source = {
4349 { "Front Mic", 0x3 },
4356 /* fill in the dac_nids table from the parsed pin configuration */
4357 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4362 spec->multiout.dac_nids = spec->private_dac_nids;
4363 for (i = 0; i < cfg->line_outs; i++) {
4364 nid = cfg->line_out_pins[i];
4366 if (i >= ARRAY_SIZE(alc861_dac_nids))
4368 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
4371 spec->multiout.num_dacs = cfg->line_outs;
4375 /* add playback controls from the parsed DAC table */
4376 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
4377 const struct auto_pin_cfg *cfg)
4380 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
4384 for (i = 0; i < cfg->line_outs; i++) {
4385 nid = spec->multiout.dac_nids[i];
4390 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
4391 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
4393 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
4394 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
4397 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
4398 if (nid == alc861_dac_nids[idx])
4400 sprintf(name, "%s Playback Switch", chname[idx]);
4401 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4402 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4409 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
4417 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
4419 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
4420 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
4422 spec->multiout.hp_nid = nid;
4427 /* create playback/capture controls for input pins */
4428 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4430 struct hda_input_mux *imux = &spec->private_imux;
4431 int i, err, idx, idx1;
4433 for (i = 0; i < AUTO_PIN_LAST; i++) {
4434 switch(cfg->input_pins[i]) {
4459 err = new_analog_input(spec, cfg->input_pins[i],
4460 auto_pin_cfg_labels[i], idx, 0x15);
4464 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
4465 imux->items[imux->num_items].index = idx1;
4471 static struct snd_kcontrol_new alc861_capture_mixer[] = {
4472 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
4473 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
4476 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4477 /* The multiple "Capture Source" controls confuse alsamixer
4478 * So call somewhat different..
4479 *FIXME: the controls appear in the "playback" view!
4481 /* .name = "Capture Source", */
4482 .name = "Input Source",
4484 .info = alc_mux_enum_info,
4485 .get = alc_mux_enum_get,
4486 .put = alc_mux_enum_put,
4491 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
4492 int pin_type, int dac_idx)
4496 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
4497 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
4501 static void alc861_auto_init_multi_out(struct hda_codec *codec)
4503 struct alc_spec *spec = codec->spec;
4506 for (i = 0; i < spec->autocfg.line_outs; i++) {
4507 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4509 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
4513 static void alc861_auto_init_hp_out(struct hda_codec *codec)
4515 struct alc_spec *spec = codec->spec;
4518 pin = spec->autocfg.hp_pin;
4519 if (pin) /* connect to front */
4520 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
4523 static void alc861_auto_init_analog_input(struct hda_codec *codec)
4525 struct alc_spec *spec = codec->spec;
4528 for (i = 0; i < AUTO_PIN_LAST; i++) {
4529 hda_nid_t nid = spec->autocfg.input_pins[i];
4530 if ((nid>=0x0c) && (nid <=0x11)) {
4531 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4532 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
4537 /* parse the BIOS configuration and set up the alc_spec */
4538 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
4539 static int alc861_parse_auto_config(struct hda_codec *codec)
4541 struct alc_spec *spec = codec->spec;
4543 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
4545 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4546 alc861_ignore)) < 0)
4548 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
4549 ! spec->autocfg.hp_pin)
4550 return 0; /* can't find valid BIOS pin config */
4552 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
4553 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
4554 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
4555 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
4558 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4560 if (spec->autocfg.dig_out_pin)
4561 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
4563 if (spec->kctl_alloc)
4564 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4566 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
4568 spec->input_mux = &spec->private_imux;
4570 spec->adc_nids = alc861_adc_nids;
4571 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
4572 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
4578 /* init callback for auto-configuration model -- overriding the default init */
4579 static int alc861_auto_init(struct hda_codec *codec)
4582 alc861_auto_init_multi_out(codec);
4583 alc861_auto_init_hp_out(codec);
4584 alc861_auto_init_analog_input(codec);
4591 * configuration and preset
4593 static struct hda_board_config alc861_cfg_tbl[] = {
4594 { .modelname = "3stack", .config = ALC861_3ST },
4595 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
4596 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
4597 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
4598 { .modelname = "auto", .config = ALC861_AUTO },
4602 static struct alc_config_preset alc861_presets[] = {
4604 .mixers = { alc861_3ST_mixer },
4605 .init_verbs = { alc861_threestack_init_verbs },
4606 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4607 .dac_nids = alc861_dac_nids,
4608 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4609 .channel_mode = alc861_threestack_modes,
4610 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4611 .adc_nids = alc861_adc_nids,
4612 .input_mux = &alc861_capture_source,
4614 [ALC861_3ST_DIG] = {
4615 .mixers = { alc861_base_mixer },
4616 .init_verbs = { alc861_threestack_init_verbs },
4617 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4618 .dac_nids = alc861_dac_nids,
4619 .dig_out_nid = ALC861_DIGOUT_NID,
4620 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
4621 .channel_mode = alc861_threestack_modes,
4622 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4623 .adc_nids = alc861_adc_nids,
4624 .input_mux = &alc861_capture_source,
4626 [ALC861_6ST_DIG] = {
4627 .mixers = { alc861_base_mixer },
4628 .init_verbs = { alc861_base_init_verbs },
4629 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
4630 .dac_nids = alc861_dac_nids,
4631 .dig_out_nid = ALC861_DIGOUT_NID,
4632 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
4633 .channel_mode = alc861_8ch_modes,
4634 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
4635 .adc_nids = alc861_adc_nids,
4636 .input_mux = &alc861_capture_source,
4641 static int patch_alc861(struct hda_codec *codec)
4643 struct alc_spec *spec;
4647 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
4653 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
4654 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
4655 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
4656 board_config = ALC861_AUTO;
4659 if (board_config == ALC861_AUTO) {
4660 /* automatic parse from the BIOS config */
4661 err = alc861_parse_auto_config(codec);
4666 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
4667 board_config = ALC861_3ST_DIG;
4671 if (board_config != ALC861_AUTO)
4672 setup_preset(spec, &alc861_presets[board_config]);
4674 spec->stream_name_analog = "ALC861 Analog";
4675 spec->stream_analog_playback = &alc861_pcm_analog_playback;
4676 spec->stream_analog_capture = &alc861_pcm_analog_capture;
4678 spec->stream_name_digital = "ALC861 Digital";
4679 spec->stream_digital_playback = &alc861_pcm_digital_playback;
4680 spec->stream_digital_capture = &alc861_pcm_digital_capture;
4682 codec->patch_ops = alc_patch_ops;
4683 if (board_config == ALC861_AUTO)
4684 codec->patch_ops.init = alc861_auto_init;
4692 struct hda_codec_preset snd_hda_preset_realtek[] = {
4693 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
4694 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
4695 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
4696 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
4697 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
4698 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
4699 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },