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