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;
122 hda_nid_t private_dac_nids[4];
129 static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
132 struct alc_spec *spec = codec->spec;
133 return snd_hda_input_mux_info(spec->input_mux, uinfo);
136 static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
138 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
139 struct alc_spec *spec = codec->spec;
140 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
142 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
146 static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
148 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
149 struct alc_spec *spec = codec->spec;
150 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
151 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
152 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
157 * channel mode setting
159 struct alc_channel_mode {
161 const struct hda_verb *sequence;
164 static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
166 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
167 struct alc_spec *spec = codec->spec;
168 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
170 snd_assert(spec->channel_mode, return -ENXIO);
171 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
173 uinfo->value.enumerated.items = items;
174 if (uinfo->value.enumerated.item >= items)
175 uinfo->value.enumerated.item = items - 1;
176 sprintf(uinfo->value.enumerated.name, "%dch",
177 spec->channel_mode[uinfo->value.enumerated.item].channels);
181 static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
183 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
184 struct alc_spec *spec = codec->spec;
185 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
188 snd_assert(spec->channel_mode, return -ENXIO);
189 for (i = 0; i < items; i++) {
190 if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
191 ucontrol->value.enumerated.item[0] = i;
198 static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
201 struct alc_spec *spec = codec->spec;
204 snd_assert(spec->channel_mode, return -ENXIO);
205 mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
206 if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
210 /* change the current channel setting */
211 spec->multiout.max_channels = spec->channel_mode[mode].channels;
212 if (spec->channel_mode[mode].sequence)
213 snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
220 * bound volume controls
222 * bind multiple volumes (# indices, from 0)
225 #define AMP_VAL_IDX_SHIFT 19
226 #define AMP_VAL_IDX_MASK (0x0f<<19)
228 static int alc_bind_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
230 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
231 struct alc_spec *spec = codec->spec;
234 down(&spec->bind_mutex);
235 pval = kcontrol->private_value;
236 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
237 snd_hda_mixer_amp_switch_info(kcontrol, uinfo);
238 kcontrol->private_value = pval;
239 up(&spec->bind_mutex);
243 static int alc_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
246 struct alc_spec *spec = codec->spec;
249 down(&spec->bind_mutex);
250 pval = kcontrol->private_value;
251 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
252 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
253 kcontrol->private_value = pval;
254 up(&spec->bind_mutex);
258 static int alc_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
260 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
261 struct alc_spec *spec = codec->spec;
263 int i, indices, change = 0;
265 down(&spec->bind_mutex);
266 pval = kcontrol->private_value;
267 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
268 for (i = 0; i < indices; i++) {
269 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
270 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
272 kcontrol->private_value = pval;
273 up(&spec->bind_mutex);
277 #define ALC_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
278 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
279 .info = alc_bind_switch_info, \
280 .get = alc_bind_switch_get, \
281 .put = alc_bind_switch_put, \
282 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
284 #define ALC_BIND_MUTE(xname,nid,indices,dir) ALC_BIND_MUTE_MONO(xname,nid,3,indices,dir)
288 * ALC880 3-stack model
290 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
291 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
295 static hda_nid_t alc880_dac_nids[4] = {
296 /* front, rear, clfe, rear_surr */
297 0x02, 0x05, 0x04, 0x03
300 static hda_nid_t alc880_adc_nids[3] = {
305 /* The datasheet says the node 0x07 is connected from inputs,
306 * but it shows zero connection in the real implementation on some devices.
308 static hda_nid_t alc880_adc_nids_alt[2] = {
313 #define ALC880_DIGOUT_NID 0x06
314 #define ALC880_DIGIN_NID 0x0a
316 static struct hda_input_mux alc880_capture_source = {
320 { "Front Mic", 0x3 },
326 /* channel source setting (2/6 channel selection for 3-stack) */
328 static struct hda_verb alc880_threestack_ch2_init[] = {
329 /* set line-in to input, mute it */
330 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
331 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
332 /* set mic-in to input vref 80%, mute it */
333 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
334 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
339 static struct hda_verb alc880_threestack_ch6_init[] = {
340 /* set line-in to output, unmute it */
341 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
342 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
343 /* set mic-in to output, unmute it */
344 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
345 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
349 static struct alc_channel_mode alc880_threestack_modes[2] = {
350 { 2, alc880_threestack_ch2_init },
351 { 6, alc880_threestack_ch6_init },
354 static snd_kcontrol_new_t alc880_three_stack_mixer[] = {
355 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
356 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
357 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
358 ALC_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
359 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
360 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
361 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
362 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
363 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
364 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
366 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
369 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
370 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
371 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
372 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
376 .name = "Channel Mode",
377 .info = alc880_ch_mode_info,
378 .get = alc880_ch_mode_get,
379 .put = alc880_ch_mode_put,
384 /* capture mixer elements */
385 static snd_kcontrol_new_t alc880_capture_mixer[] = {
386 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
387 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
388 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
389 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
390 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
391 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
394 /* The multiple "Capture Source" controls confuse alsamixer
395 * So call somewhat different..
396 * FIXME: the controls appear in the "playback" view!
398 /* .name = "Capture Source", */
399 .name = "Input Source",
401 .info = alc_mux_enum_info,
402 .get = alc_mux_enum_get,
403 .put = alc_mux_enum_put,
408 /* capture mixer elements (in case NID 0x07 not available) */
409 static snd_kcontrol_new_t alc880_capture_alt_mixer[] = {
410 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
411 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
412 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
413 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
416 /* The multiple "Capture Source" controls confuse alsamixer
417 * So call somewhat different..
418 * FIXME: the controls appear in the "playback" view!
420 /* .name = "Capture Source", */
421 .name = "Input Source",
423 .info = alc_mux_enum_info,
424 .get = alc_mux_enum_get,
425 .put = alc_mux_enum_put,
433 * ALC880 5-stack model
435 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
436 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
437 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
440 /* additional mixers to alc880_three_stack_mixer */
441 static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
442 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
443 ALC_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
447 /* channel source setting (6/8 channel selection for 5-stack) */
449 static struct hda_verb alc880_fivestack_ch6_init[] = {
450 /* set line-in to input, mute it */
451 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
452 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
457 static struct hda_verb alc880_fivestack_ch8_init[] = {
458 /* set line-in to output, unmute it */
459 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
460 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
464 static struct alc_channel_mode alc880_fivestack_modes[2] = {
465 { 6, alc880_fivestack_ch6_init },
466 { 8, alc880_fivestack_ch8_init },
471 * ALC880 6-stack model
473 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
474 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
475 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
478 static hda_nid_t alc880_6st_dac_nids[4] = {
479 /* front, rear, clfe, rear_surr */
480 0x02, 0x03, 0x04, 0x05
483 static struct hda_input_mux alc880_6stack_capture_source = {
487 { "Front Mic", 0x1 },
493 /* fixed 8-channels */
494 static struct alc_channel_mode alc880_sixstack_modes[1] = {
498 static snd_kcontrol_new_t alc880_six_stack_mixer[] = {
499 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
500 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
501 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
502 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
503 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
504 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
505 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
506 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
507 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
508 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
509 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
510 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
511 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
512 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
515 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
516 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
517 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
518 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
521 .name = "Channel Mode",
522 .info = alc880_ch_mode_info,
523 .get = alc880_ch_mode_get,
524 .put = alc880_ch_mode_put,
533 * W810 has rear IO for:
536 * Center/LFE (DAC 04)
539 * The system also has a pair of internal speakers, and a headphone jack.
540 * These are both connected to Line2 on the codec, hence to DAC 02.
542 * There is a variable resistor to control the speaker or headphone
543 * volume. This is a hardware-only device without a software API.
545 * Plugging headphones in will disable the internal speakers. This is
546 * implemented in hardware, not via the driver using jack sense. In
547 * a similar fashion, plugging into the rear socket marked "front" will
548 * disable both the speakers and headphones.
550 * For input, there's a microphone jack, and an "audio in" jack.
551 * These may not do anything useful with this driver yet, because I
552 * haven't setup any initialization verbs for these yet...
555 static hda_nid_t alc880_w810_dac_nids[3] = {
556 /* front, rear/surround, clfe */
560 /* fixed 6 channels */
561 static struct alc_channel_mode alc880_w810_modes[1] = {
565 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
566 static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
568 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
569 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
570 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
571 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
572 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
573 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
574 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
575 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
583 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
584 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
587 static hda_nid_t alc880_z71v_dac_nids[1] = {
590 #define ALC880_Z71V_HP_DAC 0x03
592 /* fixed 2 channels */
593 static struct alc_channel_mode alc880_2_jack_modes[1] = {
597 static snd_kcontrol_new_t alc880_z71v_mixer[] = {
598 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
599 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
600 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
601 ALC_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
602 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
603 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
614 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
615 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
618 static hda_nid_t alc880_f1734_dac_nids[1] = {
621 #define ALC880_F1734_HP_DAC 0x02
623 static snd_kcontrol_new_t alc880_f1734_mixer[] = {
624 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
625 ALC_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
626 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
627 ALC_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
628 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
629 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
630 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
640 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
641 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
642 * Mic = 0x18, Line = 0x1a
645 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
646 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
648 static snd_kcontrol_new_t alc880_asus_mixer[] = {
649 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
650 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
651 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
652 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
653 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
654 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
655 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
656 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
657 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
658 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
659 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
660 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
662 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
665 .name = "Channel Mode",
666 .info = alc880_ch_mode_info,
667 .get = alc880_ch_mode_get,
668 .put = alc880_ch_mode_put,
675 * ALC880 ASUS W1V model
677 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
678 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
679 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
682 /* additional mixers to alc880_asus_mixer */
683 static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = {
684 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
685 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
691 * build control elements
693 static int alc_build_controls(struct hda_codec *codec)
695 struct alc_spec *spec = codec->spec;
699 for (i = 0; i < spec->num_mixers; i++) {
700 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
705 if (spec->multiout.dig_out_nid) {
706 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
710 if (spec->dig_in_nid) {
711 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
720 * initialize the codec volumes, etc
724 * generic initialization of ADC, input mixers and output mixers
726 static struct hda_verb alc880_volume_init_verbs[] = {
728 * Unmute ADC0-2 and set the default input to mic-in
730 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
732 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
734 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
737 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
739 * Note: PASD motherboards uses the Line In 2 as the input for front panel
742 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
750 * Set up output mixers (0x0c - 0x0f)
752 /* set vol=0 to output mixers */
753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
756 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
757 /* set up input amps for analog loopback */
758 /* Amp Indices: DAC = 0, mixer = 1 */
759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
760 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
761 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
762 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
763 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
764 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
765 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
766 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
772 * 3-stack pin configuration:
773 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
775 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
777 * preset connection lists of input pins
778 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
780 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
781 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
782 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
785 * Set pin mode and muting
787 /* set front pin widgets 0x14 for output */
788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
790 /* Mic1 (rear panel) pin widget for input and vref at 80% */
791 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
792 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
793 /* Mic2 (as headphone out) for HP output */
794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
796 /* Line In pin widget for input */
797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
799 /* Line2 (as front mic) pin widget for input and vref at 80% */
800 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
801 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
802 /* CD pin widget for input */
803 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
809 * 5-stack pin configuration:
810 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
811 * line-in/side = 0x1a, f-mic = 0x1b
813 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
815 * preset connection lists of input pins
816 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
818 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
819 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
822 * Set pin mode and muting
824 /* set pin widgets 0x14-0x17 for output */
825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
828 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
829 /* unmute pins for output (no gain on this amp) */
830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
831 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
832 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
833 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
835 /* Mic1 (rear panel) pin widget for input and vref at 80% */
836 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
838 /* Mic2 (as headphone out) for HP output */
839 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
841 /* Line In pin widget for input */
842 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
844 /* Line2 (as front mic) pin widget for input and vref at 80% */
845 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
846 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
847 /* CD pin widget for input */
848 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
854 * W810 pin configuration:
855 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
857 static struct hda_verb alc880_pin_w810_init_verbs[] = {
858 /* hphone/speaker input selector: front DAC */
859 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
865 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
868 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
869 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
875 * Z71V pin configuration:
876 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
878 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
881 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
885 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
887 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
893 * 6-stack pin configuration:
894 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
895 * line = 0x1a, HP = 0x1b
897 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
898 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
902 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
904 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
905 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
906 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
907 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
911 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
912 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
915 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
916 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
917 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
924 * F1734 pin configuration:
925 * HP = 0x14, speaker-out = 0x15, mic = 0x18
927 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
928 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
929 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
930 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
931 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
934 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
938 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
940 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
941 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
942 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
943 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
944 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
945 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
946 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
953 * ASUS pin configuration:
954 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
956 static struct hda_verb alc880_pin_asus_init_verbs[] = {
957 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
958 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
959 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
960 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
964 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
966 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
968 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
973 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
975 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
977 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
979 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
984 /* Enable GPIO mask and set output */
985 static struct hda_verb alc880_gpio1_init_verbs[] = {
986 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
987 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
988 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
991 /* Enable GPIO mask and set output */
992 static struct hda_verb alc880_gpio2_init_verbs[] = {
993 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
994 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
995 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1002 static int alc_init(struct hda_codec *codec)
1004 struct alc_spec *spec = codec->spec;
1007 for (i = 0; i < spec->num_init_verbs; i++)
1008 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1016 static int alc_resume(struct hda_codec *codec)
1018 struct alc_spec *spec = codec->spec;
1022 for (i = 0; i < spec->num_mixers; i++)
1023 snd_hda_resume_ctls(codec, spec->mixers[i]);
1024 if (spec->multiout.dig_out_nid)
1025 snd_hda_resume_spdif_out(codec);
1026 if (spec->dig_in_nid)
1027 snd_hda_resume_spdif_in(codec);
1034 * Analog playback callbacks
1036 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1037 struct hda_codec *codec,
1038 snd_pcm_substream_t *substream)
1040 struct alc_spec *spec = codec->spec;
1041 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1044 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1045 struct hda_codec *codec,
1046 unsigned int stream_tag,
1047 unsigned int format,
1048 snd_pcm_substream_t *substream)
1050 struct alc_spec *spec = codec->spec;
1051 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1055 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1056 struct hda_codec *codec,
1057 snd_pcm_substream_t *substream)
1059 struct alc_spec *spec = codec->spec;
1060 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1066 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1067 struct hda_codec *codec,
1068 snd_pcm_substream_t *substream)
1070 struct alc_spec *spec = codec->spec;
1071 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1074 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1075 struct hda_codec *codec,
1076 snd_pcm_substream_t *substream)
1078 struct alc_spec *spec = codec->spec;
1079 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1085 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1086 struct hda_codec *codec,
1087 unsigned int stream_tag,
1088 unsigned int format,
1089 snd_pcm_substream_t *substream)
1091 struct alc_spec *spec = codec->spec;
1093 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1094 stream_tag, 0, format);
1098 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1099 struct hda_codec *codec,
1100 snd_pcm_substream_t *substream)
1102 struct alc_spec *spec = codec->spec;
1104 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1111 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1115 /* NID is set in alc_build_pcms */
1117 .open = alc880_playback_pcm_open,
1118 .prepare = alc880_playback_pcm_prepare,
1119 .cleanup = alc880_playback_pcm_cleanup
1123 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1127 /* NID is set in alc_build_pcms */
1129 .prepare = alc880_capture_pcm_prepare,
1130 .cleanup = alc880_capture_pcm_cleanup
1134 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1138 /* NID is set in alc_build_pcms */
1140 .open = alc880_dig_playback_pcm_open,
1141 .close = alc880_dig_playback_pcm_close
1145 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1149 /* NID is set in alc_build_pcms */
1152 static int alc_build_pcms(struct hda_codec *codec)
1154 struct alc_spec *spec = codec->spec;
1155 struct hda_pcm *info = spec->pcm_rec;
1158 codec->num_pcms = 1;
1159 codec->pcm_info = info;
1161 info->name = spec->stream_name_analog;
1162 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1163 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1164 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1165 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1167 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1168 for (i = 0; i < spec->num_channel_mode; i++) {
1169 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1170 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1174 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1177 info->name = spec->stream_name_digital;
1178 if (spec->multiout.dig_out_nid) {
1179 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1180 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1182 if (spec->dig_in_nid) {
1183 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1184 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1191 static void alc_free(struct hda_codec *codec)
1193 struct alc_spec *spec = codec->spec;
1199 if (spec->kctl_alloc) {
1200 for (i = 0; i < spec->num_kctl_used; i++)
1201 kfree(spec->kctl_alloc[i].name);
1202 kfree(spec->kctl_alloc);
1209 static struct hda_codec_ops alc_patch_ops = {
1210 .build_controls = alc_build_controls,
1211 .build_pcms = alc_build_pcms,
1215 .resume = alc_resume,
1221 * Test configuration for debugging
1223 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1226 #ifdef CONFIG_SND_DEBUG
1227 static hda_nid_t alc880_test_dac_nids[4] = {
1228 0x02, 0x03, 0x04, 0x05
1231 static struct hda_input_mux alc880_test_capture_source = {
1242 static struct alc_channel_mode alc880_test_modes[4] = {
1249 static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1251 static char *texts[] = {
1252 "N/A", "Line Out", "HP Out",
1253 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1255 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1257 uinfo->value.enumerated.items = 8;
1258 if (uinfo->value.enumerated.item >= 8)
1259 uinfo->value.enumerated.item = 7;
1260 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1264 static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1266 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1267 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1268 unsigned int pin_ctl, item = 0;
1270 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1271 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1272 if (pin_ctl & AC_PINCTL_OUT_EN) {
1273 if (pin_ctl & AC_PINCTL_HP_EN)
1277 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1278 switch (pin_ctl & AC_PINCTL_VREFEN) {
1279 case AC_PINCTL_VREF_HIZ: item = 3; break;
1280 case AC_PINCTL_VREF_50: item = 4; break;
1281 case AC_PINCTL_VREF_GRD: item = 5; break;
1282 case AC_PINCTL_VREF_80: item = 6; break;
1283 case AC_PINCTL_VREF_100: item = 7; break;
1286 ucontrol->value.enumerated.item[0] = item;
1290 static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1292 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1293 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1294 static unsigned int ctls[] = {
1295 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1296 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1297 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1298 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1299 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1300 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1302 unsigned int old_ctl, new_ctl;
1304 old_ctl = snd_hda_codec_read(codec, nid, 0,
1305 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1306 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1307 if (old_ctl != new_ctl) {
1308 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1309 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1310 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1316 static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1318 static char *texts[] = {
1319 "Front", "Surround", "CLFE", "Side"
1321 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1323 uinfo->value.enumerated.items = 4;
1324 if (uinfo->value.enumerated.item >= 4)
1325 uinfo->value.enumerated.item = 3;
1326 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1330 static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1333 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1336 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1337 ucontrol->value.enumerated.item[0] = sel & 3;
1341 static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1344 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1347 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1348 if (ucontrol->value.enumerated.item[0] != sel) {
1349 sel = ucontrol->value.enumerated.item[0] & 3;
1350 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1356 #define PIN_CTL_TEST(xname,nid) { \
1357 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1359 .info = alc_test_pin_ctl_info, \
1360 .get = alc_test_pin_ctl_get, \
1361 .put = alc_test_pin_ctl_put, \
1362 .private_value = nid \
1365 #define PIN_SRC_TEST(xname,nid) { \
1366 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1368 .info = alc_test_pin_src_info, \
1369 .get = alc_test_pin_src_get, \
1370 .put = alc_test_pin_src_put, \
1371 .private_value = nid \
1374 static snd_kcontrol_new_t alc880_test_mixer[] = {
1375 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1376 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1377 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1378 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1379 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1380 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1381 ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT),
1382 ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT),
1383 PIN_CTL_TEST("Front Pin Mode", 0x14),
1384 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1385 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1386 PIN_CTL_TEST("Side Pin Mode", 0x17),
1387 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1388 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1389 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1390 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1391 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1392 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1393 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1394 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1395 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1396 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1397 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1398 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1399 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1400 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1401 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1402 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1403 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1404 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1405 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1406 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1407 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1408 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1410 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1411 .name = "Input Source",
1413 .info = alc_mux_enum_info,
1414 .get = alc_mux_enum_get,
1415 .put = alc_mux_enum_put,
1418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1419 .name = "Channel Mode",
1420 .info = alc880_ch_mode_info,
1421 .get = alc880_ch_mode_get,
1422 .put = alc880_ch_mode_put,
1427 static struct hda_verb alc880_test_init_verbs[] = {
1428 /* Unmute inputs of 0x0c - 0x0f */
1429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1435 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1437 /* Vol output for 0x0c-0x0f */
1438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1439 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1441 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1442 /* Set output pins 0x14-0x17 */
1443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1445 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1446 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1447 /* Unmute output pins 0x14-0x17 */
1448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1450 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1451 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1452 /* Set input pins 0x18-0x1c */
1453 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1455 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1456 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1457 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1458 /* Mute input pins 0x18-0x1b */
1459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1461 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1462 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1465 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1467 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1469 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1470 /* Analog input/passthru */
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1483 static struct hda_board_config alc880_cfg_tbl[] = {
1484 /* Back 3 jack, front 2 jack */
1485 { .modelname = "3stack", .config = ALC880_3ST },
1486 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1487 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1488 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1489 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1490 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1491 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1492 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1493 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1494 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1495 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1496 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1497 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1498 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1499 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1500 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1501 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1502 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1503 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1504 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1505 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1506 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1507 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1508 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1509 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1510 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1511 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1512 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1513 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1514 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1515 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1516 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1517 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
1519 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1520 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1521 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
1523 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1524 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
1525 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
1527 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1528 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1529 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1530 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
1532 /* Back 5 jack, front 2 jack */
1533 { .modelname = "5stack", .config = ALC880_5ST },
1534 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1535 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1536 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1537 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
1538 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
1540 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1541 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
1542 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1543 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1544 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1545 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1546 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1547 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1548 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1549 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1550 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1551 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG },
1552 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1553 /* note subvendor = 0 below */
1554 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1556 { .modelname = "w810", .config = ALC880_W810 },
1557 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
1559 { .modelname = "z71v", .config = ALC880_Z71V },
1560 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1562 { .modelname = "6statack-digout", .config = ALC880_6ST_DIG },
1563 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1564 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1565 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1566 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1568 { .modelname = "asus", .config = ALC880_ASUS },
1569 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1570 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1571 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1572 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1573 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1574 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1575 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1576 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1577 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1578 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1580 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1581 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1583 { .modelname = "F1734", .config = ALC880_F1734 },
1584 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1586 #ifdef CONFIG_SND_DEBUG
1587 { .modelname = "test", .config = ALC880_TEST },
1594 * configuration template - to be copied to the spec instance
1596 struct alc_config_preset {
1597 snd_kcontrol_new_t *mixers[4];
1598 const struct hda_verb *init_verbs[4];
1599 unsigned int num_dacs;
1600 hda_nid_t *dac_nids;
1601 hda_nid_t dig_out_nid; /* optional */
1602 hda_nid_t hp_nid; /* optional */
1603 unsigned int num_adc_nids;
1604 hda_nid_t *adc_nids;
1605 unsigned int num_channel_mode;
1606 const struct alc_channel_mode *channel_mode;
1607 const struct hda_input_mux *input_mux;
1610 static struct alc_config_preset alc880_presets[] = {
1612 .mixers = { alc880_three_stack_mixer },
1613 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1614 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1615 .dac_nids = alc880_dac_nids,
1616 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1617 .channel_mode = alc880_threestack_modes,
1618 .input_mux = &alc880_capture_source,
1620 [ALC880_3ST_DIG] = {
1621 .mixers = { alc880_three_stack_mixer },
1622 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1623 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1624 .dac_nids = alc880_dac_nids,
1625 .dig_out_nid = ALC880_DIGOUT_NID,
1626 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1627 .channel_mode = alc880_threestack_modes,
1628 .input_mux = &alc880_capture_source,
1631 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1632 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1633 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1634 .dac_nids = alc880_dac_nids,
1635 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1636 .channel_mode = alc880_fivestack_modes,
1637 .input_mux = &alc880_capture_source,
1639 [ALC880_5ST_DIG] = {
1640 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1641 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1642 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1643 .dac_nids = alc880_dac_nids,
1644 .dig_out_nid = ALC880_DIGOUT_NID,
1645 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1646 .channel_mode = alc880_fivestack_modes,
1647 .input_mux = &alc880_capture_source,
1649 [ALC880_6ST_DIG] = {
1650 .mixers = { alc880_six_stack_mixer },
1651 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1652 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1653 .dac_nids = alc880_6st_dac_nids,
1654 .dig_out_nid = ALC880_DIGOUT_NID,
1655 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1656 .channel_mode = alc880_sixstack_modes,
1657 .input_mux = &alc880_6stack_capture_source,
1660 .mixers = { alc880_w810_base_mixer },
1661 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1662 alc880_gpio2_init_verbs },
1663 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1664 .dac_nids = alc880_w810_dac_nids,
1665 .dig_out_nid = ALC880_DIGOUT_NID,
1666 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1667 .channel_mode = alc880_w810_modes,
1668 .input_mux = &alc880_capture_source,
1671 .mixers = { alc880_z71v_mixer },
1672 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
1673 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1674 .dac_nids = alc880_z71v_dac_nids,
1675 .dig_out_nid = ALC880_DIGOUT_NID,
1677 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1678 .channel_mode = alc880_2_jack_modes,
1679 .input_mux = &alc880_capture_source,
1682 .mixers = { alc880_f1734_mixer },
1683 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1684 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1685 .dac_nids = alc880_f1734_dac_nids,
1687 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1688 .channel_mode = alc880_2_jack_modes,
1689 .input_mux = &alc880_capture_source,
1692 .mixers = { alc880_asus_mixer },
1693 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1694 alc880_gpio1_init_verbs },
1695 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1696 .dac_nids = alc880_asus_dac_nids,
1697 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1698 .channel_mode = alc880_asus_modes,
1699 .input_mux = &alc880_capture_source,
1701 [ALC880_ASUS_DIG] = {
1702 .mixers = { alc880_asus_mixer },
1703 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1704 alc880_gpio1_init_verbs },
1705 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1706 .dac_nids = alc880_asus_dac_nids,
1707 .dig_out_nid = ALC880_DIGOUT_NID,
1708 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1709 .channel_mode = alc880_asus_modes,
1710 .input_mux = &alc880_capture_source,
1712 [ALC880_ASUS_W1V] = {
1713 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1714 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1715 alc880_gpio1_init_verbs },
1716 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1717 .dac_nids = alc880_asus_dac_nids,
1718 .dig_out_nid = ALC880_DIGOUT_NID,
1719 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1720 .channel_mode = alc880_asus_modes,
1721 .input_mux = &alc880_capture_source,
1723 [ALC880_UNIWILL_DIG] = {
1724 .mixers = { alc880_asus_mixer },
1725 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1726 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1727 .dac_nids = alc880_asus_dac_nids,
1728 .dig_out_nid = ALC880_DIGOUT_NID,
1729 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1730 .channel_mode = alc880_asus_modes,
1731 .input_mux = &alc880_capture_source,
1733 #ifdef CONFIG_SND_DEBUG
1735 .mixers = { alc880_test_mixer },
1736 .init_verbs = { alc880_test_init_verbs },
1737 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1738 .dac_nids = alc880_test_dac_nids,
1739 .dig_out_nid = ALC880_DIGOUT_NID,
1740 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1741 .channel_mode = alc880_test_modes,
1742 .input_mux = &alc880_test_capture_source,
1748 * Automatic parse of I/O pins from the BIOS configuration
1751 #define NUM_CONTROL_ALLOC 32
1752 #define NUM_VERB_ALLOC 32
1756 ALC_CTL_WIDGET_MUTE,
1759 static snd_kcontrol_new_t alc880_control_templates[] = {
1760 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1761 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1762 ALC_BIND_MUTE(NULL, 0, 0, 0),
1765 /* add dynamic controls */
1766 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1768 snd_kcontrol_new_t *knew;
1770 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1771 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1773 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1776 if (spec->kctl_alloc) {
1777 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1778 kfree(spec->kctl_alloc);
1780 spec->kctl_alloc = knew;
1781 spec->num_kctl_alloc = num;
1784 knew = &spec->kctl_alloc[spec->num_kctl_used];
1785 *knew = alc880_control_templates[type];
1786 knew->name = kstrdup(name, GFP_KERNEL);
1789 knew->private_value = val;
1790 spec->num_kctl_used++;
1794 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1795 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1796 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1797 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1798 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
1799 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
1800 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
1801 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
1802 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1803 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
1804 #define ALC880_PIN_CD_NID 0x1c
1806 /* fill in the dac_nids table from the parsed pin configuration */
1807 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1813 memset(assigned, 0, sizeof(assigned));
1814 spec->multiout.dac_nids = spec->private_dac_nids;
1816 /* check the pins hardwired to audio widget */
1817 for (i = 0; i < cfg->line_outs; i++) {
1818 nid = cfg->line_out_pins[i];
1819 if (alc880_is_fixed_pin(nid)) {
1820 int idx = alc880_fixed_pin_idx(nid);
1821 spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
1825 /* left pins can be connect to any audio widget */
1826 for (i = 0; i < cfg->line_outs; i++) {
1827 nid = cfg->line_out_pins[i];
1828 if (alc880_is_fixed_pin(nid))
1830 /* search for an empty channel */
1831 for (j = 0; j < cfg->line_outs; j++) {
1832 if (! assigned[j]) {
1833 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1839 spec->multiout.num_dacs = cfg->line_outs;
1843 /* add playback controls from the parsed DAC table */
1844 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1847 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1851 for (i = 0; i < cfg->line_outs; i++) {
1852 if (! spec->multiout.dac_nids[i])
1854 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
1857 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
1858 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1860 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
1861 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1863 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
1864 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
1866 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
1867 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
1870 sprintf(name, "%s Playback Volume", chname[i]);
1871 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1872 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1874 sprintf(name, "%s Playback Switch", chname[i]);
1875 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
1876 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1884 /* add playback controls for HP output */
1885 static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
1893 if (alc880_is_fixed_pin(pin)) {
1894 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
1895 if (! spec->multiout.dac_nids[0]) {
1896 /* use this as the primary output */
1897 spec->multiout.dac_nids[0] = nid;
1898 if (! spec->multiout.num_dacs)
1899 spec->multiout.num_dacs = 1;
1901 /* specify the DAC as the extra HP output */
1902 spec->multiout.hp_nid = nid;
1903 /* control HP volume/switch on the output mixer amp */
1904 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
1905 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
1906 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1908 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
1909 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1911 } else if (alc880_is_multi_pin(pin)) {
1912 /* set manual connection */
1913 if (! spec->multiout.dac_nids[0]) {
1914 /* use this as the primary output */
1915 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
1916 if (! spec->multiout.num_dacs)
1917 spec->multiout.num_dacs = 1;
1919 /* we have only a switch on HP-out PIN */
1920 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
1921 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
1927 /* create input playback/capture controls for the given pin */
1928 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
1933 sprintf(name, "%s Playback Volume", ctlname);
1934 idx = alc880_input_pin_idx(pin);
1935 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1936 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1938 sprintf(name, "%s Playback Switch", ctlname);
1939 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
1940 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1945 /* create playback/capture controls for input pins */
1946 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1948 static char *labels[AUTO_PIN_LAST] = {
1949 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
1951 struct hda_input_mux *imux = &spec->private_imux;
1954 for (i = 0; i < AUTO_PIN_LAST; i++) {
1955 if (alc880_is_input_pin(cfg->input_pins[i])) {
1956 err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
1959 imux->items[imux->num_items].label = labels[i];
1960 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
1967 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
1971 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1972 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
1973 /* need the manual connection? */
1974 if (alc880_is_multi_pin(nid)) {
1975 struct alc_spec *spec = codec->spec;
1976 int idx = alc880_multi_pin_idx(nid);
1977 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
1978 AC_VERB_SET_CONNECT_SEL,
1979 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
1983 static void alc880_auto_init_multi_out(struct hda_codec *codec)
1985 struct alc_spec *spec = codec->spec;
1988 for (i = 0; i < spec->autocfg.line_outs; i++) {
1989 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1990 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
1994 static void alc880_auto_init_hp_out(struct hda_codec *codec)
1996 struct alc_spec *spec = codec->spec;
1999 pin = spec->autocfg.hp_pin;
2000 if (pin) /* connect to front */
2001 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2004 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2006 struct alc_spec *spec = codec->spec;
2009 for (i = 0; i < AUTO_PIN_LAST; i++) {
2010 hda_nid_t nid = spec->autocfg.input_pins[i];
2011 if (alc880_is_input_pin(nid)) {
2012 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2013 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2014 if (nid != ALC880_PIN_CD_NID)
2015 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2021 /* parse the BIOS configuration and set up the alc_spec */
2022 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2023 static int alc880_parse_auto_config(struct hda_codec *codec)
2025 struct alc_spec *spec = codec->spec;
2028 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
2030 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
2032 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
2033 return 0; /* can't find valid BIOS pin config */
2034 if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2035 (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
2036 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2039 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2041 if (spec->autocfg.dig_out_pin)
2042 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2043 if (spec->autocfg.dig_in_pin)
2044 spec->dig_in_nid = ALC880_DIGIN_NID;
2046 if (spec->kctl_alloc)
2047 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2049 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2051 spec->input_mux = &spec->private_imux;
2056 /* init callback for auto-configuration model -- overriding the default init */
2057 static int alc880_auto_init(struct hda_codec *codec)
2060 alc880_auto_init_multi_out(codec);
2061 alc880_auto_init_hp_out(codec);
2062 alc880_auto_init_analog_input(codec);
2067 * OK, here we have finally the patch for ALC880
2070 static int patch_alc880(struct hda_codec *codec)
2072 struct alc_spec *spec;
2076 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2080 init_MUTEX(&spec->bind_mutex);
2083 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2084 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2085 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2086 board_config = ALC880_AUTO;
2089 if (board_config == ALC880_AUTO) {
2090 /* automatic parse from the BIOS config */
2091 err = alc880_parse_auto_config(codec);
2096 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2097 board_config = ALC880_3ST;
2101 if (board_config != ALC880_AUTO) {
2102 /* set up from the preset table */
2103 const struct alc_config_preset *preset;
2105 preset = &alc880_presets[board_config];
2107 for (i = 0; preset->mixers[i]; i++) {
2108 snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
2109 spec->mixers[spec->num_mixers++] = preset->mixers[i];
2111 for (i = 0; preset->init_verbs[i]; i++) {
2112 snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
2113 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
2116 spec->channel_mode = preset->channel_mode;
2117 spec->num_channel_mode = preset->num_channel_mode;
2119 spec->multiout.max_channels = spec->channel_mode[0].channels;
2121 spec->multiout.num_dacs = preset->num_dacs;
2122 spec->multiout.dac_nids = preset->dac_nids;
2123 spec->multiout.dig_out_nid = preset->dig_out_nid;
2124 spec->multiout.hp_nid = preset->hp_nid;
2126 spec->input_mux = preset->input_mux;
2128 spec->num_adc_nids = preset->num_adc_nids;
2129 spec->adc_nids = preset->adc_nids;
2132 spec->stream_name_analog = "ALC880 Analog";
2133 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2134 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2136 spec->stream_name_digital = "ALC880 Digital";
2137 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2138 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2140 if (! spec->adc_nids && spec->input_mux) {
2141 /* check whether NID 0x07 is valid */
2142 unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
2143 AC_PAR_AUDIO_WIDGET_CAP);
2144 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2145 if (wcap != AC_WID_AUD_IN) {
2146 spec->adc_nids = alc880_adc_nids_alt;
2147 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2148 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2151 spec->adc_nids = alc880_adc_nids;
2152 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2153 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2158 codec->patch_ops = alc_patch_ops;
2159 if (board_config == ALC880_AUTO)
2160 codec->patch_ops.init = alc880_auto_init;
2170 static hda_nid_t alc260_dac_nids[1] = {
2175 static hda_nid_t alc260_adc_nids[1] = {
2180 static hda_nid_t alc260_hp_adc_nids[1] = {
2185 #define ALC260_DIGOUT_NID 0x03
2186 #define ALC260_DIGIN_NID 0x06
2188 static struct hda_input_mux alc260_capture_source = {
2192 { "Front Mic", 0x1 },
2199 * This is just place-holder, so there's something for alc_build_pcms to look
2200 * at when it calculates the maximum number of channels. ALC260 has no mixer
2201 * element which allows changing the channel mode, so the verb list is
2204 static struct alc_channel_mode alc260_modes[1] = {
2208 static snd_kcontrol_new_t alc260_base_mixer[] = {
2209 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2210 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2211 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2212 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2214 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2216 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2218 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2219 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2220 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2221 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2222 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2223 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2224 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
2225 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2226 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2228 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2229 .name = "Capture Source",
2230 .info = alc_mux_enum_info,
2231 .get = alc_mux_enum_get,
2232 .put = alc_mux_enum_put,
2237 static snd_kcontrol_new_t alc260_hp_mixer[] = {
2238 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2239 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2240 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2241 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2242 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2243 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2245 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2246 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2248 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2249 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2250 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2251 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
2252 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2253 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2255 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2256 .name = "Capture Source",
2257 .info = alc_mux_enum_info,
2258 .get = alc_mux_enum_get,
2259 .put = alc_mux_enum_put,
2264 static struct hda_verb alc260_init_verbs[] = {
2265 /* Line In pin widget for input */
2266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2267 /* CD pin widget for input */
2268 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2269 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2270 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2271 /* Mic2 (front panel) pin widget for input and vref at 80% */
2272 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2273 /* LINE-2 is used for line-out in rear */
2274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2275 /* select line-out */
2276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2278 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2280 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2282 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2283 /* mute capture amp left and right */
2284 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2285 /* set connection select to line in (default select for this ADC) */
2286 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2287 /* mute capture amp left and right */
2288 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2289 /* set connection select to line in (default select for this ADC) */
2290 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
2291 /* set vol=0 Line-Out mixer amp left and right */
2292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2293 /* unmute pin widget amp left and right (no gain on this amp) */
2294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2295 /* set vol=0 HP mixer amp left and right */
2296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2297 /* unmute pin widget amp left and right (no gain on this amp) */
2298 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2299 /* set vol=0 Mono mixer amp left and right */
2300 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2301 /* unmute pin widget amp left and right (no gain on this amp) */
2302 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2303 /* unmute LINE-2 out pin */
2304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2305 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2312 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2313 /* mute Front out path */
2314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2316 /* mute Headphone out path */
2317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2319 /* mute Mono out path */
2320 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2321 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2325 static struct hda_pcm_stream alc260_pcm_analog_playback = {
2331 static struct hda_pcm_stream alc260_pcm_analog_capture = {
2337 static struct hda_board_config alc260_cfg_tbl[] = {
2338 { .modelname = "hp", .config = ALC260_HP },
2339 { .pci_subvendor = 0x103c, .config = ALC260_HP },
2343 static int patch_alc260(struct hda_codec *codec)
2345 struct alc_spec *spec;
2348 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2352 init_MUTEX(&spec->bind_mutex);
2355 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
2356 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
2357 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
2358 board_config = ALC260_BASIC;
2361 switch (board_config) {
2363 spec->mixers[spec->num_mixers] = alc260_hp_mixer;
2367 spec->mixers[spec->num_mixers] = alc260_base_mixer;
2372 spec->init_verbs[0] = alc260_init_verbs;
2373 spec->num_init_verbs = 1;
2375 spec->channel_mode = alc260_modes;
2376 spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
2378 spec->stream_name_analog = "ALC260 Analog";
2379 spec->stream_analog_playback = &alc260_pcm_analog_playback;
2380 spec->stream_analog_capture = &alc260_pcm_analog_capture;
2382 spec->multiout.max_channels = spec->channel_mode[0].channels;
2383 spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
2384 spec->multiout.dac_nids = alc260_dac_nids;
2386 spec->input_mux = &alc260_capture_source;
2387 switch (board_config) {
2389 spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
2390 spec->adc_nids = alc260_hp_adc_nids;
2393 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2394 spec->adc_nids = alc260_adc_nids;
2398 codec->patch_ops = alc_patch_ops;
2407 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
2408 * configuration. Each pin widget can choose any input DACs and a mixer.
2409 * Each ADC is connected from a mixer of all inputs. This makes possible
2410 * 6-channel independent captures.
2412 * In addition, an independent DAC for the multi-playback (not used in this
2416 static struct alc_channel_mode alc882_ch_modes[1] = {
2420 static hda_nid_t alc882_dac_nids[4] = {
2421 /* front, rear, clfe, rear_surr */
2422 0x02, 0x03, 0x04, 0x05
2425 static hda_nid_t alc882_adc_nids[3] = {
2431 /* FIXME: should be a matrix-type input source selection */
2433 static struct hda_input_mux alc882_capture_source = {
2437 { "Front Mic", 0x1 },
2443 #define alc882_mux_enum_info alc_mux_enum_info
2444 #define alc882_mux_enum_get alc_mux_enum_get
2446 static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
2448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2449 struct alc_spec *spec = codec->spec;
2450 const struct hda_input_mux *imux = spec->input_mux;
2451 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2452 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
2453 hda_nid_t nid = capture_mixers[adc_idx];
2454 unsigned int *cur_val = &spec->cur_mux[adc_idx];
2455 unsigned int i, idx;
2457 idx = ucontrol->value.enumerated.item[0];
2458 if (idx >= imux->num_items)
2459 idx = imux->num_items - 1;
2460 if (*cur_val == idx && ! codec->in_resume)
2462 for (i = 0; i < imux->num_items; i++) {
2463 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
2464 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2465 v | (imux->items[i].index << 8));
2471 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
2472 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
2474 static snd_kcontrol_new_t alc882_base_mixer[] = {
2475 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2476 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2477 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2478 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2479 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2480 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2481 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2482 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT),
2483 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2484 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2486 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2487 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2488 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2489 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2491 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2492 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2493 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2494 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
2495 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
2496 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
2497 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
2498 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
2499 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
2500 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
2501 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
2503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2504 /* .name = "Capture Source", */
2505 .name = "Input Source",
2507 .info = alc882_mux_enum_info,
2508 .get = alc882_mux_enum_get,
2509 .put = alc882_mux_enum_put,
2514 static struct hda_verb alc882_init_verbs[] = {
2515 /* Front mixer: unmute input/output amp left and right (volume = 0) */
2516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2528 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2530 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2532 /* Front Pin: output 0 (0x0c) */
2533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2534 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2535 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2536 /* Rear Pin: output 1 (0x0d) */
2537 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
2540 /* CLFE Pin: output 2 (0x0e) */
2541 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2542 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2543 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2544 /* Side Pin: output 3 (0x0f) */
2545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2546 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2547 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2548 /* Mic (rear) pin: input vref at 80% */
2549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2551 /* Front Mic pin: input vref at 80% */
2552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2554 /* Line In pin: input */
2555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2557 /* Line-2 In: Headphone output (output 0 - 0x0c) */
2558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2560 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2561 /* CD pin widget for input */
2562 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2564 /* FIXME: use matrix-type input source selection */
2565 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
2566 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
2567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2568 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2569 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2570 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2581 /* ADC1: mute amp left and right */
2582 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2583 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2584 /* ADC2: mute amp left and right */
2585 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2586 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2587 /* ADC3: mute amp left and right */
2588 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2589 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2594 static int patch_alc882(struct hda_codec *codec)
2596 struct alc_spec *spec;
2598 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2602 init_MUTEX(&spec->bind_mutex);
2605 spec->mixers[spec->num_mixers] = alc882_base_mixer;
2608 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2609 spec->dig_in_nid = ALC880_DIGIN_NID;
2610 spec->init_verbs[0] = alc882_init_verbs;
2611 spec->num_init_verbs = 1;
2613 spec->channel_mode = alc882_ch_modes;
2614 spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
2616 spec->stream_name_analog = "ALC882 Analog";
2617 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2618 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2620 spec->stream_name_digital = "ALC882 Digital";
2621 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2622 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2624 spec->multiout.max_channels = spec->channel_mode[0].channels;
2625 spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
2626 spec->multiout.dac_nids = alc882_dac_nids;
2628 spec->input_mux = &alc882_capture_source;
2629 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
2630 spec->adc_nids = alc882_adc_nids;
2632 codec->patch_ops = alc_patch_ops;
2640 struct hda_codec_preset snd_hda_preset_realtek[] = {
2641 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
2642 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
2643 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },