xref: /openbmc/linux/sound/pci/emu10k1/emuproc.c (revision f93abe51e8dc7e929d29e6a9a1991bf7fd234d4a)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
31da177e4SLinus Torvalds  *                   Creative Labs, Inc.
41da177e4SLinus Torvalds  *  Routines for control of EMU10K1 chips / proc interface routines
51da177e4SLinus Torvalds  *
69f4bd5ddSJames Courtier-Dutton  *  Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
79f4bd5ddSJames Courtier-Dutton  *  	Added EMU 1010 support.
89f4bd5ddSJames Courtier-Dutton  *
91da177e4SLinus Torvalds  *  BUGS:
101da177e4SLinus Torvalds  *    --
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  *  TODO:
131da177e4SLinus Torvalds  *    --
141da177e4SLinus Torvalds  *
151da177e4SLinus Torvalds  *   This program is free software; you can redistribute it and/or modify
161da177e4SLinus Torvalds  *   it under the terms of the GNU General Public License as published by
171da177e4SLinus Torvalds  *   the Free Software Foundation; either version 2 of the License, or
181da177e4SLinus Torvalds  *   (at your option) any later version.
191da177e4SLinus Torvalds  *
201da177e4SLinus Torvalds  *   This program is distributed in the hope that it will be useful,
211da177e4SLinus Torvalds  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
221da177e4SLinus Torvalds  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
231da177e4SLinus Torvalds  *   GNU General Public License for more details.
241da177e4SLinus Torvalds  *
251da177e4SLinus Torvalds  *   You should have received a copy of the GNU General Public License
261da177e4SLinus Torvalds  *   along with this program; if not, write to the Free Software
271da177e4SLinus Torvalds  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
281da177e4SLinus Torvalds  *
291da177e4SLinus Torvalds  */
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds #include <sound/driver.h>
321da177e4SLinus Torvalds #include <linux/slab.h>
331da177e4SLinus Torvalds #include <linux/init.h>
341da177e4SLinus Torvalds #include <sound/core.h>
351da177e4SLinus Torvalds #include <sound/emu10k1.h>
36001f7589SJames Courtier-Dutton #include "p16v.h"
371da177e4SLinus Torvalds 
38adf1b3d2STakashi Iwai #ifdef CONFIG_PROC_FS
39eb4698f3STakashi Iwai static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu,
40eb4698f3STakashi Iwai 					  struct snd_info_buffer *buffer,
411da177e4SLinus Torvalds 					  char *title,
421da177e4SLinus Torvalds 					  int status_reg,
431da177e4SLinus Torvalds 					  int rate_reg)
441da177e4SLinus Torvalds {
451da177e4SLinus Torvalds 	static char *clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" };
461da177e4SLinus Torvalds 	static int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
471da177e4SLinus Torvalds 	static char *channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
481da177e4SLinus Torvalds 	static char *emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" };
491da177e4SLinus Torvalds 	unsigned int status, rate = 0;
501da177e4SLinus Torvalds 
511da177e4SLinus Torvalds 	status = snd_emu10k1_ptr_read(emu, status_reg, 0);
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds 	snd_iprintf(buffer, "\n%s\n", title);
541da177e4SLinus Torvalds 
55df34140aSJames Courtier-Dutton 	if (status != 0xffffffff) {
561da177e4SLinus Torvalds 		snd_iprintf(buffer, "Professional Mode     : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no");
571da177e4SLinus Torvalds 		snd_iprintf(buffer, "Not Audio Data        : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no");
581da177e4SLinus Torvalds 		snd_iprintf(buffer, "Copyright             : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no");
591da177e4SLinus Torvalds 		snd_iprintf(buffer, "Emphasis              : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]);
601da177e4SLinus Torvalds 		snd_iprintf(buffer, "Mode                  : %i\n", (status & SPCS_MODEMASK) >> 6);
611da177e4SLinus Torvalds 		snd_iprintf(buffer, "Category Code         : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8);
621da177e4SLinus Torvalds 		snd_iprintf(buffer, "Generation Status     : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy");
631da177e4SLinus Torvalds 		snd_iprintf(buffer, "Source Mask           : %i\n", (status & SPCS_SOURCENUMMASK) >> 16);
641da177e4SLinus Torvalds 		snd_iprintf(buffer, "Channel Number        : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]);
651da177e4SLinus Torvalds 		snd_iprintf(buffer, "Sample Rate           : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]);
661da177e4SLinus Torvalds 		snd_iprintf(buffer, "Clock Accuracy        : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]);
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds 		if (rate_reg > 0) {
69df34140aSJames Courtier-Dutton 			rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
70001f7589SJames Courtier-Dutton 			snd_iprintf(buffer, "S/PDIF Valid          : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off");
711da177e4SLinus Torvalds 			snd_iprintf(buffer, "S/PDIF Locked         : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off");
721da177e4SLinus Torvalds 			snd_iprintf(buffer, "Rate Locked           : %s\n", rate & SRCS_RATELOCKED ? "on" : "off");
73df34140aSJames Courtier-Dutton 			/* From ((Rate * 48000 ) / 262144); */
74df34140aSJames Courtier-Dutton 			snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11);
751da177e4SLinus Torvalds 		}
76df34140aSJames Courtier-Dutton 	} else {
77df34140aSJames Courtier-Dutton 		snd_iprintf(buffer, "No signal detected.\n");
78df34140aSJames Courtier-Dutton 	}
79df34140aSJames Courtier-Dutton 
801da177e4SLinus Torvalds }
811da177e4SLinus Torvalds 
82eb4698f3STakashi Iwai static void snd_emu10k1_proc_read(struct snd_info_entry *entry,
83eb4698f3STakashi Iwai 				  struct snd_info_buffer *buffer)
841da177e4SLinus Torvalds {
851da177e4SLinus Torvalds 	/* FIXME - output names are in emufx.c too */
861da177e4SLinus Torvalds 	static char *creative_outs[32] = {
871da177e4SLinus Torvalds 		/* 00 */ "AC97 Left",
881da177e4SLinus Torvalds 		/* 01 */ "AC97 Right",
891da177e4SLinus Torvalds 		/* 02 */ "Optical IEC958 Left",
901da177e4SLinus Torvalds 		/* 03 */ "Optical IEC958 Right",
911da177e4SLinus Torvalds 		/* 04 */ "Center",
921da177e4SLinus Torvalds 		/* 05 */ "LFE",
931da177e4SLinus Torvalds 		/* 06 */ "Headphone Left",
941da177e4SLinus Torvalds 		/* 07 */ "Headphone Right",
951da177e4SLinus Torvalds 		/* 08 */ "Surround Left",
961da177e4SLinus Torvalds 		/* 09 */ "Surround Right",
971da177e4SLinus Torvalds 		/* 10 */ "PCM Capture Left",
981da177e4SLinus Torvalds 		/* 11 */ "PCM Capture Right",
991da177e4SLinus Torvalds 		/* 12 */ "MIC Capture",
1001da177e4SLinus Torvalds 		/* 13 */ "AC97 Surround Left",
1011da177e4SLinus Torvalds 		/* 14 */ "AC97 Surround Right",
1021da177e4SLinus Torvalds 		/* 15 */ "???",
1031da177e4SLinus Torvalds 		/* 16 */ "???",
1041da177e4SLinus Torvalds 		/* 17 */ "Analog Center",
1051da177e4SLinus Torvalds 		/* 18 */ "Analog LFE",
1061da177e4SLinus Torvalds 		/* 19 */ "???",
1071da177e4SLinus Torvalds 		/* 20 */ "???",
1081da177e4SLinus Torvalds 		/* 21 */ "???",
1091da177e4SLinus Torvalds 		/* 22 */ "???",
1101da177e4SLinus Torvalds 		/* 23 */ "???",
1111da177e4SLinus Torvalds 		/* 24 */ "???",
1121da177e4SLinus Torvalds 		/* 25 */ "???",
1131da177e4SLinus Torvalds 		/* 26 */ "???",
1141da177e4SLinus Torvalds 		/* 27 */ "???",
1151da177e4SLinus Torvalds 		/* 28 */ "???",
1161da177e4SLinus Torvalds 		/* 29 */ "???",
1171da177e4SLinus Torvalds 		/* 30 */ "???",
1181da177e4SLinus Torvalds 		/* 31 */ "???"
1191da177e4SLinus Torvalds 	};
1201da177e4SLinus Torvalds 
1211da177e4SLinus Torvalds 	static char *audigy_outs[64] = {
1221da177e4SLinus Torvalds 		/* 00 */ "Digital Front Left",
1231da177e4SLinus Torvalds 		/* 01 */ "Digital Front Right",
1241da177e4SLinus Torvalds 		/* 02 */ "Digital Center",
1251da177e4SLinus Torvalds 		/* 03 */ "Digital LEF",
1261da177e4SLinus Torvalds 		/* 04 */ "Headphone Left",
1271da177e4SLinus Torvalds 		/* 05 */ "Headphone Right",
1281da177e4SLinus Torvalds 		/* 06 */ "Digital Rear Left",
1291da177e4SLinus Torvalds 		/* 07 */ "Digital Rear Right",
1301da177e4SLinus Torvalds 		/* 08 */ "Front Left",
1311da177e4SLinus Torvalds 		/* 09 */ "Front Right",
1321da177e4SLinus Torvalds 		/* 10 */ "Center",
1331da177e4SLinus Torvalds 		/* 11 */ "LFE",
1341da177e4SLinus Torvalds 		/* 12 */ "???",
1351da177e4SLinus Torvalds 		/* 13 */ "???",
1361da177e4SLinus Torvalds 		/* 14 */ "Rear Left",
1371da177e4SLinus Torvalds 		/* 15 */ "Rear Right",
1381da177e4SLinus Torvalds 		/* 16 */ "AC97 Front Left",
1391da177e4SLinus Torvalds 		/* 17 */ "AC97 Front Right",
1401da177e4SLinus Torvalds 		/* 18 */ "ADC Caputre Left",
1411da177e4SLinus Torvalds 		/* 19 */ "ADC Capture Right",
1421da177e4SLinus Torvalds 		/* 20 */ "???",
1431da177e4SLinus Torvalds 		/* 21 */ "???",
1441da177e4SLinus Torvalds 		/* 22 */ "???",
1451da177e4SLinus Torvalds 		/* 23 */ "???",
1461da177e4SLinus Torvalds 		/* 24 */ "???",
1471da177e4SLinus Torvalds 		/* 25 */ "???",
1481da177e4SLinus Torvalds 		/* 26 */ "???",
1491da177e4SLinus Torvalds 		/* 27 */ "???",
1501da177e4SLinus Torvalds 		/* 28 */ "???",
1511da177e4SLinus Torvalds 		/* 29 */ "???",
1521da177e4SLinus Torvalds 		/* 30 */ "???",
1531da177e4SLinus Torvalds 		/* 31 */ "???",
1541da177e4SLinus Torvalds 		/* 32 */ "FXBUS2_0",
1551da177e4SLinus Torvalds 		/* 33 */ "FXBUS2_1",
1561da177e4SLinus Torvalds 		/* 34 */ "FXBUS2_2",
1571da177e4SLinus Torvalds 		/* 35 */ "FXBUS2_3",
1581da177e4SLinus Torvalds 		/* 36 */ "FXBUS2_4",
1591da177e4SLinus Torvalds 		/* 37 */ "FXBUS2_5",
1601da177e4SLinus Torvalds 		/* 38 */ "FXBUS2_6",
1611da177e4SLinus Torvalds 		/* 39 */ "FXBUS2_7",
1621da177e4SLinus Torvalds 		/* 40 */ "FXBUS2_8",
1631da177e4SLinus Torvalds 		/* 41 */ "FXBUS2_9",
1641da177e4SLinus Torvalds 		/* 42 */ "FXBUS2_10",
1651da177e4SLinus Torvalds 		/* 43 */ "FXBUS2_11",
1661da177e4SLinus Torvalds 		/* 44 */ "FXBUS2_12",
1671da177e4SLinus Torvalds 		/* 45 */ "FXBUS2_13",
1681da177e4SLinus Torvalds 		/* 46 */ "FXBUS2_14",
1691da177e4SLinus Torvalds 		/* 47 */ "FXBUS2_15",
1701da177e4SLinus Torvalds 		/* 48 */ "FXBUS2_16",
1711da177e4SLinus Torvalds 		/* 49 */ "FXBUS2_17",
1721da177e4SLinus Torvalds 		/* 50 */ "FXBUS2_18",
1731da177e4SLinus Torvalds 		/* 51 */ "FXBUS2_19",
1741da177e4SLinus Torvalds 		/* 52 */ "FXBUS2_20",
1751da177e4SLinus Torvalds 		/* 53 */ "FXBUS2_21",
1761da177e4SLinus Torvalds 		/* 54 */ "FXBUS2_22",
1771da177e4SLinus Torvalds 		/* 55 */ "FXBUS2_23",
1781da177e4SLinus Torvalds 		/* 56 */ "FXBUS2_24",
1791da177e4SLinus Torvalds 		/* 57 */ "FXBUS2_25",
1801da177e4SLinus Torvalds 		/* 58 */ "FXBUS2_26",
1811da177e4SLinus Torvalds 		/* 59 */ "FXBUS2_27",
1821da177e4SLinus Torvalds 		/* 60 */ "FXBUS2_28",
1831da177e4SLinus Torvalds 		/* 61 */ "FXBUS2_29",
1841da177e4SLinus Torvalds 		/* 62 */ "FXBUS2_30",
1851da177e4SLinus Torvalds 		/* 63 */ "FXBUS2_31"
1861da177e4SLinus Torvalds 	};
1871da177e4SLinus Torvalds 
188eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
1891da177e4SLinus Torvalds 	unsigned int val, val1;
1901da177e4SLinus Torvalds 	int nefx = emu->audigy ? 64 : 32;
1911da177e4SLinus Torvalds 	char **outputs = emu->audigy ? audigy_outs : creative_outs;
1921da177e4SLinus Torvalds 	int idx;
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds 	snd_iprintf(buffer, "EMU10K1\n\n");
1951da177e4SLinus Torvalds 	snd_iprintf(buffer, "Card                  : %s\n",
1962b637da5SLee Revell 		    emu->audigy ? "Audigy" : (emu->card_capabilities->ecard ? "EMU APS" : "Creative"));
1971da177e4SLinus Torvalds 	snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
1981da177e4SLinus Torvalds 	snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2);
1991da177e4SLinus Torvalds 	snd_iprintf(buffer, "\n");
2001da177e4SLinus Torvalds 	snd_iprintf(buffer, "Effect Send Routing   :\n");
2011da177e4SLinus Torvalds 	for (idx = 0; idx < NUM_G; idx++) {
2021da177e4SLinus Torvalds 		val = emu->audigy ?
2031da177e4SLinus Torvalds 			snd_emu10k1_ptr_read(emu, A_FXRT1, idx) :
2041da177e4SLinus Torvalds 			snd_emu10k1_ptr_read(emu, FXRT, idx);
2051da177e4SLinus Torvalds 		val1 = emu->audigy ?
2061da177e4SLinus Torvalds 			snd_emu10k1_ptr_read(emu, A_FXRT2, idx) :
2071da177e4SLinus Torvalds 			0;
2081da177e4SLinus Torvalds 		if (emu->audigy) {
2091da177e4SLinus Torvalds 			snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i, ",
2101da177e4SLinus Torvalds 				idx,
2111da177e4SLinus Torvalds 				val & 0x3f,
2121da177e4SLinus Torvalds 				(val >> 8) & 0x3f,
2131da177e4SLinus Torvalds 				(val >> 16) & 0x3f,
2141da177e4SLinus Torvalds 				(val >> 24) & 0x3f);
2151da177e4SLinus Torvalds 			snd_iprintf(buffer, "E=%i, F=%i, G=%i, H=%i\n",
2161da177e4SLinus Torvalds 				val1 & 0x3f,
2171da177e4SLinus Torvalds 				(val1 >> 8) & 0x3f,
2181da177e4SLinus Torvalds 				(val1 >> 16) & 0x3f,
2191da177e4SLinus Torvalds 				(val1 >> 24) & 0x3f);
2201da177e4SLinus Torvalds 		} else {
2211da177e4SLinus Torvalds 			snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i\n",
2221da177e4SLinus Torvalds 				idx,
2231da177e4SLinus Torvalds 				(val >> 16) & 0x0f,
2241da177e4SLinus Torvalds 				(val >> 20) & 0x0f,
2251da177e4SLinus Torvalds 				(val >> 24) & 0x0f,
2261da177e4SLinus Torvalds 				(val >> 28) & 0x0f);
2271da177e4SLinus Torvalds 		}
2281da177e4SLinus Torvalds 	}
2291da177e4SLinus Torvalds 	snd_iprintf(buffer, "\nCaptured FX Outputs   :\n");
2301da177e4SLinus Torvalds 	for (idx = 0; idx < nefx; idx++) {
2311da177e4SLinus Torvalds 		if (emu->efx_voices_mask[idx/32] & (1 << (idx%32)))
2321da177e4SLinus Torvalds 			snd_iprintf(buffer, "  Output %02i [%s]\n", idx, outputs[idx]);
2331da177e4SLinus Torvalds 	}
2341da177e4SLinus Torvalds 	snd_iprintf(buffer, "\nAll FX Outputs        :\n");
2351da177e4SLinus Torvalds 	for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++)
2361da177e4SLinus Torvalds 		snd_iprintf(buffer, "  Output %02i [%s]\n", idx, outputs[idx]);
237df34140aSJames Courtier-Dutton }
238df34140aSJames Courtier-Dutton 
239eb4698f3STakashi Iwai static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry,
240eb4698f3STakashi Iwai 				  struct snd_info_buffer *buffer)
241df34140aSJames Courtier-Dutton {
242eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
243*f93abe51SJames Courtier-Dutton 	u32 value;
244*f93abe51SJames Courtier-Dutton 	u32 value2;
245*f93abe51SJames Courtier-Dutton 	unsigned long flags;
246*f93abe51SJames Courtier-Dutton 	u32 rate;
247*f93abe51SJames Courtier-Dutton 
248*f93abe51SJames Courtier-Dutton 	if (emu->card_capabilities->emu1010) {
249*f93abe51SJames Courtier-Dutton 		spin_lock_irqsave(&emu->emu_lock, flags);
250*f93abe51SJames Courtier-Dutton 		snd_emu1010_fpga_read(emu, 0x38, &value);
251*f93abe51SJames Courtier-Dutton 		spin_unlock_irqrestore(&emu->emu_lock, flags);
252*f93abe51SJames Courtier-Dutton 		if ((value & 0x1) == 0) {
253*f93abe51SJames Courtier-Dutton 			spin_lock_irqsave(&emu->emu_lock, flags);
254*f93abe51SJames Courtier-Dutton 			snd_emu1010_fpga_read(emu, 0x2a, &value);
255*f93abe51SJames Courtier-Dutton 			snd_emu1010_fpga_read(emu, 0x2b, &value2);
256*f93abe51SJames Courtier-Dutton 			spin_unlock_irqrestore(&emu->emu_lock, flags);
257*f93abe51SJames Courtier-Dutton 			rate = 0x1770000 / (((value << 5) | value2)+1);
258*f93abe51SJames Courtier-Dutton 			snd_iprintf(buffer, "ADAT Locked : %u\n", rate);
259*f93abe51SJames Courtier-Dutton 		} else {
260*f93abe51SJames Courtier-Dutton 			snd_iprintf(buffer, "ADAT Unlocked\n");
261*f93abe51SJames Courtier-Dutton 		}
262*f93abe51SJames Courtier-Dutton 		spin_lock_irqsave(&emu->emu_lock, flags);
263*f93abe51SJames Courtier-Dutton 		snd_emu1010_fpga_read(emu, 0x20, &value);
264*f93abe51SJames Courtier-Dutton 		spin_unlock_irqrestore(&emu->emu_lock, flags);
265*f93abe51SJames Courtier-Dutton 		if ((value & 0x4) == 0) {
266*f93abe51SJames Courtier-Dutton 			spin_lock_irqsave(&emu->emu_lock, flags);
267*f93abe51SJames Courtier-Dutton 			snd_emu1010_fpga_read(emu, 0x28, &value);
268*f93abe51SJames Courtier-Dutton 			snd_emu1010_fpga_read(emu, 0x29, &value2);
269*f93abe51SJames Courtier-Dutton 			spin_unlock_irqrestore(&emu->emu_lock, flags);
270*f93abe51SJames Courtier-Dutton 			rate = 0x1770000 / (((value << 5) | value2)+1);
271*f93abe51SJames Courtier-Dutton 			snd_iprintf(buffer, "SPDIF Locked : %d\n", rate);
272*f93abe51SJames Courtier-Dutton 		} else {
273*f93abe51SJames Courtier-Dutton 			snd_iprintf(buffer, "SPDIF Unlocked\n");
274*f93abe51SJames Courtier-Dutton 		}
275*f93abe51SJames Courtier-Dutton 	} else {
276df34140aSJames Courtier-Dutton 		snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
277df34140aSJames Courtier-Dutton 		snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
278*f93abe51SJames Courtier-Dutton 	}
279df34140aSJames Courtier-Dutton #if 0
2801da177e4SLinus Torvalds 	val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
2811da177e4SLinus Torvalds 	snd_iprintf(buffer, "\nZoomed Video\n");
2821da177e4SLinus Torvalds 	snd_iprintf(buffer, "Rate Locked           : %s\n", val & SRCS_RATELOCKED ? "on" : "off");
2831da177e4SLinus Torvalds 	snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
284df34140aSJames Courtier-Dutton #endif
2851da177e4SLinus Torvalds }
2861da177e4SLinus Torvalds 
287eb4698f3STakashi Iwai static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry,
288eb4698f3STakashi Iwai 				  struct snd_info_buffer *buffer)
289001f7589SJames Courtier-Dutton {
290001f7589SJames Courtier-Dutton 	static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
291eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
292001f7589SJames Courtier-Dutton 	unsigned int val, tmp, n;
293001f7589SJames Courtier-Dutton 	val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
294001f7589SJames Courtier-Dutton 	tmp = (val >> 16) & 0x8;
295001f7589SJames Courtier-Dutton 	for (n = 0; n < 4; n++) {
296001f7589SJames Courtier-Dutton 		tmp = val >> (16 + (n*4));
297001f7589SJames Courtier-Dutton 		if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
298001f7589SJames Courtier-Dutton 		else snd_iprintf(buffer, "Channel %d: No input\n", n);
299001f7589SJames Courtier-Dutton 	}
300001f7589SJames Courtier-Dutton }
301001f7589SJames Courtier-Dutton 
302eb4698f3STakashi Iwai static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry,
303eb4698f3STakashi Iwai 				        struct snd_info_buffer *buffer)
3041da177e4SLinus Torvalds {
3051da177e4SLinus Torvalds 	u32 pc;
306eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
3071da177e4SLinus Torvalds 
3081da177e4SLinus Torvalds 	snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
3091da177e4SLinus Torvalds 	snd_iprintf(buffer, "  Code dump      :\n");
3101da177e4SLinus Torvalds 	for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
3111da177e4SLinus Torvalds 		u32 low, high;
3121da177e4SLinus Torvalds 
3131da177e4SLinus Torvalds 		low = snd_emu10k1_efx_read(emu, pc * 2);
3141da177e4SLinus Torvalds 		high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
3151da177e4SLinus Torvalds 		if (emu->audigy)
3161da177e4SLinus Torvalds 			snd_iprintf(buffer, "    OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
3171da177e4SLinus Torvalds 				    (high >> 24) & 0x0f,
3181da177e4SLinus Torvalds 				    (high >> 12) & 0x7ff,
3191da177e4SLinus Torvalds 				    (high >> 0) & 0x7ff,
3201da177e4SLinus Torvalds 				    (low >> 12) & 0x7ff,
3211da177e4SLinus Torvalds 				    (low >> 0) & 0x7ff,
3221da177e4SLinus Torvalds 				    pc,
3231da177e4SLinus Torvalds 				    high, low);
3241da177e4SLinus Torvalds 		else
3251da177e4SLinus Torvalds 			snd_iprintf(buffer, "    OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
3261da177e4SLinus Torvalds 				    (high >> 20) & 0x0f,
3271da177e4SLinus Torvalds 				    (high >> 10) & 0x3ff,
3281da177e4SLinus Torvalds 				    (high >> 0) & 0x3ff,
3291da177e4SLinus Torvalds 				    (low >> 10) & 0x3ff,
3301da177e4SLinus Torvalds 				    (low >> 0) & 0x3ff,
3311da177e4SLinus Torvalds 				    pc,
3321da177e4SLinus Torvalds 				    high, low);
3331da177e4SLinus Torvalds 	}
3341da177e4SLinus Torvalds }
3351da177e4SLinus Torvalds 
3361da177e4SLinus Torvalds #define TOTAL_SIZE_GPR		(0x100*4)
3371da177e4SLinus Torvalds #define A_TOTAL_SIZE_GPR	(0x200*4)
3381da177e4SLinus Torvalds #define TOTAL_SIZE_TANKMEM_DATA	(0xa0*4)
3391da177e4SLinus Torvalds #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
3401da177e4SLinus Torvalds #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
3411da177e4SLinus Torvalds #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
3421da177e4SLinus Torvalds #define TOTAL_SIZE_CODE		(0x200*8)
3431da177e4SLinus Torvalds #define A_TOTAL_SIZE_CODE	(0x400*8)
3441da177e4SLinus Torvalds 
345eb4698f3STakashi Iwai static long snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
346eb4698f3STakashi Iwai 				    void *file_private_data,
3471da177e4SLinus Torvalds 				    struct file *file, char __user *buf,
3481da177e4SLinus Torvalds 				    unsigned long count, unsigned long pos)
3491da177e4SLinus Torvalds {
3501da177e4SLinus Torvalds 	long size;
351eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
3521da177e4SLinus Torvalds 	unsigned int offset;
3531da177e4SLinus Torvalds 	int tram_addr = 0;
3541da177e4SLinus Torvalds 
3551da177e4SLinus Torvalds 	if (!strcmp(entry->name, "fx8010_tram_addr")) {
3561da177e4SLinus Torvalds 		offset = TANKMEMADDRREGBASE;
3571da177e4SLinus Torvalds 		tram_addr = 1;
3581da177e4SLinus Torvalds 	} else if (!strcmp(entry->name, "fx8010_tram_data")) {
3591da177e4SLinus Torvalds 		offset = TANKMEMDATAREGBASE;
3601da177e4SLinus Torvalds 	} else if (!strcmp(entry->name, "fx8010_code")) {
3611da177e4SLinus Torvalds 		offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
3621da177e4SLinus Torvalds 	} else {
3631da177e4SLinus Torvalds 		offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
3641da177e4SLinus Torvalds 	}
3651da177e4SLinus Torvalds 	size = count;
3661da177e4SLinus Torvalds 	if (pos + size > entry->size)
3671da177e4SLinus Torvalds 		size = (long)entry->size - pos;
3681da177e4SLinus Torvalds 	if (size > 0) {
3691da177e4SLinus Torvalds 		unsigned int *tmp;
3701da177e4SLinus Torvalds 		long res;
3711da177e4SLinus Torvalds 		unsigned int idx;
3721da177e4SLinus Torvalds 		if ((tmp = kmalloc(size + 8, GFP_KERNEL)) == NULL)
3731da177e4SLinus Torvalds 			return -ENOMEM;
3741da177e4SLinus Torvalds 		for (idx = 0; idx < ((pos & 3) + size + 3) >> 2; idx++)
3751da177e4SLinus Torvalds 			if (tram_addr && emu->audigy) {
3761da177e4SLinus Torvalds 				tmp[idx] = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0) >> 11;
3771da177e4SLinus Torvalds 				tmp[idx] |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
3781da177e4SLinus Torvalds 			} else
3791da177e4SLinus Torvalds 				tmp[idx] = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
3801da177e4SLinus Torvalds 		if (copy_to_user(buf, ((char *)tmp) + (pos & 3), size))
3811da177e4SLinus Torvalds 			res = -EFAULT;
3821da177e4SLinus Torvalds 		else {
3831da177e4SLinus Torvalds 			res = size;
3841da177e4SLinus Torvalds 		}
3851da177e4SLinus Torvalds 		kfree(tmp);
3861da177e4SLinus Torvalds 		return res;
3871da177e4SLinus Torvalds 	}
3881da177e4SLinus Torvalds 	return 0;
3891da177e4SLinus Torvalds }
3901da177e4SLinus Torvalds 
391eb4698f3STakashi Iwai static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry,
392eb4698f3STakashi Iwai 				  struct snd_info_buffer *buffer)
3931da177e4SLinus Torvalds {
394eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
395eb4698f3STakashi Iwai 	struct snd_emu10k1_voice *voice;
3961da177e4SLinus Torvalds 	int idx;
3971da177e4SLinus Torvalds 
3981da177e4SLinus Torvalds 	snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n");
3991da177e4SLinus Torvalds 	for (idx = 0; idx < NUM_G; idx++) {
4001da177e4SLinus Torvalds 		voice = &emu->voices[idx];
4011da177e4SLinus Torvalds 		snd_iprintf(buffer, "%i\t%i\t%i\t%i\t%i\t%i\n",
4021da177e4SLinus Torvalds 			idx,
4031da177e4SLinus Torvalds 			voice->use,
4041da177e4SLinus Torvalds 			voice->pcm,
4051da177e4SLinus Torvalds 			voice->efx,
4061da177e4SLinus Torvalds 			voice->synth,
4071da177e4SLinus Torvalds 			voice->midi);
4081da177e4SLinus Torvalds 	}
4091da177e4SLinus Torvalds }
4101da177e4SLinus Torvalds 
4111da177e4SLinus Torvalds #ifdef CONFIG_SND_DEBUG
4129f4bd5ddSJames Courtier-Dutton static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
4139f4bd5ddSJames Courtier-Dutton 				     struct snd_info_buffer *buffer)
4149f4bd5ddSJames Courtier-Dutton {
4159f4bd5ddSJames Courtier-Dutton 	struct snd_emu10k1 *emu = entry->private_data;
416*f93abe51SJames Courtier-Dutton 	int value;
4179f4bd5ddSJames Courtier-Dutton 	unsigned long flags;
4189f4bd5ddSJames Courtier-Dutton 	int i;
4199f4bd5ddSJames Courtier-Dutton 	snd_iprintf(buffer, "EMU1010 Registers:\n\n");
4209f4bd5ddSJames Courtier-Dutton 
42190fd5ce5SJames Courtier-Dutton 	for(i = 0; i < 0x40; i+=1) {
4229f4bd5ddSJames Courtier-Dutton 		spin_lock_irqsave(&emu->emu_lock, flags);
423*f93abe51SJames Courtier-Dutton 		snd_emu1010_fpga_read(emu, i, &value);
4249f4bd5ddSJames Courtier-Dutton 		spin_unlock_irqrestore(&emu->emu_lock, flags);
425*f93abe51SJames Courtier-Dutton 		snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
4269f4bd5ddSJames Courtier-Dutton 	}
4279f4bd5ddSJames Courtier-Dutton }
4289f4bd5ddSJames Courtier-Dutton 
429eb4698f3STakashi Iwai static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
430eb4698f3STakashi Iwai 				     struct snd_info_buffer *buffer)
4311da177e4SLinus Torvalds {
432eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
4331da177e4SLinus Torvalds 	unsigned long value;
4341da177e4SLinus Torvalds 	unsigned long flags;
4351da177e4SLinus Torvalds 	int i;
4361da177e4SLinus Torvalds 	snd_iprintf(buffer, "IO Registers:\n\n");
4371da177e4SLinus Torvalds 	for(i = 0; i < 0x40; i+=4) {
4381da177e4SLinus Torvalds 		spin_lock_irqsave(&emu->emu_lock, flags);
4391da177e4SLinus Torvalds 		value = inl(emu->port + i);
4401da177e4SLinus Torvalds 		spin_unlock_irqrestore(&emu->emu_lock, flags);
4411da177e4SLinus Torvalds 		snd_iprintf(buffer, "%02X: %08lX\n", i, value);
4421da177e4SLinus Torvalds 	}
4431da177e4SLinus Torvalds }
4441da177e4SLinus Torvalds 
445eb4698f3STakashi Iwai static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
446eb4698f3STakashi Iwai                                       struct snd_info_buffer *buffer)
4471da177e4SLinus Torvalds {
448eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
4491da177e4SLinus Torvalds 	unsigned long flags;
4501da177e4SLinus Torvalds 	char line[64];
4511da177e4SLinus Torvalds 	u32 reg, val;
4521da177e4SLinus Torvalds 	while (!snd_info_get_line(buffer, line, sizeof(line))) {
4531da177e4SLinus Torvalds 		if (sscanf(line, "%x %x", &reg, &val) != 2)
4541da177e4SLinus Torvalds 			continue;
4551da177e4SLinus Torvalds 		if ((reg < 0x40) && (reg >= 0) && (val <= 0xffffffff) ) {
4561da177e4SLinus Torvalds 			spin_lock_irqsave(&emu->emu_lock, flags);
4571da177e4SLinus Torvalds 			outl(val, emu->port + (reg & 0xfffffffc));
4581da177e4SLinus Torvalds 			spin_unlock_irqrestore(&emu->emu_lock, flags);
4591da177e4SLinus Torvalds 		}
4601da177e4SLinus Torvalds 	}
4611da177e4SLinus Torvalds }
4621da177e4SLinus Torvalds 
463eb4698f3STakashi Iwai static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
4641da177e4SLinus Torvalds 				 unsigned int iobase,
4651da177e4SLinus Torvalds 				 unsigned int reg,
4661da177e4SLinus Torvalds 				 unsigned int chn)
4671da177e4SLinus Torvalds {
4681da177e4SLinus Torvalds 	unsigned long flags;
4691da177e4SLinus Torvalds 	unsigned int regptr, val;
4701da177e4SLinus Torvalds 
4711da177e4SLinus Torvalds 	regptr = (reg << 16) | chn;
4721da177e4SLinus Torvalds 
4731da177e4SLinus Torvalds 	spin_lock_irqsave(&emu->emu_lock, flags);
4741da177e4SLinus Torvalds 	outl(regptr, emu->port + iobase + PTR);
4751da177e4SLinus Torvalds 	val = inl(emu->port + iobase + DATA);
4761da177e4SLinus Torvalds 	spin_unlock_irqrestore(&emu->emu_lock, flags);
4771da177e4SLinus Torvalds 	return val;
4781da177e4SLinus Torvalds }
4791da177e4SLinus Torvalds 
480eb4698f3STakashi Iwai static void snd_ptr_write(struct snd_emu10k1 *emu,
4811da177e4SLinus Torvalds 			  unsigned int iobase,
4821da177e4SLinus Torvalds 			  unsigned int reg,
4831da177e4SLinus Torvalds 			  unsigned int chn,
4841da177e4SLinus Torvalds 			  unsigned int data)
4851da177e4SLinus Torvalds {
4861da177e4SLinus Torvalds 	unsigned int regptr;
4871da177e4SLinus Torvalds 	unsigned long flags;
4881da177e4SLinus Torvalds 
4891da177e4SLinus Torvalds 	regptr = (reg << 16) | chn;
4901da177e4SLinus Torvalds 
4911da177e4SLinus Torvalds 	spin_lock_irqsave(&emu->emu_lock, flags);
4921da177e4SLinus Torvalds 	outl(regptr, emu->port + iobase + PTR);
4931da177e4SLinus Torvalds 	outl(data, emu->port + iobase + DATA);
4941da177e4SLinus Torvalds 	spin_unlock_irqrestore(&emu->emu_lock, flags);
4951da177e4SLinus Torvalds }
4961da177e4SLinus Torvalds 
4971da177e4SLinus Torvalds 
498eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
499eb4698f3STakashi Iwai 				      struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
5001da177e4SLinus Torvalds {
501eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
5021da177e4SLinus Torvalds 	unsigned long value;
5031da177e4SLinus Torvalds 	int i,j;
5046ef7e861SJames Courtier-Dutton 	if (offset+length > 0xa0) {
5051da177e4SLinus Torvalds 		snd_iprintf(buffer, "Input values out of range\n");
5061da177e4SLinus Torvalds 		return;
5071da177e4SLinus Torvalds 	}
5081da177e4SLinus Torvalds 	snd_iprintf(buffer, "Registers 0x%x\n", iobase);
5091da177e4SLinus Torvalds 	for(i = offset; i < offset+length; i++) {
5101da177e4SLinus Torvalds 		snd_iprintf(buffer, "%02X: ",i);
5111da177e4SLinus Torvalds 		for (j = 0; j < voices; j++) {
5121da177e4SLinus Torvalds 			if(iobase == 0)
5131da177e4SLinus Torvalds                 		value = snd_ptr_read(emu, 0, i, j);
5141da177e4SLinus Torvalds 			else
5151da177e4SLinus Torvalds                 		value = snd_ptr_read(emu, 0x20, i, j);
5161da177e4SLinus Torvalds 			snd_iprintf(buffer, "%08lX ", value);
5171da177e4SLinus Torvalds 		}
5181da177e4SLinus Torvalds 		snd_iprintf(buffer, "\n");
5191da177e4SLinus Torvalds 	}
5201da177e4SLinus Torvalds }
5211da177e4SLinus Torvalds 
522eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
523eb4698f3STakashi Iwai 				       struct snd_info_buffer *buffer, int iobase)
5241da177e4SLinus Torvalds {
525eb4698f3STakashi Iwai 	struct snd_emu10k1 *emu = entry->private_data;
5261da177e4SLinus Torvalds 	char line[64];
5271da177e4SLinus Torvalds 	unsigned int reg, channel_id , val;
5281da177e4SLinus Torvalds 	while (!snd_info_get_line(buffer, line, sizeof(line))) {
5291da177e4SLinus Torvalds 		if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
5301da177e4SLinus Torvalds 			continue;
5316ef7e861SJames Courtier-Dutton 		if ((reg < 0xa0) && (reg >= 0) && (val <= 0xffffffff) && (channel_id >= 0) && (channel_id <= 3) )
5321da177e4SLinus Torvalds 			snd_ptr_write(emu, iobase, reg, channel_id, val);
5331da177e4SLinus Torvalds 	}
5341da177e4SLinus Torvalds }
5351da177e4SLinus Torvalds 
536eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
537eb4698f3STakashi Iwai 					 struct snd_info_buffer *buffer)
5381da177e4SLinus Torvalds {
5391da177e4SLinus Torvalds 	snd_emu_proc_ptr_reg_write(entry, buffer, 0);
5401da177e4SLinus Torvalds }
5411da177e4SLinus Torvalds 
542eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
543eb4698f3STakashi Iwai 					 struct snd_info_buffer *buffer)
5441da177e4SLinus Torvalds {
5451da177e4SLinus Torvalds 	snd_emu_proc_ptr_reg_write(entry, buffer, 0x20);
5461da177e4SLinus Torvalds }
5471da177e4SLinus Torvalds 
5481da177e4SLinus Torvalds 
549eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
550eb4698f3STakashi Iwai 					 struct snd_info_buffer *buffer)
5511da177e4SLinus Torvalds {
5521da177e4SLinus Torvalds 	snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
5531da177e4SLinus Torvalds }
5541da177e4SLinus Torvalds 
555eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
556eb4698f3STakashi Iwai 					 struct snd_info_buffer *buffer)
5571da177e4SLinus Torvalds {
5581da177e4SLinus Torvalds 	snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
5591da177e4SLinus Torvalds }
5601da177e4SLinus Torvalds 
561eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
562eb4698f3STakashi Iwai 					 struct snd_info_buffer *buffer)
5631da177e4SLinus Torvalds {
5641da177e4SLinus Torvalds 	snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
5651da177e4SLinus Torvalds }
5661da177e4SLinus Torvalds 
567eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
568eb4698f3STakashi Iwai 					 struct snd_info_buffer *buffer)
5691da177e4SLinus Torvalds {
5701da177e4SLinus Torvalds 	snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
5711da177e4SLinus Torvalds }
5726ef7e861SJames Courtier-Dutton 
573eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
574eb4698f3STakashi Iwai 					 struct snd_info_buffer * buffer)
5756ef7e861SJames Courtier-Dutton {
5766ef7e861SJames Courtier-Dutton 	snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
5776ef7e861SJames Courtier-Dutton }
5781da177e4SLinus Torvalds #endif
5791da177e4SLinus Torvalds 
5801da177e4SLinus Torvalds static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
5811da177e4SLinus Torvalds 	.read = snd_emu10k1_fx8010_read,
5821da177e4SLinus Torvalds };
5831da177e4SLinus Torvalds 
584eb4698f3STakashi Iwai int __devinit snd_emu10k1_proc_init(struct snd_emu10k1 * emu)
5851da177e4SLinus Torvalds {
586eb4698f3STakashi Iwai 	struct snd_info_entry *entry;
5871da177e4SLinus Torvalds #ifdef CONFIG_SND_DEBUG
58890fd5ce5SJames Courtier-Dutton 	if (emu->card_capabilities->emu1010) {
58990fd5ce5SJames Courtier-Dutton 		if (! snd_card_proc_new(emu->card, "emu1010_regs", &entry))
5909f4bd5ddSJames Courtier-Dutton 			snd_info_set_text_ops(entry, emu, snd_emu_proc_emu1010_reg_read);
5919f4bd5ddSJames Courtier-Dutton 	}
5921da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "io_regs", &entry)) {
593bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu_proc_io_reg_read);
5941da177e4SLinus Torvalds 		entry->c.text.write = snd_emu_proc_io_reg_write;
595bd7bf042STakashi Iwai 		entry->mode |= S_IWUSR;
5961da177e4SLinus Torvalds 	}
5971da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) {
598bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00a);
5991da177e4SLinus Torvalds 		entry->c.text.write = snd_emu_proc_ptr_reg_write00;
600bd7bf042STakashi Iwai 		entry->mode |= S_IWUSR;
6011da177e4SLinus Torvalds 	}
6021da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) {
603bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read00b);
6041da177e4SLinus Torvalds 		entry->c.text.write = snd_emu_proc_ptr_reg_write00;
605bd7bf042STakashi Iwai 		entry->mode |= S_IWUSR;
6061da177e4SLinus Torvalds 	}
6071da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) {
608bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20a);
6091da177e4SLinus Torvalds 		entry->c.text.write = snd_emu_proc_ptr_reg_write20;
610bd7bf042STakashi Iwai 		entry->mode |= S_IWUSR;
6111da177e4SLinus Torvalds 	}
6121da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) {
613bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20b);
6141da177e4SLinus Torvalds 		entry->c.text.write = snd_emu_proc_ptr_reg_write20;
615bd7bf042STakashi Iwai 		entry->mode |= S_IWUSR;
6161da177e4SLinus Torvalds 	}
6176ef7e861SJames Courtier-Dutton 	if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) {
618bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu_proc_ptr_reg_read20c);
6196ef7e861SJames Courtier-Dutton 		entry->c.text.write = snd_emu_proc_ptr_reg_write20;
6206ef7e861SJames Courtier-Dutton 		entry->mode |= S_IWUSR;
6216ef7e861SJames Courtier-Dutton 	}
6221da177e4SLinus Torvalds #endif
6231da177e4SLinus Torvalds 
6241da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "emu10k1", &entry))
625bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_read);
6261da177e4SLinus Torvalds 
627df34140aSJames Courtier-Dutton 	if (emu->card_capabilities->emu10k2_chip) {
628df34140aSJames Courtier-Dutton 		if (! snd_card_proc_new(emu->card, "spdif-in", &entry))
629bf850204STakashi Iwai 			snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_spdif_read);
630df34140aSJames Courtier-Dutton 	}
631001f7589SJames Courtier-Dutton 	if (emu->card_capabilities->ca0151_chip) {
632001f7589SJames Courtier-Dutton 		if (! snd_card_proc_new(emu->card, "capture-rates", &entry))
633bf850204STakashi Iwai 			snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_rates_read);
634001f7589SJames Courtier-Dutton 	}
635df34140aSJames Courtier-Dutton 
6361da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "voices", &entry))
637bf850204STakashi Iwai 		snd_info_set_text_ops(entry, emu, snd_emu10k1_proc_voices_read);
6381da177e4SLinus Torvalds 
6391da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
6401da177e4SLinus Torvalds 		entry->content = SNDRV_INFO_CONTENT_DATA;
6411da177e4SLinus Torvalds 		entry->private_data = emu;
6421da177e4SLinus Torvalds 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
6431da177e4SLinus Torvalds 		entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
6441da177e4SLinus Torvalds 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
6451da177e4SLinus Torvalds 	}
6461da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
6471da177e4SLinus Torvalds 		entry->content = SNDRV_INFO_CONTENT_DATA;
6481da177e4SLinus Torvalds 		entry->private_data = emu;
6491da177e4SLinus Torvalds 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
6501da177e4SLinus Torvalds 		entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
6511da177e4SLinus Torvalds 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
6521da177e4SLinus Torvalds 	}
6531da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
6541da177e4SLinus Torvalds 		entry->content = SNDRV_INFO_CONTENT_DATA;
6551da177e4SLinus Torvalds 		entry->private_data = emu;
6561da177e4SLinus Torvalds 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
6571da177e4SLinus Torvalds 		entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
6581da177e4SLinus Torvalds 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
6591da177e4SLinus Torvalds 	}
6601da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
6611da177e4SLinus Torvalds 		entry->content = SNDRV_INFO_CONTENT_DATA;
6621da177e4SLinus Torvalds 		entry->private_data = emu;
6631da177e4SLinus Torvalds 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
6641da177e4SLinus Torvalds 		entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
6651da177e4SLinus Torvalds 		entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
6661da177e4SLinus Torvalds 	}
6671da177e4SLinus Torvalds 	if (! snd_card_proc_new(emu->card, "fx8010_acode", &entry)) {
6681da177e4SLinus Torvalds 		entry->content = SNDRV_INFO_CONTENT_TEXT;
6691da177e4SLinus Torvalds 		entry->private_data = emu;
6701da177e4SLinus Torvalds 		entry->mode = S_IFREG | S_IRUGO /*| S_IWUSR*/;
6711da177e4SLinus Torvalds 		entry->c.text.read = snd_emu10k1_proc_acode_read;
6721da177e4SLinus Torvalds 	}
6731da177e4SLinus Torvalds 	return 0;
6741da177e4SLinus Torvalds }
675adf1b3d2STakashi Iwai #endif /* CONFIG_PROC_FS */
676