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 */
50 #ifdef CONFIG_SND_DEBUG
53 ALC880_MODEL_LAST /* last tag */
60 ALC260_MODEL_LAST /* last tag */
64 #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
65 #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
66 #define AMP_OUT_MUTE 0xb080
67 #define AMP_OUT_UNMUTE 0xb000
68 #define AMP_OUT_ZERO 0xb000
71 #define PIN_VREF80 0x24
72 #define PIN_VREF50 0x21
77 /* codec parameterization */
78 snd_kcontrol_new_t *mixers[3]; /* mixer arrays */
79 unsigned int num_mixers;
81 const struct hda_verb *init_verbs[3]; /* initialization verbs
82 * don't forget NULL termination!
84 unsigned int num_init_verbs;
86 char *stream_name_analog; /* analog PCM stream */
87 struct hda_pcm_stream *stream_analog_playback;
88 struct hda_pcm_stream *stream_analog_capture;
90 char *stream_name_digital; /* digital PCM stream */
91 struct hda_pcm_stream *stream_digital_playback;
92 struct hda_pcm_stream *stream_digital_capture;
95 struct hda_multi_out multiout; /* playback set-up
96 * max_channels, dacs must be set
97 * dig_out_nid and hp_nid are optional
101 unsigned int num_adc_nids;
103 hda_nid_t dig_in_nid; /* digital-in NID; optional */
106 const struct hda_input_mux *input_mux;
107 unsigned int cur_mux[3];
110 const struct alc_channel_mode *channel_mode;
111 int num_channel_mode;
113 /* PCM information */
114 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
116 struct semaphore bind_mutex; /* for bound controls */
118 /* dynamic controls, init_verbs and input_mux */
119 struct auto_pin_cfg autocfg;
120 unsigned int num_kctl_alloc, num_kctl_used;
121 snd_kcontrol_new_t *kctl_alloc;
122 struct hda_input_mux private_imux;
123 hda_nid_t private_dac_nids[4];
130 static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
132 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
133 struct alc_spec *spec = codec->spec;
134 return snd_hda_input_mux_info(spec->input_mux, uinfo);
137 static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
139 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
140 struct alc_spec *spec = codec->spec;
141 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
143 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
147 static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
149 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
150 struct alc_spec *spec = codec->spec;
151 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
152 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
153 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
158 * channel mode setting
160 struct alc_channel_mode {
162 const struct hda_verb *sequence;
165 static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
167 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
168 struct alc_spec *spec = codec->spec;
169 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
171 snd_assert(spec->channel_mode, return -ENXIO);
172 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
174 uinfo->value.enumerated.items = items;
175 if (uinfo->value.enumerated.item >= items)
176 uinfo->value.enumerated.item = items - 1;
177 sprintf(uinfo->value.enumerated.name, "%dch",
178 spec->channel_mode[uinfo->value.enumerated.item].channels);
182 static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
184 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
185 struct alc_spec *spec = codec->spec;
186 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
189 snd_assert(spec->channel_mode, return -ENXIO);
190 for (i = 0; i < items; i++) {
191 if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
192 ucontrol->value.enumerated.item[0] = i;
199 static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
201 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
202 struct alc_spec *spec = codec->spec;
205 snd_assert(spec->channel_mode, return -ENXIO);
206 mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
207 if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
211 /* change the current channel setting */
212 spec->multiout.max_channels = spec->channel_mode[mode].channels;
213 if (spec->channel_mode[mode].sequence)
214 snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
221 * bound volume controls
223 * bind multiple volumes (# indices, from 0)
226 #define AMP_VAL_IDX_SHIFT 19
227 #define AMP_VAL_IDX_MASK (0x0f<<19)
229 static int alc_bind_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
232 struct alc_spec *spec = codec->spec;
235 down(&spec->bind_mutex);
236 pval = kcontrol->private_value;
237 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
238 snd_hda_mixer_amp_switch_info(kcontrol, uinfo);
239 kcontrol->private_value = pval;
240 up(&spec->bind_mutex);
244 static int alc_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
247 struct alc_spec *spec = codec->spec;
250 down(&spec->bind_mutex);
251 pval = kcontrol->private_value;
252 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
253 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
254 kcontrol->private_value = pval;
255 up(&spec->bind_mutex);
259 static int alc_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
262 struct alc_spec *spec = codec->spec;
264 int i, indices, change = 0;
266 down(&spec->bind_mutex);
267 pval = kcontrol->private_value;
268 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
269 for (i = 0; i < indices; i++) {
270 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
271 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
273 kcontrol->private_value = pval;
274 up(&spec->bind_mutex);
278 #define ALC_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
279 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
280 .info = alc_bind_switch_info, \
281 .get = alc_bind_switch_get, \
282 .put = alc_bind_switch_put, \
283 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
285 #define ALC_BIND_MUTE(xname,nid,indices,dir) ALC_BIND_MUTE_MONO(xname,nid,3,indices,dir)
289 * ALC880 3-stack model
291 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
292 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
296 static hda_nid_t alc880_dac_nids[4] = {
297 /* front, rear, clfe, rear_surr */
298 0x02, 0x05, 0x04, 0x03
301 static hda_nid_t alc880_adc_nids[3] = {
306 /* The datasheet says the node 0x07 is connected from inputs,
307 * but it shows zero connection in the real implementation on some devices.
309 static hda_nid_t alc880_adc_nids_alt[2] = {
314 #define ALC880_DIGOUT_NID 0x06
315 #define ALC880_DIGIN_NID 0x0a
317 static struct hda_input_mux alc880_capture_source = {
321 { "Front Mic", 0x3 },
327 /* channel source setting (2/6 channel selection for 3-stack) */
329 static struct hda_verb alc880_threestack_ch2_init[] = {
330 /* set line-in to input, mute it */
331 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
332 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
333 /* set mic-in to input vref 80%, mute it */
334 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
335 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
340 static struct hda_verb alc880_threestack_ch6_init[] = {
341 /* set line-in to output, unmute it */
342 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
343 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
344 /* set mic-in to output, unmute it */
345 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
346 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
350 static struct alc_channel_mode alc880_threestack_modes[2] = {
351 { 2, alc880_threestack_ch2_init },
352 { 6, alc880_threestack_ch6_init },
355 static snd_kcontrol_new_t alc880_three_stack_mixer[] = {
356 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
357 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
358 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
359 ALC_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
360 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
361 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
362 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
363 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
370 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
372 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
373 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
374 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
377 .name = "Channel Mode",
378 .info = alc880_ch_mode_info,
379 .get = alc880_ch_mode_get,
380 .put = alc880_ch_mode_put,
385 /* capture mixer elements */
386 static snd_kcontrol_new_t alc880_capture_mixer[] = {
387 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
388 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
389 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
390 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
391 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
392 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
395 /* The multiple "Capture Source" controls confuse alsamixer
396 * So call somewhat different..
397 * FIXME: the controls appear in the "playback" view!
399 /* .name = "Capture Source", */
400 .name = "Input Source",
402 .info = alc_mux_enum_info,
403 .get = alc_mux_enum_get,
404 .put = alc_mux_enum_put,
409 /* capture mixer elements (in case NID 0x07 not available) */
410 static snd_kcontrol_new_t alc880_capture_alt_mixer[] = {
411 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
412 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
413 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
414 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
417 /* The multiple "Capture Source" controls confuse alsamixer
418 * So call somewhat different..
419 * FIXME: the controls appear in the "playback" view!
421 /* .name = "Capture Source", */
422 .name = "Input Source",
424 .info = alc_mux_enum_info,
425 .get = alc_mux_enum_get,
426 .put = alc_mux_enum_put,
434 * ALC880 5-stack model
436 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
437 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
438 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
441 /* additional mixers to alc880_three_stack_mixer */
442 static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
443 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
444 ALC_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
448 /* channel source setting (6/8 channel selection for 5-stack) */
450 static struct hda_verb alc880_fivestack_ch6_init[] = {
451 /* set line-in to input, mute it */
452 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
453 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
458 static struct hda_verb alc880_fivestack_ch8_init[] = {
459 /* set line-in to output, unmute it */
460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
465 static struct alc_channel_mode alc880_fivestack_modes[2] = {
466 { 6, alc880_fivestack_ch6_init },
467 { 8, alc880_fivestack_ch8_init },
472 * ALC880 6-stack model
474 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
475 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
476 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
479 static hda_nid_t alc880_6st_dac_nids[4] = {
480 /* front, rear, clfe, rear_surr */
481 0x02, 0x03, 0x04, 0x05
484 static struct hda_input_mux alc880_6stack_capture_source = {
488 { "Front Mic", 0x1 },
494 /* fixed 8-channels */
495 static struct alc_channel_mode alc880_sixstack_modes[1] = {
499 static snd_kcontrol_new_t alc880_six_stack_mixer[] = {
500 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
501 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
502 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
503 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
504 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
505 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
506 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
507 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
508 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
509 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
510 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
511 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
512 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
513 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
516 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
517 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
518 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
519 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
522 .name = "Channel Mode",
523 .info = alc880_ch_mode_info,
524 .get = alc880_ch_mode_get,
525 .put = alc880_ch_mode_put,
534 * W810 has rear IO for:
537 * Center/LFE (DAC 04)
540 * The system also has a pair of internal speakers, and a headphone jack.
541 * These are both connected to Line2 on the codec, hence to DAC 02.
543 * There is a variable resistor to control the speaker or headphone
544 * volume. This is a hardware-only device without a software API.
546 * Plugging headphones in will disable the internal speakers. This is
547 * implemented in hardware, not via the driver using jack sense. In
548 * a similar fashion, plugging into the rear socket marked "front" will
549 * disable both the speakers and headphones.
551 * For input, there's a microphone jack, and an "audio in" jack.
552 * These may not do anything useful with this driver yet, because I
553 * haven't setup any initialization verbs for these yet...
556 static hda_nid_t alc880_w810_dac_nids[3] = {
557 /* front, rear/surround, clfe */
561 /* fixed 6 channels */
562 static struct alc_channel_mode alc880_w810_modes[1] = {
566 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
567 static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
568 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
569 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
570 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
571 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
572 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
573 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
574 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
575 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
584 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
585 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
588 static hda_nid_t alc880_z71v_dac_nids[1] = {
591 #define ALC880_Z71V_HP_DAC 0x03
593 /* fixed 2 channels */
594 static struct alc_channel_mode alc880_2_jack_modes[1] = {
598 static snd_kcontrol_new_t alc880_z71v_mixer[] = {
599 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
600 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
601 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
602 ALC_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
603 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
604 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
605 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
606 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
615 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
616 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
619 static hda_nid_t alc880_f1734_dac_nids[1] = {
622 #define ALC880_F1734_HP_DAC 0x02
624 static snd_kcontrol_new_t alc880_f1734_mixer[] = {
625 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
626 ALC_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
627 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
628 ALC_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
629 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
630 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
641 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
642 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
643 * Mic = 0x18, Line = 0x1a
646 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
647 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
649 static snd_kcontrol_new_t alc880_asus_mixer[] = {
650 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
651 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
652 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
653 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
654 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
655 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
656 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
657 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
658 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
659 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
660 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
661 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
663 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
665 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
666 .name = "Channel Mode",
667 .info = alc880_ch_mode_info,
668 .get = alc880_ch_mode_get,
669 .put = alc880_ch_mode_put,
676 * ALC880 ASUS W1V model
678 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
679 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
680 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
683 /* additional mixers to alc880_asus_mixer */
684 static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = {
685 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
686 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
690 /* additional mixers to alc880_asus_mixer */
691 static snd_kcontrol_new_t alc880_pcbeep_mixer[] = {
692 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
693 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
698 * build control elements
700 static int alc_build_controls(struct hda_codec *codec)
702 struct alc_spec *spec = codec->spec;
706 for (i = 0; i < spec->num_mixers; i++) {
707 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
712 if (spec->multiout.dig_out_nid) {
713 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
717 if (spec->dig_in_nid) {
718 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
727 * initialize the codec volumes, etc
731 * generic initialization of ADC, input mixers and output mixers
733 static struct hda_verb alc880_volume_init_verbs[] = {
735 * Unmute ADC0-2 and set the default input to mic-in
737 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
738 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
739 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
740 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
741 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
742 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
744 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
746 * Note: PASD motherboards uses the Line In 2 as the input for front panel
749 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
750 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
751 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
752 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
753 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
754 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
757 * Set up output mixers (0x0c - 0x0f)
759 /* set vol=0 to output mixers */
760 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
761 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
763 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
764 /* set up input amps for analog loopback */
765 /* Amp Indices: DAC = 0, mixer = 1 */
766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
770 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
772 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
779 * 3-stack pin configuration:
780 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
782 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
784 * preset connection lists of input pins
785 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
787 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
788 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
789 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
792 * Set pin mode and muting
794 /* set front pin widgets 0x14 for output */
795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
797 /* Mic1 (rear panel) pin widget for input and vref at 80% */
798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
800 /* Mic2 (as headphone out) for HP output */
801 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
803 /* Line In pin widget for input */
804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
806 /* Line2 (as front mic) pin widget for input and vref at 80% */
807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
809 /* CD pin widget for input */
810 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
816 * 5-stack pin configuration:
817 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
818 * line-in/side = 0x1a, f-mic = 0x1b
820 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
822 * preset connection lists of input pins
823 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
825 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
826 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
829 * Set pin mode and muting
831 /* set pin widgets 0x14-0x17 for output */
832 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
834 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
835 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 /* unmute pins for output (no gain on this amp) */
837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
839 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
840 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
842 /* Mic1 (rear panel) pin widget for input and vref at 80% */
843 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
844 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
845 /* Mic2 (as headphone out) for HP output */
846 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
847 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
848 /* Line In pin widget for input */
849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
851 /* Line2 (as front mic) pin widget for input and vref at 80% */
852 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
853 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
854 /* CD pin widget for input */
855 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
861 * W810 pin configuration:
862 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
864 static struct hda_verb alc880_pin_w810_init_verbs[] = {
865 /* hphone/speaker input selector: front DAC */
866 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
868 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
869 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
872 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
873 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
875 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
876 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
882 * Z71V pin configuration:
883 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
885 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
888 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
891 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
892 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
894 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
900 * 6-stack pin configuration:
901 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
902 * line = 0x1a, HP = 0x1b
904 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
905 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
909 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
912 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
913 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
914 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
918 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
920 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
921 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
922 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
923 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
924 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
931 * F1734 pin configuration:
932 * HP = 0x14, speaker-out = 0x15, mic = 0x18
934 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
935 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
936 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
937 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
938 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
942 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
945 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
946 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
947 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
948 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
949 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
950 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
952 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
953 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
960 * ASUS pin configuration:
961 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
963 static struct hda_verb alc880_pin_asus_init_verbs[] = {
964 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
965 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
966 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
967 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
973 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
975 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
978 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
980 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
981 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
985 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
986 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
991 /* Enable GPIO mask and set output */
992 static struct hda_verb alc880_gpio1_init_verbs[] = {
993 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
994 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
995 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
998 /* Enable GPIO mask and set output */
999 static struct hda_verb alc880_gpio2_init_verbs[] = {
1000 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1001 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1002 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1009 static int alc_init(struct hda_codec *codec)
1011 struct alc_spec *spec = codec->spec;
1014 for (i = 0; i < spec->num_init_verbs; i++)
1015 snd_hda_sequence_write(codec, spec->init_verbs[i]);
1023 static int alc_resume(struct hda_codec *codec)
1025 struct alc_spec *spec = codec->spec;
1029 for (i = 0; i < spec->num_mixers; i++)
1030 snd_hda_resume_ctls(codec, spec->mixers[i]);
1031 if (spec->multiout.dig_out_nid)
1032 snd_hda_resume_spdif_out(codec);
1033 if (spec->dig_in_nid)
1034 snd_hda_resume_spdif_in(codec);
1041 * Analog playback callbacks
1043 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
1044 struct hda_codec *codec,
1045 snd_pcm_substream_t *substream)
1047 struct alc_spec *spec = codec->spec;
1048 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1051 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1052 struct hda_codec *codec,
1053 unsigned int stream_tag,
1054 unsigned int format,
1055 snd_pcm_substream_t *substream)
1057 struct alc_spec *spec = codec->spec;
1058 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
1062 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1063 struct hda_codec *codec,
1064 snd_pcm_substream_t *substream)
1066 struct alc_spec *spec = codec->spec;
1067 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1073 static int alc880_dig_playback_pcm_open(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_open(codec, &spec->multiout);
1081 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1082 struct hda_codec *codec,
1083 snd_pcm_substream_t *substream)
1085 struct alc_spec *spec = codec->spec;
1086 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1092 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1093 struct hda_codec *codec,
1094 unsigned int stream_tag,
1095 unsigned int format,
1096 snd_pcm_substream_t *substream)
1098 struct alc_spec *spec = codec->spec;
1100 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1101 stream_tag, 0, format);
1105 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1106 struct hda_codec *codec,
1107 snd_pcm_substream_t *substream)
1109 struct alc_spec *spec = codec->spec;
1111 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1118 static struct hda_pcm_stream alc880_pcm_analog_playback = {
1122 /* NID is set in alc_build_pcms */
1124 .open = alc880_playback_pcm_open,
1125 .prepare = alc880_playback_pcm_prepare,
1126 .cleanup = alc880_playback_pcm_cleanup
1130 static struct hda_pcm_stream alc880_pcm_analog_capture = {
1134 /* NID is set in alc_build_pcms */
1136 .prepare = alc880_capture_pcm_prepare,
1137 .cleanup = alc880_capture_pcm_cleanup
1141 static struct hda_pcm_stream alc880_pcm_digital_playback = {
1145 /* NID is set in alc_build_pcms */
1147 .open = alc880_dig_playback_pcm_open,
1148 .close = alc880_dig_playback_pcm_close
1152 static struct hda_pcm_stream alc880_pcm_digital_capture = {
1156 /* NID is set in alc_build_pcms */
1159 static int alc_build_pcms(struct hda_codec *codec)
1161 struct alc_spec *spec = codec->spec;
1162 struct hda_pcm *info = spec->pcm_rec;
1165 codec->num_pcms = 1;
1166 codec->pcm_info = info;
1168 info->name = spec->stream_name_analog;
1169 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1170 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1171 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1172 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1174 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1175 for (i = 0; i < spec->num_channel_mode; i++) {
1176 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1177 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1181 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1184 info->name = spec->stream_name_digital;
1185 if (spec->multiout.dig_out_nid) {
1186 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1187 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1189 if (spec->dig_in_nid) {
1190 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1191 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1198 static void alc_free(struct hda_codec *codec)
1200 struct alc_spec *spec = codec->spec;
1206 if (spec->kctl_alloc) {
1207 for (i = 0; i < spec->num_kctl_used; i++)
1208 kfree(spec->kctl_alloc[i].name);
1209 kfree(spec->kctl_alloc);
1216 static struct hda_codec_ops alc_patch_ops = {
1217 .build_controls = alc_build_controls,
1218 .build_pcms = alc_build_pcms,
1222 .resume = alc_resume,
1228 * Test configuration for debugging
1230 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1233 #ifdef CONFIG_SND_DEBUG
1234 static hda_nid_t alc880_test_dac_nids[4] = {
1235 0x02, 0x03, 0x04, 0x05
1238 static struct hda_input_mux alc880_test_capture_source = {
1249 static struct alc_channel_mode alc880_test_modes[4] = {
1256 static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1258 static char *texts[] = {
1259 "N/A", "Line Out", "HP Out",
1260 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1262 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1264 uinfo->value.enumerated.items = 8;
1265 if (uinfo->value.enumerated.item >= 8)
1266 uinfo->value.enumerated.item = 7;
1267 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1271 static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1274 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1275 unsigned int pin_ctl, item = 0;
1277 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1278 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1279 if (pin_ctl & AC_PINCTL_OUT_EN) {
1280 if (pin_ctl & AC_PINCTL_HP_EN)
1284 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1285 switch (pin_ctl & AC_PINCTL_VREFEN) {
1286 case AC_PINCTL_VREF_HIZ: item = 3; break;
1287 case AC_PINCTL_VREF_50: item = 4; break;
1288 case AC_PINCTL_VREF_GRD: item = 5; break;
1289 case AC_PINCTL_VREF_80: item = 6; break;
1290 case AC_PINCTL_VREF_100: item = 7; break;
1293 ucontrol->value.enumerated.item[0] = item;
1297 static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1299 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1300 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1301 static unsigned int ctls[] = {
1302 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1303 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1304 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1305 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1306 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1307 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1309 unsigned int old_ctl, new_ctl;
1311 old_ctl = snd_hda_codec_read(codec, nid, 0,
1312 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1313 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1314 if (old_ctl != new_ctl) {
1315 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1316 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1317 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1323 static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1325 static char *texts[] = {
1326 "Front", "Surround", "CLFE", "Side"
1328 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1330 uinfo->value.enumerated.items = 4;
1331 if (uinfo->value.enumerated.item >= 4)
1332 uinfo->value.enumerated.item = 3;
1333 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1337 static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1339 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1340 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1343 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1344 ucontrol->value.enumerated.item[0] = sel & 3;
1348 static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1351 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1354 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1355 if (ucontrol->value.enumerated.item[0] != sel) {
1356 sel = ucontrol->value.enumerated.item[0] & 3;
1357 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1363 #define PIN_CTL_TEST(xname,nid) { \
1364 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1366 .info = alc_test_pin_ctl_info, \
1367 .get = alc_test_pin_ctl_get, \
1368 .put = alc_test_pin_ctl_put, \
1369 .private_value = nid \
1372 #define PIN_SRC_TEST(xname,nid) { \
1373 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1375 .info = alc_test_pin_src_info, \
1376 .get = alc_test_pin_src_get, \
1377 .put = alc_test_pin_src_put, \
1378 .private_value = nid \
1381 static snd_kcontrol_new_t alc880_test_mixer[] = {
1382 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1383 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1384 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1385 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1386 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1387 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1388 ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT),
1389 ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT),
1390 PIN_CTL_TEST("Front Pin Mode", 0x14),
1391 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1392 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1393 PIN_CTL_TEST("Side Pin Mode", 0x17),
1394 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1395 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1396 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1397 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1398 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1399 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1400 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1401 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1402 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1403 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1404 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1405 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1406 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1407 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1408 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1409 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1410 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1411 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1412 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1413 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1414 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1415 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1418 .name = "Input Source",
1420 .info = alc_mux_enum_info,
1421 .get = alc_mux_enum_get,
1422 .put = alc_mux_enum_put,
1425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1426 .name = "Channel Mode",
1427 .info = alc880_ch_mode_info,
1428 .get = alc880_ch_mode_get,
1429 .put = alc880_ch_mode_put,
1434 static struct hda_verb alc880_test_init_verbs[] = {
1435 /* Unmute inputs of 0x0c - 0x0f */
1436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1439 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1441 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1442 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1443 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1444 /* Vol output for 0x0c-0x0f */
1445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1446 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1447 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1448 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1449 /* Set output pins 0x14-0x17 */
1450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1452 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1453 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1454 /* Unmute output pins 0x14-0x17 */
1455 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1457 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1458 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1459 /* Set input pins 0x18-0x1c */
1460 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1461 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1462 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1463 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1464 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1465 /* Mute input pins 0x18-0x1b */
1466 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1468 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1469 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1471 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1472 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1473 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1474 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1475 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1476 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1477 /* Analog input/passthru */
1478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1481 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1490 static struct hda_board_config alc880_cfg_tbl[] = {
1491 /* Back 3 jack, front 2 jack */
1492 { .modelname = "3stack", .config = ALC880_3ST },
1493 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
1494 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
1495 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
1496 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
1497 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
1498 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
1499 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
1500 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
1501 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
1502 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
1503 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
1504 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
1505 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
1506 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
1507 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
1508 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
1509 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
1510 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
1511 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
1512 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
1513 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
1514 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
1515 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
1516 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
1517 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
1518 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
1519 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
1520 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
1521 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
1522 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
1523 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
1524 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
1526 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
1527 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1528 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
1529 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
1531 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
1532 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
1533 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
1534 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
1536 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
1537 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
1538 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
1539 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
1541 /* Back 5 jack, front 2 jack */
1542 { .modelname = "5stack", .config = ALC880_5ST },
1543 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
1544 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
1545 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
1546 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
1547 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
1549 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
1550 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
1551 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
1552 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
1553 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
1554 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
1555 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
1556 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
1557 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
1558 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1559 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1560 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
1561 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1562 /* note subvendor = 0 below */
1563 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
1565 { .modelname = "w810", .config = ALC880_W810 },
1566 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
1568 { .modelname = "z71v", .config = ALC880_Z71V },
1569 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1571 { .modelname = "6stack", .config = ALC880_6ST },
1572 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
1574 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
1575 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1576 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1577 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1578 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1580 { .modelname = "asus", .config = ALC880_ASUS },
1581 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1582 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1583 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1584 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1585 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1586 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1587 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1588 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1589 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1590 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1592 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1593 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1595 { .modelname = "F1734", .config = ALC880_F1734 },
1596 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1598 #ifdef CONFIG_SND_DEBUG
1599 { .modelname = "test", .config = ALC880_TEST },
1606 * configuration template - to be copied to the spec instance
1608 struct alc_config_preset {
1609 snd_kcontrol_new_t *mixers[4];
1610 const struct hda_verb *init_verbs[4];
1611 unsigned int num_dacs;
1612 hda_nid_t *dac_nids;
1613 hda_nid_t dig_out_nid; /* optional */
1614 hda_nid_t hp_nid; /* optional */
1615 unsigned int num_adc_nids;
1616 hda_nid_t *adc_nids;
1617 unsigned int num_channel_mode;
1618 const struct alc_channel_mode *channel_mode;
1619 const struct hda_input_mux *input_mux;
1622 static struct alc_config_preset alc880_presets[] = {
1624 .mixers = { alc880_three_stack_mixer },
1625 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1626 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1627 .dac_nids = alc880_dac_nids,
1628 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1629 .channel_mode = alc880_threestack_modes,
1630 .input_mux = &alc880_capture_source,
1632 [ALC880_3ST_DIG] = {
1633 .mixers = { alc880_three_stack_mixer },
1634 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1635 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1636 .dac_nids = alc880_dac_nids,
1637 .dig_out_nid = ALC880_DIGOUT_NID,
1638 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1639 .channel_mode = alc880_threestack_modes,
1640 .input_mux = &alc880_capture_source,
1643 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1644 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1645 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1646 .dac_nids = alc880_dac_nids,
1647 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1648 .channel_mode = alc880_fivestack_modes,
1649 .input_mux = &alc880_capture_source,
1651 [ALC880_5ST_DIG] = {
1652 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1653 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1654 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1655 .dac_nids = alc880_dac_nids,
1656 .dig_out_nid = ALC880_DIGOUT_NID,
1657 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1658 .channel_mode = alc880_fivestack_modes,
1659 .input_mux = &alc880_capture_source,
1662 .mixers = { alc880_six_stack_mixer },
1663 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1664 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1665 .dac_nids = alc880_6st_dac_nids,
1666 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1667 .channel_mode = alc880_sixstack_modes,
1668 .input_mux = &alc880_6stack_capture_source,
1670 [ALC880_6ST_DIG] = {
1671 .mixers = { alc880_six_stack_mixer },
1672 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1673 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1674 .dac_nids = alc880_6st_dac_nids,
1675 .dig_out_nid = ALC880_DIGOUT_NID,
1676 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1677 .channel_mode = alc880_sixstack_modes,
1678 .input_mux = &alc880_6stack_capture_source,
1681 .mixers = { alc880_w810_base_mixer },
1682 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
1683 alc880_gpio2_init_verbs },
1684 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1685 .dac_nids = alc880_w810_dac_nids,
1686 .dig_out_nid = ALC880_DIGOUT_NID,
1687 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1688 .channel_mode = alc880_w810_modes,
1689 .input_mux = &alc880_capture_source,
1692 .mixers = { alc880_z71v_mixer },
1693 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
1694 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1695 .dac_nids = alc880_z71v_dac_nids,
1696 .dig_out_nid = ALC880_DIGOUT_NID,
1698 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1699 .channel_mode = alc880_2_jack_modes,
1700 .input_mux = &alc880_capture_source,
1703 .mixers = { alc880_f1734_mixer },
1704 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1705 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1706 .dac_nids = alc880_f1734_dac_nids,
1708 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1709 .channel_mode = alc880_2_jack_modes,
1710 .input_mux = &alc880_capture_source,
1713 .mixers = { alc880_asus_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 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1719 .channel_mode = alc880_asus_modes,
1720 .input_mux = &alc880_capture_source,
1722 [ALC880_ASUS_DIG] = {
1723 .mixers = { alc880_asus_mixer },
1724 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1725 alc880_gpio1_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 [ALC880_ASUS_W1V] = {
1734 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1735 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1736 alc880_gpio1_init_verbs },
1737 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1738 .dac_nids = alc880_asus_dac_nids,
1739 .dig_out_nid = ALC880_DIGOUT_NID,
1740 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1741 .channel_mode = alc880_asus_modes,
1742 .input_mux = &alc880_capture_source,
1744 [ALC880_UNIWILL_DIG] = {
1745 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
1746 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1747 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1748 .dac_nids = alc880_asus_dac_nids,
1749 .dig_out_nid = ALC880_DIGOUT_NID,
1750 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1751 .channel_mode = alc880_asus_modes,
1752 .input_mux = &alc880_capture_source,
1754 #ifdef CONFIG_SND_DEBUG
1756 .mixers = { alc880_test_mixer },
1757 .init_verbs = { alc880_test_init_verbs },
1758 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1759 .dac_nids = alc880_test_dac_nids,
1760 .dig_out_nid = ALC880_DIGOUT_NID,
1761 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1762 .channel_mode = alc880_test_modes,
1763 .input_mux = &alc880_test_capture_source,
1769 * Automatic parse of I/O pins from the BIOS configuration
1772 #define NUM_CONTROL_ALLOC 32
1773 #define NUM_VERB_ALLOC 32
1777 ALC_CTL_WIDGET_MUTE,
1780 static snd_kcontrol_new_t alc880_control_templates[] = {
1781 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1782 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1783 ALC_BIND_MUTE(NULL, 0, 0, 0),
1786 /* add dynamic controls */
1787 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1789 snd_kcontrol_new_t *knew;
1791 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1792 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1794 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1797 if (spec->kctl_alloc) {
1798 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1799 kfree(spec->kctl_alloc);
1801 spec->kctl_alloc = knew;
1802 spec->num_kctl_alloc = num;
1805 knew = &spec->kctl_alloc[spec->num_kctl_used];
1806 *knew = alc880_control_templates[type];
1807 knew->name = kstrdup(name, GFP_KERNEL);
1810 knew->private_value = val;
1811 spec->num_kctl_used++;
1815 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1816 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1817 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1818 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1819 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
1820 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
1821 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
1822 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
1823 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1824 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
1825 #define ALC880_PIN_CD_NID 0x1c
1827 /* fill in the dac_nids table from the parsed pin configuration */
1828 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1834 memset(assigned, 0, sizeof(assigned));
1835 spec->multiout.dac_nids = spec->private_dac_nids;
1837 /* check the pins hardwired to audio widget */
1838 for (i = 0; i < cfg->line_outs; i++) {
1839 nid = cfg->line_out_pins[i];
1840 if (alc880_is_fixed_pin(nid)) {
1841 int idx = alc880_fixed_pin_idx(nid);
1842 spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
1846 /* left pins can be connect to any audio widget */
1847 for (i = 0; i < cfg->line_outs; i++) {
1848 nid = cfg->line_out_pins[i];
1849 if (alc880_is_fixed_pin(nid))
1851 /* search for an empty channel */
1852 for (j = 0; j < cfg->line_outs; j++) {
1853 if (! assigned[j]) {
1854 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1860 spec->multiout.num_dacs = cfg->line_outs;
1864 /* add playback controls from the parsed DAC table */
1865 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1868 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1872 for (i = 0; i < cfg->line_outs; i++) {
1873 if (! spec->multiout.dac_nids[i])
1875 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
1878 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
1879 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1881 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
1882 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1884 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
1885 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
1887 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
1888 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
1891 sprintf(name, "%s Playback Volume", chname[i]);
1892 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1893 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1895 sprintf(name, "%s Playback Switch", chname[i]);
1896 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
1897 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1905 /* add playback controls for HP output */
1906 static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
1914 if (alc880_is_fixed_pin(pin)) {
1915 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
1916 if (! spec->multiout.dac_nids[0]) {
1917 /* use this as the primary output */
1918 spec->multiout.dac_nids[0] = nid;
1919 if (! spec->multiout.num_dacs)
1920 spec->multiout.num_dacs = 1;
1922 /* specify the DAC as the extra HP output */
1923 spec->multiout.hp_nid = nid;
1924 /* control HP volume/switch on the output mixer amp */
1925 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
1926 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
1927 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1929 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
1930 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1932 } else if (alc880_is_multi_pin(pin)) {
1933 /* set manual connection */
1934 if (! spec->multiout.dac_nids[0]) {
1935 /* use this as the primary output */
1936 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
1937 if (! spec->multiout.num_dacs)
1938 spec->multiout.num_dacs = 1;
1940 /* we have only a switch on HP-out PIN */
1941 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
1942 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
1948 /* create input playback/capture controls for the given pin */
1949 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
1954 sprintf(name, "%s Playback Volume", ctlname);
1955 idx = alc880_input_pin_idx(pin);
1956 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1957 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1959 sprintf(name, "%s Playback Switch", ctlname);
1960 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
1961 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1966 /* create playback/capture controls for input pins */
1967 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1969 static char *labels[AUTO_PIN_LAST] = {
1970 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
1972 struct hda_input_mux *imux = &spec->private_imux;
1975 for (i = 0; i < AUTO_PIN_LAST; i++) {
1976 if (alc880_is_input_pin(cfg->input_pins[i])) {
1977 err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
1980 imux->items[imux->num_items].label = labels[i];
1981 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
1988 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
1992 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1993 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
1994 /* need the manual connection? */
1995 if (alc880_is_multi_pin(nid)) {
1996 struct alc_spec *spec = codec->spec;
1997 int idx = alc880_multi_pin_idx(nid);
1998 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
1999 AC_VERB_SET_CONNECT_SEL,
2000 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
2004 static void alc880_auto_init_multi_out(struct hda_codec *codec)
2006 struct alc_spec *spec = codec->spec;
2009 for (i = 0; i < spec->autocfg.line_outs; i++) {
2010 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2011 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
2015 static void alc880_auto_init_hp_out(struct hda_codec *codec)
2017 struct alc_spec *spec = codec->spec;
2020 pin = spec->autocfg.hp_pin;
2021 if (pin) /* connect to front */
2022 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
2025 static void alc880_auto_init_analog_input(struct hda_codec *codec)
2027 struct alc_spec *spec = codec->spec;
2030 for (i = 0; i < AUTO_PIN_LAST; i++) {
2031 hda_nid_t nid = spec->autocfg.input_pins[i];
2032 if (alc880_is_input_pin(nid)) {
2033 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2034 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2035 if (nid != ALC880_PIN_CD_NID)
2036 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2042 /* parse the BIOS configuration and set up the alc_spec */
2043 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2044 static int alc880_parse_auto_config(struct hda_codec *codec)
2046 struct alc_spec *spec = codec->spec;
2049 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
2051 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
2053 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
2054 return 0; /* can't find valid BIOS pin config */
2055 if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2056 (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
2057 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2060 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2062 if (spec->autocfg.dig_out_pin)
2063 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2064 if (spec->autocfg.dig_in_pin)
2065 spec->dig_in_nid = ALC880_DIGIN_NID;
2067 if (spec->kctl_alloc)
2068 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2070 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2072 spec->input_mux = &spec->private_imux;
2077 /* init callback for auto-configuration model -- overriding the default init */
2078 static int alc880_auto_init(struct hda_codec *codec)
2081 alc880_auto_init_multi_out(codec);
2082 alc880_auto_init_hp_out(codec);
2083 alc880_auto_init_analog_input(codec);
2088 * OK, here we have finally the patch for ALC880
2091 static int patch_alc880(struct hda_codec *codec)
2093 struct alc_spec *spec;
2097 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2101 init_MUTEX(&spec->bind_mutex);
2104 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
2105 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
2106 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
2107 board_config = ALC880_AUTO;
2110 if (board_config == ALC880_AUTO) {
2111 /* automatic parse from the BIOS config */
2112 err = alc880_parse_auto_config(codec);
2117 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
2118 board_config = ALC880_3ST;
2122 if (board_config != ALC880_AUTO) {
2123 /* set up from the preset table */
2124 const struct alc_config_preset *preset;
2126 preset = &alc880_presets[board_config];
2128 for (i = 0; preset->mixers[i]; i++) {
2129 snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
2130 spec->mixers[spec->num_mixers++] = preset->mixers[i];
2132 for (i = 0; preset->init_verbs[i]; i++) {
2133 snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
2134 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
2137 spec->channel_mode = preset->channel_mode;
2138 spec->num_channel_mode = preset->num_channel_mode;
2140 spec->multiout.max_channels = spec->channel_mode[0].channels;
2142 spec->multiout.num_dacs = preset->num_dacs;
2143 spec->multiout.dac_nids = preset->dac_nids;
2144 spec->multiout.dig_out_nid = preset->dig_out_nid;
2145 spec->multiout.hp_nid = preset->hp_nid;
2147 spec->input_mux = preset->input_mux;
2149 spec->num_adc_nids = preset->num_adc_nids;
2150 spec->adc_nids = preset->adc_nids;
2153 spec->stream_name_analog = "ALC880 Analog";
2154 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2155 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2157 spec->stream_name_digital = "ALC880 Digital";
2158 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2159 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2161 if (! spec->adc_nids && spec->input_mux) {
2162 /* check whether NID 0x07 is valid */
2163 unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
2164 AC_PAR_AUDIO_WIDGET_CAP);
2165 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2166 if (wcap != AC_WID_AUD_IN) {
2167 spec->adc_nids = alc880_adc_nids_alt;
2168 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
2169 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
2172 spec->adc_nids = alc880_adc_nids;
2173 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2174 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2179 codec->patch_ops = alc_patch_ops;
2180 if (board_config == ALC880_AUTO)
2181 codec->patch_ops.init = alc880_auto_init;
2191 static hda_nid_t alc260_dac_nids[1] = {
2196 static hda_nid_t alc260_adc_nids[1] = {
2201 static hda_nid_t alc260_hp_adc_nids[1] = {
2206 #define ALC260_DIGOUT_NID 0x03
2207 #define ALC260_DIGIN_NID 0x06
2209 static struct hda_input_mux alc260_capture_source = {
2213 { "Front Mic", 0x1 },
2220 * This is just place-holder, so there's something for alc_build_pcms to look
2221 * at when it calculates the maximum number of channels. ALC260 has no mixer
2222 * element which allows changing the channel mode, so the verb list is
2225 static struct alc_channel_mode alc260_modes[1] = {
2229 static snd_kcontrol_new_t alc260_base_mixer[] = {
2230 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2231 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2232 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2233 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2234 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2235 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2237 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2238 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2240 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
2241 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
2242 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2243 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2244 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2245 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
2246 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
2247 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
2249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2250 .name = "Capture Source",
2251 .info = alc_mux_enum_info,
2252 .get = alc_mux_enum_get,
2253 .put = alc_mux_enum_put,
2258 static snd_kcontrol_new_t alc260_hp_mixer[] = {
2259 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2260 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2261 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2262 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2263 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2264 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2265 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2266 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2267 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2268 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2269 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2270 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2271 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2272 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
2273 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2274 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2276 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2277 .name = "Capture Source",
2278 .info = alc_mux_enum_info,
2279 .get = alc_mux_enum_get,
2280 .put = alc_mux_enum_put,
2285 static struct hda_verb alc260_init_verbs[] = {
2286 /* Line In pin widget for input */
2287 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2288 /* CD pin widget for input */
2289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2290 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2291 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2292 /* Mic2 (front panel) pin widget for input and vref at 80% */
2293 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2294 /* LINE-2 is used for line-out in rear */
2295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2296 /* select line-out */
2297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2299 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2301 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2303 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2304 /* mute capture amp left and right */
2305 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2306 /* set connection select to line in (default select for this ADC) */
2307 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
2308 /* mute capture amp left and right */
2309 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2310 /* set connection select to line in (default select for this ADC) */
2311 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
2312 /* set vol=0 Line-Out mixer amp left and right */
2313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2314 /* unmute pin widget amp left and right (no gain on this amp) */
2315 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2316 /* set vol=0 HP mixer amp left and right */
2317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2318 /* unmute pin widget amp left and right (no gain on this amp) */
2319 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2320 /* set vol=0 Mono mixer amp left and right */
2321 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2322 /* unmute pin widget amp left and right (no gain on this amp) */
2323 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2324 /* unmute LINE-2 out pin */
2325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2326 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
2328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
2330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
2332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2333 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
2334 /* mute Front out path */
2335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2337 /* mute Headphone out path */
2338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2340 /* mute Mono out path */
2341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2346 static struct hda_pcm_stream alc260_pcm_analog_playback = {
2352 static struct hda_pcm_stream alc260_pcm_analog_capture = {
2358 static struct hda_board_config alc260_cfg_tbl[] = {
2359 { .modelname = "hp", .config = ALC260_HP },
2360 { .pci_subvendor = 0x103c, .config = ALC260_HP },
2364 static int patch_alc260(struct hda_codec *codec)
2366 struct alc_spec *spec;
2369 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2373 init_MUTEX(&spec->bind_mutex);
2376 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
2377 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
2378 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
2379 board_config = ALC260_BASIC;
2382 switch (board_config) {
2384 spec->mixers[spec->num_mixers] = alc260_hp_mixer;
2388 spec->mixers[spec->num_mixers] = alc260_base_mixer;
2393 spec->init_verbs[0] = alc260_init_verbs;
2394 spec->num_init_verbs = 1;
2396 spec->channel_mode = alc260_modes;
2397 spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
2399 spec->stream_name_analog = "ALC260 Analog";
2400 spec->stream_analog_playback = &alc260_pcm_analog_playback;
2401 spec->stream_analog_capture = &alc260_pcm_analog_capture;
2403 spec->multiout.max_channels = spec->channel_mode[0].channels;
2404 spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
2405 spec->multiout.dac_nids = alc260_dac_nids;
2407 spec->input_mux = &alc260_capture_source;
2408 switch (board_config) {
2410 spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
2411 spec->adc_nids = alc260_hp_adc_nids;
2414 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2415 spec->adc_nids = alc260_adc_nids;
2419 codec->patch_ops = alc_patch_ops;
2428 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
2429 * configuration. Each pin widget can choose any input DACs and a mixer.
2430 * Each ADC is connected from a mixer of all inputs. This makes possible
2431 * 6-channel independent captures.
2433 * In addition, an independent DAC for the multi-playback (not used in this
2437 static struct alc_channel_mode alc882_ch_modes[1] = {
2441 static hda_nid_t alc882_dac_nids[4] = {
2442 /* front, rear, clfe, rear_surr */
2443 0x02, 0x03, 0x04, 0x05
2446 static hda_nid_t alc882_adc_nids[3] = {
2452 /* FIXME: should be a matrix-type input source selection */
2454 static struct hda_input_mux alc882_capture_source = {
2458 { "Front Mic", 0x1 },
2464 #define alc882_mux_enum_info alc_mux_enum_info
2465 #define alc882_mux_enum_get alc_mux_enum_get
2467 static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
2469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2470 struct alc_spec *spec = codec->spec;
2471 const struct hda_input_mux *imux = spec->input_mux;
2472 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2473 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
2474 hda_nid_t nid = capture_mixers[adc_idx];
2475 unsigned int *cur_val = &spec->cur_mux[adc_idx];
2476 unsigned int i, idx;
2478 idx = ucontrol->value.enumerated.item[0];
2479 if (idx >= imux->num_items)
2480 idx = imux->num_items - 1;
2481 if (*cur_val == idx && ! codec->in_resume)
2483 for (i = 0; i < imux->num_items; i++) {
2484 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
2485 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2486 v | (imux->items[i].index << 8));
2492 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
2493 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
2495 static snd_kcontrol_new_t alc882_base_mixer[] = {
2496 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2497 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2498 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2499 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2500 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2501 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2502 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2503 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT),
2504 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2505 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2506 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2507 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2508 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2509 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2510 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2513 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2515 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
2516 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
2517 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
2518 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
2519 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
2520 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
2521 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
2522 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
2524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2525 /* .name = "Capture Source", */
2526 .name = "Input Source",
2528 .info = alc882_mux_enum_info,
2529 .get = alc882_mux_enum_get,
2530 .put = alc882_mux_enum_put,
2535 static struct hda_verb alc882_init_verbs[] = {
2536 /* Front mixer: unmute input/output amp left and right (volume = 0) */
2537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2541 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2547 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2549 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2550 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2551 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2553 /* Front Pin: output 0 (0x0c) */
2554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2555 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2557 /* Rear Pin: output 1 (0x0d) */
2558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2560 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
2561 /* CLFE Pin: output 2 (0x0e) */
2562 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2563 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2564 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2565 /* Side Pin: output 3 (0x0f) */
2566 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2567 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2568 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
2569 /* Mic (rear) pin: input vref at 80% */
2570 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2572 /* Front Mic pin: input vref at 80% */
2573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2574 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2575 /* Line In pin: input */
2576 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2578 /* Line-2 In: Headphone output (output 0 - 0x0c) */
2579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2580 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2581 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2582 /* CD pin widget for input */
2583 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2585 /* FIXME: use matrix-type input source selection */
2586 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
2587 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
2588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2602 /* ADC1: mute amp left and right */
2603 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2604 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2605 /* ADC2: mute amp left and right */
2606 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2607 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2608 /* ADC3: mute amp left and right */
2609 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2610 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2615 static int patch_alc882(struct hda_codec *codec)
2617 struct alc_spec *spec;
2619 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
2623 init_MUTEX(&spec->bind_mutex);
2626 spec->mixers[spec->num_mixers] = alc882_base_mixer;
2629 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2630 spec->dig_in_nid = ALC880_DIGIN_NID;
2631 spec->init_verbs[0] = alc882_init_verbs;
2632 spec->num_init_verbs = 1;
2634 spec->channel_mode = alc882_ch_modes;
2635 spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
2637 spec->stream_name_analog = "ALC882 Analog";
2638 spec->stream_analog_playback = &alc880_pcm_analog_playback;
2639 spec->stream_analog_capture = &alc880_pcm_analog_capture;
2641 spec->stream_name_digital = "ALC882 Digital";
2642 spec->stream_digital_playback = &alc880_pcm_digital_playback;
2643 spec->stream_digital_capture = &alc880_pcm_digital_capture;
2645 spec->multiout.max_channels = spec->channel_mode[0].channels;
2646 spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
2647 spec->multiout.dac_nids = alc882_dac_nids;
2649 spec->input_mux = &alc882_capture_source;
2650 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
2651 spec->adc_nids = alc882_adc_nids;
2653 codec->patch_ops = alc_patch_ops;
2661 struct hda_codec_preset snd_hda_preset_realtek[] = {
2662 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
2663 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
2664 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },