1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 * Lee Revell <rlrevell@joe-job.com>
5 * James Courtier-Dutton <James@superbug.co.uk>
6 * Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
9 * Routines for control of EMU10K1 chips / proc interface routines
12 #include <linux/slab.h>
13 #include <linux/init.h>
14 #include <sound/core.h>
15 #include <sound/emu10k1.h>
18 static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu,
19 struct snd_info_buffer *buffer,
24 static const char * const clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" };
25 static const int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
26 static const char * const channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
27 static const char * const emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" };
28 unsigned int status, rate = 0;
30 status = snd_emu10k1_ptr_read(emu, status_reg, 0);
32 snd_iprintf(buffer, "\n%s\n", title);
34 if (status != 0xffffffff) {
35 snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no");
36 snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no");
37 snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no");
38 snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]);
39 snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6);
40 snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8);
41 snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy");
42 snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16);
43 snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]);
44 snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]);
45 snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]);
48 rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
49 snd_iprintf(buffer, "S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off");
50 snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off");
51 snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off");
52 /* From ((Rate * 48000 ) / 262144); */
53 snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11);
56 snd_iprintf(buffer, "No signal detected.\n");
61 static void snd_emu10k1_proc_read(struct snd_info_entry *entry,
62 struct snd_info_buffer *buffer)
64 struct snd_emu10k1 *emu = entry->private_data;
65 const char * const *inputs = emu->audigy ?
66 snd_emu10k1_audigy_ins : snd_emu10k1_sblive_ins;
67 const char * const *outputs = emu->audigy ?
68 snd_emu10k1_audigy_outs : snd_emu10k1_sblive_outs;
69 unsigned short extin_mask = emu->audigy ? ~0 : emu->fx8010.extin_mask;
70 unsigned short extout_mask = emu->audigy ? ~0 : emu->fx8010.extout_mask;
71 unsigned int val, val1, ptrx, psst, dsl, snda;
72 int nefx = emu->audigy ? 32 : 16;
75 snd_iprintf(buffer, "EMU10K1\n\n");
76 snd_iprintf(buffer, "Card : %s\n",
77 emu->card_capabilities->emu_model ? "E-MU D.A.S." :
78 emu->card_capabilities->ecard ? "E-MU A.P.S." :
79 emu->audigy ? "SB Audigy" : "SB Live!");
80 snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
81 snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2);
83 snd_iprintf(buffer, "\nEffect Send Routing & Amounts:\n");
84 for (idx = 0; idx < NUM_G; idx++) {
85 ptrx = snd_emu10k1_ptr_read(emu, PTRX, idx);
86 psst = snd_emu10k1_ptr_read(emu, PSST, idx);
87 dsl = snd_emu10k1_ptr_read(emu, DSL, idx);
89 val = snd_emu10k1_ptr_read(emu, A_FXRT1, idx);
90 val1 = snd_emu10k1_ptr_read(emu, A_FXRT2, idx);
91 snda = snd_emu10k1_ptr_read(emu, A_SENDAMOUNTS, idx);
92 snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x, ",
94 val & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx),
95 (val >> 8) & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx),
96 (val >> 16) & 0x3f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst),
97 (val >> 24) & 0x3f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl));
98 snd_iprintf(buffer, "E=%2i:%02x, F=%2i:%02x, G=%2i:%02x, H=%2i:%02x\n",
99 val1 & 0x3f, (snda >> 24) & 0xff,
100 (val1 >> 8) & 0x3f, (snda >> 16) & 0xff,
101 (val1 >> 16) & 0x3f, (snda >> 8) & 0xff,
102 (val1 >> 24) & 0x3f, snda & 0xff);
104 val = snd_emu10k1_ptr_read(emu, FXRT, idx);
105 snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x\n",
107 (val >> 16) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx),
108 (val >> 20) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx),
109 (val >> 24) & 0x0f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst),
110 (val >> 28) & 0x0f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl));
113 snd_iprintf(buffer, "\nEffect Send Targets:\n");
114 // Audigy actually has 64, but we don't use them all.
115 for (idx = 0; idx < 32; idx++) {
116 const char *c = snd_emu10k1_fxbus[idx];
118 snd_iprintf(buffer, " Channel %02i [%s]\n", idx, c);
120 if (!emu->card_capabilities->emu_model) {
121 snd_iprintf(buffer, "\nOutput Channels:\n");
122 for (idx = 0; idx < 32; idx++)
123 if (outputs[idx] && (extout_mask & (1 << idx)))
124 snd_iprintf(buffer, " Channel %02i [%s]\n", idx, outputs[idx]);
125 snd_iprintf(buffer, "\nInput Channels:\n");
126 for (idx = 0; idx < 16; idx++)
127 if (inputs[idx] && (extin_mask & (1 << idx)))
128 snd_iprintf(buffer, " Channel %02i [%s]\n", idx, inputs[idx]);
129 snd_iprintf(buffer, "\nMultichannel Capture Sources:\n");
130 for (idx = 0; idx < nefx; idx++)
131 if (emu->efx_voices_mask[0] & (1 << idx))
132 snd_iprintf(buffer, " Channel %02i [Output: %s]\n",
133 idx, outputs[idx] ? outputs[idx] : "???");
135 for (idx = 0; idx < 32; idx++)
136 if (emu->efx_voices_mask[1] & (1 << idx))
137 snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
138 idx + 32, inputs[idx] ? inputs[idx] : "???");
140 for (idx = 0; idx < 16; idx++) {
141 if (emu->efx_voices_mask[0] & ((1 << 16) << idx)) {
142 if (emu->card_capabilities->sblive51) {
143 s8 c = snd_emu10k1_sblive51_fxbus2_map[idx];
145 snd_iprintf(buffer, " Channel %02i [Output: %s]\n",
146 idx + 16, outputs[idx + 16]);
148 snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
149 idx + 16, inputs[c]);
151 snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
152 idx + 16, inputs[idx] ? inputs[idx] : "???");
160 static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
161 struct snd_info_buffer *buffer)
163 struct snd_emu10k1 *emu = entry->private_data;
167 if (emu->card_capabilities->emu_model) {
168 // This represents the S/PDIF lock status on 0404b, which is
169 // kinda weird and unhelpful, because monitoring it via IRQ is
170 // impractical (one gets an IRQ flood as long as it is desynced).
171 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &value);
172 snd_iprintf(buffer, "Lock status 1: %#x\n", value & 0x10);
174 // Bit 0x1 in LO being 0 is supposedly for ADAT lock.
175 // The registers are always all zero on 0404b.
176 snd_emu1010_fpga_read(emu, EMU_HANA_LOCK_STS_LO, &value);
177 snd_emu1010_fpga_read(emu, EMU_HANA_LOCK_STS_HI, &value2);
178 snd_iprintf(buffer, "Lock status 2: %#x %#x\n", value, value2);
180 snd_iprintf(buffer, "S/PDIF rate: %dHz\n",
181 snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_HANA_SPDIF_IN));
182 if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) {
183 snd_iprintf(buffer, "ADAT rate: %dHz\n",
184 snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_HANA_ADAT_IN));
185 snd_iprintf(buffer, "Dock rate: %dHz\n",
186 snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_2ND_HANA));
188 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU0404 ||
189 emu->card_capabilities->emu_model == EMU_MODEL_EMU1010)
190 snd_iprintf(buffer, "BNC rate: %dHz\n",
191 snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_SYNC_BNC));
193 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &value);
194 if (value & EMU_HANA_SPDIF_MODE_RX_INVALID)
195 snd_iprintf(buffer, "\nS/PDIF input invalid\n");
197 snd_iprintf(buffer, "\nS/PDIF mode: %s%s\n",
198 value & EMU_HANA_SPDIF_MODE_RX_PRO ? "professional" : "consumer",
199 value & EMU_HANA_SPDIF_MODE_RX_NOCOPY ? ", no copy" : "");
201 snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
202 snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
205 val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
206 snd_iprintf(buffer, "\nZoomed Video\n");
207 snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off");
208 snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
212 static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry,
213 struct snd_info_buffer *buffer)
215 static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
216 struct snd_emu10k1 *emu = entry->private_data;
217 unsigned int val, tmp, n;
218 val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
219 for (n = 0; n < 4; n++) {
220 tmp = val >> (16 + (n*4));
221 if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
222 else snd_iprintf(buffer, "Channel %d: No input\n", n);
226 struct emu10k1_reg_entry {
227 unsigned short base, size;
231 static const struct emu10k1_reg_entry sblive_reg_entries[] = {
232 { 0, 0x10, "FXBUS" },
233 { 0x10, 0x10, "EXTIN" },
234 { 0x20, 0x10, "EXTOUT" },
235 { 0x30, 0x10, "FXBUS2" },
236 { 0x40, 0x20, NULL }, // Constants
237 { 0x100, 0x100, "GPR" },
238 { 0x200, 0x80, "ITRAM_DATA" },
239 { 0x280, 0x20, "ETRAM_DATA" },
240 { 0x300, 0x80, "ITRAM_ADDR" },
241 { 0x380, 0x20, "ETRAM_ADDR" },
245 static const struct emu10k1_reg_entry audigy_reg_entries[] = {
246 { 0, 0x40, "FXBUS" },
247 { 0x40, 0x10, "EXTIN" },
248 { 0x50, 0x10, "P16VIN" },
249 { 0x60, 0x20, "EXTOUT" },
250 { 0x80, 0x20, "FXBUS2" },
251 { 0xa0, 0x10, "EMU32OUTH" },
252 { 0xb0, 0x10, "EMU32OUTL" },
253 { 0xc0, 0x20, NULL }, // Constants
254 // This can't be quite right - overlap.
255 //{ 0x100, 0xc0, "ITRAM_CTL" },
256 //{ 0x1c0, 0x40, "ETRAM_CTL" },
257 { 0x160, 0x20, "A3_EMU32IN" },
258 { 0x1e0, 0x20, "A3_EMU32OUT" },
259 { 0x200, 0xc0, "ITRAM_DATA" },
260 { 0x2c0, 0x40, "ETRAM_DATA" },
261 { 0x300, 0xc0, "ITRAM_ADDR" },
262 { 0x3c0, 0x40, "ETRAM_ADDR" },
263 { 0x400, 0x200, "GPR" },
267 static const char * const emu10k1_const_entries[] = {
300 static int disasm_emu10k1_reg(char *buffer,
301 const struct emu10k1_reg_entry *entries,
302 unsigned reg, const char *pfx)
304 for (int i = 0; ; i++) {
305 unsigned base = entries[i].base;
306 unsigned size = entries[i].size;
308 return sprintf(buffer, "%s0x%03x", pfx, reg);
309 if (reg >= base && reg < base + size) {
310 const char *name = entries[i].name;
313 return sprintf(buffer, "%s%s(%u)", pfx, name, reg);
314 return sprintf(buffer, "%s%s", pfx, emu10k1_const_entries[reg]);
319 static int disasm_sblive_reg(char *buffer, unsigned reg, const char *pfx)
321 return disasm_emu10k1_reg(buffer, sblive_reg_entries, reg, pfx);
324 static int disasm_audigy_reg(char *buffer, unsigned reg, const char *pfx)
326 return disasm_emu10k1_reg(buffer, audigy_reg_entries, reg, pfx);
329 static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry,
330 struct snd_info_buffer *buffer)
333 struct snd_emu10k1 *emu = entry->private_data;
334 static const char * const insns[16] = {
335 "MAC0", "MAC1", "MAC2", "MAC3", "MACINT0", "MACINT1", "ACC3", "MACMV",
336 "ANDXOR", "TSTNEG", "LIMITGE", "LIMITLT", "LOG", "EXP", "INTERP", "SKIP",
338 static const char spaces[] = " ";
339 const int nspaces = sizeof(spaces) - 1;
341 snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
342 snd_iprintf(buffer, " Code dump :\n");
343 for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
349 low = snd_emu10k1_efx_read(emu, pc * 2);
350 high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
352 bufp += sprintf(bufp, " %-7s ", insns[(high >> 24) & 0x0f]);
353 bufp += disasm_audigy_reg(bufp, (high >> 12) & 0x7ff, "");
354 bufp += disasm_audigy_reg(bufp, (high >> 0) & 0x7ff, ", ");
355 bufp += disasm_audigy_reg(bufp, (low >> 12) & 0x7ff, ", ");
356 bufp += disasm_audigy_reg(bufp, (low >> 0) & 0x7ff, ", ");
358 bufp += sprintf(bufp, " %-7s ", insns[(high >> 20) & 0x0f]);
359 bufp += disasm_sblive_reg(bufp, (high >> 10) & 0x3ff, "");
360 bufp += disasm_sblive_reg(bufp, (high >> 0) & 0x3ff, ", ");
361 bufp += disasm_sblive_reg(bufp, (low >> 10) & 0x3ff, ", ");
362 bufp += disasm_sblive_reg(bufp, (low >> 0) & 0x3ff, ", ");
364 len = (int)(ptrdiff_t)(bufp - buf);
365 snd_iprintf(buffer, "%s %s /* 0x%04x: 0x%08x%08x */\n",
366 buf, &spaces[nspaces - clamp(65 - len, 0, nspaces)],
371 #define TOTAL_SIZE_GPR (0x100*4)
372 #define A_TOTAL_SIZE_GPR (0x200*4)
373 #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
374 #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
375 #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
376 #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
377 #define TOTAL_SIZE_CODE (0x200*8)
378 #define A_TOTAL_SIZE_CODE (0x400*8)
380 static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
381 void *file_private_data,
382 struct file *file, char __user *buf,
383 size_t count, loff_t pos)
385 struct snd_emu10k1 *emu = entry->private_data;
392 if (!strcmp(entry->name, "fx8010_tram_addr")) {
393 offset = TANKMEMADDRREGBASE;
395 } else if (!strcmp(entry->name, "fx8010_tram_data")) {
396 offset = TANKMEMDATAREGBASE;
397 } else if (!strcmp(entry->name, "fx8010_code")) {
398 offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
400 offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
403 tmp = kmalloc(count + 8, GFP_KERNEL);
406 for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
408 val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
409 if (tram_addr && emu->audigy) {
411 val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
415 if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
423 static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
424 struct snd_info_buffer *buffer)
426 struct snd_emu10k1 *emu = entry->private_data;
427 struct snd_emu10k1_voice *voice;
429 static const char * const types[] = {
430 "Unused", "EFX", "EFX IRQ", "PCM", "PCM IRQ", "Synth"
432 static_assert(ARRAY_SIZE(types) == EMU10K1_NUM_TYPES);
434 snd_iprintf(buffer, "ch\tdirty\tlast\tuse\n");
435 for (idx = 0; idx < NUM_G; idx++) {
436 voice = &emu->voices[idx];
437 snd_iprintf(buffer, "%i\t%u\t%u\t%s\n",
445 #ifdef CONFIG_SND_DEBUG
447 static void snd_emu_proc_emu1010_link_read(struct snd_emu10k1 *emu,
448 struct snd_info_buffer *buffer,
451 u32 src = snd_emu1010_fpga_link_dst_src_read(emu, dst);
452 snd_iprintf(buffer, "%04x: %04x\n", dst, src);
455 static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
456 struct snd_info_buffer *buffer)
458 struct snd_emu10k1 *emu = entry->private_data;
461 snd_iprintf(buffer, "EMU1010 Registers:\n\n");
463 for(i = 0; i < 0x40; i+=1) {
464 snd_emu1010_fpga_read(emu, i, &value);
465 snd_iprintf(buffer, "%02x: %02x\n", i, value);
468 snd_iprintf(buffer, "\nEMU1010 Routes:\n\n");
470 for (i = 0; i < 16; i++) // To Alice2/Tina[2] via EMU32
471 snd_emu_proc_emu1010_link_read(emu, buffer, i);
472 if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404)
473 for (i = 0; i < 32; i++) // To Dock via EDI
474 snd_emu_proc_emu1010_link_read(emu, buffer, 0x100 + i);
475 if (emu->card_capabilities->emu_model != EMU_MODEL_EMU1616)
476 for (i = 0; i < 8; i++) // To Hamoa/local
477 snd_emu_proc_emu1010_link_read(emu, buffer, 0x200 + i);
478 for (i = 0; i < 8; i++) // To Hamoa/Mana/local
479 snd_emu_proc_emu1010_link_read(emu, buffer, 0x300 + i);
480 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
481 for (i = 0; i < 16; i++) // To Tina2 via EMU32
482 snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
483 } else if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) {
484 for (i = 0; i < 8; i++) // To Hana ADAT
485 snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
486 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010B) {
487 for (i = 0; i < 16; i++) // To Tina via EMU32
488 snd_emu_proc_emu1010_link_read(emu, buffer, 0x500 + i);
491 snd_emu_proc_emu1010_link_read(emu, buffer, 0x500);
492 snd_emu_proc_emu1010_link_read(emu, buffer, 0x501);
493 snd_emu_proc_emu1010_link_read(emu, buffer, 0x600);
494 snd_emu_proc_emu1010_link_read(emu, buffer, 0x601);
495 snd_emu_proc_emu1010_link_read(emu, buffer, 0x700);
496 snd_emu_proc_emu1010_link_read(emu, buffer, 0x701);
501 static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
502 struct snd_info_buffer *buffer)
504 struct snd_emu10k1 *emu = entry->private_data;
507 snd_iprintf(buffer, "IO Registers:\n\n");
508 for(i = 0; i < 0x40; i+=4) {
509 value = inl(emu->port + i);
510 snd_iprintf(buffer, "%02X: %08lX\n", i, value);
514 static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
515 struct snd_info_buffer *buffer)
517 struct snd_emu10k1 *emu = entry->private_data;
520 while (!snd_info_get_line(buffer, line, sizeof(line))) {
521 if (sscanf(line, "%x %x", ®, &val) != 2)
523 if (reg < 0x40 && val <= 0xffffffff) {
524 outl(val, emu->port + (reg & 0xfffffffc));
529 static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
534 unsigned int regptr, val;
536 regptr = (reg << 16) | chn;
538 spin_lock_irq(&emu->emu_lock);
539 outl(regptr, emu->port + iobase + PTR);
540 val = inl(emu->port + iobase + DATA);
541 spin_unlock_irq(&emu->emu_lock);
545 static void snd_ptr_write(struct snd_emu10k1 *emu,
553 regptr = (reg << 16) | chn;
555 spin_lock_irq(&emu->emu_lock);
556 outl(regptr, emu->port + iobase + PTR);
557 outl(data, emu->port + iobase + DATA);
558 spin_unlock_irq(&emu->emu_lock);
562 static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
563 struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
565 struct snd_emu10k1 *emu = entry->private_data;
568 if (offset+length > 0xa0) {
569 snd_iprintf(buffer, "Input values out of range\n");
572 snd_iprintf(buffer, "Registers 0x%x\n", iobase);
573 for(i = offset; i < offset+length; i++) {
574 snd_iprintf(buffer, "%02X: ",i);
575 for (j = 0; j < voices; j++) {
576 value = snd_ptr_read(emu, iobase, i, j);
577 snd_iprintf(buffer, "%08lX ", value);
579 snd_iprintf(buffer, "\n");
583 static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
584 struct snd_info_buffer *buffer,
585 int iobase, int length, int voices)
587 struct snd_emu10k1 *emu = entry->private_data;
589 unsigned int reg, channel_id , val;
590 while (!snd_info_get_line(buffer, line, sizeof(line))) {
591 if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3)
593 if (reg < length && channel_id < voices)
594 snd_ptr_write(emu, iobase, reg, channel_id, val);
598 static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
599 struct snd_info_buffer *buffer)
601 snd_emu_proc_ptr_reg_write(entry, buffer, 0, 0x80, 64);
604 static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
605 struct snd_info_buffer *buffer)
607 struct snd_emu10k1 *emu = entry->private_data;
608 snd_emu_proc_ptr_reg_write(entry, buffer, 0x20,
609 emu->card_capabilities->ca0108_chip ? 0xa0 : 0x80, 4);
613 static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
614 struct snd_info_buffer *buffer)
616 snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
619 static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
620 struct snd_info_buffer *buffer)
622 snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
625 static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
626 struct snd_info_buffer *buffer)
628 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
631 static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
632 struct snd_info_buffer *buffer)
634 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
637 static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
638 struct snd_info_buffer * buffer)
640 snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
644 static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
645 .read = snd_emu10k1_fx8010_read,
648 int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
650 struct snd_info_entry *entry;
651 #ifdef CONFIG_SND_DEBUG
652 if (emu->card_capabilities->emu_model) {
653 snd_card_ro_proc_new(emu->card, "emu1010_regs",
654 emu, snd_emu_proc_emu1010_reg_read);
656 snd_card_rw_proc_new(emu->card, "io_regs", emu,
657 snd_emu_proc_io_reg_read,
658 snd_emu_proc_io_reg_write);
659 snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu,
660 snd_emu_proc_ptr_reg_read00a,
661 snd_emu_proc_ptr_reg_write00);
662 snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu,
663 snd_emu_proc_ptr_reg_read00b,
664 snd_emu_proc_ptr_reg_write00);
665 if (!emu->card_capabilities->emu_model &&
666 (emu->card_capabilities->ca0151_chip || emu->card_capabilities->ca0108_chip)) {
667 snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu,
668 snd_emu_proc_ptr_reg_read20a,
669 snd_emu_proc_ptr_reg_write20);
670 snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu,
671 snd_emu_proc_ptr_reg_read20b,
672 snd_emu_proc_ptr_reg_write20);
673 if (emu->card_capabilities->ca0108_chip)
674 snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu,
675 snd_emu_proc_ptr_reg_read20c,
676 snd_emu_proc_ptr_reg_write20);
680 snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read);
682 if (emu->card_capabilities->emu10k2_chip)
683 snd_card_ro_proc_new(emu->card, "spdif-in", emu,
684 snd_emu10k1_proc_spdif_read);
685 if (emu->card_capabilities->ca0151_chip)
686 snd_card_ro_proc_new(emu->card, "capture-rates", emu,
687 snd_emu10k1_proc_rates_read);
689 snd_card_ro_proc_new(emu->card, "voices", emu,
690 snd_emu10k1_proc_voices_read);
692 if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
693 entry->content = SNDRV_INFO_CONTENT_DATA;
694 entry->private_data = emu;
695 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
696 entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
697 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
699 if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
700 entry->content = SNDRV_INFO_CONTENT_DATA;
701 entry->private_data = emu;
702 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
703 entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
704 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
706 if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
707 entry->content = SNDRV_INFO_CONTENT_DATA;
708 entry->private_data = emu;
709 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
710 entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
711 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
713 if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
714 entry->content = SNDRV_INFO_CONTENT_DATA;
715 entry->private_data = emu;
716 entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
717 entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
718 entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
720 snd_card_ro_proc_new(emu->card, "fx8010_acode", emu,
721 snd_emu10k1_proc_acode_read);