Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
c1017a4c | 2 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
1da177e4 LT |
3 | * Creative Labs, Inc. |
4 | * Routines for control of EMU10K1 chips / proc interface routines | |
5 | * | |
9f4bd5dd JCD |
6 | * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk> |
7 | * Added EMU 1010 support. | |
8 | * | |
1da177e4 LT |
9 | * BUGS: |
10 | * -- | |
11 | * | |
12 | * TODO: | |
13 | * -- | |
14 | * | |
15 | * This program is free software; you can redistribute it and/or modify | |
16 | * it under the terms of the GNU General Public License as published by | |
17 | * the Free Software Foundation; either version 2 of the License, or | |
18 | * (at your option) any later version. | |
19 | * | |
20 | * This program is distributed in the hope that it will be useful, | |
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 | * GNU General Public License for more details. | |
24 | * | |
25 | * You should have received a copy of the GNU General Public License | |
26 | * along with this program; if not, write to the Free Software | |
27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
28 | * | |
29 | */ | |
30 | ||
1da177e4 LT |
31 | #include <linux/slab.h> |
32 | #include <linux/init.h> | |
33 | #include <sound/core.h> | |
34 | #include <sound/emu10k1.h> | |
001f7589 | 35 | #include "p16v.h" |
1da177e4 | 36 | |
adf1b3d2 | 37 | #ifdef CONFIG_PROC_FS |
eb4698f3 TI |
38 | static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, |
39 | struct snd_info_buffer *buffer, | |
1da177e4 LT |
40 | char *title, |
41 | int status_reg, | |
42 | int rate_reg) | |
43 | { | |
44 | static char *clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" }; | |
45 | static int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; | |
46 | static char *channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; | |
47 | static char *emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" }; | |
48 | unsigned int status, rate = 0; | |
49 | ||
50 | status = snd_emu10k1_ptr_read(emu, status_reg, 0); | |
1da177e4 LT |
51 | |
52 | snd_iprintf(buffer, "\n%s\n", title); | |
53 | ||
df34140a JCD |
54 | if (status != 0xffffffff) { |
55 | snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no"); | |
56 | snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no"); | |
57 | snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no"); | |
58 | snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]); | |
59 | snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6); | |
60 | snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8); | |
61 | snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy"); | |
62 | snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16); | |
63 | snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]); | |
64 | snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]); | |
65 | snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]); | |
66 | ||
67 | if (rate_reg > 0) { | |
68 | rate = snd_emu10k1_ptr_read(emu, rate_reg, 0); | |
001f7589 | 69 | snd_iprintf(buffer, "S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off"); |
df34140a JCD |
70 | snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off"); |
71 | snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off"); | |
72 | /* From ((Rate * 48000 ) / 262144); */ | |
73 | snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11); | |
74 | } | |
75 | } else { | |
76 | snd_iprintf(buffer, "No signal detected.\n"); | |
1da177e4 | 77 | } |
df34140a | 78 | |
1da177e4 LT |
79 | } |
80 | ||
eb4698f3 TI |
81 | static void snd_emu10k1_proc_read(struct snd_info_entry *entry, |
82 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
83 | { |
84 | /* FIXME - output names are in emufx.c too */ | |
85 | static char *creative_outs[32] = { | |
86 | /* 00 */ "AC97 Left", | |
87 | /* 01 */ "AC97 Right", | |
88 | /* 02 */ "Optical IEC958 Left", | |
89 | /* 03 */ "Optical IEC958 Right", | |
90 | /* 04 */ "Center", | |
91 | /* 05 */ "LFE", | |
92 | /* 06 */ "Headphone Left", | |
93 | /* 07 */ "Headphone Right", | |
94 | /* 08 */ "Surround Left", | |
95 | /* 09 */ "Surround Right", | |
96 | /* 10 */ "PCM Capture Left", | |
97 | /* 11 */ "PCM Capture Right", | |
98 | /* 12 */ "MIC Capture", | |
99 | /* 13 */ "AC97 Surround Left", | |
100 | /* 14 */ "AC97 Surround Right", | |
101 | /* 15 */ "???", | |
102 | /* 16 */ "???", | |
103 | /* 17 */ "Analog Center", | |
104 | /* 18 */ "Analog LFE", | |
105 | /* 19 */ "???", | |
106 | /* 20 */ "???", | |
107 | /* 21 */ "???", | |
108 | /* 22 */ "???", | |
109 | /* 23 */ "???", | |
110 | /* 24 */ "???", | |
111 | /* 25 */ "???", | |
112 | /* 26 */ "???", | |
113 | /* 27 */ "???", | |
114 | /* 28 */ "???", | |
115 | /* 29 */ "???", | |
116 | /* 30 */ "???", | |
117 | /* 31 */ "???" | |
118 | }; | |
119 | ||
120 | static char *audigy_outs[64] = { | |
121 | /* 00 */ "Digital Front Left", | |
122 | /* 01 */ "Digital Front Right", | |
123 | /* 02 */ "Digital Center", | |
124 | /* 03 */ "Digital LEF", | |
125 | /* 04 */ "Headphone Left", | |
126 | /* 05 */ "Headphone Right", | |
127 | /* 06 */ "Digital Rear Left", | |
128 | /* 07 */ "Digital Rear Right", | |
129 | /* 08 */ "Front Left", | |
130 | /* 09 */ "Front Right", | |
131 | /* 10 */ "Center", | |
132 | /* 11 */ "LFE", | |
133 | /* 12 */ "???", | |
134 | /* 13 */ "???", | |
135 | /* 14 */ "Rear Left", | |
136 | /* 15 */ "Rear Right", | |
137 | /* 16 */ "AC97 Front Left", | |
138 | /* 17 */ "AC97 Front Right", | |
139 | /* 18 */ "ADC Caputre Left", | |
140 | /* 19 */ "ADC Capture Right", | |
141 | /* 20 */ "???", | |
142 | /* 21 */ "???", | |
143 | /* 22 */ "???", | |
144 | /* 23 */ "???", | |
145 | /* 24 */ "???", | |
146 | /* 25 */ "???", | |
147 | /* 26 */ "???", | |
148 | /* 27 */ "???", | |
149 | /* 28 */ "???", | |
150 | /* 29 */ "???", | |
151 | /* 30 */ "???", | |
152 | /* 31 */ "???", | |
153 | /* 32 */ "FXBUS2_0", | |
154 | /* 33 */ "FXBUS2_1", | |
155 | /* 34 */ "FXBUS2_2", | |
156 | /* 35 */ "FXBUS2_3", | |
157 | /* 36 */ "FXBUS2_4", | |
158 | /* 37 */ "FXBUS2_5", | |
159 | /* 38 */ "FXBUS2_6", | |
160 | /* 39 */ "FXBUS2_7", | |
161 | /* 40 */ "FXBUS2_8", | |
162 | /* 41 */ "FXBUS2_9", | |
163 | /* 42 */ "FXBUS2_10", | |
164 | /* 43 */ "FXBUS2_11", | |
165 | /* 44 */ "FXBUS2_12", | |
166 | /* 45 */ "FXBUS2_13", | |
167 | /* 46 */ "FXBUS2_14", | |
168 | /* 47 */ "FXBUS2_15", | |
169 | /* 48 */ "FXBUS2_16", | |
170 | /* 49 */ "FXBUS2_17", | |
171 | /* 50 */ "FXBUS2_18", | |
172 | /* 51 */ "FXBUS2_19", | |
173 | /* 52 */ "FXBUS2_20", | |
174 | /* 53 */ "FXBUS2_21", | |
175 | /* 54 */ "FXBUS2_22", | |
176 | /* 55 */ "FXBUS2_23", | |
177 | /* 56 */ "FXBUS2_24", | |
178 | /* 57 */ "FXBUS2_25", | |
179 | /* 58 */ "FXBUS2_26", | |
180 | /* 59 */ "FXBUS2_27", | |
181 | /* 60 */ "FXBUS2_28", | |
182 | /* 61 */ "FXBUS2_29", | |
183 | /* 62 */ "FXBUS2_30", | |
184 | /* 63 */ "FXBUS2_31" | |
185 | }; | |
186 | ||
eb4698f3 | 187 | struct snd_emu10k1 *emu = entry->private_data; |
1da177e4 LT |
188 | unsigned int val, val1; |
189 | int nefx = emu->audigy ? 64 : 32; | |
190 | char **outputs = emu->audigy ? audigy_outs : creative_outs; | |
191 | int idx; | |
192 | ||
193 | snd_iprintf(buffer, "EMU10K1\n\n"); | |
194 | snd_iprintf(buffer, "Card : %s\n", | |
2b637da5 | 195 | emu->audigy ? "Audigy" : (emu->card_capabilities->ecard ? "EMU APS" : "Creative")); |
1da177e4 LT |
196 | snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size); |
197 | snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2); | |
198 | snd_iprintf(buffer, "\n"); | |
199 | snd_iprintf(buffer, "Effect Send Routing :\n"); | |
200 | for (idx = 0; idx < NUM_G; idx++) { | |
201 | val = emu->audigy ? | |
202 | snd_emu10k1_ptr_read(emu, A_FXRT1, idx) : | |
203 | snd_emu10k1_ptr_read(emu, FXRT, idx); | |
204 | val1 = emu->audigy ? | |
205 | snd_emu10k1_ptr_read(emu, A_FXRT2, idx) : | |
206 | 0; | |
207 | if (emu->audigy) { | |
208 | snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i, ", | |
209 | idx, | |
210 | val & 0x3f, | |
211 | (val >> 8) & 0x3f, | |
212 | (val >> 16) & 0x3f, | |
213 | (val >> 24) & 0x3f); | |
214 | snd_iprintf(buffer, "E=%i, F=%i, G=%i, H=%i\n", | |
215 | val1 & 0x3f, | |
216 | (val1 >> 8) & 0x3f, | |
217 | (val1 >> 16) & 0x3f, | |
218 | (val1 >> 24) & 0x3f); | |
219 | } else { | |
220 | snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i\n", | |
221 | idx, | |
222 | (val >> 16) & 0x0f, | |
223 | (val >> 20) & 0x0f, | |
224 | (val >> 24) & 0x0f, | |
225 | (val >> 28) & 0x0f); | |
226 | } | |
227 | } | |
228 | snd_iprintf(buffer, "\nCaptured FX Outputs :\n"); | |
229 | for (idx = 0; idx < nefx; idx++) { | |
230 | if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) | |
231 | snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]); | |
232 | } | |
233 | snd_iprintf(buffer, "\nAll FX Outputs :\n"); | |
234 | for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++) | |
235 | snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]); | |
df34140a JCD |
236 | } |
237 | ||
eb4698f3 TI |
238 | static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, |
239 | struct snd_info_buffer *buffer) | |
df34140a | 240 | { |
eb4698f3 | 241 | struct snd_emu10k1 *emu = entry->private_data; |
f93abe51 JCD |
242 | u32 value; |
243 | u32 value2; | |
244 | unsigned long flags; | |
245 | u32 rate; | |
246 | ||
190d2c46 | 247 | if (emu->card_capabilities->emu_model) { |
f93abe51 JCD |
248 | spin_lock_irqsave(&emu->emu_lock, flags); |
249 | snd_emu1010_fpga_read(emu, 0x38, &value); | |
250 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
251 | if ((value & 0x1) == 0) { | |
252 | spin_lock_irqsave(&emu->emu_lock, flags); | |
253 | snd_emu1010_fpga_read(emu, 0x2a, &value); | |
254 | snd_emu1010_fpga_read(emu, 0x2b, &value2); | |
255 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
256 | rate = 0x1770000 / (((value << 5) | value2)+1); | |
257 | snd_iprintf(buffer, "ADAT Locked : %u\n", rate); | |
258 | } else { | |
259 | snd_iprintf(buffer, "ADAT Unlocked\n"); | |
260 | } | |
261 | spin_lock_irqsave(&emu->emu_lock, flags); | |
262 | snd_emu1010_fpga_read(emu, 0x20, &value); | |
263 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
264 | if ((value & 0x4) == 0) { | |
265 | spin_lock_irqsave(&emu->emu_lock, flags); | |
266 | snd_emu1010_fpga_read(emu, 0x28, &value); | |
267 | snd_emu1010_fpga_read(emu, 0x29, &value2); | |
268 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
269 | rate = 0x1770000 / (((value << 5) | value2)+1); | |
270 | snd_iprintf(buffer, "SPDIF Locked : %d\n", rate); | |
271 | } else { | |
272 | snd_iprintf(buffer, "SPDIF Unlocked\n"); | |
273 | } | |
274 | } else { | |
275 | snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS); | |
276 | snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS); | |
277 | } | |
df34140a | 278 | #if 0 |
1da177e4 LT |
279 | val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0); |
280 | snd_iprintf(buffer, "\nZoomed Video\n"); | |
281 | snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off"); | |
282 | snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE); | |
df34140a | 283 | #endif |
1da177e4 LT |
284 | } |
285 | ||
eb4698f3 TI |
286 | static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry, |
287 | struct snd_info_buffer *buffer) | |
001f7589 JCD |
288 | { |
289 | static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; | |
eb4698f3 | 290 | struct snd_emu10k1 *emu = entry->private_data; |
001f7589 JCD |
291 | unsigned int val, tmp, n; |
292 | val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); | |
293 | tmp = (val >> 16) & 0x8; | |
9f4bd5dd | 294 | for (n = 0; n < 4; n++) { |
001f7589 JCD |
295 | tmp = val >> (16 + (n*4)); |
296 | if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]); | |
297 | else snd_iprintf(buffer, "Channel %d: No input\n", n); | |
298 | } | |
299 | } | |
300 | ||
eb4698f3 TI |
301 | static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry, |
302 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
303 | { |
304 | u32 pc; | |
eb4698f3 | 305 | struct snd_emu10k1 *emu = entry->private_data; |
1da177e4 LT |
306 | |
307 | snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name); | |
308 | snd_iprintf(buffer, " Code dump :\n"); | |
309 | for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) { | |
310 | u32 low, high; | |
311 | ||
312 | low = snd_emu10k1_efx_read(emu, pc * 2); | |
313 | high = snd_emu10k1_efx_read(emu, pc * 2 + 1); | |
314 | if (emu->audigy) | |
315 | snd_iprintf(buffer, " OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n", | |
316 | (high >> 24) & 0x0f, | |
317 | (high >> 12) & 0x7ff, | |
318 | (high >> 0) & 0x7ff, | |
319 | (low >> 12) & 0x7ff, | |
320 | (low >> 0) & 0x7ff, | |
321 | pc, | |
322 | high, low); | |
323 | else | |
324 | snd_iprintf(buffer, " OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n", | |
325 | (high >> 20) & 0x0f, | |
326 | (high >> 10) & 0x3ff, | |
327 | (high >> 0) & 0x3ff, | |
328 | (low >> 10) & 0x3ff, | |
329 | (low >> 0) & 0x3ff, | |
330 | pc, | |
331 | high, low); | |
332 | } | |
333 | } | |
334 | ||
335 | #define TOTAL_SIZE_GPR (0x100*4) | |
336 | #define A_TOTAL_SIZE_GPR (0x200*4) | |
337 | #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4) | |
338 | #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4) | |
339 | #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4) | |
340 | #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4) | |
341 | #define TOTAL_SIZE_CODE (0x200*8) | |
342 | #define A_TOTAL_SIZE_CODE (0x400*8) | |
343 | ||
24e4a121 TI |
344 | static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry, |
345 | void *file_private_data, | |
346 | struct file *file, char __user *buf, | |
347 | size_t count, loff_t pos) | |
1da177e4 | 348 | { |
eb4698f3 | 349 | struct snd_emu10k1 *emu = entry->private_data; |
1da177e4 LT |
350 | unsigned int offset; |
351 | int tram_addr = 0; | |
d97e1b78 TI |
352 | unsigned int *tmp; |
353 | long res; | |
354 | unsigned int idx; | |
1da177e4 LT |
355 | |
356 | if (!strcmp(entry->name, "fx8010_tram_addr")) { | |
357 | offset = TANKMEMADDRREGBASE; | |
358 | tram_addr = 1; | |
359 | } else if (!strcmp(entry->name, "fx8010_tram_data")) { | |
360 | offset = TANKMEMDATAREGBASE; | |
361 | } else if (!strcmp(entry->name, "fx8010_code")) { | |
362 | offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; | |
363 | } else { | |
364 | offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE; | |
365 | } | |
d97e1b78 TI |
366 | |
367 | tmp = kmalloc(count + 8, GFP_KERNEL); | |
368 | if (!tmp) | |
369 | return -ENOMEM; | |
370 | for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) { | |
371 | unsigned int val; | |
372 | val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0); | |
373 | if (tram_addr && emu->audigy) { | |
374 | val >>= 11; | |
375 | val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20; | |
1da177e4 | 376 | } |
d97e1b78 | 377 | tmp[idx] = val; |
1da177e4 | 378 | } |
d97e1b78 TI |
379 | if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count)) |
380 | res = -EFAULT; | |
381 | else | |
382 | res = count; | |
383 | kfree(tmp); | |
384 | return res; | |
1da177e4 LT |
385 | } |
386 | ||
eb4698f3 TI |
387 | static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry, |
388 | struct snd_info_buffer *buffer) | |
1da177e4 | 389 | { |
eb4698f3 TI |
390 | struct snd_emu10k1 *emu = entry->private_data; |
391 | struct snd_emu10k1_voice *voice; | |
1da177e4 LT |
392 | int idx; |
393 | ||
394 | snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n"); | |
395 | for (idx = 0; idx < NUM_G; idx++) { | |
396 | voice = &emu->voices[idx]; | |
397 | snd_iprintf(buffer, "%i\t%i\t%i\t%i\t%i\t%i\n", | |
398 | idx, | |
399 | voice->use, | |
400 | voice->pcm, | |
401 | voice->efx, | |
402 | voice->synth, | |
403 | voice->midi); | |
404 | } | |
405 | } | |
406 | ||
407 | #ifdef CONFIG_SND_DEBUG | |
9f4bd5dd JCD |
408 | static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry, |
409 | struct snd_info_buffer *buffer) | |
410 | { | |
411 | struct snd_emu10k1 *emu = entry->private_data; | |
4677df07 | 412 | u32 value; |
9f4bd5dd | 413 | unsigned long flags; |
9f4bd5dd JCD |
414 | int i; |
415 | snd_iprintf(buffer, "EMU1010 Registers:\n\n"); | |
416 | ||
90fd5ce5 | 417 | for(i = 0; i < 0x40; i+=1) { |
9f4bd5dd | 418 | spin_lock_irqsave(&emu->emu_lock, flags); |
f93abe51 | 419 | snd_emu1010_fpga_read(emu, i, &value); |
9f4bd5dd | 420 | spin_unlock_irqrestore(&emu->emu_lock, flags); |
f93abe51 | 421 | snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f); |
9f4bd5dd JCD |
422 | } |
423 | } | |
424 | ||
eb4698f3 TI |
425 | static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry, |
426 | struct snd_info_buffer *buffer) | |
1da177e4 | 427 | { |
eb4698f3 | 428 | struct snd_emu10k1 *emu = entry->private_data; |
1da177e4 LT |
429 | unsigned long value; |
430 | unsigned long flags; | |
431 | int i; | |
432 | snd_iprintf(buffer, "IO Registers:\n\n"); | |
433 | for(i = 0; i < 0x40; i+=4) { | |
434 | spin_lock_irqsave(&emu->emu_lock, flags); | |
435 | value = inl(emu->port + i); | |
436 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
437 | snd_iprintf(buffer, "%02X: %08lX\n", i, value); | |
438 | } | |
439 | } | |
440 | ||
eb4698f3 TI |
441 | static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry, |
442 | struct snd_info_buffer *buffer) | |
1da177e4 | 443 | { |
eb4698f3 | 444 | struct snd_emu10k1 *emu = entry->private_data; |
1da177e4 LT |
445 | unsigned long flags; |
446 | char line[64]; | |
447 | u32 reg, val; | |
448 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | |
449 | if (sscanf(line, "%x %x", ®, &val) != 2) | |
450 | continue; | |
84ed1a19 | 451 | if (reg < 0x40 && val <= 0xffffffff) { |
1da177e4 LT |
452 | spin_lock_irqsave(&emu->emu_lock, flags); |
453 | outl(val, emu->port + (reg & 0xfffffffc)); | |
454 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
455 | } | |
456 | } | |
457 | } | |
458 | ||
eb4698f3 | 459 | static unsigned int snd_ptr_read(struct snd_emu10k1 * emu, |
1da177e4 LT |
460 | unsigned int iobase, |
461 | unsigned int reg, | |
462 | unsigned int chn) | |
463 | { | |
464 | unsigned long flags; | |
465 | unsigned int regptr, val; | |
466 | ||
467 | regptr = (reg << 16) | chn; | |
468 | ||
469 | spin_lock_irqsave(&emu->emu_lock, flags); | |
470 | outl(regptr, emu->port + iobase + PTR); | |
471 | val = inl(emu->port + iobase + DATA); | |
472 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
473 | return val; | |
474 | } | |
475 | ||
eb4698f3 | 476 | static void snd_ptr_write(struct snd_emu10k1 *emu, |
1da177e4 LT |
477 | unsigned int iobase, |
478 | unsigned int reg, | |
479 | unsigned int chn, | |
480 | unsigned int data) | |
481 | { | |
482 | unsigned int regptr; | |
483 | unsigned long flags; | |
484 | ||
485 | regptr = (reg << 16) | chn; | |
486 | ||
487 | spin_lock_irqsave(&emu->emu_lock, flags); | |
488 | outl(regptr, emu->port + iobase + PTR); | |
489 | outl(data, emu->port + iobase + DATA); | |
490 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
491 | } | |
492 | ||
493 | ||
eb4698f3 TI |
494 | static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry, |
495 | struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices) | |
1da177e4 | 496 | { |
eb4698f3 | 497 | struct snd_emu10k1 *emu = entry->private_data; |
1da177e4 LT |
498 | unsigned long value; |
499 | int i,j; | |
6ef7e861 | 500 | if (offset+length > 0xa0) { |
1da177e4 LT |
501 | snd_iprintf(buffer, "Input values out of range\n"); |
502 | return; | |
503 | } | |
504 | snd_iprintf(buffer, "Registers 0x%x\n", iobase); | |
505 | for(i = offset; i < offset+length; i++) { | |
506 | snd_iprintf(buffer, "%02X: ",i); | |
507 | for (j = 0; j < voices; j++) { | |
508 | if(iobase == 0) | |
509 | value = snd_ptr_read(emu, 0, i, j); | |
510 | else | |
511 | value = snd_ptr_read(emu, 0x20, i, j); | |
512 | snd_iprintf(buffer, "%08lX ", value); | |
513 | } | |
514 | snd_iprintf(buffer, "\n"); | |
515 | } | |
516 | } | |
517 | ||
eb4698f3 TI |
518 | static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry, |
519 | struct snd_info_buffer *buffer, int iobase) | |
1da177e4 | 520 | { |
eb4698f3 | 521 | struct snd_emu10k1 *emu = entry->private_data; |
1da177e4 LT |
522 | char line[64]; |
523 | unsigned int reg, channel_id , val; | |
524 | while (!snd_info_get_line(buffer, line, sizeof(line))) { | |
525 | if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) | |
526 | continue; | |
84ed1a19 | 527 | if (reg < 0xa0 && val <= 0xffffffff && channel_id <= 3) |
1da177e4 LT |
528 | snd_ptr_write(emu, iobase, reg, channel_id, val); |
529 | } | |
530 | } | |
531 | ||
eb4698f3 TI |
532 | static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry, |
533 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
534 | { |
535 | snd_emu_proc_ptr_reg_write(entry, buffer, 0); | |
536 | } | |
537 | ||
eb4698f3 TI |
538 | static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry, |
539 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
540 | { |
541 | snd_emu_proc_ptr_reg_write(entry, buffer, 0x20); | |
542 | } | |
543 | ||
544 | ||
eb4698f3 TI |
545 | static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry, |
546 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
547 | { |
548 | snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64); | |
549 | } | |
550 | ||
eb4698f3 TI |
551 | static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry, |
552 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
553 | { |
554 | snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64); | |
555 | } | |
556 | ||
eb4698f3 TI |
557 | static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry, |
558 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
559 | { |
560 | snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4); | |
561 | } | |
562 | ||
eb4698f3 TI |
563 | static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry, |
564 | struct snd_info_buffer *buffer) | |
1da177e4 LT |
565 | { |
566 | snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4); | |
567 | } | |
6ef7e861 | 568 | |
eb4698f3 TI |
569 | static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry, |
570 | struct snd_info_buffer * buffer) | |
6ef7e861 JCD |
571 | { |
572 | snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4); | |
573 | } | |
1da177e4 LT |
574 | #endif |
575 | ||
576 | static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { | |
577 | .read = snd_emu10k1_fx8010_read, | |
578 | }; | |
579 | ||
e23e7a14 | 580 | int snd_emu10k1_proc_init(struct snd_emu10k1 *emu) |
1da177e4 | 581 | { |
eb4698f3 | 582 | struct snd_info_entry *entry; |
1da177e4 | 583 | #ifdef CONFIG_SND_DEBUG |
190d2c46 | 584 | if (emu->card_capabilities->emu_model) { |
90fd5ce5 JCD |
585 | if (! snd_card_proc_new(emu->card, "emu1010_regs", &entry)) |
586 | snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read); | |
9f4bd5dd | 587 | } |
1da177e4 | 588 | if (! snd_card_proc_new(emu->card, "io_regs", &entry)) { |
bf850204 | 589 | snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read); |
1da177e4 | 590 | entry->c.text.write = snd_emu_proc_io_reg_write; |
bd7bf042 | 591 | entry->mode |= S_IWUSR; |
1da177e4 LT |
592 | } |
593 | if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) { | |
bf850204 | 594 | snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a); |
1da177e4 | 595 | entry->c.text.write = snd_emu_proc_ptr_reg_write00; |
bd7bf042 | 596 | entry->mode |= S_IWUSR; |
1da177e4 LT |
597 | } |
598 | if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) { | |
bf850204 | 599 | snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b); |
1da177e4 | 600 | entry->c.text.write = snd_emu_proc_ptr_reg_write00; |
bd7bf042 | 601 | entry->mode |= S_IWUSR; |
1da177e4 LT |
602 | } |
603 | if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) { | |
bf850204 | 604 | snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a); |
1da177e4 | 605 | entry->c.text.write = snd_emu_proc_ptr_reg_write20; |
bd7bf042 | 606 | entry->mode |= S_IWUSR; |
1da177e4 LT |
607 | } |
608 | if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) { | |
bf850204 | 609 | snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b); |
1da177e4 | 610 | entry->c.text.write = snd_emu_proc_ptr_reg_write20; |
bd7bf042 | 611 | entry->mode |= S_IWUSR; |
1da177e4 | 612 | } |
6ef7e861 | 613 | if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) { |
bf850204 | 614 | snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c); |
6ef7e861 JCD |
615 | entry->c.text.write = snd_emu_proc_ptr_reg_write20; |
616 | entry->mode |= S_IWUSR; | |
617 | } | |
1da177e4 LT |
618 | #endif |
619 | ||
620 | if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) | |
bf850204 | 621 | snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read); |
1da177e4 | 622 | |
df34140a JCD |
623 | if (emu->card_capabilities->emu10k2_chip) { |
624 | if (! snd_card_proc_new(emu->card, "spdif-in", &entry)) | |
bf850204 | 625 | snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read); |
df34140a | 626 | } |
001f7589 JCD |
627 | if (emu->card_capabilities->ca0151_chip) { |
628 | if (! snd_card_proc_new(emu->card, "capture-rates", &entry)) | |
bf850204 | 629 | snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read); |
001f7589 | 630 | } |
df34140a | 631 | |
1da177e4 | 632 | if (! snd_card_proc_new(emu->card, "voices", &entry)) |
bf850204 | 633 | snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read); |
1da177e4 LT |
634 | |
635 | if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) { | |
636 | entry->content = SNDRV_INFO_CONTENT_DATA; | |
637 | entry->private_data = emu; | |
638 | entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/; | |
639 | entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR; | |
640 | entry->c.ops = &snd_emu10k1_proc_ops_fx8010; | |
641 | } | |
642 | if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) { | |
643 | entry->content = SNDRV_INFO_CONTENT_DATA; | |
644 | entry->private_data = emu; | |
645 | entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/; | |
646 | entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ; | |
647 | entry->c.ops = &snd_emu10k1_proc_ops_fx8010; | |
648 | } | |
649 | if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) { | |
650 | entry->content = SNDRV_INFO_CONTENT_DATA; | |
651 | entry->private_data = emu; | |
652 | entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/; | |
653 | entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ; | |
654 | entry->c.ops = &snd_emu10k1_proc_ops_fx8010; | |
655 | } | |
656 | if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) { | |
657 | entry->content = SNDRV_INFO_CONTENT_DATA; | |
658 | entry->private_data = emu; | |
659 | entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/; | |
660 | entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE; | |
661 | entry->c.ops = &snd_emu10k1_proc_ops_fx8010; | |
662 | } | |
663 | if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) { | |
664 | entry->content = SNDRV_INFO_CONTENT_TEXT; | |
665 | entry->private_data = emu; | |
666 | entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/; | |
1da177e4 LT |
667 | entry->c.text.read = snd_emu10k1_proc_acode_read; |
668 | } | |
669 | return 0; | |
670 | } | |
adf1b3d2 | 671 | #endif /* CONFIG_PROC_FS */ |