Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/sound/pci/emu10k1/emuproc.c
26451 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
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
204
snd_emu1010_fpga_unlock(emu);
205
} else {
206
snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
207
snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
208
}
209
#if 0
210
val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
211
snd_iprintf(buffer, "\nZoomed Video\n");
212
snd_iprintf(buffer, "Rate Locked : %s\n", str_on_off(val & SRCS_RATELOCKED));
213
snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
214
#endif
215
}
216
217
static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry,
218
struct snd_info_buffer *buffer)
219
{
220
static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
221
struct snd_emu10k1 *emu = entry->private_data;
222
unsigned int val, tmp, n;
223
val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
224
for (n = 0; n < 4; n++) {
225
tmp = val >> (16 + (n*4));
226
if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
227
else snd_iprintf(buffer, "Channel %d: No input\n", n);
228
}
229
}
230
231
struct emu10k1_reg_entry {
232
unsigned short base, size;
233
const char *name;
234
};
235
236
static const struct emu10k1_reg_entry sblive_reg_entries[] = {
237
{ 0, 0x10, "FXBUS" },
238
{ 0x10, 0x10, "EXTIN" },
239
{ 0x20, 0x10, "EXTOUT" },
240
{ 0x30, 0x10, "FXBUS2" },
241
{ 0x40, 0x20, NULL }, // Constants
242
{ 0x100, 0x100, "GPR" },
243
{ 0x200, 0x80, "ITRAM_DATA" },
244
{ 0x280, 0x20, "ETRAM_DATA" },
245
{ 0x300, 0x80, "ITRAM_ADDR" },
246
{ 0x380, 0x20, "ETRAM_ADDR" },
247
{ 0x400, 0, NULL }
248
};
249
250
static const struct emu10k1_reg_entry audigy_reg_entries[] = {
251
{ 0, 0x40, "FXBUS" },
252
{ 0x40, 0x10, "EXTIN" },
253
{ 0x50, 0x10, "P16VIN" },
254
{ 0x60, 0x20, "EXTOUT" },
255
{ 0x80, 0x20, "FXBUS2" },
256
{ 0xa0, 0x10, "EMU32OUTH" },
257
{ 0xb0, 0x10, "EMU32OUTL" },
258
{ 0xc0, 0x20, NULL }, // Constants
259
// This can't be quite right - overlap.
260
//{ 0x100, 0xc0, "ITRAM_CTL" },
261
//{ 0x1c0, 0x40, "ETRAM_CTL" },
262
{ 0x160, 0x20, "A3_EMU32IN" },
263
{ 0x1e0, 0x20, "A3_EMU32OUT" },
264
{ 0x200, 0xc0, "ITRAM_DATA" },
265
{ 0x2c0, 0x40, "ETRAM_DATA" },
266
{ 0x300, 0xc0, "ITRAM_ADDR" },
267
{ 0x3c0, 0x40, "ETRAM_ADDR" },
268
{ 0x400, 0x200, "GPR" },
269
{ 0x600, 0, NULL }
270
};
271
272
static const char * const emu10k1_const_entries[] = {
273
"C_00000000",
274
"C_00000001",
275
"C_00000002",
276
"C_00000003",
277
"C_00000004",
278
"C_00000008",
279
"C_00000010",
280
"C_00000020",
281
"C_00000100",
282
"C_00010000",
283
"C_00000800",
284
"C_10000000",
285
"C_20000000",
286
"C_40000000",
287
"C_80000000",
288
"C_7fffffff",
289
"C_ffffffff",
290
"C_fffffffe",
291
"C_c0000000",
292
"C_4f1bbcdc",
293
"C_5a7ef9db",
294
"C_00100000",
295
"GPR_ACCU",
296
"GPR_COND",
297
"GPR_NOISE0",
298
"GPR_NOISE1",
299
"GPR_IRQ",
300
"GPR_DBAC",
301
"GPR_DBACE",
302
"???",
303
};
304
305
static int disasm_emu10k1_reg(char *buffer,
306
const struct emu10k1_reg_entry *entries,
307
unsigned reg, const char *pfx)
308
{
309
for (int i = 0; ; i++) {
310
unsigned base = entries[i].base;
311
unsigned size = entries[i].size;
312
if (!size)
313
return sprintf(buffer, "%s0x%03x", pfx, reg);
314
if (reg >= base && reg < base + size) {
315
const char *name = entries[i].name;
316
reg -= base;
317
if (name)
318
return sprintf(buffer, "%s%s(%u)", pfx, name, reg);
319
return sprintf(buffer, "%s%s", pfx, emu10k1_const_entries[reg]);
320
}
321
}
322
}
323
324
static int disasm_sblive_reg(char *buffer, unsigned reg, const char *pfx)
325
{
326
return disasm_emu10k1_reg(buffer, sblive_reg_entries, reg, pfx);
327
}
328
329
static int disasm_audigy_reg(char *buffer, unsigned reg, const char *pfx)
330
{
331
return disasm_emu10k1_reg(buffer, audigy_reg_entries, reg, pfx);
332
}
333
334
static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry,
335
struct snd_info_buffer *buffer)
336
{
337
u32 pc;
338
struct snd_emu10k1 *emu = entry->private_data;
339
static const char * const insns[16] = {
340
"MAC0", "MAC1", "MAC2", "MAC3", "MACINT0", "MACINT1", "ACC3", "MACMV",
341
"ANDXOR", "TSTNEG", "LIMITGE", "LIMITLT", "LOG", "EXP", "INTERP", "SKIP",
342
};
343
static const char spaces[] = " ";
344
const int nspaces = sizeof(spaces) - 1;
345
346
snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
347
snd_iprintf(buffer, " Code dump :\n");
348
for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
349
u32 low, high;
350
int len;
351
char buf[100];
352
char *bufp = buf;
353
354
low = snd_emu10k1_efx_read(emu, pc * 2);
355
high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
356
if (emu->audigy) {
357
bufp += sprintf(bufp, " %-7s ", insns[(high >> 24) & 0x0f]);
358
bufp += disasm_audigy_reg(bufp, (high >> 12) & 0x7ff, "");
359
bufp += disasm_audigy_reg(bufp, (high >> 0) & 0x7ff, ", ");
360
bufp += disasm_audigy_reg(bufp, (low >> 12) & 0x7ff, ", ");
361
bufp += disasm_audigy_reg(bufp, (low >> 0) & 0x7ff, ", ");
362
} else {
363
bufp += sprintf(bufp, " %-7s ", insns[(high >> 20) & 0x0f]);
364
bufp += disasm_sblive_reg(bufp, (high >> 10) & 0x3ff, "");
365
bufp += disasm_sblive_reg(bufp, (high >> 0) & 0x3ff, ", ");
366
bufp += disasm_sblive_reg(bufp, (low >> 10) & 0x3ff, ", ");
367
bufp += disasm_sblive_reg(bufp, (low >> 0) & 0x3ff, ", ");
368
}
369
len = (int)(ptrdiff_t)(bufp - buf);
370
snd_iprintf(buffer, "%s %s /* 0x%04x: 0x%08x%08x */\n",
371
buf, &spaces[nspaces - clamp(65 - len, 0, nspaces)],
372
pc, high, low);
373
}
374
}
375
376
#define TOTAL_SIZE_GPR (0x100*4)
377
#define A_TOTAL_SIZE_GPR (0x200*4)
378
#define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
379
#define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
380
#define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
381
#define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
382
#define TOTAL_SIZE_CODE (0x200*8)
383
#define A_TOTAL_SIZE_CODE (0x400*8)
384
385
static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
386
void *file_private_data,
387
struct file *file, char __user *buf,
388
size_t count, loff_t pos)
389
{
390
struct snd_emu10k1 *emu = entry->private_data;
391
unsigned int offset;
392
int tram_addr = 0;
393
unsigned int *tmp;
394
long res;
395
unsigned int idx;
396
397
if (!strcmp(entry->name, "fx8010_tram_addr")) {
398
offset = TANKMEMADDRREGBASE;
399
tram_addr = 1;
400
} else if (!strcmp(entry->name, "fx8010_tram_data")) {
401
offset = TANKMEMDATAREGBASE;
402
} else if (!strcmp(entry->name, "fx8010_code")) {
403
offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
404
} else {
405
offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
406
}
407
408
tmp = kmalloc(count + 8, GFP_KERNEL);
409
if (!tmp)
410
return -ENOMEM;
411
for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
412
unsigned int val;
413
val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
414
if (tram_addr && emu->audigy) {
415
val >>= 11;
416
val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
417
}
418
tmp[idx] = val;
419
}
420
if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
421
res = -EFAULT;
422
else
423
res = count;
424
kfree(tmp);
425
return res;
426
}
427
428
static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
429
struct snd_info_buffer *buffer)
430
{
431
struct snd_emu10k1 *emu = entry->private_data;
432
struct snd_emu10k1_voice *voice;
433
int idx;
434
static const char * const types[] = {
435
"Unused", "EFX", "EFX IRQ", "PCM", "PCM IRQ", "Synth"
436
};
437
static_assert(ARRAY_SIZE(types) == EMU10K1_NUM_TYPES);
438
439
snd_iprintf(buffer, "ch\tdirty\tlast\tuse\n");
440
for (idx = 0; idx < NUM_G; idx++) {
441
voice = &emu->voices[idx];
442
snd_iprintf(buffer, "%i\t%u\t%u\t%s\n",
443
idx,
444
voice->dirty,
445
voice->last,
446
types[voice->use]);
447
}
448
}
449
450
#ifdef CONFIG_SND_DEBUG
451
452
static void snd_emu_proc_emu1010_link_read(struct snd_emu10k1 *emu,
453
struct snd_info_buffer *buffer,
454
u32 dst)
455
{
456
u32 src = snd_emu1010_fpga_link_dst_src_read(emu, dst);
457
snd_iprintf(buffer, "%04x: %04x\n", dst, src);
458
}
459
460
static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
461
struct snd_info_buffer *buffer)
462
{
463
struct snd_emu10k1 *emu = entry->private_data;
464
u32 value;
465
int i;
466
467
snd_emu1010_fpga_lock(emu);
468
469
snd_iprintf(buffer, "EMU1010 Registers:\n\n");
470
471
for(i = 0; i < 0x40; i+=1) {
472
snd_emu1010_fpga_read(emu, i, &value);
473
snd_iprintf(buffer, "%02x: %02x\n", i, value);
474
}
475
476
snd_iprintf(buffer, "\nEMU1010 Routes:\n\n");
477
478
for (i = 0; i < 16; i++) // To Alice2/Tina[2] via EMU32
479
snd_emu_proc_emu1010_link_read(emu, buffer, i);
480
if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404)
481
for (i = 0; i < 32; i++) // To Dock via EDI
482
snd_emu_proc_emu1010_link_read(emu, buffer, 0x100 + i);
483
if (emu->card_capabilities->emu_model != EMU_MODEL_EMU1616)
484
for (i = 0; i < 8; i++) // To Hamoa/local
485
snd_emu_proc_emu1010_link_read(emu, buffer, 0x200 + i);
486
for (i = 0; i < 8; i++) // To Hamoa/Mana/local
487
snd_emu_proc_emu1010_link_read(emu, buffer, 0x300 + i);
488
if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) {
489
for (i = 0; i < 16; i++) // To Tina2 via EMU32
490
snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
491
} else if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) {
492
for (i = 0; i < 8; i++) // To Hana ADAT
493
snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i);
494
if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010B) {
495
for (i = 0; i < 16; i++) // To Tina via EMU32
496
snd_emu_proc_emu1010_link_read(emu, buffer, 0x500 + i);
497
} else {
498
// To Alice2 via I2S
499
snd_emu_proc_emu1010_link_read(emu, buffer, 0x500);
500
snd_emu_proc_emu1010_link_read(emu, buffer, 0x501);
501
snd_emu_proc_emu1010_link_read(emu, buffer, 0x600);
502
snd_emu_proc_emu1010_link_read(emu, buffer, 0x601);
503
snd_emu_proc_emu1010_link_read(emu, buffer, 0x700);
504
snd_emu_proc_emu1010_link_read(emu, buffer, 0x701);
505
}
506
}
507
508
snd_emu1010_fpga_unlock(emu);
509
}
510
511
static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
512
struct snd_info_buffer *buffer)
513
{
514
struct snd_emu10k1 *emu = entry->private_data;
515
unsigned long value;
516
int i;
517
snd_iprintf(buffer, "IO Registers:\n\n");
518
for(i = 0; i < 0x40; i+=4) {
519
value = inl(emu->port + i);
520
snd_iprintf(buffer, "%02X: %08lX\n", i, value);
521
}
522
}
523
524
static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
525
struct snd_info_buffer *buffer)
526
{
527
struct snd_emu10k1 *emu = entry->private_data;
528
char line[64];
529
u32 reg, val;
530
while (!snd_info_get_line(buffer, line, sizeof(line))) {
531
if (sscanf(line, "%x %x", &reg, &val) != 2)
532
continue;
533
if (reg < 0x40 && val <= 0xffffffff) {
534
outl(val, emu->port + (reg & 0xfffffffc));
535
}
536
}
537
}
538
539
static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
540
unsigned int iobase,
541
unsigned int reg,
542
unsigned int chn)
543
{
544
unsigned int regptr, val;
545
546
regptr = (reg << 16) | chn;
547
548
spin_lock_irq(&emu->emu_lock);
549
outl(regptr, emu->port + iobase + PTR);
550
val = inl(emu->port + iobase + DATA);
551
spin_unlock_irq(&emu->emu_lock);
552
return val;
553
}
554
555
static void snd_ptr_write(struct snd_emu10k1 *emu,
556
unsigned int iobase,
557
unsigned int reg,
558
unsigned int chn,
559
unsigned int data)
560
{
561
unsigned int regptr;
562
563
regptr = (reg << 16) | chn;
564
565
spin_lock_irq(&emu->emu_lock);
566
outl(regptr, emu->port + iobase + PTR);
567
outl(data, emu->port + iobase + DATA);
568
spin_unlock_irq(&emu->emu_lock);
569
}
570
571
572
static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
573
struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
574
{
575
struct snd_emu10k1 *emu = entry->private_data;
576
unsigned long value;
577
int i,j;
578
if (offset+length > 0xa0) {
579
snd_iprintf(buffer, "Input values out of range\n");
580
return;
581
}
582
snd_iprintf(buffer, "Registers 0x%x\n", iobase);
583
for(i = offset; i < offset+length; i++) {
584
snd_iprintf(buffer, "%02X: ",i);
585
for (j = 0; j < voices; j++) {
586
value = snd_ptr_read(emu, iobase, i, j);
587
snd_iprintf(buffer, "%08lX ", value);
588
}
589
snd_iprintf(buffer, "\n");
590
}
591
}
592
593
static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
594
struct snd_info_buffer *buffer,
595
int iobase, int length, int voices)
596
{
597
struct snd_emu10k1 *emu = entry->private_data;
598
char line[64];
599
unsigned int reg, channel_id , val;
600
while (!snd_info_get_line(buffer, line, sizeof(line))) {
601
if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
602
continue;
603
if (reg < length && channel_id < voices)
604
snd_ptr_write(emu, iobase, reg, channel_id, val);
605
}
606
}
607
608
static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
609
struct snd_info_buffer *buffer)
610
{
611
snd_emu_proc_ptr_reg_write(entry, buffer, 0, 0x80, 64);
612
}
613
614
static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
615
struct snd_info_buffer *buffer)
616
{
617
struct snd_emu10k1 *emu = entry->private_data;
618
snd_emu_proc_ptr_reg_write(entry, buffer, 0x20,
619
emu->card_capabilities->ca0108_chip ? 0xa0 : 0x80, 4);
620
}
621
622
623
static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
624
struct snd_info_buffer *buffer)
625
{
626
snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
627
}
628
629
static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
630
struct snd_info_buffer *buffer)
631
{
632
snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
633
}
634
635
static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
636
struct snd_info_buffer *buffer)
637
{
638
snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
639
}
640
641
static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
642
struct snd_info_buffer *buffer)
643
{
644
snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
645
}
646
647
static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
648
struct snd_info_buffer * buffer)
649
{
650
snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
651
}
652
#endif
653
654
static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
655
.read = snd_emu10k1_fx8010_read,
656
};
657
658
int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
659
{
660
struct snd_info_entry *entry;
661
#ifdef CONFIG_SND_DEBUG
662
if (emu->card_capabilities->emu_model) {
663
snd_card_ro_proc_new(emu->card, "emu1010_regs",
664
emu, snd_emu_proc_emu1010_reg_read);
665
}
666
snd_card_rw_proc_new(emu->card, "io_regs", emu,
667
snd_emu_proc_io_reg_read,
668
snd_emu_proc_io_reg_write);
669
snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu,
670
snd_emu_proc_ptr_reg_read00a,
671
snd_emu_proc_ptr_reg_write00);
672
snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu,
673
snd_emu_proc_ptr_reg_read00b,
674
snd_emu_proc_ptr_reg_write00);
675
if (!emu->card_capabilities->emu_model &&
676
(emu->card_capabilities->ca0151_chip || emu->card_capabilities->ca0108_chip)) {
677
snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu,
678
snd_emu_proc_ptr_reg_read20a,
679
snd_emu_proc_ptr_reg_write20);
680
snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu,
681
snd_emu_proc_ptr_reg_read20b,
682
snd_emu_proc_ptr_reg_write20);
683
if (emu->card_capabilities->ca0108_chip)
684
snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu,
685
snd_emu_proc_ptr_reg_read20c,
686
snd_emu_proc_ptr_reg_write20);
687
}
688
#endif
689
690
snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read);
691
692
if (emu->card_capabilities->emu10k2_chip)
693
snd_card_ro_proc_new(emu->card, "spdif-in", emu,
694
snd_emu10k1_proc_spdif_read);
695
if (emu->card_capabilities->ca0151_chip)
696
snd_card_ro_proc_new(emu->card, "capture-rates", emu,
697
snd_emu10k1_proc_rates_read);
698
699
snd_card_ro_proc_new(emu->card, "voices", emu,
700
snd_emu10k1_proc_voices_read);
701
702
if (! snd_card_proc_new(emu->card, "fx8010_gpr", &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_GPR : TOTAL_SIZE_GPR;
707
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
708
}
709
if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &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_DATA : TOTAL_SIZE_TANKMEM_DATA ;
714
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
715
}
716
if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &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_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
721
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
722
}
723
if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
724
entry->content = SNDRV_INFO_CONTENT_DATA;
725
entry->private_data = emu;
726
entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
727
entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
728
entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
729
}
730
snd_card_ro_proc_new(emu->card, "fx8010_acode", emu,
731
snd_emu10k1_proc_acode_read);
732
return 0;
733
}
734
735