31 #include <linux/slab.h>
38 static void snd_emu10k1_proc_spdif_status(
struct snd_emu10k1 *
emu,
44 static char *clkaccy[4] = {
"1000ppm",
"50ppm",
"variable",
"unknown" };
45 static int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
46 static char *
channel[16] = {
"unspec",
"left",
"right",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15" };
47 static char *emphasis[8] = {
"none",
"50/15 usec 2 channel",
"2",
"3",
"4",
"5",
"6",
"7" };
52 snd_iprintf(buffer,
"\n%s\n", title);
54 if (status != 0xffffffff) {
55 snd_iprintf(buffer,
"Professional Mode : %s\n", (status &
SPCS_PROFESSIONAL) ?
"yes" :
"no");
56 snd_iprintf(buffer,
"Not Audio Data : %s\n", (status &
SPCS_NOTAUDIODATA) ?
"yes" :
"no");
57 snd_iprintf(buffer,
"Copyright : %s\n", (status &
SPCS_COPYRIGHT) ?
"yes" :
"no");
58 snd_iprintf(buffer,
"Emphasis : %s\n", emphasis[(status &
SPCS_EMPHASISMASK) >> 3]);
59 snd_iprintf(buffer,
"Mode : %i\n", (status &
SPCS_MODEMASK) >> 6);
61 snd_iprintf(buffer,
"Generation Status : %s\n", status &
SPCS_GENERATIONSTATUS ?
"original" :
"copy");
63 snd_iprintf(buffer,
"Channel Number : %s\n", channel[(status &
SPCS_CHANNELNUMMASK) >> 20]);
64 snd_iprintf(buffer,
"Sample Rate : %iHz\n", samplerate[(status &
SPCS_SAMPLERATEMASK) >> 24]);
65 snd_iprintf(buffer,
"Clock Accuracy : %s\n", clkaccy[(status &
SPCS_CLKACCYMASK) >> 28]);
69 snd_iprintf(buffer,
"S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ?
"on" :
"off");
70 snd_iprintf(buffer,
"S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ?
"on" :
"off");
71 snd_iprintf(buffer,
"Rate Locked : %s\n", rate & SRCS_RATELOCKED ?
"on" :
"off");
73 snd_iprintf(buffer,
"Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11);
76 snd_iprintf(buffer,
"No signal detected.\n");
85 static char *creative_outs[32] = {
88 "Optical IEC958 Left",
89 "Optical IEC958 Right",
100 "AC97 Surround Right",
120 static char *audigy_outs[64] = {
121 "Digital Front Left",
122 "Digital Front Right",
128 "Digital Rear Right",
188 unsigned int val, val1;
189 int nefx = emu->audigy ? 64 : 32;
190 char **outputs = emu->audigy ? audigy_outs : creative_outs;
193 snd_iprintf(buffer,
"EMU10K1\n\n");
194 snd_iprintf(buffer,
"Card : %s\n",
195 emu->audigy ?
"Audigy" : (emu->card_capabilities->ecard ?
"EMU APS" :
"Creative"));
196 snd_iprintf(buffer,
"Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
197 snd_iprintf(buffer,
"External TRAM (words) : 0x%x\n", (
int)emu->fx8010.etram_pages.bytes / 2);
198 snd_iprintf(buffer,
"\n");
199 snd_iprintf(buffer,
"Effect Send Routing :\n");
200 for (idx = 0; idx < NUM_G; idx++) {
208 snd_iprintf(buffer,
"Ch%i: A=%i, B=%i, C=%i, D=%i, ",
214 snd_iprintf(buffer,
"E=%i, F=%i, G=%i, H=%i\n",
218 (val1 >> 24) & 0x3f);
220 snd_iprintf(buffer,
"Ch%i: A=%i, B=%i, C=%i, D=%i\n",
228 snd_iprintf(buffer,
"\nCaptured FX Outputs :\n");
229 for (idx = 0; idx < nefx; idx++) {
230 if (emu->efx_voices_mask[idx/32] & (1 << (idx%32)))
231 snd_iprintf(buffer,
" Output %02i [%s]\n", idx, outputs[idx]);
233 snd_iprintf(buffer,
"\nAll FX Outputs :\n");
234 for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++)
235 snd_iprintf(buffer,
" Output %02i [%s]\n", idx, outputs[idx]);
238 static void snd_emu10k1_proc_spdif_read(
struct snd_info_entry *entry,
247 if (emu->card_capabilities->emu_model) {
250 spin_unlock_irqrestore(&emu->emu_lock, flags);
251 if ((value & 0x1) == 0) {
255 spin_unlock_irqrestore(&emu->emu_lock, flags);
256 rate = 0x1770000 / (((value << 5) | value2)+1);
257 snd_iprintf(buffer,
"ADAT Locked : %u\n", rate);
259 snd_iprintf(buffer,
"ADAT Unlocked\n");
263 spin_unlock_irqrestore(&emu->emu_lock, flags);
264 if ((value & 0x4) == 0) {
268 spin_unlock_irqrestore(&emu->emu_lock, flags);
269 rate = 0x1770000 / (((value << 5) | value2)+1);
270 snd_iprintf(buffer,
"SPDIF Locked : %d\n", rate);
272 snd_iprintf(buffer,
"SPDIF Unlocked\n");
275 snd_emu10k1_proc_spdif_status(emu, buffer,
"CD-ROM S/PDIF In", CDCS, CDSRCS);
276 snd_emu10k1_proc_spdif_status(emu, buffer,
"Optical or Coax S/PDIF In", GPSCS, GPSRCS);
280 snd_iprintf(buffer,
"\nZoomed Video\n");
281 snd_iprintf(buffer,
"Rate Locked : %s\n", val & SRCS_RATELOCKED ?
"on" :
"off");
282 snd_iprintf(buffer,
"Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
286 static void snd_emu10k1_proc_rates_read(
struct snd_info_entry *entry,
289 static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
293 tmp = (val >> 16) & 0x8;
294 for (n = 0; n < 4; n++) {
295 tmp = val >> (16 + (n*4));
296 if (tmp & 0x8) snd_iprintf(buffer,
"Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
297 else snd_iprintf(buffer,
"Channel %d: No input\n", n);
301 static void snd_emu10k1_proc_acode_read(
struct snd_info_entry *entry,
307 snd_iprintf(buffer,
"FX8010 Instruction List '%s'\n", emu->fx8010.name);
308 snd_iprintf(buffer,
" Code dump :\n");
309 for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
315 snd_iprintf(buffer,
" OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
317 (high >> 12) & 0x7ff,
324 snd_iprintf(buffer,
" OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
326 (high >> 10) & 0x3ff,
335 #define TOTAL_SIZE_GPR (0x100*4)
336 #define A_TOTAL_SIZE_GPR (0x200*4)
337 #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
338 #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
339 #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
340 #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
341 #define TOTAL_SIZE_CODE (0x200*8)
342 #define A_TOTAL_SIZE_CODE (0x400*8)
345 void *file_private_data,
356 if (!
strcmp(entry->
name,
"fx8010_tram_addr")) {
357 offset = TANKMEMADDRREGBASE;
359 }
else if (!
strcmp(entry->
name,
"fx8010_tram_data")) {
360 offset = TANKMEMDATAREGBASE;
361 }
else if (!
strcmp(entry->
name,
"fx8010_code")) {
362 offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
364 offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
370 for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
373 if (tram_addr && emu->audigy) {
379 if (
copy_to_user(buf, ((
char *)tmp) + (pos & 3), count))
387 static void snd_emu10k1_proc_voices_read(
struct snd_info_entry *entry,
391 struct snd_emu10k1_voice *
voice;
394 snd_iprintf(buffer,
"ch\tuse\tpcm\tefx\tsynth\tmidi\n");
395 for (idx = 0; idx < NUM_G; idx++) {
396 voice = &emu->voices[
idx];
397 snd_iprintf(buffer,
"%i\t%i\t%i\t%i\t%i\t%i\n",
407 #ifdef CONFIG_SND_DEBUG
408 static void snd_emu_proc_emu1010_reg_read(
struct snd_info_entry *entry,
415 snd_iprintf(buffer,
"EMU1010 Registers:\n\n");
417 for(i = 0; i < 0x40; i+=1) {
420 spin_unlock_irqrestore(&emu->emu_lock, flags);
421 snd_iprintf(buffer,
"%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
425 static void snd_emu_proc_io_reg_read(
struct snd_info_entry *entry,
432 snd_iprintf(buffer,
"IO Registers:\n\n");
433 for(i = 0; i < 0x40; i+=4) {
435 value =
inl(emu->port + i);
436 spin_unlock_irqrestore(&emu->emu_lock, flags);
437 snd_iprintf(buffer,
"%02X: %08lX\n", i, value);
441 static void snd_emu_proc_io_reg_write(
struct snd_info_entry *entry,
448 while (!snd_info_get_line(buffer, line,
sizeof(line))) {
449 if (
sscanf(line,
"%x %x", ®, &val) != 2)
451 if (reg < 0x40 && val <= 0xffffffff) {
453 outl(val, emu->port + (reg & 0xfffffffc));
454 spin_unlock_irqrestore(&emu->emu_lock, flags);
459 static unsigned int snd_ptr_read(
struct snd_emu10k1 * emu,
467 regptr = (reg << 16) | chn;
470 outl(regptr, emu->port + iobase +
PTR);
471 val =
inl(emu->port + iobase +
DATA);
472 spin_unlock_irqrestore(&emu->emu_lock, flags);
476 static void snd_ptr_write(
struct snd_emu10k1 *emu,
485 regptr = (reg << 16) | chn;
488 outl(regptr, emu->port + iobase +
PTR);
489 outl(data, emu->port + iobase +
DATA);
490 spin_unlock_irqrestore(&emu->emu_lock, flags);
494 static void snd_emu_proc_ptr_reg_read(
struct snd_info_entry *entry,
500 if (offset+length > 0xa0) {
501 snd_iprintf(buffer,
"Input values out of range\n");
504 snd_iprintf(buffer,
"Registers 0x%x\n", iobase);
505 for(i = offset; i < offset+
length; i++) {
506 snd_iprintf(buffer,
"%02X: ",i);
507 for (j = 0; j < voices; j++) {
509 value = snd_ptr_read(emu, 0, i, j);
511 value = snd_ptr_read(emu, 0x20, i, j);
512 snd_iprintf(buffer,
"%08lX ", value);
514 snd_iprintf(buffer,
"\n");
518 static void snd_emu_proc_ptr_reg_write(
struct snd_info_entry *entry,
523 unsigned int reg, channel_id ,
val;
524 while (!snd_info_get_line(buffer, line,
sizeof(line))) {
525 if (
sscanf(line,
"%x %x %x", ®, &channel_id, &val) != 3)
527 if (reg < 0xa0 && val <= 0xffffffff && channel_id <= 3)
528 snd_ptr_write(emu, iobase, reg, channel_id, val);
532 static void snd_emu_proc_ptr_reg_write00(
struct snd_info_entry *entry,
535 snd_emu_proc_ptr_reg_write(entry, buffer, 0);
538 static void snd_emu_proc_ptr_reg_write20(
struct snd_info_entry *entry,
541 snd_emu_proc_ptr_reg_write(entry, buffer, 0x20);
545 static void snd_emu_proc_ptr_reg_read00a(
struct snd_info_entry *entry,
548 snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
551 static void snd_emu_proc_ptr_reg_read00b(
struct snd_info_entry *entry,
554 snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
557 static void snd_emu_proc_ptr_reg_read20a(
struct snd_info_entry *entry,
560 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
563 static void snd_emu_proc_ptr_reg_read20b(
struct snd_info_entry *entry,
566 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
569 static void snd_emu_proc_ptr_reg_read20c(
struct snd_info_entry *entry,
572 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
577 .
read = snd_emu10k1_fx8010_read,
580 int __devinit snd_emu10k1_proc_init(
struct snd_emu10k1 * emu)
583 #ifdef CONFIG_SND_DEBUG
584 if (emu->card_capabilities->emu_model) {
585 if (! snd_card_proc_new(emu->card,
"emu1010_regs", &entry))
586 snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read);
588 if (! snd_card_proc_new(emu->card,
"io_regs", &entry)) {
589 snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read);
590 entry->
c.
text.write = snd_emu_proc_io_reg_write;
593 if (! snd_card_proc_new(emu->card,
"ptr_regs00a", &entry)) {
594 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a);
595 entry->
c.
text.write = snd_emu_proc_ptr_reg_write00;
598 if (! snd_card_proc_new(emu->card,
"ptr_regs00b", &entry)) {
599 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b);
600 entry->
c.
text.write = snd_emu_proc_ptr_reg_write00;
603 if (! snd_card_proc_new(emu->card,
"ptr_regs20a", &entry)) {
604 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a);
605 entry->
c.
text.write = snd_emu_proc_ptr_reg_write20;
608 if (! snd_card_proc_new(emu->card,
"ptr_regs20b", &entry)) {
609 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b);
610 entry->
c.
text.write = snd_emu_proc_ptr_reg_write20;
613 if (! snd_card_proc_new(emu->card,
"ptr_regs20c", &entry)) {
614 snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c);
615 entry->
c.
text.write = snd_emu_proc_ptr_reg_write20;
620 if (! snd_card_proc_new(emu->card,
"emu10k1", &entry))
621 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read);
623 if (emu->card_capabilities->emu10k2_chip) {
624 if (! snd_card_proc_new(emu->card,
"spdif-in", &entry))
625 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read);
627 if (emu->card_capabilities->ca0151_chip) {
628 if (! snd_card_proc_new(emu->card,
"capture-rates", &entry))
629 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read);
632 if (! snd_card_proc_new(emu->card,
"voices", &entry))
633 snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read);
635 if (! snd_card_proc_new(emu->card,
"fx8010_gpr", &entry)) {
639 entry->
size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
640 entry->
c.
ops = &snd_emu10k1_proc_ops_fx8010;
642 if (! snd_card_proc_new(emu->card,
"fx8010_tram_data", &entry)) {
646 entry->
size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
647 entry->
c.
ops = &snd_emu10k1_proc_ops_fx8010;
649 if (! snd_card_proc_new(emu->card,
"fx8010_tram_addr", &entry)) {
653 entry->
size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
654 entry->
c.
ops = &snd_emu10k1_proc_ops_fx8010;
656 if (! snd_card_proc_new(emu->card,
"fx8010_code", &entry)) {
660 entry->
size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
661 entry->
c.
ops = &snd_emu10k1_proc_ops_fx8010;
663 if (! snd_card_proc_new(emu->card,
"fx8010_acode", &entry)) {
667 entry->
c.
text.read = snd_emu10k1_proc_acode_read;