1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
5 * Routines for control of EMU10K1 chips / proc interface routines
7 * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
8 * Added EMU 1010 support.
17 #include <linux/slab.h>
18 #include <linux/init.h>
19 #include <sound/core.h>
20 #include <sound/emu10k1.h>
23 static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu,
24 struct snd_info_buffer *buffer,
29 static const char * const clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" };
30 static const int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
31 static const char * const channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
32 static const char * const emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" };
33 unsigned int status, rate = 0;
35 status = snd_emu10k1_ptr_read(emu, status_reg, 0);
37 snd_iprintf(buffer, "\n%s\n", title);
39 if (status != 0xffffffff) {
40 snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no");
41 snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no");
42 snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no");
43 snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]);
44 snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6);
45 snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8);
46 snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy");
47 snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16);
48 snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]);
49 snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]);
50 snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]);
53 rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
54 snd_iprintf(buffer, "S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off");
55 snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off");
56 snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off");
57 /* From ((Rate * 48000 ) / 262144); */
58 snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11);
61 snd_iprintf(buffer, "No signal detected.\n");
66 static void snd_emu10k1_proc_read(struct snd_info_entry *entry,
67 struct snd_info_buffer *buffer)
69 struct snd_emu10k1 *emu = entry->private_data;
70 const char * const *inputs = emu->audigy ?
71 snd_emu10k1_audigy_ins : snd_emu10k1_sblive_ins;
72 const char * const *outputs = emu->audigy ?
73 snd_emu10k1_audigy_outs : snd_emu10k1_sblive_outs;
74 unsigned short extin_mask = emu->audigy ? ~0 : emu->fx8010.extin_mask;
75 unsigned short extout_mask = emu->audigy ? ~0 : emu->fx8010.extout_mask;
76 unsigned int val, val1, ptrx, psst, dsl, snda;
77 int nefx = emu->audigy ? 32 : 16;
80 snd_iprintf(buffer, "EMU10K1\n\n");
81 snd_iprintf(buffer, "Card : %s\n",
82 emu->card_capabilities->emu_model ? "E-MU D.A.S." :
83 emu->card_capabilities->ecard ? "E-MU A.P.S." :
84 emu->audigy ? "SB Audigy" : "SB Live!");
85 snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
86 snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2);
88 snd_iprintf(buffer, "\nEffect Send Routing & Amounts:\n");
89 for (idx = 0; idx < NUM_G; idx++) {
90 ptrx = snd_emu10k1_ptr_read(emu, PTRX, idx);
91 psst = snd_emu10k1_ptr_read(emu, PSST, idx);
92 dsl = snd_emu10k1_ptr_read(emu, DSL, idx);
94 val = snd_emu10k1_ptr_read(emu, A_FXRT1, idx);
95 val1 = snd_emu10k1_ptr_read(emu, A_FXRT2, idx);
96 snda = snd_emu10k1_ptr_read(emu, A_SENDAMOUNTS, idx);
97 snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x, ",
99 val & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx),
100 (val >> 8) & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx),
101 (val >> 16) & 0x3f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst),
102 (val >> 24) & 0x3f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl));
103 snd_iprintf(buffer, "E=%2i:%02x, F=%2i:%02x, G=%2i:%02x, H=%2i:%02x\n",
104 val1 & 0x3f, (snda >> 24) & 0xff,
105 (val1 >> 8) & 0x3f, (snda >> 16) & 0xff,
106 (val1 >> 16) & 0x3f, (snda >> 8) & 0xff,
107 (val1 >> 24) & 0x3f, snda & 0xff);
109 val = snd_emu10k1_ptr_read(emu, FXRT, idx);
110 snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x\n",
112 (val >> 16) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx),
113 (val >> 20) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx),
114 (val >> 24) & 0x0f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst),
115 (val >> 28) & 0x0f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl));
118 snd_iprintf(buffer, "\nEffect Send Targets:\n");
119 // Audigy actually has 64, but we don't use them all.
120 for (idx = 0; idx < 32; idx++) {
121 const char *c = snd_emu10k1_fxbus[idx];
123 snd_iprintf(buffer, " Channel %02i [%s]\n", idx, c);
125 if (!emu->card_capabilities->emu_model) {
126 snd_iprintf(buffer, "\nOutput Channels:\n");
127 for (idx = 0; idx < 32; idx++)
128 if (outputs[idx] && (extout_mask & (1 << idx)))
129 snd_iprintf(buffer, " Channel %02i [%s]\n", idx, outputs[idx]);
130 snd_iprintf(buffer, "\nInput Channels:\n");
131 for (idx = 0; idx < 16; idx++)
132 if (inputs[idx] && (extin_mask & (1 << idx)))
133 snd_iprintf(buffer, " Channel %02i [%s]\n", idx, inputs[idx]);
134 snd_iprintf(buffer, "\nMultichannel Capture Sources:\n");
135 for (idx = 0; idx < nefx; idx++)
136 if (emu->efx_voices_mask[0] & (1 << idx))
137 snd_iprintf(buffer, " Channel %02i [Output: %s]\n",
138 idx, outputs[idx] ? outputs[idx] : "???");
140 for (idx = 0; idx < 32; idx++)
141 if (emu->efx_voices_mask[1] & (1 << idx))
142 snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
143 idx + 32, inputs[idx] ? inputs[idx] : "???");
145 for (idx = 0; idx < 16; idx++) {
146 if (emu->efx_voices_mask[0] & ((1 << 16) << idx)) {
147 if (emu->card_capabilities->sblive51) {
148 s8 c = snd_emu10k1_sblive51_fxbus2_map[idx];
150 snd_iprintf(buffer, " Channel %02i [Output: %s]\n",
151 idx + 16, outputs[idx + 16]);
153 snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
154 idx + 16, inputs[c]);
156 snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
157 idx + 16, inputs[idx] ? inputs[idx] : "???");
165 static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
166 struct snd_info_buffer *buffer)
168 struct snd_emu10k1 *emu = entry->private_data;
173 if (emu->card_capabilities->emu_model) {
174 if (!emu->card_capabilities->no_adat) {
175 snd_emu1010_fpga_read(emu, 0x38, &value);
176 if ((value & 0x1) == 0) {
177 snd_emu1010_fpga_read(emu, 0x2a, &value);
178 snd_emu1010_fpga_read(emu, 0x2b, &value2);
179 rate = 0x1770000 / (((value << 5) | value2)+1);
180 snd_iprintf(buffer, "ADAT Locked : %u\n", rate);
182 snd_iprintf(buffer, "ADAT Unlocked\n");
185 snd_emu1010_fpga_read(emu, 0x20, &value);
186 if ((value & 0x4) == 0) {
187 snd_emu1010_fpga_read(emu, 0x28, &value);
188 snd_emu1010_fpga_read(emu, 0x29, &value2);
189 rate = 0x1770000 / (((value << 5) | value2)+1);
190 snd_iprintf(buffer, "SPDIF Locked : %d\n", rate);
192 snd_iprintf(buffer, "SPDIF Unlocked\n");
195 snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
196 snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
199 val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
200 snd_iprintf(buffer, "\nZoomed Video\n");
201 snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off");
202 snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
206 static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry,
207 struct snd_info_buffer *buffer)
209 static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
210 struct snd_emu10k1 *emu = entry->private_data;
211 unsigned int val, tmp, n;
212 val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
213 for (n = 0; n < 4; n++) {
214 tmp = val >> (16 + (n*4));
215 if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
216 else snd_iprintf(buffer, "Channel %d: No input\n", n);
220 struct emu10k1_reg_entry {
221 unsigned short base, size;
225 static const struct emu10k1_reg_entry sblive_reg_entries[] = {
226 { 0, 0x10, "FXBUS" },
227 { 0x10, 0x10, "EXTIN" },
228 { 0x20, 0x10, "EXTOUT" },
229 { 0x30, 0x10, "FXBUS2" },
230 { 0x40, 0x20, NULL }, // Constants
231 { 0x100, 0x100, "GPR" },
232 { 0x200, 0x80, "ITRAM_DATA" },
233 { 0x280, 0x20, "ETRAM_DATA" },
234 { 0x300, 0x80, "ITRAM_ADDR" },
235 { 0x380, 0x20, "ETRAM_ADDR" },
239 static const struct emu10k1_reg_entry audigy_reg_entries[] = {
240 { 0, 0x40, "FXBUS" },
241 { 0x40, 0x10, "EXTIN" },
242 { 0x50, 0x10, "P16VIN" },
243 { 0x60, 0x20, "EXTOUT" },
244 { 0x80, 0x20, "FXBUS2" },
245 { 0xa0, 0x10, "EMU32OUTH" },
246 { 0xb0, 0x10, "EMU32OUTL" },
247 { 0xc0, 0x20, NULL }, // Constants
248 // This can't be quite right - overlap.
249 //{ 0x100, 0xc0, "ITRAM_CTL" },
250 //{ 0x1c0, 0x40, "ETRAM_CTL" },
251 { 0x160, 0x20, "A3_EMU32IN" },
252 { 0x1e0, 0x20, "A3_EMU32OUT" },
253 { 0x200, 0xc0, "ITRAM_DATA" },
254 { 0x2c0, 0x40, "ETRAM_DATA" },
255 { 0x300, 0xc0, "ITRAM_ADDR" },
256 { 0x3c0, 0x40, "ETRAM_ADDR" },
257 { 0x400, 0x200, "GPR" },
261 static const char * const emu10k1_const_entries[] = {
294 static int disasm_emu10k1_reg(char *buffer,
295 const struct emu10k1_reg_entry *entries,
296 unsigned reg, const char *pfx)
298 for (int i = 0; ; i++) {
299 unsigned base = entries[i].base;
300 unsigned size = entries[i].size;
302 return sprintf(buffer, "%s0x%03x", pfx, reg);
303 if (reg >= base && reg < base + size) {
304 const char *name = entries[i].name;
307 return sprintf(buffer, "%s%s(%u)", pfx, name, reg);
308 return sprintf(buffer, "%s%s", pfx, emu10k1_const_entries[reg]);
313 static int disasm_sblive_reg(char *buffer, unsigned reg, const char *pfx)
315 return disasm_emu10k1_reg(buffer, sblive_reg_entries, reg, pfx);
318 static int disasm_audigy_reg(char *buffer, unsigned reg, const char *pfx)
320 return disasm_emu10k1_reg(buffer, audigy_reg_entries, reg, pfx);
323 static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry,
324 struct snd_info_buffer *buffer)
327 struct snd_emu10k1 *emu = entry->private_data;
328 static const char * const insns[16] = {
329 "MAC0", "MAC1", "MAC2", "MAC3", "MACINT0", "MACINT1", "ACC3", "MACMV",
330 "ANDXOR", "TSTNEG", "LIMITGE", "LIMITLT", "LOG", "EXP", "INTERP", "SKIP",
332 static const char spaces[] = " ";
333 const int nspaces = sizeof(spaces) - 1;
335 snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
336 snd_iprintf(buffer, " Code dump :\n");
337 for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
343 low = snd_emu10k1_efx_read(emu, pc * 2);
344 high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
346 bufp += sprintf(bufp, " %-7s ", insns[(high >> 24) & 0x0f]);
347 bufp += disasm_audigy_reg(bufp, (high >> 12) & 0x7ff, "");
348 bufp += disasm_audigy_reg(bufp, (high >> 0) & 0x7ff, ", ");
349 bufp += disasm_audigy_reg(bufp, (low >> 12) & 0x7ff, ", ");
350 bufp += disasm_audigy_reg(bufp, (low >> 0) & 0x7ff, ", ");
352 bufp += sprintf(bufp, " %-7s ", insns[(high >> 20) & 0x0f]);
353 bufp += disasm_sblive_reg(bufp, (high >> 10) & 0x3ff, "");
354 bufp += disasm_sblive_reg(bufp, (high >> 0) & 0x3ff, ", ");
355 bufp += disasm_sblive_reg(bufp, (low >> 10) & 0x3ff, ", ");
356 bufp += disasm_sblive_reg(bufp, (low >> 0) & 0x3ff, ", ");
358 len = (int)(ptrdiff_t)(bufp - buf);
359 snd_iprintf(buffer, "%s %s /* 0x%04x: 0x%08x%08x */\n",
360 buf, &spaces[nspaces - clamp(65 - len, 0, nspaces)],
365 #define TOTAL_SIZE_GPR (0x100*4)
366 #define A_TOTAL_SIZE_GPR (0x200*4)
367 #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
368 #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
369 #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
370 #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
371 #define TOTAL_SIZE_CODE (0x200*8)
372 #define A_TOTAL_SIZE_CODE (0x400*8)
374 static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
375 void *file_private_data,
376 struct file *file, char __user *buf,
377 size_t count, loff_t pos)
379 struct snd_emu10k1 *emu = entry->private_data;
386 if (!strcmp(entry->name, "fx8010_tram_addr")) {
387 offset = TANKMEMADDRREGBASE;
389 } else if (!strcmp(entry->name, "fx8010_tram_data")) {
390 offset = TANKMEMDATAREGBASE;
391 } else if (!strcmp(entry->name, "fx8010_code")) {
392 offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
394 offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
397 tmp = kmalloc(count + 8, GFP_KERNEL);
400 for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
402 val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
403 if (tram_addr && emu->audigy) {
405 val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
409 if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
417 static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
418 struct snd_info_buffer *buffer)
420 struct snd_emu10k1 *emu = entry->private_data;
421 struct snd_emu10k1_voice *voice;
423 static const char * const types[] = {
424 "Unused", "EFX", "EFX IRQ", "PCM", "PCM IRQ", "Synth"
426 static_assert(ARRAY_SIZE(types) == EMU10K1_NUM_TYPES);
428 snd_iprintf(buffer, "ch\tdirty\tlast\tuse\n");
429 for (idx = 0; idx < NUM_G; idx++) {
430 voice = &emu->voices[idx];
431 snd_iprintf(buffer, "%i\t%u\t%u\t%s\n",
439 #ifdef CONFIG_SND_DEBUG
441 static void snd_emu_proc_emu1010_link_read(struct snd_emu10k1 *emu,
442 struct snd_info_buffer *buffer,
445 u32 src = snd_emu1010_fpga_link_dst_src_read(emu, dst);
446 snd_iprintf(buffer, "%04x: %04x\n", dst, src);
449 static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
450 struct snd_info_buffer *buffer)
452 struct snd_emu10k1 *emu = entry->private_data;
455 snd_iprintf(buffer, "EMU1010 Registers:\n\n");
457 for(i = 0; i < 0x40; i+=1) {
458 snd_emu1010_fpga_read(emu, i, &value);
459 snd_iprintf(buffer, "%02x: %02x\n", i, value);
462 snd_iprintf(buffer, "\nEMU1010 Routes:\n\n");
464 for (i = 0; i < 16; i++) // To Alice2/Tina[2] via EMU32
465 snd_emu_proc_emu1010_link_read(emu, buffer, i);
466 if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404)
467 for (i = 0; i < 32; i++) // To Dock via EDI
468 snd_emu_proc_emu1010_link_read(emu, buffer, 0x100 + i);
469 if (emu->card_capabilities->emu_model != EMU_MODEL_EMU1616)
470 for (i = 0; i < 8; i++) // To Hamoa/local
471 snd_emu_proc_emu1010_link_read(emu, buffer, 0x200 + i);
472 for (i = 0; i < 8; i++) // To Hamoa/Mana/local
473 snd_emu_proc_emu1010_link_read(emu, buffer, 0x300 + i);
474 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
475 for (i = 0; i < 16; i++) // To Tina2 via EMU32
476 snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
477 } else if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) {
478 for (i = 0; i < 8; i++) // To Hana ADAT
479 snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
480 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010B) {
481 for (i = 0; i < 16; i++) // To Tina via EMU32
482 snd_emu_proc_emu1010_link_read(emu, buffer, 0x500 + i);
485 snd_emu_proc_emu1010_link_read(emu, buffer, 0x500);
486 snd_emu_proc_emu1010_link_read(emu, buffer, 0x501);
487 snd_emu_proc_emu1010_link_read(emu, buffer, 0x600);
488 snd_emu_proc_emu1010_link_read(emu, buffer, 0x601);
489 snd_emu_proc_emu1010_link_read(emu, buffer, 0x700);
490 snd_emu_proc_emu1010_link_read(emu, buffer, 0x701);
495 static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
496 struct snd_info_buffer *buffer)
498 struct snd_emu10k1 *emu = entry->private_data;
501 snd_iprintf(buffer, "IO Registers:\n\n");
502 for(i = 0; i < 0x40; i+=4) {
503 value = inl(emu->port + i);
504 snd_iprintf(buffer, "%02X: %08lX\n", i, value);
508 static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
509 struct snd_info_buffer *buffer)
511 struct snd_emu10k1 *emu = entry->private_data;
514 while (!snd_info_get_line(buffer, line, sizeof(line))) {
515 if (sscanf(line, "%x %x", ®, &val) != 2)
517 if (reg < 0x40 && val <= 0xffffffff) {
518 outl(val, emu->port + (reg & 0xfffffffc));
523 static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
529 unsigned int regptr, val;
531 regptr = (reg << 16) | chn;
533 spin_lock_irqsave(&emu->emu_lock, flags);
534 outl(regptr, emu->port + iobase + PTR);
535 val = inl(emu->port + iobase + DATA);
536 spin_unlock_irqrestore(&emu->emu_lock, flags);
540 static void snd_ptr_write(struct snd_emu10k1 *emu,
549 regptr = (reg << 16) | chn;
551 spin_lock_irqsave(&emu->emu_lock, flags);
552 outl(regptr, emu->port + iobase + PTR);
553 outl(data, emu->port + iobase + DATA);
554 spin_unlock_irqrestore(&emu->emu_lock, flags);
558 static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
559 struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
561 struct snd_emu10k1 *emu = entry->private_data;
564 if (offset+length > 0xa0) {
565 snd_iprintf(buffer, "Input values out of range\n");
568 snd_iprintf(buffer, "Registers 0x%x\n", iobase);
569 for(i = offset; i < offset+length; i++) {
570 snd_iprintf(buffer, "%02X: ",i);
571 for (j = 0; j < voices; j++) {
572 value = snd_ptr_read(emu, iobase, i, j);
573 snd_iprintf(buffer, "%08lX ", value);
575 snd_iprintf(buffer, "\n");
579 static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
580 struct snd_info_buffer *buffer,
581 int iobase, int length, int voices)
583 struct snd_emu10k1 *emu = entry->private_data;
585 unsigned int reg, channel_id , val;
586 while (!snd_info_get_line(buffer, line, sizeof(line))) {
587 if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3)
589 if (reg < length && channel_id < voices)
590 snd_ptr_write(emu, iobase, reg, channel_id, val);
594 static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
595 struct snd_info_buffer *buffer)
597 snd_emu_proc_ptr_reg_write(entry, buffer, 0, 0x80, 64);
600 static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
601 struct snd_info_buffer *buffer)
603 struct snd_emu10k1 *emu = entry->private_data;
604 snd_emu_proc_ptr_reg_write(entry, buffer, 0x20,
605 emu->card_capabilities->ca0108_chip ? 0xa0 : 0x80, 4);
609 static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
610 struct snd_info_buffer *buffer)
612 snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
615 static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
616 struct snd_info_buffer *buffer)
618 snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
621 static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
622 struct snd_info_buffer *buffer)
624 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
627 static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
628 struct snd_info_buffer *buffer)
630 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
633 static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
634 struct snd_info_buffer * buffer)
636 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
640 static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
641 .read = snd_emu10k1_fx8010_read,
644 int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
646 struct snd_info_entry *entry;
647 #ifdef CONFIG_SND_DEBUG
648 if (emu->card_capabilities->emu_model) {
649 snd_card_ro_proc_new(emu->card, "emu1010_regs",
650 emu, snd_emu_proc_emu1010_reg_read);
652 snd_card_rw_proc_new(emu->card, "io_regs", emu,
653 snd_emu_proc_io_reg_read,
654 snd_emu_proc_io_reg_write);
655 snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu,
656 snd_emu_proc_ptr_reg_read00a,
657 snd_emu_proc_ptr_reg_write00);
658 snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu,
659 snd_emu_proc_ptr_reg_read00b,
660 snd_emu_proc_ptr_reg_write00);
661 if (!emu->card_capabilities->emu_model &&
662 (emu->card_capabilities->ca0151_chip || emu->card_capabilities->ca0108_chip)) {
663 snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu,
664 snd_emu_proc_ptr_reg_read20a,
665 snd_emu_proc_ptr_reg_write20);
666 snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu,
667 snd_emu_proc_ptr_reg_read20b,
668 snd_emu_proc_ptr_reg_write20);
669 if (emu->card_capabilities->ca0108_chip)
670 snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu,
671 snd_emu_proc_ptr_reg_read20c,
672 snd_emu_proc_ptr_reg_write20);
676 snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read);
678 if (emu->card_capabilities->emu10k2_chip)
679 snd_card_ro_proc_new(emu->card, "spdif-in", emu,
680 snd_emu10k1_proc_spdif_read);
681 if (emu->card_capabilities->ca0151_chip)
682 snd_card_ro_proc_new(emu->card, "capture-rates", emu,
683 snd_emu10k1_proc_rates_read);
685 snd_card_ro_proc_new(emu->card, "voices", emu,
686 snd_emu10k1_proc_voices_read);
688 if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
689 entry->content = SNDRV_INFO_CONTENT_DATA;
690 entry->private_data = emu;
691 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
692 entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
693 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
695 if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
696 entry->content = SNDRV_INFO_CONTENT_DATA;
697 entry->private_data = emu;
698 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
699 entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
700 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
702 if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
703 entry->content = SNDRV_INFO_CONTENT_DATA;
704 entry->private_data = emu;
705 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
706 entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
707 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
709 if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
710 entry->content = SNDRV_INFO_CONTENT_DATA;
711 entry->private_data = emu;
712 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
713 entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
714 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
716 snd_card_ro_proc_new(emu->card, "fx8010_acode", emu,
717 snd_emu10k1_proc_acode_read);