Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/sound/pci/emu10k1/emuproc.c
29266 views
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
/*
3
* Copyright (c) by Jaroslav Kysela <[email protected]>
4
* Lee Revell <[email protected]>
5
* James Courtier-Dutton <[email protected]>
6
* Oswald Buddenhagen <[email protected]>
7
* Creative Labs, Inc.
8
*
9
* Routines for control of EMU10K1 chips / proc interface routines
10
*/
11
12
#include <linux/slab.h>
13
#include <linux/init.h>
14
#include <linux/string_choices.h>
15
#include <sound/core.h>
16
#include <sound/emu10k1.h>
17
#include "p16v.h"
18
19
static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu,
20
struct snd_info_buffer *buffer,
21
char *title,
22
int status_reg,
23
int rate_reg)
24
{
25
static const char * const clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" };
26
static const int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
27
static const char * const channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
28
static const char * const emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" };
29
unsigned int status, rate = 0;
30
31
status = snd_emu10k1_ptr_read(emu, status_reg, 0);
32
33
snd_iprintf(buffer, "\n%s\n", title);
34
35
if (status != 0xffffffff) {
36
snd_iprintf(buffer, "Professional Mode : %s\n", str_yes_no(status & SPCS_PROFESSIONAL));
37
snd_iprintf(buffer, "Not Audio Data : %s\n", str_yes_no(status & SPCS_NOTAUDIODATA));
38
snd_iprintf(buffer, "Copyright : %s\n", str_yes_no(status & SPCS_COPYRIGHT));
39
snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]);
40
snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6);
41
snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8);
42
snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy");
43
snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16);
44
snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]);
45
snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]);
46
snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]);
47
48
if (rate_reg > 0) {
49
rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
50
snd_iprintf(buffer, "S/PDIF Valid : %s\n", str_on_off(rate & SRCS_SPDIFVALID));
51
snd_iprintf(buffer, "S/PDIF Locked : %s\n", str_on_off(rate & SRCS_SPDIFLOCKED));
52
snd_iprintf(buffer, "Rate Locked : %s\n", str_on_off(rate & SRCS_RATELOCKED));
53
/* From ((Rate * 48000 ) / 262144); */
54
snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11);
55
}
56
} else {
57
snd_iprintf(buffer, "No signal detected.\n");
58
}
59
60
}
61
62
static void snd_emu10k1_proc_read(struct snd_info_entry *entry,
63
struct snd_info_buffer *buffer)
64
{
65
struct snd_emu10k1 *emu = entry->private_data;
66
const char * const *inputs = emu->audigy ?
67
snd_emu10k1_audigy_ins : snd_emu10k1_sblive_ins;
68
const char * const *outputs = emu->audigy ?
69
snd_emu10k1_audigy_outs : snd_emu10k1_sblive_outs;
70
unsigned short extin_mask = emu->audigy ? ~0 : emu->fx8010.extin_mask;
71
unsigned short extout_mask = emu->audigy ? ~0 : emu->fx8010.extout_mask;
72
unsigned int val, val1, ptrx, psst, dsl, snda;
73
int nefx = emu->audigy ? 32 : 16;
74
int idx;
75
76
snd_iprintf(buffer, "EMU10K1\n\n");
77
snd_iprintf(buffer, "Card : %s\n",
78
emu->card_capabilities->emu_model ? "E-MU D.A.S." :
79
emu->card_capabilities->ecard ? "E-MU A.P.S." :
80
emu->audigy ? "SB Audigy" : "SB Live!");
81
snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
82
snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2);
83
84
snd_iprintf(buffer, "\nEffect Send Routing & Amounts:\n");
85
for (idx = 0; idx < NUM_G; idx++) {
86
ptrx = snd_emu10k1_ptr_read(emu, PTRX, idx);
87
psst = snd_emu10k1_ptr_read(emu, PSST, idx);
88
dsl = snd_emu10k1_ptr_read(emu, DSL, idx);
89
if (emu->audigy) {
90
val = snd_emu10k1_ptr_read(emu, A_FXRT1, idx);
91
val1 = snd_emu10k1_ptr_read(emu, A_FXRT2, idx);
92
snda = snd_emu10k1_ptr_read(emu, A_SENDAMOUNTS, idx);
93
snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x, ",
94
idx,
95
val & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx),
96
(val >> 8) & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx),
97
(val >> 16) & 0x3f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst),
98
(val >> 24) & 0x3f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl));
99
snd_iprintf(buffer, "E=%2i:%02x, F=%2i:%02x, G=%2i:%02x, H=%2i:%02x\n",
100
val1 & 0x3f, (snda >> 24) & 0xff,
101
(val1 >> 8) & 0x3f, (snda >> 16) & 0xff,
102
(val1 >> 16) & 0x3f, (snda >> 8) & 0xff,
103
(val1 >> 24) & 0x3f, snda & 0xff);
104
} else {
105
val = snd_emu10k1_ptr_read(emu, FXRT, idx);
106
snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x\n",
107
idx,
108
(val >> 16) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx),
109
(val >> 20) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx),
110
(val >> 24) & 0x0f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst),
111
(val >> 28) & 0x0f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl));
112
}
113
}
114
snd_iprintf(buffer, "\nEffect Send Targets:\n");
115
// Audigy actually has 64, but we don't use them all.
116
for (idx = 0; idx < 32; idx++) {
117
const char *c = snd_emu10k1_fxbus[idx];
118
if (c)
119
snd_iprintf(buffer, " Channel %02i [%s]\n", idx, c);
120
}
121
if (!emu->card_capabilities->emu_model) {
122
snd_iprintf(buffer, "\nOutput Channels:\n");
123
for (idx = 0; idx < 32; idx++)
124
if (outputs[idx] && (extout_mask & (1 << idx)))
125
snd_iprintf(buffer, " Channel %02i [%s]\n", idx, outputs[idx]);
126
snd_iprintf(buffer, "\nInput Channels:\n");
127
for (idx = 0; idx < 16; idx++)
128
if (inputs[idx] && (extin_mask & (1 << idx)))
129
snd_iprintf(buffer, " Channel %02i [%s]\n", idx, inputs[idx]);
130
snd_iprintf(buffer, "\nMultichannel Capture Sources:\n");
131
for (idx = 0; idx < nefx; idx++)
132
if (emu->efx_voices_mask[0] & (1 << idx))
133
snd_iprintf(buffer, " Channel %02i [Output: %s]\n",
134
idx, outputs[idx] ? outputs[idx] : "???");
135
if (emu->audigy) {
136
for (idx = 0; idx < 32; idx++)
137
if (emu->efx_voices_mask[1] & (1 << idx))
138
snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
139
idx + 32, inputs[idx] ? inputs[idx] : "???");
140
} else {
141
for (idx = 0; idx < 16; idx++) {
142
if (emu->efx_voices_mask[0] & ((1 << 16) << idx)) {
143
if (emu->card_capabilities->sblive51) {
144
s8 c = snd_emu10k1_sblive51_fxbus2_map[idx];
145
if (c == -1)
146
snd_iprintf(buffer, " Channel %02i [Output: %s]\n",
147
idx + 16, outputs[idx + 16]);
148
else
149
snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
150
idx + 16, inputs[c]);
151
} else {
152
snd_iprintf(buffer, " Channel %02i [Input: %s]\n",
153
idx + 16, inputs[idx] ? inputs[idx] : "???");
154
}
155
}
156
}
157
}
158
}
159
}
160
161
static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
162
struct snd_info_buffer *buffer)
163
{
164
struct snd_emu10k1 *emu = entry->private_data;
165
u32 value;
166
u32 value2;
167
168
if (emu->card_capabilities->emu_model) {
169
guard(snd_emu1010_fpga_lock)(emu);
170
171
// This represents the S/PDIF lock status on 0404b, which is
172
// kinda weird and unhelpful, because monitoring it via IRQ is
173
// impractical (one gets an IRQ flood as long as it is desynced).
174
snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &value);
175
snd_iprintf(buffer, "Lock status 1: %#x\n", value & 0x10);
176
177
// Bit 0x1 in LO being 0 is supposedly for ADAT lock.
178
// The registers are always all zero on 0404b.
179
snd_emu1010_fpga_read(emu, EMU_HANA_LOCK_STS_LO, &value);
180
snd_emu1010_fpga_read(emu, EMU_HANA_LOCK_STS_HI, &value2);
181
snd_iprintf(buffer, "Lock status 2: %#x %#x\n", value, value2);
182
183
snd_iprintf(buffer, "S/PDIF rate: %dHz\n",
184
snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_HANA_SPDIF_IN));
185
if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) {
186
snd_iprintf(buffer, "ADAT rate: %dHz\n",
187
snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_HANA_ADAT_IN));
188
snd_iprintf(buffer, "Dock rate: %dHz\n",
189
snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_2ND_HANA));
190
}
191
if (emu->card_capabilities->emu_model == EMU_MODEL_EMU0404 ||
192
emu->card_capabilities->emu_model == EMU_MODEL_EMU1010)
193
snd_iprintf(buffer, "BNC rate: %dHz\n",
194
snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_SYNC_BNC));
195
196
snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &value);
197
if (value & EMU_HANA_SPDIF_MODE_RX_INVALID)
198
snd_iprintf(buffer, "\nS/PDIF input invalid\n");
199
else
200
snd_iprintf(buffer, "\nS/PDIF mode: %s%s\n",
201
value & EMU_HANA_SPDIF_MODE_RX_PRO ? "professional" : "consumer",
202
value & EMU_HANA_SPDIF_MODE_RX_NOCOPY ? ", no copy" : "");
203
} else {
204
snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
205
snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
206
}
207
#if 0
208
val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
209
snd_iprintf(buffer, "\nZoomed Video\n");
210
snd_iprintf(buffer, "Rate Locked : %s\n", str_on_off(val & SRCS_RATELOCKED));
211
snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
212
#endif
213
}
214
215
static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry,
216
struct snd_info_buffer *buffer)
217
{
218
static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
219
struct snd_emu10k1 *emu = entry->private_data;
220
unsigned int val, tmp, n;
221
val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
222
for (n = 0; n < 4; n++) {
223
tmp = val >> (16 + (n*4));
224
if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
225
else snd_iprintf(buffer, "Channel %d: No input\n", n);
226
}
227
}
228
229
struct emu10k1_reg_entry {
230
unsigned short base, size;
231
const char *name;
232
};
233
234
static const struct emu10k1_reg_entry sblive_reg_entries[] = {
235
{ 0, 0x10, "FXBUS" },
236
{ 0x10, 0x10, "EXTIN" },
237
{ 0x20, 0x10, "EXTOUT" },
238
{ 0x30, 0x10, "FXBUS2" },
239
{ 0x40, 0x20, NULL }, // Constants
240
{ 0x100, 0x100, "GPR" },
241
{ 0x200, 0x80, "ITRAM_DATA" },
242
{ 0x280, 0x20, "ETRAM_DATA" },
243
{ 0x300, 0x80, "ITRAM_ADDR" },
244
{ 0x380, 0x20, "ETRAM_ADDR" },
245
{ 0x400, 0, NULL }
246
};
247
248
static const struct emu10k1_reg_entry audigy_reg_entries[] = {
249
{ 0, 0x40, "FXBUS" },
250
{ 0x40, 0x10, "EXTIN" },
251
{ 0x50, 0x10, "P16VIN" },
252
{ 0x60, 0x20, "EXTOUT" },
253
{ 0x80, 0x20, "FXBUS2" },
254
{ 0xa0, 0x10, "EMU32OUTH" },
255
{ 0xb0, 0x10, "EMU32OUTL" },
256
{ 0xc0, 0x20, NULL }, // Constants
257
// This can't be quite right - overlap.
258
//{ 0x100, 0xc0, "ITRAM_CTL" },
259
//{ 0x1c0, 0x40, "ETRAM_CTL" },
260
{ 0x160, 0x20, "A3_EMU32IN" },
261
{ 0x1e0, 0x20, "A3_EMU32OUT" },
262
{ 0x200, 0xc0, "ITRAM_DATA" },
263
{ 0x2c0, 0x40, "ETRAM_DATA" },
264
{ 0x300, 0xc0, "ITRAM_ADDR" },
265
{ 0x3c0, 0x40, "ETRAM_ADDR" },
266
{ 0x400, 0x200, "GPR" },
267
{ 0x600, 0, NULL }
268
};
269
270
static const char * const emu10k1_const_entries[] = {
271
"C_00000000",
272
"C_00000001",
273
"C_00000002",
274
"C_00000003",
275
"C_00000004",
276
"C_00000008",
277
"C_00000010",
278
"C_00000020",
279
"C_00000100",
280
"C_00010000",
281
"C_00000800",
282
"C_10000000",
283
"C_20000000",
284
"C_40000000",
285
"C_80000000",
286
"C_7fffffff",
287
"C_ffffffff",
288
"C_fffffffe",
289
"C_c0000000",
290
"C_4f1bbcdc",
291
"C_5a7ef9db",
292
"C_00100000",
293
"GPR_ACCU",
294
"GPR_COND",
295
"GPR_NOISE0",
296
"GPR_NOISE1",
297
"GPR_IRQ",
298
"GPR_DBAC",
299
"GPR_DBACE",
300
"???",
301
};
302
303
static int disasm_emu10k1_reg(char *buffer,
304
const struct emu10k1_reg_entry *entries,
305
unsigned reg, const char *pfx)
306
{
307
for (int i = 0; ; i++) {
308
unsigned base = entries[i].base;
309
unsigned size = entries[i].size;
310
if (!size)
311
return sprintf(buffer, "%s0x%03x", pfx, reg);
312
if (reg >= base && reg < base + size) {
313
const char *name = entries[i].name;
314
reg -= base;
315
if (name)
316
return sprintf(buffer, "%s%s(%u)", pfx, name, reg);
317
return sprintf(buffer, "%s%s", pfx, emu10k1_const_entries[reg]);
318
}
319
}
320
}
321
322
static int disasm_sblive_reg(char *buffer, unsigned reg, const char *pfx)
323
{
324
return disasm_emu10k1_reg(buffer, sblive_reg_entries, reg, pfx);
325
}
326
327
static int disasm_audigy_reg(char *buffer, unsigned reg, const char *pfx)
328
{
329
return disasm_emu10k1_reg(buffer, audigy_reg_entries, reg, pfx);
330
}
331
332
static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry,
333
struct snd_info_buffer *buffer)
334
{
335
u32 pc;
336
struct snd_emu10k1 *emu = entry->private_data;
337
static const char * const insns[16] = {
338
"MAC0", "MAC1", "MAC2", "MAC3", "MACINT0", "MACINT1", "ACC3", "MACMV",
339
"ANDXOR", "TSTNEG", "LIMITGE", "LIMITLT", "LOG", "EXP", "INTERP", "SKIP",
340
};
341
static const char spaces[] = " ";
342
const int nspaces = sizeof(spaces) - 1;
343
344
snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
345
snd_iprintf(buffer, " Code dump :\n");
346
for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
347
u32 low, high;
348
int len;
349
char buf[100];
350
char *bufp = buf;
351
352
low = snd_emu10k1_efx_read(emu, pc * 2);
353
high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
354
if (emu->audigy) {
355
bufp += sprintf(bufp, " %-7s ", insns[(high >> 24) & 0x0f]);
356
bufp += disasm_audigy_reg(bufp, (high >> 12) & 0x7ff, "");
357
bufp += disasm_audigy_reg(bufp, (high >> 0) & 0x7ff, ", ");
358
bufp += disasm_audigy_reg(bufp, (low >> 12) & 0x7ff, ", ");
359
bufp += disasm_audigy_reg(bufp, (low >> 0) & 0x7ff, ", ");
360
} else {
361
bufp += sprintf(bufp, " %-7s ", insns[(high >> 20) & 0x0f]);
362
bufp += disasm_sblive_reg(bufp, (high >> 10) & 0x3ff, "");
363
bufp += disasm_sblive_reg(bufp, (high >> 0) & 0x3ff, ", ");
364
bufp += disasm_sblive_reg(bufp, (low >> 10) & 0x3ff, ", ");
365
bufp += disasm_sblive_reg(bufp, (low >> 0) & 0x3ff, ", ");
366
}
367
len = (int)(ptrdiff_t)(bufp - buf);
368
snd_iprintf(buffer, "%s %s /* 0x%04x: 0x%08x%08x */\n",
369
buf, &spaces[nspaces - clamp(65 - len, 0, nspaces)],
370
pc, high, low);
371
}
372
}
373
374
#define TOTAL_SIZE_GPR (0x100*4)
375
#define A_TOTAL_SIZE_GPR (0x200*4)
376
#define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
377
#define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
378
#define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
379
#define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
380
#define TOTAL_SIZE_CODE (0x200*8)
381
#define A_TOTAL_SIZE_CODE (0x400*8)
382
383
static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
384
void *file_private_data,
385
struct file *file, char __user *buf,
386
size_t count, loff_t pos)
387
{
388
struct snd_emu10k1 *emu = entry->private_data;
389
unsigned int offset;
390
int tram_addr = 0;
391
unsigned int *tmp;
392
long res;
393
unsigned int idx;
394
395
if (!strcmp(entry->name, "fx8010_tram_addr")) {
396
offset = TANKMEMADDRREGBASE;
397
tram_addr = 1;
398
} else if (!strcmp(entry->name, "fx8010_tram_data")) {
399
offset = TANKMEMDATAREGBASE;
400
} else if (!strcmp(entry->name, "fx8010_code")) {
401
offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
402
} else {
403
offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
404
}
405
406
tmp = kmalloc(count + 8, GFP_KERNEL);
407
if (!tmp)
408
return -ENOMEM;
409
for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
410
unsigned int val;
411
val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
412
if (tram_addr && emu->audigy) {
413
val >>= 11;
414
val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
415
}
416
tmp[idx] = val;
417
}
418
if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
419
res = -EFAULT;
420
else
421
res = count;
422
kfree(tmp);
423
return res;
424
}
425
426
static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
427
struct snd_info_buffer *buffer)
428
{
429
struct snd_emu10k1 *emu = entry->private_data;
430
struct snd_emu10k1_voice *voice;
431
int idx;
432
static const char * const types[] = {
433
"Unused", "EFX", "EFX IRQ", "PCM", "PCM IRQ", "Synth"
434
};
435
static_assert(ARRAY_SIZE(types) == EMU10K1_NUM_TYPES);
436
437
snd_iprintf(buffer, "ch\tdirty\tlast\tuse\n");
438
for (idx = 0; idx < NUM_G; idx++) {
439
voice = &emu->voices[idx];
440
snd_iprintf(buffer, "%i\t%u\t%u\t%s\n",
441
idx,
442
voice->dirty,
443
voice->last,
444
types[voice->use]);
445
}
446
}
447
448
#ifdef CONFIG_SND_DEBUG
449
450
static void snd_emu_proc_emu1010_link_read(struct snd_emu10k1 *emu,
451
struct snd_info_buffer *buffer,
452
u32 dst)
453
{
454
u32 src = snd_emu1010_fpga_link_dst_src_read(emu, dst);
455
snd_iprintf(buffer, "%04x: %04x\n", dst, src);
456
}
457
458
static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
459
struct snd_info_buffer *buffer)
460
{
461
struct snd_emu10k1 *emu = entry->private_data;
462
u32 value;
463
int i;
464
465
guard(snd_emu1010_fpga_lock)(emu);
466
467
snd_iprintf(buffer, "EMU1010 Registers:\n\n");
468
469
for(i = 0; i < 0x40; i+=1) {
470
snd_emu1010_fpga_read(emu, i, &value);
471
snd_iprintf(buffer, "%02x: %02x\n", i, value);
472
}
473
474
snd_iprintf(buffer, "\nEMU1010 Routes:\n\n");
475
476
for (i = 0; i < 16; i++) // To Alice2/Tina[2] via EMU32
477
snd_emu_proc_emu1010_link_read(emu, buffer, i);
478
if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404)
479
for (i = 0; i < 32; i++) // To Dock via EDI
480
snd_emu_proc_emu1010_link_read(emu, buffer, 0x100 + i);
481
if (emu->card_capabilities->emu_model != EMU_MODEL_EMU1616)
482
for (i = 0; i < 8; i++) // To Hamoa/local
483
snd_emu_proc_emu1010_link_read(emu, buffer, 0x200 + i);
484
for (i = 0; i < 8; i++) // To Hamoa/Mana/local
485
snd_emu_proc_emu1010_link_read(emu, buffer, 0x300 + i);
486
if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
487
for (i = 0; i < 16; i++) // To Tina2 via EMU32
488
snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
489
} else if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) {
490
for (i = 0; i < 8; i++) // To Hana ADAT
491
snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
492
if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010B) {
493
for (i = 0; i < 16; i++) // To Tina via EMU32
494
snd_emu_proc_emu1010_link_read(emu, buffer, 0x500 + i);
495
} else {
496
// To Alice2 via I2S
497
snd_emu_proc_emu1010_link_read(emu, buffer, 0x500);
498
snd_emu_proc_emu1010_link_read(emu, buffer, 0x501);
499
snd_emu_proc_emu1010_link_read(emu, buffer, 0x600);
500
snd_emu_proc_emu1010_link_read(emu, buffer, 0x601);
501
snd_emu_proc_emu1010_link_read(emu, buffer, 0x700);
502
snd_emu_proc_emu1010_link_read(emu, buffer, 0x701);
503
}
504
}
505
}
506
507
static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
508
struct snd_info_buffer *buffer)
509
{
510
struct snd_emu10k1 *emu = entry->private_data;
511
unsigned long value;
512
int i;
513
snd_iprintf(buffer, "IO Registers:\n\n");
514
for(i = 0; i < 0x40; i+=4) {
515
value = inl(emu->port + i);
516
snd_iprintf(buffer, "%02X: %08lX\n", i, value);
517
}
518
}
519
520
static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
521
struct snd_info_buffer *buffer)
522
{
523
struct snd_emu10k1 *emu = entry->private_data;
524
char line[64];
525
u32 reg, val;
526
while (!snd_info_get_line(buffer, line, sizeof(line))) {
527
if (sscanf(line, "%x %x", &reg, &val) != 2)
528
continue;
529
if (reg < 0x40 && val <= 0xffffffff) {
530
outl(val, emu->port + (reg & 0xfffffffc));
531
}
532
}
533
}
534
535
static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
536
unsigned int iobase,
537
unsigned int reg,
538
unsigned int chn)
539
{
540
unsigned int regptr;
541
542
regptr = (reg << 16) | chn;
543
544
guard(spinlock_irq)(&emu->emu_lock);
545
outl(regptr, emu->port + iobase + PTR);
546
return inl(emu->port + iobase + DATA);
547
}
548
549
static void snd_ptr_write(struct snd_emu10k1 *emu,
550
unsigned int iobase,
551
unsigned int reg,
552
unsigned int chn,
553
unsigned int data)
554
{
555
unsigned int regptr;
556
557
regptr = (reg << 16) | chn;
558
559
guard(spinlock_irq)(&emu->emu_lock);
560
outl(regptr, emu->port + iobase + PTR);
561
outl(data, emu->port + iobase + DATA);
562
}
563
564
565
static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
566
struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
567
{
568
struct snd_emu10k1 *emu = entry->private_data;
569
unsigned long value;
570
int i,j;
571
if (offset+length > 0xa0) {
572
snd_iprintf(buffer, "Input values out of range\n");
573
return;
574
}
575
snd_iprintf(buffer, "Registers 0x%x\n", iobase);
576
for(i = offset; i < offset+length; i++) {
577
snd_iprintf(buffer, "%02X: ",i);
578
for (j = 0; j < voices; j++) {
579
value = snd_ptr_read(emu, iobase, i, j);
580
snd_iprintf(buffer, "%08lX ", value);
581
}
582
snd_iprintf(buffer, "\n");
583
}
584
}
585
586
static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
587
struct snd_info_buffer *buffer,
588
int iobase, int length, int voices)
589
{
590
struct snd_emu10k1 *emu = entry->private_data;
591
char line[64];
592
unsigned int reg, channel_id , val;
593
while (!snd_info_get_line(buffer, line, sizeof(line))) {
594
if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
595
continue;
596
if (reg < length && channel_id < voices)
597
snd_ptr_write(emu, iobase, reg, channel_id, val);
598
}
599
}
600
601
static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
602
struct snd_info_buffer *buffer)
603
{
604
snd_emu_proc_ptr_reg_write(entry, buffer, 0, 0x80, 64);
605
}
606
607
static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
608
struct snd_info_buffer *buffer)
609
{
610
struct snd_emu10k1 *emu = entry->private_data;
611
snd_emu_proc_ptr_reg_write(entry, buffer, 0x20,
612
emu->card_capabilities->ca0108_chip ? 0xa0 : 0x80, 4);
613
}
614
615
616
static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
617
struct snd_info_buffer *buffer)
618
{
619
snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
620
}
621
622
static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
623
struct snd_info_buffer *buffer)
624
{
625
snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
626
}
627
628
static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
629
struct snd_info_buffer *buffer)
630
{
631
snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
632
}
633
634
static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
635
struct snd_info_buffer *buffer)
636
{
637
snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
638
}
639
640
static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
641
struct snd_info_buffer * buffer)
642
{
643
snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
644
}
645
#endif
646
647
static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
648
.read = snd_emu10k1_fx8010_read,
649
};
650
651
int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
652
{
653
struct snd_info_entry *entry;
654
#ifdef CONFIG_SND_DEBUG
655
if (emu->card_capabilities->emu_model) {
656
snd_card_ro_proc_new(emu->card, "emu1010_regs",
657
emu, snd_emu_proc_emu1010_reg_read);
658
}
659
snd_card_rw_proc_new(emu->card, "io_regs", emu,
660
snd_emu_proc_io_reg_read,
661
snd_emu_proc_io_reg_write);
662
snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu,
663
snd_emu_proc_ptr_reg_read00a,
664
snd_emu_proc_ptr_reg_write00);
665
snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu,
666
snd_emu_proc_ptr_reg_read00b,
667
snd_emu_proc_ptr_reg_write00);
668
if (!emu->card_capabilities->emu_model &&
669
(emu->card_capabilities->ca0151_chip || emu->card_capabilities->ca0108_chip)) {
670
snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu,
671
snd_emu_proc_ptr_reg_read20a,
672
snd_emu_proc_ptr_reg_write20);
673
snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu,
674
snd_emu_proc_ptr_reg_read20b,
675
snd_emu_proc_ptr_reg_write20);
676
if (emu->card_capabilities->ca0108_chip)
677
snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu,
678
snd_emu_proc_ptr_reg_read20c,
679
snd_emu_proc_ptr_reg_write20);
680
}
681
#endif
682
683
snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read);
684
685
if (emu->card_capabilities->emu10k2_chip)
686
snd_card_ro_proc_new(emu->card, "spdif-in", emu,
687
snd_emu10k1_proc_spdif_read);
688
if (emu->card_capabilities->ca0151_chip)
689
snd_card_ro_proc_new(emu->card, "capture-rates", emu,
690
snd_emu10k1_proc_rates_read);
691
692
snd_card_ro_proc_new(emu->card, "voices", emu,
693
snd_emu10k1_proc_voices_read);
694
695
if (! snd_card_proc_new(emu->card, "fx8010_gpr", &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_GPR : TOTAL_SIZE_GPR;
700
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
701
}
702
if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &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_DATA : TOTAL_SIZE_TANKMEM_DATA ;
707
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
708
}
709
if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &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_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
714
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
715
}
716
if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
717
entry->content = SNDRV_INFO_CONTENT_DATA;
718
entry->private_data = emu;
719
entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
720
entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
721
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
722
}
723
snd_card_ro_proc_new(emu->card, "fx8010_acode", emu,
724
snd_emu10k1_proc_acode_read);
725
return 0;
726
}
727
728