2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
6 * Copyright (c) 2004 PeiSen Hou <pshou@realtek.com.tw>
7 * Takashi Iwai <tiwai@suse.de>
9 * This driver is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This driver is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sound/driver.h>
25 #include <linux/init.h>
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28 #include <linux/pci.h>
29 #include <sound/core.h>
30 #include "hda_codec.h"
31 #include "hda_local.h"
34 /* ALC880 board config type */
49 #ifdef CONFIG_SND_DEBUG
52 ALC880_MODEL_LAST /* last tag */
59 ALC260_MODEL_LAST /* last tag */
63 #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
64 #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
65 #define AMP_OUT_MUTE 0xb080
66 #define AMP_OUT_UNMUTE 0xb000
67 #define AMP_OUT_ZERO 0xb000
70 #define PIN_VREF80 0x24
71 #define PIN_VREF50 0x21
76 /* codec parameterization */
77 snd_kcontrol_new_t *mixers[3]; /* mixer arrays */
78 unsigned int num_mixers;
80 const struct hda_verb *init_verbs[3]; /* initialization verbs
81 * don't forget NULL termination!
83 unsigned int num_init_verbs;
85 char *stream_name_analog; /* analog PCM stream */
86 struct hda_pcm_stream *stream_analog_playback;
87 struct hda_pcm_stream *stream_analog_capture;
89 char *stream_name_digital; /* digital PCM stream */
90 struct hda_pcm_stream *stream_digital_playback;
91 struct hda_pcm_stream *stream_digital_capture;
94 struct hda_multi_out multiout; /* playback set-up
95 * max_channels, dacs must be set
96 * dig_out_nid and hp_nid are optional
100 unsigned int num_adc_nids;
102 hda_nid_t dig_in_nid; /* digital-in NID; optional */
105 const struct hda_input_mux *input_mux;
106 unsigned int cur_mux[3];
109 const struct alc_channel_mode *channel_mode;
110 int num_channel_mode;
112 /* PCM information */
113 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
115 struct semaphore bind_mutex; /* for bound controls */
117 /* dynamic controls, init_verbs and input_mux */
118 struct auto_pin_cfg autocfg;
119 unsigned int num_kctl_alloc, num_kctl_used;
120 snd_kcontrol_new_t *kctl_alloc;
121 struct hda_input_mux private_imux;
128 static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
130 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
131 struct alc_spec *spec = codec->spec;
132 return snd_hda_input_mux_info(spec->input_mux, uinfo);
135 static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
137 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
138 struct alc_spec *spec = codec->spec;
139 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
141 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
145 static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
147 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
148 struct alc_spec *spec = codec->spec;
149 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
150 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
151 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
156 * channel mode setting
158 struct alc_channel_mode {
160 const struct hda_verb *sequence;
163 static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
165 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
166 struct alc_spec *spec = codec->spec;
167 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
169 snd_assert(spec->channel_mode, return -ENXIO);
170 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
172 uinfo->value.enumerated.items = items;
173 if (uinfo->value.enumerated.item >= items)
174 uinfo->value.enumerated.item = items - 1;
175 sprintf(uinfo->value.enumerated.name, "%dch",
176 spec->channel_mode[uinfo->value.enumerated.item].channels);
180 static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
182 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
183 struct alc_spec *spec = codec->spec;
184 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
187 snd_assert(spec->channel_mode, return -ENXIO);
188 for (i = 0; i < items; i++) {
189 if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
190 ucontrol->value.enumerated.item[0] = i;
197 static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
200 struct alc_spec *spec = codec->spec;
203 snd_assert(spec->channel_mode, return -ENXIO);
204 mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
205 if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
209 /* change the current channel setting */
210 spec->multiout.max_channels = spec->channel_mode[mode].channels;
211 if (spec->channel_mode[mode].sequence)
212 snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
219 * bound volume controls
221 * bind multiple volumes (# indices, from 0)
224 #define AMP_VAL_IDX_SHIFT 19
225 #define AMP_VAL_IDX_MASK (0x0f<<19)
227 static int alc_bind_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
229 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
230 struct alc_spec *spec = codec->spec;
233 down(&spec->bind_mutex);
234 pval = kcontrol->private_value;
235 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
236 snd_hda_mixer_amp_switch_info(kcontrol, uinfo);
237 kcontrol->private_value = pval;
238 up(&spec->bind_mutex);
242 static int alc_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
245 struct alc_spec *spec = codec->spec;
248 down(&spec->bind_mutex);
249 pval = kcontrol->private_value;
250 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
251 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
252 kcontrol->private_value = pval;
253 up(&spec->bind_mutex);
257 static int alc_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
260 struct alc_spec *spec = codec->spec;
262 int i, indices, change = 0;
264 down(&spec->bind_mutex);
265 pval = kcontrol->private_value;
266 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
267 for (i = 0; i < indices; i++) {
268 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
269 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
271 kcontrol->private_value = pval;
272 up(&spec->bind_mutex);
276 #define ALC_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
277 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
278 .info = alc_bind_switch_info, \
279 .get = alc_bind_switch_get, \
280 .put = alc_bind_switch_put, \
281 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
283 #define ALC_BIND_MUTE(xname,nid,indices,dir) ALC_BIND_MUTE_MONO(xname,nid,3,indices,dir)
287 * ALC880 3-stack model
289 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
290 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
294 static hda_nid_t alc880_dac_nids[4] = {
295 /* front, rear, clfe, rear_surr */
296 0x02, 0x05, 0x04, 0x03
299 static hda_nid_t alc880_adc_nids[3] = {
304 /* The datasheet says the node 0x07 is connected from inputs,
305 * but it shows zero connection in the real implementation on some devices.
307 static hda_nid_t alc880_adc_nids_alt[2] = {
312 #define ALC880_DIGOUT_NID 0x06
313 #define ALC880_DIGIN_NID 0x0a
315 static struct hda_input_mux alc880_capture_source = {
319 { "Front Mic", 0x3 },
325 /* channel source setting (2/6 channel selection for 3-stack) */
327 static struct hda_verb alc880_threestack_ch2_init[] = {
328 /* set line-in to input, mute it */
329 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
330 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
331 /* set mic-in to input vref 80%, mute it */
332 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
333 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
338 static struct hda_verb alc880_threestack_ch6_init[] = {
339 /* set line-in to output, unmute it */
340 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
341 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
342 /* set mic-in to output, unmute it */
343 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
344 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
348 static struct alc_channel_mode alc880_threestack_modes[2] = {
349 { 2, alc880_threestack_ch2_init },
350 { 6, alc880_threestack_ch6_init },
353 static snd_kcontrol_new_t alc880_three_stack_mixer[] = {
354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
355 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
356 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
357 ALC_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
358 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
359 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
360 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
361 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
368 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
369 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
370 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
371 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
375 .name = "Channel Mode",
376 .info = alc880_ch_mode_info,
377 .get = alc880_ch_mode_get,
378 .put = alc880_ch_mode_put,
383 /* capture mixer elements */
384 static snd_kcontrol_new_t alc880_capture_mixer[] = {
385 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
386 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
387 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
388 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
389 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
390 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
393 /* The multiple "Capture Source" controls confuse alsamixer
394 * So call somewhat different..
395 * FIXME: the controls appear in the "playback" view!
397 /* .name = "Capture Source", */
398 .name = "Input Source",
400 .info = alc_mux_enum_info,
401 .get = alc_mux_enum_get,
402 .put = alc_mux_enum_put,
407 /* capture mixer elements (in case NID 0x07 not available) */
408 static snd_kcontrol_new_t alc880_capture_alt_mixer[] = {
409 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
410 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
411 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
412 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
415 /* The multiple "Capture Source" controls confuse alsamixer
416 * So call somewhat different..
417 * FIXME: the controls appear in the "playback" view!
419 /* .name = "Capture Source", */
420 .name = "Input Source",
422 .info = alc_mux_enum_info,
423 .get = alc_mux_enum_get,
424 .put = alc_mux_enum_put,
432 * ALC880 5-stack model
434 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
435 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
436 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
439 /* additional mixers to alc880_three_stack_mixer */
440 static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
441 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
442 ALC_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
446 /* channel source setting (6/8 channel selection for 5-stack) */
448 static struct hda_verb alc880_fivestack_ch6_init[] = {
449 /* set line-in to input, mute it */
450 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
451 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
456 static struct hda_verb alc880_fivestack_ch8_init[] = {
457 /* set line-in to output, unmute it */
458 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
459 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
463 static struct alc_channel_mode alc880_fivestack_modes[2] = {
464 { 6, alc880_fivestack_ch6_init },
465 { 8, alc880_fivestack_ch8_init },
470 * ALC880 6-stack model
472 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
473 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
474 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
477 static hda_nid_t alc880_6st_dac_nids[4] = {
478 /* front, rear, clfe, rear_surr */
479 0x02, 0x03, 0x04, 0x05
482 static struct hda_input_mux alc880_6stack_capture_source = {
486 { "Front Mic", 0x1 },
492 /* fixed 8-channels */
493 static struct alc_channel_mode alc880_sixstack_modes[1] = {
497 static snd_kcontrol_new_t alc880_six_stack_mixer[] = {
498 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
499 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
500 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
501 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
502 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
503 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
504 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
505 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
506 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
507 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
508 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
509 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
514 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
515 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
516 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
517 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
520 .name = "Channel Mode",
521 .info = alc880_ch_mode_info,
522 .get = alc880_ch_mode_get,
523 .put = alc880_ch_mode_put,
532 * W810 has rear IO for:
535 * Center/LFE (DAC 04)
538 * The system also has a pair of internal speakers, and a headphone jack.
539 * These are both connected to Line2 on the codec, hence to DAC 02.
541 * There is a variable resistor to control the speaker or headphone
542 * volume. This is a hardware-only device without a software API.
544 * Plugging headphones in will disable the internal speakers. This is
545 * implemented in hardware, not via the driver using jack sense. In
546 * a similar fashion, plugging into the rear socket marked "front" will
547 * disable both the speakers and headphones.
549 * For input, there's a microphone jack, and an "audio in" jack.
550 * These may not do anything useful with this driver yet, because I
551 * haven't setup any initialization verbs for these yet...
554 static hda_nid_t alc880_w810_dac_nids[3] = {
555 /* front, rear/surround, clfe */
559 /* fixed 6 channels */
560 static struct alc_channel_mode alc880_w810_modes[1] = {
564 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
565 static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
567 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
569 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
570 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
571 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
572 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
573 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
582 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
583 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
586 static hda_nid_t alc880_z71v_dac_nids[1] = {
589 #define ALC880_Z71V_HP_DAC 0x03
591 /* fixed 2 channels */
592 static struct alc_channel_mode alc880_2_jack_modes[1] = {
596 static snd_kcontrol_new_t alc880_z71v_mixer[] = {
597 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
598 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
599 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
600 ALC_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
601 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
602 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
613 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
614 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
617 static hda_nid_t alc880_f1734_dac_nids[1] = {
620 #define ALC880_F1734_HP_DAC 0x02
622 static snd_kcontrol_new_t alc880_f1734_mixer[] = {
623 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
624 ALC_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
625 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
626 ALC_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
627 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
628 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
639 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
640 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
641 * Mic = 0x18, Line = 0x1a
644 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
645 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
647 static snd_kcontrol_new_t alc880_asus_mixer[] = {
648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
649 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
650 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
651 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
652 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
653 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
654 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
655 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
656 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
657 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
664 .name = "Channel Mode",
665 .info = alc880_ch_mode_info,
666 .get = alc880_ch_mode_get,
667 .put = alc880_ch_mode_put,
674 * ALC880 ASUS W1V model
676 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
677 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
678 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
681 /* additional mixers to alc880_asus_mixer */
682 static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = {
683 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
684 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
690 * build control elements
692 static int alc_build_controls(struct hda_codec *codec)
694 struct alc_spec *spec = codec->spec;
698 for (i = 0; i < spec->num_mixers; i++) {
699 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
704 if (spec->multiout.dig_out_nid) {
705 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
709 if (spec->dig_in_nid) {
710 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
719 * initialize the codec volumes, etc
723 * generic initialization of ADC, input mixers and output mixers
725 static struct hda_verb alc880_volume_init_verbs[] = {
727 * Unmute ADC0-2 and set the default input to mic-in
729 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
731 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
733 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
736 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
738 * Note: PASD motherboards uses the Line In 2 as the input for front panel
741 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
749 * Set up output mixers (0x0c - 0x0f)
751 /* set vol=0 to output mixers */
752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
756 /* set up input amps for analog loopback */
757 /* Amp Indices: DAC = 0, mixer = 1 */
758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
761 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
763 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
765 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
771 * 3-stack pin configuration:
772 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
774 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
776 * preset connection lists of input pins
777 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
779 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
780 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
781 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
784 * Set pin mode and muting
786 /* set front pin widgets 0x14 for output */
787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
788 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
789 /* Mic1 (rear panel) pin widget for input and vref at 80% */
790 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
791 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
792 /* Mic2 (as headphone out) for HP output */
793 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
794 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
795 /* Line In pin widget for input */
796 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
797 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
798 /* Line2 (as front mic) pin widget for input and vref at 80% */
799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
800 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
801 /* CD pin widget for input */
802 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
808 * 5-stack pin configuration:
809 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
810 * line-in/side = 0x1a, f-mic = 0x1b
812 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
814 * preset connection lists of input pins
815 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
817 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
818 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
821 * Set pin mode and muting
823 /* set pin widgets 0x14-0x17 for output */
824 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
828 /* unmute pins for output (no gain on this amp) */
829 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
831 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
832 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
834 /* Mic1 (rear panel) pin widget for input and vref at 80% */
835 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
836 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
837 /* Mic2 (as headphone out) for HP output */
838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
840 /* Line In pin widget for input */
841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
843 /* Line2 (as front mic) pin widget for input and vref at 80% */
844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
846 /* CD pin widget for input */
847 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
853 * W810 pin configuration:
854 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
856 static struct hda_verb alc880_pin_w810_init_verbs[] = {
857 /* hphone/speaker input selector: front DAC */
858 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
874 * Z71V pin configuration:
875 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
877 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
880 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
883 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
886 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
892 * 6-stack pin configuration:
893 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
894 * line = 0x1a, HP = 0x1b
896 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
897 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
904 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
905 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
906 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
908 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
914 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
915 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
923 * F1734 pin configuration:
924 * HP = 0x14, speaker-out = 0x15, mic = 0x18
926 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
927 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
928 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
929 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
930 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
932 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
933 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
937 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
939 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
941 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
952 * ASUS pin configuration:
953 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
955 static struct hda_verb alc880_pin_asus_init_verbs[] = {
956 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
957 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
958 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
959 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
965 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
967 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
972 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
978 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
983 /* Enable GPIO mask and set output */
984 static struct hda_verb alc880_gpio1_init_verbs[] = {
985 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
986 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
987 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
990 /* Enable GPIO mask and set output */
991 static struct hda_verb alc880_gpio2_init_verbs[] = {
992 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
993 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
994 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1001 static int alc_init(struct hda_codec *codec)
1003 struct alc_spec *spec = codec->spec;
1006 for (i = 0; i < spec->num_init_verbs; i++)
1007 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1015 static int alc_resume(struct hda_codec *codec)
1017 struct alc_spec *spec = codec->spec;
1021 for (i = 0; i < spec->num_mixers; i++)
1022 snd_hda_resume_ctls(codec, spec->mixers[i]);
1023 if (spec->multiout.dig_out_nid)
1024 snd_hda_resume_spdif_out(codec);
1025 if (spec->dig_in_nid)
1026 snd_hda_resume_spdif_in(codec);
1033 * Analog playback callbacks
1035 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1036 struct hda_codec *codec,
1037 snd_pcm_substream_t *substream)
1039 struct alc_spec *spec = codec->spec;
1040 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1043 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1044 struct hda_codec *codec,
1045 unsigned int stream_tag,
1046 unsigned int format,
1047 snd_pcm_substream_t *substream)
1049 struct alc_spec *spec = codec->spec;
1050 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1054 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1055 struct hda_codec *codec,
1056 snd_pcm_substream_t *substream)
1058 struct alc_spec *spec = codec->spec;
1059 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1065 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1066 struct hda_codec *codec,
1067 snd_pcm_substream_t *substream)
1069 struct alc_spec *spec = codec->spec;
1070 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1073 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1074 struct hda_codec *codec,
1075 snd_pcm_substream_t *substream)
1077 struct alc_spec *spec = codec->spec;
1078 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1084 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1085 struct hda_codec *codec,
1086 unsigned int stream_tag,
1087 unsigned int format,
1088 snd_pcm_substream_t *substream)
1090 struct alc_spec *spec = codec->spec;
1092 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1093 stream_tag, 0, format);
1097 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1098 struct hda_codec *codec,
1099 snd_pcm_substream_t *substream)
1101 struct alc_spec *spec = codec->spec;
1103 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1110 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1114 /* NID is set in alc_build_pcms */
1116 .open = alc880_playback_pcm_open,
1117 .prepare = alc880_playback_pcm_prepare,
1118 .cleanup = alc880_playback_pcm_cleanup
1122 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1126 /* NID is set in alc_build_pcms */
1128 .prepare = alc880_capture_pcm_prepare,
1129 .cleanup = alc880_capture_pcm_cleanup
1133 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1137 /* NID is set in alc_build_pcms */
1139 .open = alc880_dig_playback_pcm_open,
1140 .close = alc880_dig_playback_pcm_close
1144 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1148 /* NID is set in alc_build_pcms */
1151 static int alc_build_pcms(struct hda_codec *codec)
1153 struct alc_spec *spec = codec->spec;
1154 struct hda_pcm *info = spec->pcm_rec;
1157 codec->num_pcms = 1;
1158 codec->pcm_info = info;
1160 info->name = spec->stream_name_analog;
1161 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1162 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1163 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1164 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1166 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1167 for (i = 0; i < spec->num_channel_mode; i++) {
1168 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1169 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1173 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1176 info->name = spec->stream_name_digital;
1177 if (spec->multiout.dig_out_nid) {
1178 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1179 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1181 if (spec->dig_in_nid) {
1182 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1183 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1190 static void alc_free(struct hda_codec *codec)
1192 struct alc_spec *spec = codec->spec;
1198 if (spec->kctl_alloc) {
1199 for (i = 0; i < spec->num_kctl_used; i++)
1200 kfree(spec->kctl_alloc[i].name);
1201 kfree(spec->kctl_alloc);
1208 static struct hda_codec_ops alc_patch_ops = {
1209 .build_controls = alc_build_controls,
1210 .build_pcms = alc_build_pcms,
1214 .resume = alc_resume,
1220 * Test configuration for debugging
1222 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1225 #ifdef CONFIG_SND_DEBUG
1226 static hda_nid_t alc880_test_dac_nids[4] = {
1227 0x02, 0x03, 0x04, 0x05
1230 static struct hda_input_mux alc880_test_capture_source = {
1241 static struct alc_channel_mode alc880_test_modes[4] = {
1248 static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1250 static char *texts[] = {
1251 "N/A", "Line Out", "HP Out",
1252 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1254 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1256 uinfo->value.enumerated.items = 8;
1257 if (uinfo->value.enumerated.item >= 8)
1258 uinfo->value.enumerated.item = 7;
1259 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1263 static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1265 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1266 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1267 unsigned int pin_ctl, item = 0;
1269 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1270 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1271 if (pin_ctl & AC_PINCTL_OUT_EN) {
1272 if (pin_ctl & AC_PINCTL_HP_EN)
1276 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1277 switch (pin_ctl & AC_PINCTL_VREFEN) {
1278 case AC_PINCTL_VREF_HIZ: item = 3; break;
1279 case AC_PINCTL_VREF_50: item = 4; break;
1280 case AC_PINCTL_VREF_GRD: item = 5; break;
1281 case AC_PINCTL_VREF_80: item = 6; break;
1282 case AC_PINCTL_VREF_100: item = 7; break;
1285 ucontrol->value.enumerated.item[0] = item;
1289 static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1292 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1293 static unsigned int ctls[] = {
1294 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1295 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1296 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1297 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1298 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1299 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1301 unsigned int old_ctl, new_ctl;
1303 old_ctl = snd_hda_codec_read(codec, nid, 0,
1304 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1305 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1306 if (old_ctl != new_ctl) {
1307 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1308 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1309 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1315 static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1317 static char *texts[] = {
1318 "Front", "Surround", "CLFE", "Side"
1320 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1322 uinfo->value.enumerated.items = 4;
1323 if (uinfo->value.enumerated.item >= 4)
1324 uinfo->value.enumerated.item = 3;
1325 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1329 static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1332 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1335 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1336 ucontrol->value.enumerated.item[0] = sel & 3;
1340 static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1343 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1346 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1347 if (ucontrol->value.enumerated.item[0] != sel) {
1348 sel = ucontrol->value.enumerated.item[0] & 3;
1349 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1355 #define PIN_CTL_TEST(xname,nid) { \
1356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1358 .info = alc_test_pin_ctl_info, \
1359 .get = alc_test_pin_ctl_get, \
1360 .put = alc_test_pin_ctl_put, \
1361 .private_value = nid \
1364 #define PIN_SRC_TEST(xname,nid) { \
1365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1367 .info = alc_test_pin_src_info, \
1368 .get = alc_test_pin_src_get, \
1369 .put = alc_test_pin_src_put, \
1370 .private_value = nid \
1373 static snd_kcontrol_new_t alc880_test_mixer[] = {
1374 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1375 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1376 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1377 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1378 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1379 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1380 ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT),
1381 ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT),
1382 PIN_CTL_TEST("Front Pin Mode", 0x14),
1383 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1384 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1385 PIN_CTL_TEST("Side Pin Mode", 0x17),
1386 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1387 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1388 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1389 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1390 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1391 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1392 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1393 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1394 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1395 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1396 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1397 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1398 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1399 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1400 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1401 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1402 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1403 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1404 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1405 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1406 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1407 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1409 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1410 .name = "Input Source",
1412 .info = alc_mux_enum_info,
1413 .get = alc_mux_enum_get,
1414 .put = alc_mux_enum_put,
1417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1418 .name = "Channel Mode",
1419 .info = alc880_ch_mode_info,
1420 .get = alc880_ch_mode_get,
1421 .put = alc880_ch_mode_put,
1426 static struct hda_verb alc880_test_init_verbs[] = {
1427 /* Unmute inputs of 0x0c - 0x0f */
1428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1435 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1436 /* Vol output for 0x0c-0x0f */
1437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1440 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1441 /* Set output pins 0x14-0x17 */
1442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1444 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1445 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1446 /* Unmute output pins 0x14-0x17 */
1447 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1449 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1450 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1451 /* Set input pins 0x18-0x1c */
1452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1454 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1456 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1457 /* Mute input pins 0x18-0x1b */
1458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1460 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1461 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1464 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1466 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1468 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1469 /* Analog input/passthru */
1470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1482 static struct hda_board_config alc880_cfg_tbl[] = {
1483 /* Back 3 jack, front 2 jack */
1484 { .modelname = "3stack", .config = ALC880_3ST },
1485 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1486 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1487 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1488 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1489 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1490 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1491 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1492 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1493 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1494 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1495 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1496 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1497 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1498 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1499 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1500 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1501 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1502 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1503 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1504 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1505 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1506 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1507 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1508 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1509 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1510 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1511 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1512 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1513 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1514 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1515 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1516 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
1518 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1519 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1520 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
1522 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1523 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
1524 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
1526 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1527 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1528 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1529 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
1531 /* Back 5 jack, front 2 jack */
1532 { .modelname = "5stack", .config = ALC880_5ST },
1533 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1534 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1535 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1536 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
1537 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
1539 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1540 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
1541 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1542 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1543 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1544 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1545 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1546 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1547 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1548 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1549 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1550 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG },
1551 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1552 { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG },
1554 { .modelname = "w810", .config = ALC880_W810 },
1555 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
1557 { .modelname = "z71v", .config = ALC880_Z71V },
1558 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1560 { .modelname = "6statack-digout", .config = ALC880_6ST_DIG },
1561 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1562 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1563 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1564 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1566 { .modelname = "asus", .config = ALC880_ASUS },
1567 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1568 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1569 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1570 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1571 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1572 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1573 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1574 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1575 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1576 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1578 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1579 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1581 { .modelname = "F1734", .config = ALC880_F1734 },
1582 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1584 #ifdef CONFIG_SND_DEBUG
1585 { .modelname = "test", .config = ALC880_TEST },
1592 * configuration template - to be copied to the spec instance
1594 struct alc_config_preset {
1595 snd_kcontrol_new_t *mixers[4];
1596 const struct hda_verb *init_verbs[4];
1597 unsigned int num_dacs;
1598 hda_nid_t *dac_nids;
1599 hda_nid_t dig_out_nid; /* optional */
1600 hda_nid_t hp_nid; /* optional */
1601 unsigned int num_adc_nids;
1602 hda_nid_t *adc_nids;
1603 unsigned int num_channel_mode;
1604 const struct alc_channel_mode *channel_mode;
1605 const struct hda_input_mux *input_mux;
1608 static struct alc_config_preset alc880_presets[] = {
1610 .mixers = { alc880_three_stack_mixer },
1611 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1612 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1613 .dac_nids = alc880_dac_nids,
1614 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1615 .channel_mode = alc880_threestack_modes,
1616 .input_mux = &alc880_capture_source,
1618 [ALC880_3ST_DIG] = {
1619 .mixers = { alc880_three_stack_mixer },
1620 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1621 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1622 .dac_nids = alc880_dac_nids,
1623 .dig_out_nid = ALC880_DIGOUT_NID,
1624 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1625 .channel_mode = alc880_threestack_modes,
1626 .input_mux = &alc880_capture_source,
1629 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1630 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1631 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1632 .dac_nids = alc880_dac_nids,
1633 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1634 .channel_mode = alc880_fivestack_modes,
1635 .input_mux = &alc880_capture_source,
1637 [ALC880_5ST_DIG] = {
1638 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1639 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1640 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1641 .dac_nids = alc880_dac_nids,
1642 .dig_out_nid = ALC880_DIGOUT_NID,
1643 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1644 .channel_mode = alc880_fivestack_modes,
1645 .input_mux = &alc880_capture_source,
1647 [ALC880_6ST_DIG] = {
1648 .mixers = { alc880_six_stack_mixer },
1649 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1650 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1651 .dac_nids = alc880_6st_dac_nids,
1652 .dig_out_nid = ALC880_DIGOUT_NID,
1653 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1654 .channel_mode = alc880_sixstack_modes,
1655 .input_mux = &alc880_6stack_capture_source,
1658 .mixers = { alc880_w810_base_mixer },
1659 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs },
1660 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1661 .dac_nids = alc880_w810_dac_nids,
1662 .dig_out_nid = ALC880_DIGOUT_NID,
1663 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1664 .channel_mode = alc880_w810_modes,
1665 .input_mux = &alc880_capture_source,
1668 .mixers = { alc880_z71v_mixer },
1669 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs,
1670 alc880_gpio2_init_verbs },
1671 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1672 .dac_nids = alc880_z71v_dac_nids,
1673 .dig_out_nid = ALC880_DIGOUT_NID,
1675 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1676 .channel_mode = alc880_2_jack_modes,
1677 .input_mux = &alc880_capture_source,
1680 .mixers = { alc880_f1734_mixer },
1681 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1682 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1683 .dac_nids = alc880_f1734_dac_nids,
1685 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1686 .channel_mode = alc880_2_jack_modes,
1687 .input_mux = &alc880_capture_source,
1690 .mixers = { alc880_asus_mixer },
1691 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1692 alc880_gpio1_init_verbs },
1693 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1694 .dac_nids = alc880_asus_dac_nids,
1695 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1696 .channel_mode = alc880_asus_modes,
1697 .input_mux = &alc880_capture_source,
1699 [ALC880_ASUS_DIG] = {
1700 .mixers = { alc880_asus_mixer },
1701 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1702 alc880_gpio1_init_verbs },
1703 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1704 .dac_nids = alc880_asus_dac_nids,
1705 .dig_out_nid = ALC880_DIGOUT_NID,
1706 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1707 .channel_mode = alc880_asus_modes,
1708 .input_mux = &alc880_capture_source,
1710 [ALC880_ASUS_W1V] = {
1711 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1712 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1713 alc880_gpio1_init_verbs },
1714 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1715 .dac_nids = alc880_asus_dac_nids,
1716 .dig_out_nid = ALC880_DIGOUT_NID,
1717 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1718 .channel_mode = alc880_asus_modes,
1719 .input_mux = &alc880_capture_source,
1721 [ALC880_UNIWILL_DIG] = {
1722 .mixers = { alc880_asus_mixer },
1723 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1724 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1725 .dac_nids = alc880_asus_dac_nids,
1726 .dig_out_nid = ALC880_DIGOUT_NID,
1727 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1728 .channel_mode = alc880_asus_modes,
1729 .input_mux = &alc880_capture_source,
1731 #ifdef CONFIG_SND_DEBUG
1733 .mixers = { alc880_test_mixer },
1734 .init_verbs = { alc880_test_init_verbs },
1735 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1736 .dac_nids = alc880_test_dac_nids,
1737 .dig_out_nid = ALC880_DIGOUT_NID,
1738 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1739 .channel_mode = alc880_test_modes,
1740 .input_mux = &alc880_test_capture_source,
1746 * Automatic parse of I/O pins from the BIOS configuration
1749 #define NUM_CONTROL_ALLOC 32
1750 #define NUM_VERB_ALLOC 32
1754 ALC_CTL_WIDGET_MUTE,
1757 static snd_kcontrol_new_t alc880_control_templates[] = {
1758 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1759 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1760 ALC_BIND_MUTE(NULL, 0, 0, 0),
1763 /* add dynamic controls */
1764 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1766 snd_kcontrol_new_t *knew;
1768 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1769 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1771 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1774 if (spec->kctl_alloc) {
1775 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1776 kfree(spec->kctl_alloc);
1778 spec->kctl_alloc = knew;
1779 spec->num_kctl_alloc = num;
1782 knew = &spec->kctl_alloc[spec->num_kctl_used];
1783 *knew = alc880_control_templates[type];
1784 knew->name = kstrdup(name, GFP_KERNEL);
1787 knew->private_value = val;
1788 spec->num_kctl_used++;
1792 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1793 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1794 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1795 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1796 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
1797 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
1798 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
1799 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
1800 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1801 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
1802 #define ALC880_PIN_CD_NID 0x1c
1804 /* fill in the dac_nids table from the parsed pin configuration */
1805 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1811 memset(assigned, 0, sizeof(assigned));
1813 /* check the pins hardwired to audio widget */
1814 for (i = 0; i < cfg->line_outs; i++) {
1815 nid = cfg->line_out_pins[i];
1816 if (alc880_is_fixed_pin(nid)) {
1817 int idx = alc880_fixed_pin_idx(nid);
1818 spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
1822 /* left pins can be connect to any audio widget */
1823 for (i = 0; i < cfg->line_outs; i++) {
1824 nid = cfg->line_out_pins[i];
1825 if (alc880_is_fixed_pin(nid))
1827 /* search for an empty channel */
1828 for (j = 0; j < cfg->line_outs; j++) {
1829 if (! assigned[j]) {
1830 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1836 spec->multiout.num_dacs = cfg->line_outs;
1840 /* add playback controls from the parsed DAC table */
1841 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1844 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1848 for (i = 0; i < cfg->line_outs; i++) {
1849 if (! spec->multiout.dac_nids[i])
1851 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
1854 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
1855 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1857 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
1858 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1860 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
1861 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
1863 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
1864 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
1867 sprintf(name, "%s Playback Volume", chname[i]);
1868 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1869 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1871 sprintf(name, "%s Playback Switch", chname[i]);
1872 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
1873 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1881 /* add playback controls for HP output */
1882 static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
1890 if (alc880_is_fixed_pin(pin)) {
1891 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
1892 if (! spec->multiout.dac_nids[0]) {
1893 /* use this as the primary output */
1894 spec->multiout.dac_nids[0] = nid;
1895 if (! spec->multiout.num_dacs)
1896 spec->multiout.num_dacs = 1;
1898 /* specify the DAC as the extra HP output */
1899 spec->multiout.hp_nid = nid;
1900 /* control HP volume/switch on the output mixer amp */
1901 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
1902 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
1903 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1905 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
1906 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1908 } else if (alc880_is_multi_pin(pin)) {
1909 /* set manual connection */
1910 if (! spec->multiout.dac_nids[0]) {
1911 /* use this as the primary output */
1912 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
1913 if (! spec->multiout.num_dacs)
1914 spec->multiout.num_dacs = 1;
1916 /* we have only a switch on HP-out PIN */
1917 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
1918 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
1924 /* create input playback/capture controls for the given pin */
1925 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
1930 sprintf(name, "%s Playback Volume", ctlname);
1931 idx = alc880_input_pin_idx(pin);
1932 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1933 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1935 sprintf(name, "%s Playback Switch", ctlname);
1936 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
1937 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1942 /* create playback/capture controls for input pins */
1943 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1945 static char *labels[AUTO_PIN_LAST] = {
1946 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
1948 struct hda_input_mux *imux = &spec->private_imux;
1951 for (i = 0; i < AUTO_PIN_LAST; i++) {
1952 if (alc880_is_input_pin(cfg->input_pins[i])) {
1953 err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
1956 imux->items[imux->num_items].label = labels[i];
1957 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
1964 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
1968 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1969 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
1970 /* need the manual connection? */
1971 if (alc880_is_multi_pin(nid)) {
1972 struct alc_spec *spec = codec->spec;
1973 int idx = alc880_multi_pin_idx(nid);
1974 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
1975 AC_VERB_SET_CONNECT_SEL,
1976 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
1980 static void alc880_auto_init_multi_out(struct hda_codec *codec)
1982 struct alc_spec *spec = codec->spec;
1985 for (i = 0; i < spec->autocfg.line_outs; i++) {
1986 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1987 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
1991 static void alc880_auto_init_hp_out(struct hda_codec *codec)
1993 struct alc_spec *spec = codec->spec;
1996 pin = spec->autocfg.hp_pin;
1997 if (pin) /* connect to front */
1998 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2001 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2003 struct alc_spec *spec = codec->spec;
2006 for (i = 0; i < AUTO_PIN_LAST; i++) {
2007 hda_nid_t nid = spec->autocfg.input_pins[i];
2008 if (alc880_is_input_pin(nid)) {
2009 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2010 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2011 if (nid != ALC880_PIN_CD_NID)
2012 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2018 /* parse the BIOS configuration and set up the alc_spec */
2019 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2020 static int alc880_parse_auto_config(struct hda_codec *codec)
2022 struct alc_spec *spec = codec->spec;
2025 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
2027 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
2029 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
2030 return 0; /* can't find valid BIOS pin config */
2031 if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2032 (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
2033 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2036 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2038 if (spec->autocfg.dig_out_pin)
2039 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2040 if (spec->autocfg.dig_in_pin)
2041 spec->dig_in_nid = ALC880_DIGIN_NID;
2043 if (spec->kctl_alloc)
2044 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2046 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2048 spec->input_mux = &spec->private_imux;
2053 /* init callback for auto-configuration model -- overriding the default init */
2054 static int alc880_auto_init(struct hda_codec *codec)
2057 alc880_auto_init_multi_out(codec);
2058 alc880_auto_init_hp_out(codec);
2059 alc880_auto_init_analog_input(codec);
2064 * OK, here we have finally the patch for ALC880
2067 static int patch_alc880(struct hda_codec *codec)
2069 struct alc_spec *spec;
2073 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2077 init_MUTEX(&spec->bind_mutex);
2080 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2081 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2082 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2083 board_config = ALC880_AUTO;
2086 if (board_config == ALC880_AUTO) {
2087 /* automatic parse from the BIOS config */
2088 err = alc880_parse_auto_config(codec);
2093 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2094 board_config = ALC880_3ST;
2098 if (board_config != ALC880_AUTO) {
2099 /* set up from the preset table */
2100 const struct alc_config_preset *preset;
2102 preset = &alc880_presets[board_config];
2104 for (i = 0; preset->mixers[i]; i++) {
2105 snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
2106 spec->mixers[spec->num_mixers++] = preset->mixers[i];
2108 for (i = 0; preset->init_verbs[i]; i++) {
2109 snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
2110 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
2113 spec->channel_mode = preset->channel_mode;
2114 spec->num_channel_mode = preset->num_channel_mode;
2116 spec->multiout.max_channels = spec->channel_mode[0].channels;
2118 spec->multiout.num_dacs = preset->num_dacs;
2119 spec->multiout.dac_nids = preset->dac_nids;
2120 spec->multiout.dig_out_nid = preset->dig_out_nid;
2121 spec->multiout.hp_nid = preset->hp_nid;
2123 spec->input_mux = preset->input_mux;
2125 spec->num_adc_nids = preset->num_adc_nids;
2126 spec->adc_nids = preset->adc_nids;
2129 spec->stream_name_analog = "ALC880 Analog";
2130 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2131 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2133 spec->stream_name_digital = "ALC880 Digital";
2134 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2135 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2137 if (! spec->adc_nids && spec->input_mux) {
2138 /* check whether NID 0x07 is valid */
2139 unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
2140 AC_PAR_AUDIO_WIDGET_CAP);
2141 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2142 if (wcap != AC_WID_AUD_IN) {
2143 spec->adc_nids = alc880_adc_nids_alt;
2144 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2145 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2148 spec->adc_nids = alc880_adc_nids;
2149 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2150 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2155 codec->patch_ops = alc_patch_ops;
2156 if (board_config == ALC880_AUTO)
2157 codec->patch_ops.init = alc880_auto_init;
2167 static hda_nid_t alc260_dac_nids[1] = {
2172 static hda_nid_t alc260_adc_nids[1] = {
2177 static hda_nid_t alc260_hp_adc_nids[1] = {
2182 #define ALC260_DIGOUT_NID 0x03
2183 #define ALC260_DIGIN_NID 0x06
2185 static struct hda_input_mux alc260_capture_source = {
2189 { "Front Mic", 0x1 },
2196 * This is just place-holder, so there's something for alc_build_pcms to look
2197 * at when it calculates the maximum number of channels. ALC260 has no mixer
2198 * element which allows changing the channel mode, so the verb list is
2201 static struct alc_channel_mode alc260_modes[1] = {
2205 static snd_kcontrol_new_t alc260_base_mixer[] = {
2206 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2207 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2209 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2210 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2211 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2212 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2213 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2216 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2217 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2219 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2220 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2221 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
2222 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2223 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2226 .name = "Capture Source",
2227 .info = alc_mux_enum_info,
2228 .get = alc_mux_enum_get,
2229 .put = alc_mux_enum_put,
2234 static snd_kcontrol_new_t alc260_hp_mixer[] = {
2235 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2236 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2237 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2238 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2239 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2240 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2242 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2243 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2246 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2247 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2248 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
2249 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2250 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2253 .name = "Capture Source",
2254 .info = alc_mux_enum_info,
2255 .get = alc_mux_enum_get,
2256 .put = alc_mux_enum_put,
2261 static struct hda_verb alc260_init_verbs[] = {
2262 /* Line In pin widget for input */
2263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2264 /* CD pin widget for input */
2265 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2266 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2267 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2268 /* Mic2 (front panel) pin widget for input and vref at 80% */
2269 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2270 /* LINE-2 is used for line-out in rear */
2271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2272 /* select line-out */
2273 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2275 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2277 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2279 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2280 /* mute capture amp left and right */
2281 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2282 /* set connection select to line in (default select for this ADC) */
2283 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2284 /* mute capture amp left and right */
2285 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2286 /* set connection select to line in (default select for this ADC) */
2287 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
2288 /* set vol=0 Line-Out mixer amp left and right */
2289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2290 /* unmute pin widget amp left and right (no gain on this amp) */
2291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2292 /* set vol=0 HP mixer amp left and right */
2293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2294 /* unmute pin widget amp left and right (no gain on this amp) */
2295 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2296 /* set vol=0 Mono mixer amp left and right */
2297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2298 /* unmute pin widget amp left and right (no gain on this amp) */
2299 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2300 /* unmute LINE-2 out pin */
2301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2309 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2310 /* mute Front out path */
2311 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2313 /* mute Headphone out path */
2314 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2315 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2316 /* mute Mono out path */
2317 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2318 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2322 static struct hda_pcm_stream alc260_pcm_analog_playback = {
2328 static struct hda_pcm_stream alc260_pcm_analog_capture = {
2334 static struct hda_board_config alc260_cfg_tbl[] = {
2335 { .modelname = "hp", .config = ALC260_HP },
2336 { .pci_subvendor = 0x103c, .config = ALC260_HP },
2340 static int patch_alc260(struct hda_codec *codec)
2342 struct alc_spec *spec;
2345 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2349 init_MUTEX(&spec->bind_mutex);
2352 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
2353 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
2354 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
2355 board_config = ALC260_BASIC;
2358 switch (board_config) {
2360 spec->mixers[spec->num_mixers] = alc260_hp_mixer;
2364 spec->mixers[spec->num_mixers] = alc260_base_mixer;
2369 spec->init_verbs[0] = alc260_init_verbs;
2370 spec->num_init_verbs = 1;
2372 spec->channel_mode = alc260_modes;
2373 spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
2375 spec->stream_name_analog = "ALC260 Analog";
2376 spec->stream_analog_playback = &alc260_pcm_analog_playback;
2377 spec->stream_analog_capture = &alc260_pcm_analog_capture;
2379 spec->multiout.max_channels = spec->channel_mode[0].channels;
2380 spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
2381 spec->multiout.dac_nids = alc260_dac_nids;
2383 spec->input_mux = &alc260_capture_source;
2384 switch (board_config) {
2386 spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
2387 spec->adc_nids = alc260_hp_adc_nids;
2390 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2391 spec->adc_nids = alc260_adc_nids;
2395 codec->patch_ops = alc_patch_ops;
2404 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
2405 * configuration. Each pin widget can choose any input DACs and a mixer.
2406 * Each ADC is connected from a mixer of all inputs. This makes possible
2407 * 6-channel independent captures.
2409 * In addition, an independent DAC for the multi-playback (not used in this
2413 static struct alc_channel_mode alc882_ch_modes[1] = {
2417 static hda_nid_t alc882_dac_nids[4] = {
2418 /* front, rear, clfe, rear_surr */
2419 0x02, 0x03, 0x04, 0x05
2422 static hda_nid_t alc882_adc_nids[3] = {
2428 /* FIXME: should be a matrix-type input source selection */
2430 static struct hda_input_mux alc882_capture_source = {
2434 { "Front Mic", 0x1 },
2440 #define alc882_mux_enum_info alc_mux_enum_info
2441 #define alc882_mux_enum_get alc_mux_enum_get
2443 static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
2445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2446 struct alc_spec *spec = codec->spec;
2447 const struct hda_input_mux *imux = spec->input_mux;
2448 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2449 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
2450 hda_nid_t nid = capture_mixers[adc_idx];
2451 unsigned int *cur_val = &spec->cur_mux[adc_idx];
2452 unsigned int i, idx;
2454 idx = ucontrol->value.enumerated.item[0];
2455 if (idx >= imux->num_items)
2456 idx = imux->num_items - 1;
2457 if (*cur_val == idx && ! codec->in_resume)
2459 for (i = 0; i < imux->num_items; i++) {
2460 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
2461 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2462 v | (imux->items[i].index << 8));
2468 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
2469 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
2471 static snd_kcontrol_new_t alc882_base_mixer[] = {
2472 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2473 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2474 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2475 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2476 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2477 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2478 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2479 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT),
2480 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2481 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2482 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2483 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2484 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2485 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2486 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2487 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2488 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2489 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2490 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2491 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
2492 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
2493 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
2494 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
2495 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
2496 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
2497 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
2498 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
2500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2501 /* .name = "Capture Source", */
2502 .name = "Input Source",
2504 .info = alc882_mux_enum_info,
2505 .get = alc882_mux_enum_get,
2506 .put = alc882_mux_enum_put,
2511 static struct hda_verb alc882_init_verbs[] = {
2512 /* Front mixer: unmute input/output amp left and right (volume = 0) */
2513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2529 /* Front Pin: output 0 (0x0c) */
2530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2532 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2533 /* Rear Pin: output 1 (0x0d) */
2534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2536 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
2537 /* CLFE Pin: output 2 (0x0e) */
2538 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2540 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2541 /* Side Pin: output 3 (0x0f) */
2542 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2543 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2544 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2545 /* Mic (rear) pin: input vref at 80% */
2546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2548 /* Front Mic pin: input vref at 80% */
2549 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2551 /* Line In pin: input */
2552 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2554 /* Line-2 In: Headphone output (output 0 - 0x0c) */
2555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2556 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2557 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2558 /* CD pin widget for input */
2559 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2561 /* FIXME: use matrix-type input source selection */
2562 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
2563 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
2564 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2566 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2578 /* ADC1: mute amp left and right */
2579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2580 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2581 /* ADC2: mute amp left and right */
2582 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2583 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2584 /* ADC3: mute amp left and right */
2585 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2586 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2591 static int patch_alc882(struct hda_codec *codec)
2593 struct alc_spec *spec;
2595 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2599 init_MUTEX(&spec->bind_mutex);
2602 spec->mixers[spec->num_mixers] = alc882_base_mixer;
2605 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2606 spec->dig_in_nid = ALC880_DIGIN_NID;
2607 spec->init_verbs[0] = alc882_init_verbs;
2608 spec->num_init_verbs = 1;
2610 spec->channel_mode = alc882_ch_modes;
2611 spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
2613 spec->stream_name_analog = "ALC882 Analog";
2614 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2615 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2617 spec->stream_name_digital = "ALC882 Digital";
2618 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2619 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2621 spec->multiout.max_channels = spec->channel_mode[0].channels;
2622 spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
2623 spec->multiout.dac_nids = alc882_dac_nids;
2625 spec->input_mux = &alc882_capture_source;
2626 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
2627 spec->adc_nids = alc882_adc_nids;
2629 codec->patch_ops = alc_patch_ops;
2637 struct hda_codec_preset snd_hda_preset_realtek[] = {
2638 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
2639 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
2640 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },