33 #include <linux/time.h>
42 #define AC97_ID_STAC9758 0x83847658
53 static int snd_emu10k1_spdif_get(
struct snd_kcontrol *kcontrol,
57 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
64 ucontrol->
value.iec958.status[0] = (emu->spdif_bits[
idx] >> 0) & 0xff;
65 ucontrol->
value.iec958.status[1] = (emu->spdif_bits[
idx] >> 8) & 0xff;
66 ucontrol->
value.iec958.status[2] = (emu->spdif_bits[
idx] >> 16) & 0xff;
67 ucontrol->
value.iec958.status[3] = (emu->spdif_bits[
idx] >> 24) & 0xff;
68 spin_unlock_irqrestore(&emu->reg_lock, flags);
72 static int snd_emu10k1_spdif_get_mask(
struct snd_kcontrol *kcontrol,
75 ucontrol->
value.iec958.status[0] = 0xff;
76 ucontrol->
value.iec958.status[1] = 0xff;
77 ucontrol->
value.iec958.status[2] = 0xff;
78 ucontrol->
value.iec958.status[3] = 0xff;
86 static char *emu1010_src_texts[] = {
144 static char *emu1616_src_texts[] = {
200 static unsigned int emu1010_src_regs[] = {
204 EMU_SRC_DOCK_ADC1_LEFT1,
205 EMU_SRC_DOCK_ADC1_RIGHT1,
206 EMU_SRC_DOCK_ADC2_LEFT1,
207 EMU_SRC_DOCK_ADC2_RIGHT1,
208 EMU_SRC_DOCK_ADC3_LEFT1,
209 EMU_SRC_DOCK_ADC3_RIGHT1,
210 EMU_SRC_HAMOA_ADC_LEFT1,
211 EMU_SRC_HAMOA_ADC_RIGHT1,
212 EMU_SRC_HANA_SPDIF_LEFT1,
213 EMU_SRC_HANA_SPDIF_RIGHT1,
222 EMU_SRC_ALICE_EMU32A,
223 EMU_SRC_ALICE_EMU32A+1,
224 EMU_SRC_ALICE_EMU32A+2,
225 EMU_SRC_ALICE_EMU32A+3,
226 EMU_SRC_ALICE_EMU32A+4,
227 EMU_SRC_ALICE_EMU32A+5,
228 EMU_SRC_ALICE_EMU32A+6,
229 EMU_SRC_ALICE_EMU32A+7,
230 EMU_SRC_ALICE_EMU32A+8,
231 EMU_SRC_ALICE_EMU32A+9,
232 EMU_SRC_ALICE_EMU32A+0xa,
233 EMU_SRC_ALICE_EMU32A+0xb,
234 EMU_SRC_ALICE_EMU32A+0xc,
235 EMU_SRC_ALICE_EMU32A+0xd,
236 EMU_SRC_ALICE_EMU32A+0xe,
237 EMU_SRC_ALICE_EMU32A+0xf,
238 EMU_SRC_ALICE_EMU32B,
239 EMU_SRC_ALICE_EMU32B+1,
240 EMU_SRC_ALICE_EMU32B+2,
241 EMU_SRC_ALICE_EMU32B+3,
242 EMU_SRC_ALICE_EMU32B+4,
243 EMU_SRC_ALICE_EMU32B+5,
244 EMU_SRC_ALICE_EMU32B+6,
245 EMU_SRC_ALICE_EMU32B+7,
246 EMU_SRC_ALICE_EMU32B+8,
247 EMU_SRC_ALICE_EMU32B+9,
248 EMU_SRC_ALICE_EMU32B+0xa,
249 EMU_SRC_ALICE_EMU32B+0xb,
250 EMU_SRC_ALICE_EMU32B+0xc,
251 EMU_SRC_ALICE_EMU32B+0xd,
252 EMU_SRC_ALICE_EMU32B+0xe,
253 EMU_SRC_ALICE_EMU32B+0xf,
257 static unsigned int emu1616_src_regs[] = {
261 EMU_SRC_DOCK_ADC1_LEFT1,
262 EMU_SRC_DOCK_ADC1_RIGHT1,
263 EMU_SRC_DOCK_ADC2_LEFT1,
264 EMU_SRC_DOCK_ADC2_RIGHT1,
265 EMU_SRC_MDOCK_SPDIF_LEFT1,
266 EMU_SRC_MDOCK_SPDIF_RIGHT1,
268 EMU_SRC_MDOCK_ADAT+1,
269 EMU_SRC_MDOCK_ADAT+2,
270 EMU_SRC_MDOCK_ADAT+3,
271 EMU_SRC_MDOCK_ADAT+4,
272 EMU_SRC_MDOCK_ADAT+5,
273 EMU_SRC_MDOCK_ADAT+6,
274 EMU_SRC_MDOCK_ADAT+7,
275 EMU_SRC_ALICE_EMU32A,
276 EMU_SRC_ALICE_EMU32A+1,
277 EMU_SRC_ALICE_EMU32A+2,
278 EMU_SRC_ALICE_EMU32A+3,
279 EMU_SRC_ALICE_EMU32A+4,
280 EMU_SRC_ALICE_EMU32A+5,
281 EMU_SRC_ALICE_EMU32A+6,
282 EMU_SRC_ALICE_EMU32A+7,
283 EMU_SRC_ALICE_EMU32A+8,
284 EMU_SRC_ALICE_EMU32A+9,
285 EMU_SRC_ALICE_EMU32A+0xa,
286 EMU_SRC_ALICE_EMU32A+0xb,
287 EMU_SRC_ALICE_EMU32A+0xc,
288 EMU_SRC_ALICE_EMU32A+0xd,
289 EMU_SRC_ALICE_EMU32A+0xe,
290 EMU_SRC_ALICE_EMU32A+0xf,
291 EMU_SRC_ALICE_EMU32B,
292 EMU_SRC_ALICE_EMU32B+1,
293 EMU_SRC_ALICE_EMU32B+2,
294 EMU_SRC_ALICE_EMU32B+3,
295 EMU_SRC_ALICE_EMU32B+4,
296 EMU_SRC_ALICE_EMU32B+5,
297 EMU_SRC_ALICE_EMU32B+6,
298 EMU_SRC_ALICE_EMU32B+7,
299 EMU_SRC_ALICE_EMU32B+8,
300 EMU_SRC_ALICE_EMU32B+9,
301 EMU_SRC_ALICE_EMU32B+0xa,
302 EMU_SRC_ALICE_EMU32B+0xb,
303 EMU_SRC_ALICE_EMU32B+0xc,
304 EMU_SRC_ALICE_EMU32B+0xd,
305 EMU_SRC_ALICE_EMU32B+0xe,
306 EMU_SRC_ALICE_EMU32B+0xf,
313 static unsigned int emu1010_output_dst[] = {
314 EMU_DST_DOCK_DAC1_LEFT1,
315 EMU_DST_DOCK_DAC1_RIGHT1,
316 EMU_DST_DOCK_DAC2_LEFT1,
317 EMU_DST_DOCK_DAC2_RIGHT1,
318 EMU_DST_DOCK_DAC3_LEFT1,
319 EMU_DST_DOCK_DAC3_RIGHT1,
320 EMU_DST_DOCK_DAC4_LEFT1,
321 EMU_DST_DOCK_DAC4_RIGHT1,
322 EMU_DST_DOCK_PHONES_LEFT1,
323 EMU_DST_DOCK_PHONES_RIGHT1,
324 EMU_DST_DOCK_SPDIF_LEFT1,
325 EMU_DST_DOCK_SPDIF_RIGHT1,
326 EMU_DST_HANA_SPDIF_LEFT1,
327 EMU_DST_HANA_SPDIF_RIGHT1,
328 EMU_DST_HAMOA_DAC_LEFT1,
329 EMU_DST_HAMOA_DAC_RIGHT1,
341 static unsigned int emu1616_output_dst[] = {
342 EMU_DST_DOCK_DAC1_LEFT1,
343 EMU_DST_DOCK_DAC1_RIGHT1,
344 EMU_DST_DOCK_DAC2_LEFT1,
345 EMU_DST_DOCK_DAC2_RIGHT1,
346 EMU_DST_DOCK_DAC3_LEFT1,
347 EMU_DST_DOCK_DAC3_RIGHT1,
348 EMU_DST_MDOCK_SPDIF_LEFT1,
349 EMU_DST_MDOCK_SPDIF_RIGHT1,
351 EMU_DST_MDOCK_ADAT+1,
352 EMU_DST_MDOCK_ADAT+2,
353 EMU_DST_MDOCK_ADAT+3,
354 EMU_DST_MDOCK_ADAT+4,
355 EMU_DST_MDOCK_ADAT+5,
356 EMU_DST_MDOCK_ADAT+6,
357 EMU_DST_MDOCK_ADAT+7,
358 EMU_DST_MANA_DAC_LEFT,
359 EMU_DST_MANA_DAC_RIGHT,
367 static unsigned int emu1010_input_dst[] = {
368 EMU_DST_ALICE2_EMU32_0,
369 EMU_DST_ALICE2_EMU32_1,
370 EMU_DST_ALICE2_EMU32_2,
371 EMU_DST_ALICE2_EMU32_3,
372 EMU_DST_ALICE2_EMU32_4,
373 EMU_DST_ALICE2_EMU32_5,
374 EMU_DST_ALICE2_EMU32_6,
375 EMU_DST_ALICE2_EMU32_7,
376 EMU_DST_ALICE2_EMU32_8,
377 EMU_DST_ALICE2_EMU32_9,
378 EMU_DST_ALICE2_EMU32_A,
379 EMU_DST_ALICE2_EMU32_B,
380 EMU_DST_ALICE2_EMU32_C,
381 EMU_DST_ALICE2_EMU32_D,
382 EMU_DST_ALICE2_EMU32_E,
383 EMU_DST_ALICE2_EMU32_F,
384 EMU_DST_ALICE_I2S0_LEFT,
385 EMU_DST_ALICE_I2S0_RIGHT,
386 EMU_DST_ALICE_I2S1_LEFT,
387 EMU_DST_ALICE_I2S1_RIGHT,
388 EMU_DST_ALICE_I2S2_LEFT,
389 EMU_DST_ALICE_I2S2_RIGHT,
392 static int snd_emu1010_input_output_source_info(
struct snd_kcontrol *kcontrol,
400 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
402 items = emu1616_src_texts;
405 items = emu1010_src_texts;
415 static int snd_emu1010_output_source_get(
struct snd_kcontrol *kcontrol,
424 (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616 &&
427 ucontrol->
value.enumerated.item[0] = emu->emu1010.output_source[
channel];
431 static int snd_emu1010_output_source_put(
struct snd_kcontrol *kcontrol,
438 val = ucontrol->
value.enumerated.item[0];
440 (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616 &&
446 (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616 &&
449 if (emu->emu1010.output_source[channel] == val)
452 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616)
454 emu1616_output_dst[channel], emu1616_src_regs[val]);
457 emu1010_output_dst[channel], emu1010_src_regs[val]);
461 static int snd_emu1010_input_source_get(
struct snd_kcontrol *kcontrol,
471 ucontrol->
value.enumerated.item[0] = emu->emu1010.input_source[
channel];
475 static int snd_emu1010_input_source_put(
struct snd_kcontrol *kcontrol,
482 val = ucontrol->
value.enumerated.item[0];
484 (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616 &&
491 if (emu->emu1010.input_source[channel] == val)
494 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616)
496 emu1010_input_dst[channel], emu1616_src_regs[val]);
499 emu1010_input_dst[channel], emu1010_src_regs[val]);
503 #define EMU1010_SOURCE_OUTPUT(xname,chid) \
505 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
506 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
507 .info = snd_emu1010_input_output_source_info, \
508 .get = snd_emu1010_output_source_get, \
509 .put = snd_emu1010_output_source_put, \
510 .private_value = chid \
542 static struct snd_kcontrol_new snd_emu1616_output_enum_ctls[] __devinitdata = {
564 #define EMU1010_SOURCE_INPUT(xname,chid) \
566 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
567 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
568 .info = snd_emu1010_input_output_source_info, \
569 .get = snd_emu1010_input_source_get, \
570 .put = snd_emu1010_input_source_put, \
571 .private_value = chid \
574 static struct snd_kcontrol_new snd_emu1010_input_enum_ctls[] __devinitdata = {
601 #define snd_emu1010_adc_pads_info snd_ctl_boolean_mono_info
607 ucontrol->
value.integer.value[0] = (emu->emu1010.adc_pads &
mask) ? 1 : 0;
616 val = ucontrol->
value.integer.value[0];
617 cache = emu->emu1010.adc_pads;
619 cache = cache |
mask;
621 cache = cache & ~mask;
622 if (cache != emu->emu1010.adc_pads) {
624 emu->emu1010.adc_pads =
cache;
632 #define EMU1010_ADC_PADS(xname,chid) \
634 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
635 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
636 .info = snd_emu1010_adc_pads_info, \
637 .get = snd_emu1010_adc_pads_get, \
638 .put = snd_emu1010_adc_pads_put, \
639 .private_value = chid \
643 EMU1010_ADC_PADS(
"ADC1 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD1),
644 EMU1010_ADC_PADS(
"ADC2 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD2),
645 EMU1010_ADC_PADS(
"ADC3 14dB PAD Audio Dock Capture Switch", EMU_HANA_DOCK_ADC_PAD3),
646 EMU1010_ADC_PADS(
"ADC1 14dB PAD 0202 Capture Switch", EMU_HANA_0202_ADC_PAD1),
649 #define snd_emu1010_dac_pads_info snd_ctl_boolean_mono_info
655 ucontrol->
value.integer.value[0] = (emu->emu1010.dac_pads &
mask) ? 1 : 0;
664 val = ucontrol->
value.integer.value[0];
665 cache = emu->emu1010.dac_pads;
667 cache = cache |
mask;
669 cache = cache & ~mask;
670 if (cache != emu->emu1010.dac_pads) {
672 emu->emu1010.dac_pads =
cache;
680 #define EMU1010_DAC_PADS(xname,chid) \
682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
683 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
684 .info = snd_emu1010_dac_pads_info, \
685 .get = snd_emu1010_dac_pads_get, \
686 .put = snd_emu1010_dac_pads_put, \
687 .private_value = chid \
691 EMU1010_DAC_PADS(
"DAC1 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD1),
692 EMU1010_DAC_PADS(
"DAC2 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD2),
693 EMU1010_DAC_PADS(
"DAC3 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD3),
694 EMU1010_DAC_PADS(
"DAC4 Audio Dock 14dB PAD Playback Switch", EMU_HANA_DOCK_DAC_PAD4),
695 EMU1010_DAC_PADS(
"DAC1 0202 14dB PAD Playback Switch", EMU_HANA_0202_DAC_PAD1),
699 static int snd_emu1010_internal_clock_info(
struct snd_kcontrol *kcontrol,
702 static char *texts[4] = {
703 "44100",
"48000",
"SPDIF",
"ADAT"
717 static int snd_emu1010_internal_clock_get(
struct snd_kcontrol *kcontrol,
722 ucontrol->
value.enumerated.item[0] = emu->emu1010.internal_clock;
726 static int snd_emu1010_internal_clock_put(
struct snd_kcontrol *kcontrol,
733 val = ucontrol->
value.enumerated.item[0] ;
737 change = (emu->emu1010.internal_clock !=
val);
739 emu->emu1010.internal_clock =
val;
749 EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X );
752 EMU_HANA_DOCK_LEDS_2_44K | EMU_HANA_DOCK_LEDS_2_LOCK );
766 EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X );
769 EMU_HANA_DOCK_LEDS_2_48K | EMU_HANA_DOCK_LEDS_2_LOCK );
783 EMU_HANA_WCLOCK_HANA_SPDIF_IN | EMU_HANA_WCLOCK_1X );
786 EMU_HANA_DOCK_LEDS_2_EXT | EMU_HANA_DOCK_LEDS_2_LOCK );
802 EMU_HANA_WCLOCK_HANA_ADAT_IN | EMU_HANA_WCLOCK_1X );
822 .name =
"Clock Internal Rate",
824 .info = snd_emu1010_internal_clock_info,
825 .get = snd_emu1010_internal_clock_get,
826 .put = snd_emu1010_internal_clock_put
829 static int snd_audigy_i2c_capture_source_info(
struct snd_kcontrol *kcontrol,
833 static char *texts[4] = {
834 "Unknown1",
"Unknown2",
"Mic",
"Line"
837 static char *texts[2] = {
850 static int snd_audigy_i2c_capture_source_get(
struct snd_kcontrol *kcontrol,
855 ucontrol->
value.enumerated.item[0] = emu->i2c_capture_source;
859 static int snd_audigy_i2c_capture_source_put(
struct snd_kcontrol *kcontrol,
863 unsigned int source_id;
864 unsigned int ngain, ogain;
873 source_id = ucontrol->
value.enumerated.item[0];
878 change = (emu->i2c_capture_source != source_id);
882 gpio =
inl(emu->port + A_IOCFG);
884 outl(gpio | 0x4, emu->port + A_IOCFG);
886 outl(gpio & ~0x4, emu->port + A_IOCFG);
887 spin_unlock_irqrestore(&emu->emu_lock, flags);
889 ngain = emu->i2c_capture_volume[source_id][0];
890 ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0];
893 ngain = emu->i2c_capture_volume[source_id][1];
894 ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1];
898 source = 1 << (source_id + 2);
900 emu->i2c_capture_source = source_id;
908 .name =
"Capture Source",
909 .info = snd_audigy_i2c_capture_source_info,
910 .get = snd_audigy_i2c_capture_source_get,
911 .put = snd_audigy_i2c_capture_source_put
914 static int snd_audigy_i2c_volume_info(
struct snd_kcontrol *kcontrol,
924 static int snd_audigy_i2c_volume_get(
struct snd_kcontrol *kcontrol,
928 unsigned int source_id;
936 ucontrol->
value.integer.value[0] = emu->i2c_capture_volume[source_id][0];
937 ucontrol->
value.integer.value[1] = emu->i2c_capture_volume[source_id][1];
941 static int snd_audigy_i2c_volume_put(
struct snd_kcontrol *kcontrol,
947 unsigned int source_id;
955 ogain = emu->i2c_capture_volume[source_id][0];
956 ngain = ucontrol->
value.integer.value[0];
959 if (ogain != ngain) {
960 if (emu->i2c_capture_source == source_id)
962 emu->i2c_capture_volume[source_id][0] = ngain;
965 ogain = emu->i2c_capture_volume[source_id][1];
966 ngain = ucontrol->
value.integer.value[1];
969 if (ogain != ngain) {
970 if (emu->i2c_capture_source == source_id)
972 emu->i2c_capture_volume[source_id][1] = ngain;
979 #define I2C_VOLUME(xname,chid) \
981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
982 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
983 SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
984 .info = snd_audigy_i2c_volume_info, \
985 .get = snd_audigy_i2c_volume_get, \
986 .put = snd_audigy_i2c_volume_put, \
987 .tlv = { .p = snd_audigy_db_scale2 }, \
988 .private_value = chid \
992 static struct snd_kcontrol_new snd_audigy_i2c_volume_ctls[] __devinitdata = {
1000 static char *texts[] = {
"44100",
"48000",
"96000"};
1011 static int snd_audigy_spdif_output_rate_get(
struct snd_kcontrol *kcontrol,
1016 unsigned long flags;
1021 switch (tmp & A_SPDIF_RATE_MASK) {
1023 ucontrol->
value.enumerated.item[0] = 0;
1026 ucontrol->
value.enumerated.item[0] = 1;
1029 ucontrol->
value.enumerated.item[0] = 2;
1032 ucontrol->
value.enumerated.item[0] = 1;
1034 spin_unlock_irqrestore(&emu->reg_lock, flags);
1038 static int snd_audigy_spdif_output_rate_put(
struct snd_kcontrol *kcontrol,
1044 unsigned long flags;
1046 switch(ucontrol->
value.enumerated.item[0]) {
1048 val = A_SPDIF_44100;
1051 val = A_SPDIF_48000;
1054 val = A_SPDIF_96000;
1057 val = A_SPDIF_48000;
1064 tmp = reg & ~A_SPDIF_RATE_MASK;
1066 if ((change = (tmp != reg)))
1068 spin_unlock_irqrestore(&emu->reg_lock, flags);
1076 .name =
"Audigy SPDIF Output Sample Rate",
1078 .info = snd_audigy_spdif_output_rate_info,
1079 .get = snd_audigy_spdif_output_rate_get,
1080 .put = snd_audigy_spdif_output_rate_put
1084 static int snd_emu10k1_spdif_put(
struct snd_kcontrol *kcontrol,
1088 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
1091 unsigned long flags;
1096 val = (ucontrol->
value.iec958.status[0] << 0) |
1097 (ucontrol->
value.iec958.status[1] << 8) |
1098 (ucontrol->
value.iec958.status[2] << 16) |
1099 (ucontrol->
value.iec958.status[3] << 24);
1101 change = val != emu->spdif_bits[
idx];
1104 emu->spdif_bits[
idx] =
val;
1106 spin_unlock_irqrestore(&emu->reg_lock, flags);
1116 .info = snd_emu10k1_spdif_info,
1117 .get = snd_emu10k1_spdif_get_mask
1125 .info = snd_emu10k1_spdif_info,
1126 .get = snd_emu10k1_spdif_get,
1127 .put = snd_emu10k1_spdif_put
1131 static void update_emu10k1_fxrt(
struct snd_emu10k1 *emu,
int voice,
unsigned char *route)
1135 snd_emu10k1_compose_audigy_fxrt1(route));
1137 snd_emu10k1_compose_audigy_fxrt2(route));
1140 snd_emu10k1_compose_send_routing(route));
1144 static void update_emu10k1_send_volume(
struct snd_emu10k1 *emu,
int voice,
unsigned char *
volume)
1151 unsigned int val = ((
unsigned int)volume[4] << 24) |
1152 ((
unsigned int)volume[5] << 16) |
1153 ((
unsigned int)volume[6] << 8) |
1154 (
unsigned int)volume[7];
1165 uinfo->
count = emu->audigy ? 3*8 : 3*4;
1171 static int snd_emu10k1_send_routing_get(
struct snd_kcontrol *kcontrol,
1174 unsigned long flags;
1176 struct snd_emu10k1_pcm_mixer *
mix =
1177 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1179 int num_efx = emu->audigy ? 8 : 4;
1180 int mask = emu->audigy ? 0x3f : 0x0f;
1183 for (voice = 0; voice < 3; voice++)
1184 for (idx = 0; idx < num_efx; idx++)
1185 ucontrol->
value.integer.value[(voice * num_efx) +
idx] =
1186 mix->send_routing[voice][
idx] &
mask;
1187 spin_unlock_irqrestore(&emu->reg_lock, flags);
1191 static int snd_emu10k1_send_routing_put(
struct snd_kcontrol *kcontrol,
1194 unsigned long flags;
1196 struct snd_emu10k1_pcm_mixer *mix =
1197 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1198 int change = 0, voice,
idx,
val;
1199 int num_efx = emu->audigy ? 8 : 4;
1200 int mask = emu->audigy ? 0x3f : 0x0f;
1203 for (voice = 0; voice < 3; voice++)
1204 for (idx = 0; idx < num_efx; idx++) {
1205 val = ucontrol->
value.integer.value[(voice * num_efx) + idx] & mask;
1206 if (mix->send_routing[voice][idx] != val) {
1207 mix->send_routing[voice][
idx] =
val;
1211 if (change && mix->epcm) {
1212 if (mix->epcm->voices[0] && mix->epcm->voices[1]) {
1213 update_emu10k1_fxrt(emu, mix->epcm->voices[0]->number,
1214 &mix->send_routing[1][0]);
1215 update_emu10k1_fxrt(emu, mix->epcm->voices[1]->number,
1216 &mix->send_routing[2][0]);
1217 }
else if (mix->epcm->voices[0]) {
1218 update_emu10k1_fxrt(emu, mix->epcm->voices[0]->number,
1219 &mix->send_routing[0][0]);
1222 spin_unlock_irqrestore(&emu->reg_lock, flags);
1230 .name =
"EMU10K1 PCM Send Routing",
1232 .info = snd_emu10k1_send_routing_info,
1233 .get = snd_emu10k1_send_routing_get,
1234 .put = snd_emu10k1_send_routing_put
1241 uinfo->
count = emu->audigy ? 3*8 : 3*4;
1247 static int snd_emu10k1_send_volume_get(
struct snd_kcontrol *kcontrol,
1250 unsigned long flags;
1252 struct snd_emu10k1_pcm_mixer *mix =
1253 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1255 int num_efx = emu->audigy ? 8 : 4;
1258 for (idx = 0; idx < 3*num_efx; idx++)
1259 ucontrol->
value.integer.value[idx] = mix->send_volume[idx/num_efx][idx%num_efx];
1260 spin_unlock_irqrestore(&emu->reg_lock, flags);
1264 static int snd_emu10k1_send_volume_put(
struct snd_kcontrol *kcontrol,
1267 unsigned long flags;
1269 struct snd_emu10k1_pcm_mixer *mix =
1270 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1271 int change = 0,
idx,
val;
1272 int num_efx = emu->audigy ? 8 : 4;
1275 for (idx = 0; idx < 3*num_efx; idx++) {
1276 val = ucontrol->
value.integer.value[
idx] & 255;
1277 if (mix->send_volume[idx/num_efx][idx%num_efx] != val) {
1278 mix->send_volume[idx/num_efx][idx%num_efx] =
val;
1282 if (change && mix->epcm) {
1283 if (mix->epcm->voices[0] && mix->epcm->voices[1]) {
1284 update_emu10k1_send_volume(emu, mix->epcm->voices[0]->number,
1285 &mix->send_volume[1][0]);
1286 update_emu10k1_send_volume(emu, mix->epcm->voices[1]->number,
1287 &mix->send_volume[2][0]);
1288 }
else if (mix->epcm->voices[0]) {
1289 update_emu10k1_send_volume(emu, mix->epcm->voices[0]->number,
1290 &mix->send_volume[0][0]);
1293 spin_unlock_irqrestore(&emu->reg_lock, flags);
1301 .name =
"EMU10K1 PCM Send Volume",
1303 .info = snd_emu10k1_send_volume_info,
1304 .get = snd_emu10k1_send_volume_get,
1305 .put = snd_emu10k1_send_volume_put
1317 static int snd_emu10k1_attn_get(
struct snd_kcontrol *kcontrol,
1321 struct snd_emu10k1_pcm_mixer *mix =
1322 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1323 unsigned long flags;
1327 for (idx = 0; idx < 3; idx++)
1328 ucontrol->
value.integer.value[idx] = mix->attn[idx];
1329 spin_unlock_irqrestore(&emu->reg_lock, flags);
1333 static int snd_emu10k1_attn_put(
struct snd_kcontrol *kcontrol,
1336 unsigned long flags;
1338 struct snd_emu10k1_pcm_mixer *mix =
1339 &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1340 int change = 0,
idx,
val;
1343 for (idx = 0; idx < 3; idx++) {
1344 val = ucontrol->
value.integer.value[
idx] & 0xffff;
1345 if (mix->attn[idx] != val) {
1350 if (change && mix->epcm) {
1351 if (mix->epcm->voices[0] && mix->epcm->voices[1]) {
1354 }
else if (mix->epcm->voices[0]) {
1358 spin_unlock_irqrestore(&emu->reg_lock, flags);
1366 .name =
"EMU10K1 PCM Volume",
1368 .info = snd_emu10k1_attn_info,
1369 .get = snd_emu10k1_attn_get,
1370 .put = snd_emu10k1_attn_put
1379 uinfo->
count = emu->audigy ? 8 : 4;
1385 static int snd_emu10k1_efx_send_routing_get(
struct snd_kcontrol *kcontrol,
1388 unsigned long flags;
1390 struct snd_emu10k1_pcm_mixer *mix =
1391 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1393 int num_efx = emu->audigy ? 8 : 4;
1394 int mask = emu->audigy ? 0x3f : 0x0f;
1397 for (idx = 0; idx < num_efx; idx++)
1398 ucontrol->
value.integer.value[idx] =
1399 mix->send_routing[0][idx] & mask;
1400 spin_unlock_irqrestore(&emu->reg_lock, flags);
1404 static int snd_emu10k1_efx_send_routing_put(
struct snd_kcontrol *kcontrol,
1407 unsigned long flags;
1409 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
1410 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
1411 int change = 0,
idx,
val;
1412 int num_efx = emu->audigy ? 8 : 4;
1413 int mask = emu->audigy ? 0x3f : 0x0f;
1416 for (idx = 0; idx < num_efx; idx++) {
1418 if (mix->send_routing[0][idx] != val) {
1419 mix->send_routing[0][
idx] =
val;
1424 if (change && mix->epcm) {
1425 if (mix->epcm->voices[ch]) {
1426 update_emu10k1_fxrt(emu, mix->epcm->voices[ch]->number,
1427 &mix->send_routing[0][0]);
1430 spin_unlock_irqrestore(&emu->reg_lock, flags);
1438 .name =
"Multichannel PCM Send Routing",
1440 .info = snd_emu10k1_efx_send_routing_info,
1441 .get = snd_emu10k1_efx_send_routing_get,
1442 .put = snd_emu10k1_efx_send_routing_put
1449 uinfo->
count = emu->audigy ? 8 : 4;
1455 static int snd_emu10k1_efx_send_volume_get(
struct snd_kcontrol *kcontrol,
1458 unsigned long flags;
1460 struct snd_emu10k1_pcm_mixer *mix =
1461 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1463 int num_efx = emu->audigy ? 8 : 4;
1466 for (idx = 0; idx < num_efx; idx++)
1467 ucontrol->
value.integer.value[idx] = mix->send_volume[0][idx];
1468 spin_unlock_irqrestore(&emu->reg_lock, flags);
1472 static int snd_emu10k1_efx_send_volume_put(
struct snd_kcontrol *kcontrol,
1475 unsigned long flags;
1477 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
1478 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
1479 int change = 0,
idx,
val;
1480 int num_efx = emu->audigy ? 8 : 4;
1483 for (idx = 0; idx < num_efx; idx++) {
1484 val = ucontrol->
value.integer.value[
idx] & 255;
1485 if (mix->send_volume[0][idx] != val) {
1486 mix->send_volume[0][
idx] =
val;
1490 if (change && mix->epcm) {
1491 if (mix->epcm->voices[ch]) {
1492 update_emu10k1_send_volume(emu, mix->epcm->voices[ch]->number,
1493 &mix->send_volume[0][0]);
1496 spin_unlock_irqrestore(&emu->reg_lock, flags);
1505 .name =
"Multichannel PCM Send Volume",
1507 .info = snd_emu10k1_efx_send_volume_info,
1508 .get = snd_emu10k1_efx_send_volume_get,
1509 .put = snd_emu10k1_efx_send_volume_put
1521 static int snd_emu10k1_efx_attn_get(
struct snd_kcontrol *kcontrol,
1525 struct snd_emu10k1_pcm_mixer *mix =
1526 &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id)];
1527 unsigned long flags;
1530 ucontrol->
value.integer.value[0] = mix->attn[0];
1531 spin_unlock_irqrestore(&emu->reg_lock, flags);
1535 static int snd_emu10k1_efx_attn_put(
struct snd_kcontrol *kcontrol,
1538 unsigned long flags;
1540 int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
1541 struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch];
1542 int change = 0,
val;
1545 val = ucontrol->
value.integer.value[0] & 0xffff;
1546 if (mix->attn[0] != val) {
1550 if (change && mix->epcm) {
1551 if (mix->epcm->voices[ch]) {
1555 spin_unlock_irqrestore(&emu->reg_lock, flags);
1563 .name =
"Multichannel PCM Volume",
1565 .info = snd_emu10k1_efx_attn_info,
1566 .get = snd_emu10k1_efx_attn_get,
1567 .put = snd_emu10k1_efx_attn_put
1570 #define snd_emu10k1_shared_spdif_info snd_ctl_boolean_mono_info
1572 static int snd_emu10k1_shared_spdif_get(
struct snd_kcontrol *kcontrol,
1578 ucontrol->
value.integer.value[0] =
inl(emu->port + A_IOCFG) & A_IOCFG_GPOUT0 ? 1 : 0;
1580 ucontrol->
value.integer.value[0] =
inl(emu->port +
HCFG) & HCFG_GPOUT0 ? 1 : 0;
1581 if (emu->card_capabilities->invert_shared_spdif)
1582 ucontrol->
value.integer.value[0] =
1583 !ucontrol->
value.integer.value[0];
1588 static int snd_emu10k1_shared_spdif_put(
struct snd_kcontrol *kcontrol,
1591 unsigned long flags;
1596 sw = ucontrol->
value.integer.value[0];
1597 if (emu->card_capabilities->invert_shared_spdif)
1600 if ( emu->card_capabilities->i2c_adc) {
1602 }
else if (emu->audigy) {
1603 reg =
inl(emu->port + A_IOCFG);
1604 val = sw ? A_IOCFG_GPOUT0 : 0;
1605 change = (reg & A_IOCFG_GPOUT0) != val;
1607 reg &= ~A_IOCFG_GPOUT0;
1609 outl(reg | val, emu->port + A_IOCFG);
1613 val = sw ? HCFG_GPOUT0 : 0;
1614 change |= (reg & HCFG_GPOUT0) != val;
1616 reg &= ~HCFG_GPOUT0;
1620 spin_unlock_irqrestore(&emu->reg_lock, flags);
1627 .name =
"SB Live Analog/Digital Output Jack",
1629 .get = snd_emu10k1_shared_spdif_get,
1630 .put = snd_emu10k1_shared_spdif_put
1636 .name =
"Audigy Analog/Digital Output Jack",
1638 .get = snd_emu10k1_shared_spdif_get,
1639 .put = snd_emu10k1_shared_spdif_put
1644 #define snd_audigy_capture_boost_info snd_ctl_boolean_mono_info
1646 static int snd_audigy_capture_boost_get(
struct snd_kcontrol *kcontrol,
1654 ucontrol->
value.integer.value[0] = !!
val;
1658 static int snd_audigy_capture_boost_put(
struct snd_kcontrol *kcontrol,
1664 if (ucontrol->
value.integer.value[0])
1674 .name =
"Analog Capture Boost",
1676 .get = snd_audigy_capture_boost_get,
1677 .put = snd_audigy_capture_boost_put
1683 static void snd_emu10k1_mixer_free_ac97(
struct snd_ac97 *ac97)
1694 memset(&
id, 0,
sizeof(
id));
1709 static int rename_ctl(
struct snd_card *card,
const char *
src,
const char *
dst)
1720 int pcm_device,
int multi_device)
1726 static char *emu10k1_remove_ctls[] = {
1728 "Master Mono Playback Switch",
1729 "Master Mono Playback Volume",
1730 "PCM Out Path & Mute",
1731 "Mono Output Select",
1732 "Surround Playback Switch",
1733 "Surround Playback Volume",
1734 "Center Playback Switch",
1735 "Center Playback Volume",
1736 "LFE Playback Switch",
1737 "LFE Playback Volume",
1740 static char *emu10k1_rename_ctls[] = {
1741 "Surround Digital Playback Volume",
"Surround Playback Volume",
1742 "Center Digital Playback Volume",
"Center Playback Volume",
1743 "LFE Digital Playback Volume",
"LFE Playback Volume",
1746 static char *audigy_remove_ctls[] = {
1750 "PCM Playback Switch",
1751 "PCM Playback Volume",
1752 "Master Mono Playback Switch",
1753 "Master Mono Playback Volume",
1754 "Master Playback Switch",
1755 "Master Playback Volume",
1756 "PCM Out Path & Mute",
1757 "Mono Output Select",
1763 "Video Playback Switch",
1764 "Video Playback Volume",
1765 "Mic Playback Switch",
1766 "Mic Playback Volume",
1769 static char *audigy_rename_ctls[] = {
1771 "Wave Playback Volume",
"PCM Playback Volume",
1773 "Wave Master Playback Volume",
"Master Playback Volume",
1774 "AMic Playback Volume",
"Mic Playback Volume",
1777 static char *audigy_rename_ctls_i2c_adc[] = {
1779 "Line Capture Volume",
"Analog Mix Capture Volume",
1780 "Wave Playback Volume",
"OLD PCM Playback Volume",
1781 "Wave Master Playback Volume",
"Master Playback Volume",
1782 "AMic Playback Volume",
"Old Mic Playback Volume",
1783 "CD Capture Volume",
"IEC958 Optical Capture Volume",
1786 static char *audigy_remove_ctls_i2c_adc[] = {
1789 "Mic Capture Volume",
1790 "Analog Mix Capture Volume",
1791 "Aux Capture Volume",
1792 "IEC958 Optical Capture Volume",
1795 static char *audigy_remove_ctls_1361t_adc[] = {
1798 "PCM Playback Switch",
1799 "PCM Playback Volume",
1800 "Master Mono Playback Switch",
1801 "Master Mono Playback Volume",
1805 "Mic Capture Volume",
1806 "Headphone Playback Switch",
1807 "Headphone Playback Volume",
1808 "3D Control - Center",
1809 "3D Control - Depth",
1810 "3D Control - Switch",
1811 "Line2 Playback Volume",
1812 "Line2 Capture Volume",
1815 static char *audigy_rename_ctls_1361t_adc[] = {
1816 "Master Playback Switch",
"Master Capture Switch",
1817 "Master Playback Volume",
"Master Capture Volume",
1818 "Wave Master Playback Volume",
"Master Playback Volume",
1819 "Beep Playback Switch",
"Beep Capture Switch",
1820 "Beep Playback Volume",
"Beep Capture Volume",
1821 "Phone Playback Switch",
"Phone Capture Switch",
1822 "Phone Playback Volume",
"Phone Capture Volume",
1823 "Mic Playback Switch",
"Mic Capture Switch",
1824 "Mic Playback Volume",
"Mic Capture Volume",
1825 "Line Playback Switch",
"Line Capture Switch",
1826 "Line Playback Volume",
"Line Capture Volume",
1827 "CD Playback Switch",
"CD Capture Switch",
1828 "CD Playback Volume",
"CD Capture Volume",
1829 "Aux Playback Switch",
"Aux Capture Switch",
1830 "Aux Playback Volume",
"Aux Capture Volume",
1831 "Video Playback Switch",
"Video Capture Switch",
1832 "Video Playback Volume",
"Video Capture Volume",
1837 if (emu->card_capabilities->ac97_chip) {
1849 memset(&ac97, 0,
sizeof(ac97));
1854 if (emu->card_capabilities->ac97_chip == 1)
1866 if (emu->card_capabilities->adc_1361t)
1867 c = audigy_remove_ctls_1361t_adc;
1869 c = audigy_remove_ctls;
1878 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE|AC97SLOT_REAR_LEFT|AC97SLOT_REAR_RIGHT);
1880 remove_ctl(card,
"Front Playback Volume");
1881 remove_ctl(card,
"Front Playback Switch");
1886 c = emu10k1_remove_ctls;
1889 remove_ctl(card, *c);
1890 }
else if (emu->card_capabilities->i2c_adc) {
1891 c = audigy_remove_ctls_i2c_adc;
1893 remove_ctl(card, *c);
1896 if (emu->card_capabilities->ecard)
1897 strcpy(emu->card->mixername,
"EMU APS");
1898 else if (emu->audigy)
1899 strcpy(emu->card->mixername,
"SB Audigy");
1901 strcpy(emu->card->mixername,
"Emu10k1");
1905 if (emu->card_capabilities->adc_1361t)
1906 c = audigy_rename_ctls_1361t_adc;
1907 else if (emu->card_capabilities->i2c_adc)
1908 c = audigy_rename_ctls_i2c_adc;
1910 c = audigy_rename_ctls;
1912 c = emu10k1_rename_ctls;
1914 rename_ctl(card, c[0], c[1]);
1916 if (emu->card_capabilities->subsystem == 0x80401102) {
1917 remove_ctl(card,
"Center Playback Volume");
1918 remove_ctl(card,
"LFE Playback Volume");
1919 remove_ctl(card,
"Wave Center Playback Volume");
1920 remove_ctl(card,
"Wave LFE Playback Volume");
1922 if (emu->card_capabilities->subsystem == 0x20071102) {
1923 rename_ctl(card,
"Line2 Capture Volume",
"Line1/Mic Capture Volume");
1924 rename_ctl(card,
"Analog Mix Capture Volume",
"Line2 Capture Volume");
1925 rename_ctl(card,
"Aux2 Capture Volume",
"Line3 Capture Volume");
1926 rename_ctl(card,
"Mic Capture Volume",
"Unknown1 Capture Volume");
1927 remove_ctl(card,
"Headphone Playback Switch");
1928 remove_ctl(card,
"Headphone Playback Volume");
1929 remove_ctl(card,
"3D Control - Center");
1930 remove_ctl(card,
"3D Control - Depth");
1931 remove_ctl(card,
"3D Control - Switch");
1933 if ((kctl = emu->ctl_send_routing =
snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) ==
NULL)
1935 kctl->
id.device = pcm_device;
1938 if ((kctl = emu->ctl_send_volume =
snd_ctl_new1(&snd_emu10k1_send_volume_control, emu)) ==
NULL)
1940 kctl->
id.device = pcm_device;
1943 if ((kctl = emu->ctl_attn =
snd_ctl_new1(&snd_emu10k1_attn_control, emu)) ==
NULL)
1945 kctl->
id.device = pcm_device;
1949 if ((kctl = emu->ctl_efx_send_routing =
snd_ctl_new1(&snd_emu10k1_efx_send_routing_control, emu)) ==
NULL)
1951 kctl->
id.device = multi_device;
1955 if ((kctl = emu->ctl_efx_send_volume =
snd_ctl_new1(&snd_emu10k1_efx_send_volume_control, emu)) ==
NULL)
1957 kctl->
id.device = multi_device;
1961 if ((kctl = emu->ctl_efx_attn =
snd_ctl_new1(&snd_emu10k1_efx_attn_control, emu)) ==
NULL)
1963 kctl->
id.device = multi_device;
1968 for (pcm = 0; pcm < 32; pcm++) {
1969 struct snd_emu10k1_pcm_mixer *
mix;
1972 mix = &emu->pcm_mixer[pcm];
1975 for (v = 0; v < 4; v++)
1976 mix->send_routing[0][v] =
1977 mix->send_routing[1][v] =
1978 mix->send_routing[2][v] = v;
1980 memset(&mix->send_volume, 0,
sizeof(mix->send_volume));
1981 mix->send_volume[0][0] = mix->send_volume[0][1] =
1982 mix->send_volume[1][0] = mix->send_volume[2][1] = 255;
1984 mix->attn[0] = mix->attn[1] = mix->attn[2] = 0xffff;
1988 for (pcm = 0; pcm < NUM_EFX_PLAYBACK; pcm++) {
1989 struct snd_emu10k1_pcm_mixer *
mix;
1992 mix = &emu->efx_pcm_mixer[pcm];
1995 mix->send_routing[0][0] = pcm;
1996 mix->send_routing[0][1] = (pcm == 0) ? 1 : 0;
1997 for (v = 0; v < 2; v++)
1998 mix->send_routing[0][2+v] = 13+v;
2000 for (v = 0; v < 4; v++)
2001 mix->send_routing[0][4+v] = 60+v;
2003 memset(&mix->send_volume, 0,
sizeof(mix->send_volume));
2004 mix->send_volume[0][0] = 255;
2006 mix->attn[0] = 0xffff;
2009 if (! emu->card_capabilities->ecard) {
2014 kctl->
id.device = emu->pcm_efx->device;
2020 kctl->
id.device = emu->pcm_efx->device;
2025 if (emu->card_capabilities->emu_model) {
2027 }
else if (emu->audigy) {
2038 }
else if (! emu->card_capabilities->ecard) {
2045 if (emu->card_capabilities->ca0151_chip) {
2050 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
2054 for (i = 0; i <
ARRAY_SIZE(snd_emu1616_output_enum_ctls); i++) {
2061 for (i = 0; i <
ARRAY_SIZE(snd_emu1010_input_enum_ctls); i++) {
2068 for (i = 0; i <
ARRAY_SIZE(snd_emu1010_adc_pads) - 2; i++) {
2074 for (i = 0; i <
ARRAY_SIZE(snd_emu1010_dac_pads) - 2; i++) {
2085 }
else if (emu->card_capabilities->emu_model) {
2089 for (i = 0; i <
ARRAY_SIZE(snd_emu1010_output_enum_ctls); i++) {
2096 for (i = 0; i <
ARRAY_SIZE(snd_emu1010_input_enum_ctls); i++) {
2103 for (i = 0; i <
ARRAY_SIZE(snd_emu1010_adc_pads); i++) {
2109 for (i = 0; i <
ARRAY_SIZE(snd_emu1010_dac_pads); i++) {
2121 if ( emu->card_capabilities->i2c_adc) {
2128 for (i = 0; i <
ARRAY_SIZE(snd_audigy_i2c_volume_ctls); i++) {
2135 if (emu->card_capabilities->ac97_chip && emu->audigy) {