11a59d1b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 21da177e4SLinus Torvalds /* 3c1017a4cSJaroslav Kysela * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 41da177e4SLinus Torvalds * Creative Labs, Inc. 51da177e4SLinus Torvalds * Routines for control of EMU10K1 chips / proc interface routines 61da177e4SLinus Torvalds * 79f4bd5ddSJames Courtier-Dutton * Copyright (c) by James Courtier-Dutton <James@superbug.co.uk> 89f4bd5ddSJames Courtier-Dutton * Added EMU 1010 support. 99f4bd5ddSJames Courtier-Dutton * 101da177e4SLinus Torvalds * BUGS: 111da177e4SLinus Torvalds * -- 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * TODO: 141da177e4SLinus Torvalds * -- 151da177e4SLinus Torvalds */ 161da177e4SLinus Torvalds 171da177e4SLinus Torvalds #include <linux/slab.h> 181da177e4SLinus Torvalds #include <linux/init.h> 191da177e4SLinus Torvalds #include <sound/core.h> 201da177e4SLinus Torvalds #include <sound/emu10k1.h> 21001f7589SJames Courtier-Dutton #include "p16v.h" 221da177e4SLinus Torvalds 23eb4698f3STakashi Iwai static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, 24eb4698f3STakashi Iwai struct snd_info_buffer *buffer, 251da177e4SLinus Torvalds char *title, 261da177e4SLinus Torvalds int status_reg, 271da177e4SLinus Torvalds int rate_reg) 281da177e4SLinus Torvalds { 296fddce26STakashi Iwai static const char * const clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" }; 306fddce26STakashi Iwai static const int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; 316fddce26STakashi Iwai static const char * const channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; 326fddce26STakashi Iwai static const char * const emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" }; 331da177e4SLinus Torvalds unsigned int status, rate = 0; 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds status = snd_emu10k1_ptr_read(emu, status_reg, 0); 361da177e4SLinus Torvalds 371da177e4SLinus Torvalds snd_iprintf(buffer, "\n%s\n", title); 381da177e4SLinus Torvalds 39df34140aSJames Courtier-Dutton if (status != 0xffffffff) { 401da177e4SLinus Torvalds snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no"); 411da177e4SLinus Torvalds snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no"); 421da177e4SLinus Torvalds snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no"); 431da177e4SLinus Torvalds snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]); 441da177e4SLinus Torvalds snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6); 451da177e4SLinus Torvalds snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8); 461da177e4SLinus Torvalds snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy"); 471da177e4SLinus Torvalds snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16); 481da177e4SLinus Torvalds snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]); 491da177e4SLinus Torvalds snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]); 501da177e4SLinus Torvalds snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]); 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds if (rate_reg > 0) { 53df34140aSJames Courtier-Dutton rate = snd_emu10k1_ptr_read(emu, rate_reg, 0); 54001f7589SJames Courtier-Dutton snd_iprintf(buffer, "S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off"); 551da177e4SLinus Torvalds snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off"); 561da177e4SLinus Torvalds snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off"); 57df34140aSJames Courtier-Dutton /* From ((Rate * 48000 ) / 262144); */ 58df34140aSJames Courtier-Dutton snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11); 591da177e4SLinus Torvalds } 60df34140aSJames Courtier-Dutton } else { 61df34140aSJames Courtier-Dutton snd_iprintf(buffer, "No signal detected.\n"); 62df34140aSJames Courtier-Dutton } 63df34140aSJames Courtier-Dutton 641da177e4SLinus Torvalds } 651da177e4SLinus Torvalds 66eb4698f3STakashi Iwai static void snd_emu10k1_proc_read(struct snd_info_entry *entry, 67eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 681da177e4SLinus Torvalds { 69eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 70db987421SOswald Buddenhagen const char * const *inputs = emu->audigy ? 71db987421SOswald Buddenhagen snd_emu10k1_audigy_ins : snd_emu10k1_sblive_ins; 72db987421SOswald Buddenhagen const char * const *outputs = emu->audigy ? 73db987421SOswald Buddenhagen snd_emu10k1_audigy_outs : snd_emu10k1_sblive_outs; 74db987421SOswald Buddenhagen unsigned short extin_mask = emu->audigy ? ~0 : emu->fx8010.extin_mask; 75db987421SOswald Buddenhagen unsigned short extout_mask = emu->audigy ? ~0 : emu->fx8010.extout_mask; 76ad326d4aSOswald Buddenhagen unsigned int val, val1, ptrx, psst, dsl, snda; 77db987421SOswald Buddenhagen int nefx = emu->audigy ? 32 : 16; 781da177e4SLinus Torvalds int idx; 791da177e4SLinus Torvalds 801da177e4SLinus Torvalds snd_iprintf(buffer, "EMU10K1\n\n"); 811da177e4SLinus Torvalds snd_iprintf(buffer, "Card : %s\n", 82db987421SOswald Buddenhagen emu->card_capabilities->emu_model ? "E-MU D.A.S." : 83db987421SOswald Buddenhagen emu->card_capabilities->ecard ? "E-MU A.P.S." : 84db987421SOswald Buddenhagen emu->audigy ? "SB Audigy" : "SB Live!"); 851da177e4SLinus Torvalds snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size); 861da177e4SLinus Torvalds snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2); 87ad326d4aSOswald Buddenhagen 88ad326d4aSOswald Buddenhagen snd_iprintf(buffer, "\nEffect Send Routing & Amounts:\n"); 891da177e4SLinus Torvalds for (idx = 0; idx < NUM_G; idx++) { 90ad326d4aSOswald Buddenhagen ptrx = snd_emu10k1_ptr_read(emu, PTRX, idx); 91ad326d4aSOswald Buddenhagen psst = snd_emu10k1_ptr_read(emu, PSST, idx); 92ad326d4aSOswald Buddenhagen dsl = snd_emu10k1_ptr_read(emu, DSL, idx); 931da177e4SLinus Torvalds if (emu->audigy) { 94ad326d4aSOswald Buddenhagen val = snd_emu10k1_ptr_read(emu, A_FXRT1, idx); 95ad326d4aSOswald Buddenhagen val1 = snd_emu10k1_ptr_read(emu, A_FXRT2, idx); 96ad326d4aSOswald Buddenhagen snda = snd_emu10k1_ptr_read(emu, A_SENDAMOUNTS, idx); 97ad326d4aSOswald Buddenhagen snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x, ", 981da177e4SLinus Torvalds idx, 99ad326d4aSOswald Buddenhagen val & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx), 100ad326d4aSOswald Buddenhagen (val >> 8) & 0x3f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx), 101ad326d4aSOswald Buddenhagen (val >> 16) & 0x3f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst), 102ad326d4aSOswald Buddenhagen (val >> 24) & 0x3f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl)); 103ad326d4aSOswald Buddenhagen snd_iprintf(buffer, "E=%2i:%02x, F=%2i:%02x, G=%2i:%02x, H=%2i:%02x\n", 104ad326d4aSOswald Buddenhagen val1 & 0x3f, (snda >> 24) & 0xff, 105ad326d4aSOswald Buddenhagen (val1 >> 8) & 0x3f, (snda >> 16) & 0xff, 106ad326d4aSOswald Buddenhagen (val1 >> 16) & 0x3f, (snda >> 8) & 0xff, 107ad326d4aSOswald Buddenhagen (val1 >> 24) & 0x3f, snda & 0xff); 1081da177e4SLinus Torvalds } else { 109ad326d4aSOswald Buddenhagen val = snd_emu10k1_ptr_read(emu, FXRT, idx); 110ad326d4aSOswald Buddenhagen snd_iprintf(buffer, "Ch%-2i: A=%2i:%02x, B=%2i:%02x, C=%2i:%02x, D=%2i:%02x\n", 1111da177e4SLinus Torvalds idx, 112ad326d4aSOswald Buddenhagen (val >> 16) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_A, ptrx), 113ad326d4aSOswald Buddenhagen (val >> 20) & 0x0f, REG_VAL_GET(PTRX_FXSENDAMOUNT_B, ptrx), 114ad326d4aSOswald Buddenhagen (val >> 24) & 0x0f, REG_VAL_GET(PSST_FXSENDAMOUNT_C, psst), 115ad326d4aSOswald Buddenhagen (val >> 28) & 0x0f, REG_VAL_GET(DSL_FXSENDAMOUNT_D, dsl)); 1161da177e4SLinus Torvalds } 1171da177e4SLinus Torvalds } 118db987421SOswald Buddenhagen snd_iprintf(buffer, "\nEffect Send Targets:\n"); 119db987421SOswald Buddenhagen // Audigy actually has 64, but we don't use them all. 120db987421SOswald Buddenhagen for (idx = 0; idx < 32; idx++) { 121db987421SOswald Buddenhagen const char *c = snd_emu10k1_fxbus[idx]; 122db987421SOswald Buddenhagen if (c) 123db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [%s]\n", idx, c); 1241da177e4SLinus Torvalds } 125db987421SOswald Buddenhagen if (!emu->card_capabilities->emu_model) { 126db987421SOswald Buddenhagen snd_iprintf(buffer, "\nOutput Channels:\n"); 127db987421SOswald Buddenhagen for (idx = 0; idx < 32; idx++) 128db987421SOswald Buddenhagen if (outputs[idx] && (extout_mask & (1 << idx))) 129db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [%s]\n", idx, outputs[idx]); 130db987421SOswald Buddenhagen snd_iprintf(buffer, "\nInput Channels:\n"); 131db987421SOswald Buddenhagen for (idx = 0; idx < 16; idx++) 132db987421SOswald Buddenhagen if (inputs[idx] && (extin_mask & (1 << idx))) 133db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [%s]\n", idx, inputs[idx]); 134db987421SOswald Buddenhagen snd_iprintf(buffer, "\nMultichannel Capture Sources:\n"); 135db987421SOswald Buddenhagen for (idx = 0; idx < nefx; idx++) 136db987421SOswald Buddenhagen if (emu->efx_voices_mask[0] & (1 << idx)) 137db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [Output: %s]\n", 138db987421SOswald Buddenhagen idx, outputs[idx] ? outputs[idx] : "???"); 139db987421SOswald Buddenhagen if (emu->audigy) { 140db987421SOswald Buddenhagen for (idx = 0; idx < 32; idx++) 141db987421SOswald Buddenhagen if (emu->efx_voices_mask[1] & (1 << idx)) 142db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [Input: %s]\n", 143db987421SOswald Buddenhagen idx + 32, inputs[idx] ? inputs[idx] : "???"); 144db987421SOswald Buddenhagen } else { 145db987421SOswald Buddenhagen for (idx = 0; idx < 16; idx++) { 146db987421SOswald Buddenhagen if (emu->efx_voices_mask[0] & ((1 << 16) << idx)) { 147db987421SOswald Buddenhagen if (emu->card_capabilities->sblive51) { 148db987421SOswald Buddenhagen s8 c = snd_emu10k1_sblive51_fxbus2_map[idx]; 149db987421SOswald Buddenhagen if (c == -1) 150db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [Output: %s]\n", 151db987421SOswald Buddenhagen idx + 16, outputs[idx + 16]); 152db987421SOswald Buddenhagen else 153db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [Input: %s]\n", 154db987421SOswald Buddenhagen idx + 16, inputs[c]); 155db987421SOswald Buddenhagen } else { 156db987421SOswald Buddenhagen snd_iprintf(buffer, " Channel %02i [Input: %s]\n", 157db987421SOswald Buddenhagen idx + 16, inputs[idx] ? inputs[idx] : "???"); 158db987421SOswald Buddenhagen } 159db987421SOswald Buddenhagen } 160db987421SOswald Buddenhagen } 161db987421SOswald Buddenhagen } 162db987421SOswald Buddenhagen } 163df34140aSJames Courtier-Dutton } 164df34140aSJames Courtier-Dutton 165eb4698f3STakashi Iwai static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, 166eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 167df34140aSJames Courtier-Dutton { 168eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 169f93abe51SJames Courtier-Dutton u32 value; 170f93abe51SJames Courtier-Dutton u32 value2; 171f93abe51SJames Courtier-Dutton 172190d2c46SJames Courtier-Dutton if (emu->card_capabilities->emu_model) { 173e73b597eSOswald Buddenhagen // This represents the S/PDIF lock status on 0404b, which is 174e73b597eSOswald Buddenhagen // kinda weird and unhelpful, because monitoring it via IRQ is 175e73b597eSOswald Buddenhagen // impractical (one gets an IRQ flood as long as it is desynced). 176e73b597eSOswald Buddenhagen snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &value); 177e73b597eSOswald Buddenhagen snd_iprintf(buffer, "Lock status 1: %#x\n", value & 0x10); 178e73b597eSOswald Buddenhagen 179e73b597eSOswald Buddenhagen // Bit 0x1 in LO being 0 is supposedly for ADAT lock. 180e73b597eSOswald Buddenhagen // The registers are always all zero on 0404b. 181e73b597eSOswald Buddenhagen snd_emu1010_fpga_read(emu, EMU_HANA_LOCK_STS_LO, &value); 182e73b597eSOswald Buddenhagen snd_emu1010_fpga_read(emu, EMU_HANA_LOCK_STS_HI, &value2); 183e73b597eSOswald Buddenhagen snd_iprintf(buffer, "Lock status 2: %#x %#x\n", value, value2); 184e73b597eSOswald Buddenhagen 185e73b597eSOswald Buddenhagen snd_iprintf(buffer, "S/PDIF rate: %dHz\n", 186e73b597eSOswald Buddenhagen snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_HANA_SPDIF_IN)); 187e73b597eSOswald Buddenhagen if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) { 188e73b597eSOswald Buddenhagen snd_iprintf(buffer, "ADAT rate: %dHz\n", 189e73b597eSOswald Buddenhagen snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_HANA_ADAT_IN)); 190e73b597eSOswald Buddenhagen snd_iprintf(buffer, "Dock rate: %dHz\n", 191e73b597eSOswald Buddenhagen snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_2ND_HANA)); 192f93abe51SJames Courtier-Dutton } 193e73b597eSOswald Buddenhagen if (emu->card_capabilities->emu_model == EMU_MODEL_EMU0404 || 194e73b597eSOswald Buddenhagen emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) 195e73b597eSOswald Buddenhagen snd_iprintf(buffer, "BNC rate: %dHz\n", 196e73b597eSOswald Buddenhagen snd_emu1010_get_raw_rate(emu, EMU_HANA_WCLOCK_SYNC_BNC)); 197*58cc6133SOswald Buddenhagen 198*58cc6133SOswald Buddenhagen snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &value); 199*58cc6133SOswald Buddenhagen if (value & EMU_HANA_SPDIF_MODE_RX_INVALID) 200*58cc6133SOswald Buddenhagen snd_iprintf(buffer, "\nS/PDIF input invalid\n"); 201*58cc6133SOswald Buddenhagen else 202*58cc6133SOswald Buddenhagen snd_iprintf(buffer, "\nS/PDIF mode: %s%s\n", 203*58cc6133SOswald Buddenhagen value & EMU_HANA_SPDIF_MODE_RX_PRO ? "professional" : "consumer", 204*58cc6133SOswald Buddenhagen value & EMU_HANA_SPDIF_MODE_RX_NOCOPY ? ", no copy" : ""); 205f93abe51SJames Courtier-Dutton } else { 206df34140aSJames Courtier-Dutton snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS); 207df34140aSJames Courtier-Dutton snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS); 208f93abe51SJames Courtier-Dutton } 209df34140aSJames Courtier-Dutton #if 0 2101da177e4SLinus Torvalds val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0); 2111da177e4SLinus Torvalds snd_iprintf(buffer, "\nZoomed Video\n"); 2121da177e4SLinus Torvalds snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off"); 2131da177e4SLinus Torvalds snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE); 214df34140aSJames Courtier-Dutton #endif 2151da177e4SLinus Torvalds } 2161da177e4SLinus Torvalds 217eb4698f3STakashi Iwai static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry, 218eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 219001f7589SJames Courtier-Dutton { 2206fddce26STakashi Iwai static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; 221eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 222001f7589SJames Courtier-Dutton unsigned int val, tmp, n; 223001f7589SJames Courtier-Dutton val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); 224001f7589SJames Courtier-Dutton for (n = 0; n < 4; n++) { 225001f7589SJames Courtier-Dutton tmp = val >> (16 + (n*4)); 226001f7589SJames Courtier-Dutton if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]); 227001f7589SJames Courtier-Dutton else snd_iprintf(buffer, "Channel %d: No input\n", n); 228001f7589SJames Courtier-Dutton } 229001f7589SJames Courtier-Dutton } 230001f7589SJames Courtier-Dutton 2316e91a93dSOswald Buddenhagen struct emu10k1_reg_entry { 2326e91a93dSOswald Buddenhagen unsigned short base, size; 2336e91a93dSOswald Buddenhagen const char *name; 2346e91a93dSOswald Buddenhagen }; 2356e91a93dSOswald Buddenhagen 2366e91a93dSOswald Buddenhagen static const struct emu10k1_reg_entry sblive_reg_entries[] = { 2376e91a93dSOswald Buddenhagen { 0, 0x10, "FXBUS" }, 2386e91a93dSOswald Buddenhagen { 0x10, 0x10, "EXTIN" }, 2396e91a93dSOswald Buddenhagen { 0x20, 0x10, "EXTOUT" }, 2406e91a93dSOswald Buddenhagen { 0x30, 0x10, "FXBUS2" }, 2416e91a93dSOswald Buddenhagen { 0x40, 0x20, NULL }, // Constants 2426e91a93dSOswald Buddenhagen { 0x100, 0x100, "GPR" }, 2436e91a93dSOswald Buddenhagen { 0x200, 0x80, "ITRAM_DATA" }, 2446e91a93dSOswald Buddenhagen { 0x280, 0x20, "ETRAM_DATA" }, 2456e91a93dSOswald Buddenhagen { 0x300, 0x80, "ITRAM_ADDR" }, 2466e91a93dSOswald Buddenhagen { 0x380, 0x20, "ETRAM_ADDR" }, 2476e91a93dSOswald Buddenhagen { 0x400, 0, NULL } 2486e91a93dSOswald Buddenhagen }; 2496e91a93dSOswald Buddenhagen 2506e91a93dSOswald Buddenhagen static const struct emu10k1_reg_entry audigy_reg_entries[] = { 2516e91a93dSOswald Buddenhagen { 0, 0x40, "FXBUS" }, 2526e91a93dSOswald Buddenhagen { 0x40, 0x10, "EXTIN" }, 2536e91a93dSOswald Buddenhagen { 0x50, 0x10, "P16VIN" }, 2546e91a93dSOswald Buddenhagen { 0x60, 0x20, "EXTOUT" }, 2556e91a93dSOswald Buddenhagen { 0x80, 0x20, "FXBUS2" }, 2566e91a93dSOswald Buddenhagen { 0xa0, 0x10, "EMU32OUTH" }, 2576e91a93dSOswald Buddenhagen { 0xb0, 0x10, "EMU32OUTL" }, 2586e91a93dSOswald Buddenhagen { 0xc0, 0x20, NULL }, // Constants 2596e91a93dSOswald Buddenhagen // This can't be quite right - overlap. 2606e91a93dSOswald Buddenhagen //{ 0x100, 0xc0, "ITRAM_CTL" }, 2616e91a93dSOswald Buddenhagen //{ 0x1c0, 0x40, "ETRAM_CTL" }, 2626e91a93dSOswald Buddenhagen { 0x160, 0x20, "A3_EMU32IN" }, 2636e91a93dSOswald Buddenhagen { 0x1e0, 0x20, "A3_EMU32OUT" }, 2646e91a93dSOswald Buddenhagen { 0x200, 0xc0, "ITRAM_DATA" }, 2656e91a93dSOswald Buddenhagen { 0x2c0, 0x40, "ETRAM_DATA" }, 2666e91a93dSOswald Buddenhagen { 0x300, 0xc0, "ITRAM_ADDR" }, 2676e91a93dSOswald Buddenhagen { 0x3c0, 0x40, "ETRAM_ADDR" }, 2686e91a93dSOswald Buddenhagen { 0x400, 0x200, "GPR" }, 2696e91a93dSOswald Buddenhagen { 0x600, 0, NULL } 2706e91a93dSOswald Buddenhagen }; 2716e91a93dSOswald Buddenhagen 2726e91a93dSOswald Buddenhagen static const char * const emu10k1_const_entries[] = { 2736e91a93dSOswald Buddenhagen "C_00000000", 2746e91a93dSOswald Buddenhagen "C_00000001", 2756e91a93dSOswald Buddenhagen "C_00000002", 2766e91a93dSOswald Buddenhagen "C_00000003", 2776e91a93dSOswald Buddenhagen "C_00000004", 2786e91a93dSOswald Buddenhagen "C_00000008", 2796e91a93dSOswald Buddenhagen "C_00000010", 2806e91a93dSOswald Buddenhagen "C_00000020", 2816e91a93dSOswald Buddenhagen "C_00000100", 2826e91a93dSOswald Buddenhagen "C_00010000", 2836e91a93dSOswald Buddenhagen "C_00000800", 2846e91a93dSOswald Buddenhagen "C_10000000", 2856e91a93dSOswald Buddenhagen "C_20000000", 2866e91a93dSOswald Buddenhagen "C_40000000", 2876e91a93dSOswald Buddenhagen "C_80000000", 2886e91a93dSOswald Buddenhagen "C_7fffffff", 2896e91a93dSOswald Buddenhagen "C_ffffffff", 2906e91a93dSOswald Buddenhagen "C_fffffffe", 2916e91a93dSOswald Buddenhagen "C_c0000000", 2926e91a93dSOswald Buddenhagen "C_4f1bbcdc", 2936e91a93dSOswald Buddenhagen "C_5a7ef9db", 2946e91a93dSOswald Buddenhagen "C_00100000", 2956e91a93dSOswald Buddenhagen "GPR_ACCU", 2966e91a93dSOswald Buddenhagen "GPR_COND", 2976e91a93dSOswald Buddenhagen "GPR_NOISE0", 2986e91a93dSOswald Buddenhagen "GPR_NOISE1", 2996e91a93dSOswald Buddenhagen "GPR_IRQ", 3006e91a93dSOswald Buddenhagen "GPR_DBAC", 3016e91a93dSOswald Buddenhagen "GPR_DBACE", 3026e91a93dSOswald Buddenhagen "???", 3036e91a93dSOswald Buddenhagen }; 3046e91a93dSOswald Buddenhagen 3056e91a93dSOswald Buddenhagen static int disasm_emu10k1_reg(char *buffer, 3066e91a93dSOswald Buddenhagen const struct emu10k1_reg_entry *entries, 3076e91a93dSOswald Buddenhagen unsigned reg, const char *pfx) 3086e91a93dSOswald Buddenhagen { 3096e91a93dSOswald Buddenhagen for (int i = 0; ; i++) { 3106e91a93dSOswald Buddenhagen unsigned base = entries[i].base; 3116e91a93dSOswald Buddenhagen unsigned size = entries[i].size; 3126e91a93dSOswald Buddenhagen if (!size) 3136e91a93dSOswald Buddenhagen return sprintf(buffer, "%s0x%03x", pfx, reg); 3146e91a93dSOswald Buddenhagen if (reg >= base && reg < base + size) { 3156e91a93dSOswald Buddenhagen const char *name = entries[i].name; 3166e91a93dSOswald Buddenhagen reg -= base; 3176e91a93dSOswald Buddenhagen if (name) 3186e91a93dSOswald Buddenhagen return sprintf(buffer, "%s%s(%u)", pfx, name, reg); 3196e91a93dSOswald Buddenhagen return sprintf(buffer, "%s%s", pfx, emu10k1_const_entries[reg]); 3206e91a93dSOswald Buddenhagen } 3216e91a93dSOswald Buddenhagen } 3226e91a93dSOswald Buddenhagen } 3236e91a93dSOswald Buddenhagen 3246e91a93dSOswald Buddenhagen static int disasm_sblive_reg(char *buffer, unsigned reg, const char *pfx) 3256e91a93dSOswald Buddenhagen { 3266e91a93dSOswald Buddenhagen return disasm_emu10k1_reg(buffer, sblive_reg_entries, reg, pfx); 3276e91a93dSOswald Buddenhagen } 3286e91a93dSOswald Buddenhagen 3296e91a93dSOswald Buddenhagen static int disasm_audigy_reg(char *buffer, unsigned reg, const char *pfx) 3306e91a93dSOswald Buddenhagen { 3316e91a93dSOswald Buddenhagen return disasm_emu10k1_reg(buffer, audigy_reg_entries, reg, pfx); 3326e91a93dSOswald Buddenhagen } 3336e91a93dSOswald Buddenhagen 334eb4698f3STakashi Iwai static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry, 335eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 3361da177e4SLinus Torvalds { 3371da177e4SLinus Torvalds u32 pc; 338eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 3396e91a93dSOswald Buddenhagen static const char * const insns[16] = { 3406e91a93dSOswald Buddenhagen "MAC0", "MAC1", "MAC2", "MAC3", "MACINT0", "MACINT1", "ACC3", "MACMV", 3416e91a93dSOswald Buddenhagen "ANDXOR", "TSTNEG", "LIMITGE", "LIMITLT", "LOG", "EXP", "INTERP", "SKIP", 3426e91a93dSOswald Buddenhagen }; 3436e91a93dSOswald Buddenhagen static const char spaces[] = " "; 3446e91a93dSOswald Buddenhagen const int nspaces = sizeof(spaces) - 1; 3451da177e4SLinus Torvalds 3461da177e4SLinus Torvalds snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name); 3471da177e4SLinus Torvalds snd_iprintf(buffer, " Code dump :\n"); 3481da177e4SLinus Torvalds for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) { 3491da177e4SLinus Torvalds u32 low, high; 3506e91a93dSOswald Buddenhagen int len; 3516e91a93dSOswald Buddenhagen char buf[100]; 3526e91a93dSOswald Buddenhagen char *bufp = buf; 3531da177e4SLinus Torvalds 3541da177e4SLinus Torvalds low = snd_emu10k1_efx_read(emu, pc * 2); 3551da177e4SLinus Torvalds high = snd_emu10k1_efx_read(emu, pc * 2 + 1); 3566e91a93dSOswald Buddenhagen if (emu->audigy) { 3576e91a93dSOswald Buddenhagen bufp += sprintf(bufp, " %-7s ", insns[(high >> 24) & 0x0f]); 3586e91a93dSOswald Buddenhagen bufp += disasm_audigy_reg(bufp, (high >> 12) & 0x7ff, ""); 3596e91a93dSOswald Buddenhagen bufp += disasm_audigy_reg(bufp, (high >> 0) & 0x7ff, ", "); 3606e91a93dSOswald Buddenhagen bufp += disasm_audigy_reg(bufp, (low >> 12) & 0x7ff, ", "); 3616e91a93dSOswald Buddenhagen bufp += disasm_audigy_reg(bufp, (low >> 0) & 0x7ff, ", "); 3626e91a93dSOswald Buddenhagen } else { 3636e91a93dSOswald Buddenhagen bufp += sprintf(bufp, " %-7s ", insns[(high >> 20) & 0x0f]); 3646e91a93dSOswald Buddenhagen bufp += disasm_sblive_reg(bufp, (high >> 10) & 0x3ff, ""); 3656e91a93dSOswald Buddenhagen bufp += disasm_sblive_reg(bufp, (high >> 0) & 0x3ff, ", "); 3666e91a93dSOswald Buddenhagen bufp += disasm_sblive_reg(bufp, (low >> 10) & 0x3ff, ", "); 3676e91a93dSOswald Buddenhagen bufp += disasm_sblive_reg(bufp, (low >> 0) & 0x3ff, ", "); 3686e91a93dSOswald Buddenhagen } 3696e91a93dSOswald Buddenhagen len = (int)(ptrdiff_t)(bufp - buf); 3706e91a93dSOswald Buddenhagen snd_iprintf(buffer, "%s %s /* 0x%04x: 0x%08x%08x */\n", 3716e91a93dSOswald Buddenhagen buf, &spaces[nspaces - clamp(65 - len, 0, nspaces)], 3726e91a93dSOswald Buddenhagen pc, high, low); 3731da177e4SLinus Torvalds } 3741da177e4SLinus Torvalds } 3751da177e4SLinus Torvalds 3761da177e4SLinus Torvalds #define TOTAL_SIZE_GPR (0x100*4) 3771da177e4SLinus Torvalds #define A_TOTAL_SIZE_GPR (0x200*4) 3781da177e4SLinus Torvalds #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4) 3791da177e4SLinus Torvalds #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4) 3801da177e4SLinus Torvalds #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4) 3811da177e4SLinus Torvalds #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4) 3821da177e4SLinus Torvalds #define TOTAL_SIZE_CODE (0x200*8) 3831da177e4SLinus Torvalds #define A_TOTAL_SIZE_CODE (0x400*8) 3841da177e4SLinus Torvalds 38524e4a121STakashi Iwai static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry, 386eb4698f3STakashi Iwai void *file_private_data, 3871da177e4SLinus Torvalds struct file *file, char __user *buf, 38824e4a121STakashi Iwai size_t count, loff_t pos) 3891da177e4SLinus Torvalds { 390eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 3911da177e4SLinus Torvalds unsigned int offset; 3921da177e4SLinus Torvalds int tram_addr = 0; 393d97e1b78STakashi Iwai unsigned int *tmp; 394d97e1b78STakashi Iwai long res; 395d97e1b78STakashi Iwai unsigned int idx; 3961da177e4SLinus Torvalds 3971da177e4SLinus Torvalds if (!strcmp(entry->name, "fx8010_tram_addr")) { 3981da177e4SLinus Torvalds offset = TANKMEMADDRREGBASE; 3991da177e4SLinus Torvalds tram_addr = 1; 4001da177e4SLinus Torvalds } else if (!strcmp(entry->name, "fx8010_tram_data")) { 4011da177e4SLinus Torvalds offset = TANKMEMDATAREGBASE; 4021da177e4SLinus Torvalds } else if (!strcmp(entry->name, "fx8010_code")) { 4031da177e4SLinus Torvalds offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; 4041da177e4SLinus Torvalds } else { 4051da177e4SLinus Torvalds offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE; 4061da177e4SLinus Torvalds } 407d97e1b78STakashi Iwai 408d97e1b78STakashi Iwai tmp = kmalloc(count + 8, GFP_KERNEL); 409d97e1b78STakashi Iwai if (!tmp) 4101da177e4SLinus Torvalds return -ENOMEM; 411d97e1b78STakashi Iwai for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) { 412d97e1b78STakashi Iwai unsigned int val; 413d97e1b78STakashi Iwai val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0); 4141da177e4SLinus Torvalds if (tram_addr && emu->audigy) { 415d97e1b78STakashi Iwai val >>= 11; 416d97e1b78STakashi Iwai val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20; 4171da177e4SLinus Torvalds } 418d97e1b78STakashi Iwai tmp[idx] = val; 419d97e1b78STakashi Iwai } 420d97e1b78STakashi Iwai if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count)) 421d97e1b78STakashi Iwai res = -EFAULT; 422d97e1b78STakashi Iwai else 423d97e1b78STakashi Iwai res = count; 4241da177e4SLinus Torvalds kfree(tmp); 4251da177e4SLinus Torvalds return res; 4261da177e4SLinus Torvalds } 4271da177e4SLinus Torvalds 428eb4698f3STakashi Iwai static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry, 429eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 4301da177e4SLinus Torvalds { 431eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 432eb4698f3STakashi Iwai struct snd_emu10k1_voice *voice; 4331da177e4SLinus Torvalds int idx; 434b840f8d8SOswald Buddenhagen static const char * const types[] = { 435b840f8d8SOswald Buddenhagen "Unused", "EFX", "EFX IRQ", "PCM", "PCM IRQ", "Synth" 436b840f8d8SOswald Buddenhagen }; 437b840f8d8SOswald Buddenhagen static_assert(ARRAY_SIZE(types) == EMU10K1_NUM_TYPES); 4381da177e4SLinus Torvalds 439a915d604SOswald Buddenhagen snd_iprintf(buffer, "ch\tdirty\tlast\tuse\n"); 4401da177e4SLinus Torvalds for (idx = 0; idx < NUM_G; idx++) { 4411da177e4SLinus Torvalds voice = &emu->voices[idx]; 442a915d604SOswald Buddenhagen snd_iprintf(buffer, "%i\t%u\t%u\t%s\n", 4431da177e4SLinus Torvalds idx, 44482a9fa6eSOswald Buddenhagen voice->dirty, 445a915d604SOswald Buddenhagen voice->last, 446b840f8d8SOswald Buddenhagen types[voice->use]); 4471da177e4SLinus Torvalds } 4481da177e4SLinus Torvalds } 4491da177e4SLinus Torvalds 4501da177e4SLinus Torvalds #ifdef CONFIG_SND_DEBUG 4516ab13291SOswald Buddenhagen 4526ab13291SOswald Buddenhagen static void snd_emu_proc_emu1010_link_read(struct snd_emu10k1 *emu, 4536ab13291SOswald Buddenhagen struct snd_info_buffer *buffer, 4546ab13291SOswald Buddenhagen u32 dst) 4556ab13291SOswald Buddenhagen { 4566ab13291SOswald Buddenhagen u32 src = snd_emu1010_fpga_link_dst_src_read(emu, dst); 4576ab13291SOswald Buddenhagen snd_iprintf(buffer, "%04x: %04x\n", dst, src); 4586ab13291SOswald Buddenhagen } 4596ab13291SOswald Buddenhagen 4609f4bd5ddSJames Courtier-Dutton static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry, 4619f4bd5ddSJames Courtier-Dutton struct snd_info_buffer *buffer) 4629f4bd5ddSJames Courtier-Dutton { 4639f4bd5ddSJames Courtier-Dutton struct snd_emu10k1 *emu = entry->private_data; 4644677df07SHarvey Harrison u32 value; 4659f4bd5ddSJames Courtier-Dutton int i; 4669f4bd5ddSJames Courtier-Dutton snd_iprintf(buffer, "EMU1010 Registers:\n\n"); 4679f4bd5ddSJames Courtier-Dutton 46890fd5ce5SJames Courtier-Dutton for(i = 0; i < 0x40; i+=1) { 469f93abe51SJames Courtier-Dutton snd_emu1010_fpga_read(emu, i, &value); 4706ab13291SOswald Buddenhagen snd_iprintf(buffer, "%02x: %02x\n", i, value); 4716ab13291SOswald Buddenhagen } 4726ab13291SOswald Buddenhagen 4736ab13291SOswald Buddenhagen snd_iprintf(buffer, "\nEMU1010 Routes:\n\n"); 4746ab13291SOswald Buddenhagen 4756ab13291SOswald Buddenhagen for (i = 0; i < 16; i++) // To Alice2/Tina[2] via EMU32 4766ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, i); 4776ab13291SOswald Buddenhagen if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) 4786ab13291SOswald Buddenhagen for (i = 0; i < 32; i++) // To Dock via EDI 4796ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x100 + i); 4806ab13291SOswald Buddenhagen if (emu->card_capabilities->emu_model != EMU_MODEL_EMU1616) 4816ab13291SOswald Buddenhagen for (i = 0; i < 8; i++) // To Hamoa/local 4826ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x200 + i); 4836ab13291SOswald Buddenhagen for (i = 0; i < 8; i++) // To Hamoa/Mana/local 4846ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x300 + i); 4856ab13291SOswald Buddenhagen if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1616) { 4866ab13291SOswald Buddenhagen for (i = 0; i < 16; i++) // To Tina2 via EMU32 4876ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i); 4886ab13291SOswald Buddenhagen } else if (emu->card_capabilities->emu_model != EMU_MODEL_EMU0404) { 4896ab13291SOswald Buddenhagen for (i = 0; i < 8; i++) // To Hana ADAT 4906ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x400 + i); 4916ab13291SOswald Buddenhagen if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010B) { 4926ab13291SOswald Buddenhagen for (i = 0; i < 16; i++) // To Tina via EMU32 4936ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x500 + i); 4946ab13291SOswald Buddenhagen } else { 4956ab13291SOswald Buddenhagen // To Alice2 via I2S 4966ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x500); 4976ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x501); 4986ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x600); 4996ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x601); 5006ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x700); 5016ab13291SOswald Buddenhagen snd_emu_proc_emu1010_link_read(emu, buffer, 0x701); 5026ab13291SOswald Buddenhagen } 5039f4bd5ddSJames Courtier-Dutton } 5049f4bd5ddSJames Courtier-Dutton } 5059f4bd5ddSJames Courtier-Dutton 506eb4698f3STakashi Iwai static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry, 507eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 5081da177e4SLinus Torvalds { 509eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 5101da177e4SLinus Torvalds unsigned long value; 5111da177e4SLinus Torvalds int i; 5121da177e4SLinus Torvalds snd_iprintf(buffer, "IO Registers:\n\n"); 5131da177e4SLinus Torvalds for(i = 0; i < 0x40; i+=4) { 5141da177e4SLinus Torvalds value = inl(emu->port + i); 5151da177e4SLinus Torvalds snd_iprintf(buffer, "%02X: %08lX\n", i, value); 5161da177e4SLinus Torvalds } 5171da177e4SLinus Torvalds } 5181da177e4SLinus Torvalds 519eb4698f3STakashi Iwai static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry, 520eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 5211da177e4SLinus Torvalds { 522eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 5231da177e4SLinus Torvalds char line[64]; 5241da177e4SLinus Torvalds u32 reg, val; 5251da177e4SLinus Torvalds while (!snd_info_get_line(buffer, line, sizeof(line))) { 5261da177e4SLinus Torvalds if (sscanf(line, "%x %x", ®, &val) != 2) 5271da177e4SLinus Torvalds continue; 52884ed1a19SRoel Kluin if (reg < 0x40 && val <= 0xffffffff) { 5291da177e4SLinus Torvalds outl(val, emu->port + (reg & 0xfffffffc)); 5301da177e4SLinus Torvalds } 5311da177e4SLinus Torvalds } 5321da177e4SLinus Torvalds } 5331da177e4SLinus Torvalds 534eb4698f3STakashi Iwai static unsigned int snd_ptr_read(struct snd_emu10k1 * emu, 5351da177e4SLinus Torvalds unsigned int iobase, 5361da177e4SLinus Torvalds unsigned int reg, 5371da177e4SLinus Torvalds unsigned int chn) 5381da177e4SLinus Torvalds { 5391da177e4SLinus Torvalds unsigned long flags; 5401da177e4SLinus Torvalds unsigned int regptr, val; 5411da177e4SLinus Torvalds 5421da177e4SLinus Torvalds regptr = (reg << 16) | chn; 5431da177e4SLinus Torvalds 5441da177e4SLinus Torvalds spin_lock_irqsave(&emu->emu_lock, flags); 5451da177e4SLinus Torvalds outl(regptr, emu->port + iobase + PTR); 5461da177e4SLinus Torvalds val = inl(emu->port + iobase + DATA); 5471da177e4SLinus Torvalds spin_unlock_irqrestore(&emu->emu_lock, flags); 5481da177e4SLinus Torvalds return val; 5491da177e4SLinus Torvalds } 5501da177e4SLinus Torvalds 551eb4698f3STakashi Iwai static void snd_ptr_write(struct snd_emu10k1 *emu, 5521da177e4SLinus Torvalds unsigned int iobase, 5531da177e4SLinus Torvalds unsigned int reg, 5541da177e4SLinus Torvalds unsigned int chn, 5551da177e4SLinus Torvalds unsigned int data) 5561da177e4SLinus Torvalds { 5571da177e4SLinus Torvalds unsigned int regptr; 5581da177e4SLinus Torvalds unsigned long flags; 5591da177e4SLinus Torvalds 5601da177e4SLinus Torvalds regptr = (reg << 16) | chn; 5611da177e4SLinus Torvalds 5621da177e4SLinus Torvalds spin_lock_irqsave(&emu->emu_lock, flags); 5631da177e4SLinus Torvalds outl(regptr, emu->port + iobase + PTR); 5641da177e4SLinus Torvalds outl(data, emu->port + iobase + DATA); 5651da177e4SLinus Torvalds spin_unlock_irqrestore(&emu->emu_lock, flags); 5661da177e4SLinus Torvalds } 5671da177e4SLinus Torvalds 5681da177e4SLinus Torvalds 569eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry, 570eb4698f3STakashi Iwai struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices) 5711da177e4SLinus Torvalds { 572eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 5731da177e4SLinus Torvalds unsigned long value; 5741da177e4SLinus Torvalds int i,j; 5756ef7e861SJames Courtier-Dutton if (offset+length > 0xa0) { 5761da177e4SLinus Torvalds snd_iprintf(buffer, "Input values out of range\n"); 5771da177e4SLinus Torvalds return; 5781da177e4SLinus Torvalds } 5791da177e4SLinus Torvalds snd_iprintf(buffer, "Registers 0x%x\n", iobase); 5801da177e4SLinus Torvalds for(i = offset; i < offset+length; i++) { 5811da177e4SLinus Torvalds snd_iprintf(buffer, "%02X: ",i); 5821da177e4SLinus Torvalds for (j = 0; j < voices; j++) { 583e922da40SOswald Buddenhagen value = snd_ptr_read(emu, iobase, i, j); 5841da177e4SLinus Torvalds snd_iprintf(buffer, "%08lX ", value); 5851da177e4SLinus Torvalds } 5861da177e4SLinus Torvalds snd_iprintf(buffer, "\n"); 5871da177e4SLinus Torvalds } 5881da177e4SLinus Torvalds } 5891da177e4SLinus Torvalds 590eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry, 59167ff2addSOswald Buddenhagen struct snd_info_buffer *buffer, 59267ff2addSOswald Buddenhagen int iobase, int length, int voices) 5931da177e4SLinus Torvalds { 594eb4698f3STakashi Iwai struct snd_emu10k1 *emu = entry->private_data; 5951da177e4SLinus Torvalds char line[64]; 5961da177e4SLinus Torvalds unsigned int reg, channel_id , val; 5971da177e4SLinus Torvalds while (!snd_info_get_line(buffer, line, sizeof(line))) { 5981da177e4SLinus Torvalds if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) 5991da177e4SLinus Torvalds continue; 60067ff2addSOswald Buddenhagen if (reg < length && channel_id < voices) 6011da177e4SLinus Torvalds snd_ptr_write(emu, iobase, reg, channel_id, val); 6021da177e4SLinus Torvalds } 6031da177e4SLinus Torvalds } 6041da177e4SLinus Torvalds 605eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry, 606eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 6071da177e4SLinus Torvalds { 60867ff2addSOswald Buddenhagen snd_emu_proc_ptr_reg_write(entry, buffer, 0, 0x80, 64); 6091da177e4SLinus Torvalds } 6101da177e4SLinus Torvalds 611eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry, 612eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 6131da177e4SLinus Torvalds { 61467ff2addSOswald Buddenhagen struct snd_emu10k1 *emu = entry->private_data; 61567ff2addSOswald Buddenhagen snd_emu_proc_ptr_reg_write(entry, buffer, 0x20, 61667ff2addSOswald Buddenhagen emu->card_capabilities->ca0108_chip ? 0xa0 : 0x80, 4); 6171da177e4SLinus Torvalds } 6181da177e4SLinus Torvalds 6191da177e4SLinus Torvalds 620eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry, 621eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 6221da177e4SLinus Torvalds { 6231da177e4SLinus Torvalds snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64); 6241da177e4SLinus Torvalds } 6251da177e4SLinus Torvalds 626eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry, 627eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 6281da177e4SLinus Torvalds { 6291da177e4SLinus Torvalds snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64); 6301da177e4SLinus Torvalds } 6311da177e4SLinus Torvalds 632eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry, 633eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 6341da177e4SLinus Torvalds { 6351da177e4SLinus Torvalds snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4); 6361da177e4SLinus Torvalds } 6371da177e4SLinus Torvalds 638eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry, 639eb4698f3STakashi Iwai struct snd_info_buffer *buffer) 6401da177e4SLinus Torvalds { 6411da177e4SLinus Torvalds snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4); 6421da177e4SLinus Torvalds } 6436ef7e861SJames Courtier-Dutton 644eb4698f3STakashi Iwai static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry, 645eb4698f3STakashi Iwai struct snd_info_buffer * buffer) 6466ef7e861SJames Courtier-Dutton { 6476ef7e861SJames Courtier-Dutton snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4); 6486ef7e861SJames Courtier-Dutton } 6491da177e4SLinus Torvalds #endif 6501da177e4SLinus Torvalds 651d25ff268STakashi Iwai static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { 6521da177e4SLinus Torvalds .read = snd_emu10k1_fx8010_read, 6531da177e4SLinus Torvalds }; 6541da177e4SLinus Torvalds 655e23e7a14SBill Pemberton int snd_emu10k1_proc_init(struct snd_emu10k1 *emu) 6561da177e4SLinus Torvalds { 657eb4698f3STakashi Iwai struct snd_info_entry *entry; 6581da177e4SLinus Torvalds #ifdef CONFIG_SND_DEBUG 659190d2c46SJames Courtier-Dutton if (emu->card_capabilities->emu_model) { 66047f2769bSTakashi Iwai snd_card_ro_proc_new(emu->card, "emu1010_regs", 66147f2769bSTakashi Iwai emu, snd_emu_proc_emu1010_reg_read); 6629f4bd5ddSJames Courtier-Dutton } 66347f2769bSTakashi Iwai snd_card_rw_proc_new(emu->card, "io_regs", emu, 66447f2769bSTakashi Iwai snd_emu_proc_io_reg_read, 66547f2769bSTakashi Iwai snd_emu_proc_io_reg_write); 66647f2769bSTakashi Iwai snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu, 66747f2769bSTakashi Iwai snd_emu_proc_ptr_reg_read00a, 66847f2769bSTakashi Iwai snd_emu_proc_ptr_reg_write00); 66947f2769bSTakashi Iwai snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu, 67047f2769bSTakashi Iwai snd_emu_proc_ptr_reg_read00b, 67147f2769bSTakashi Iwai snd_emu_proc_ptr_reg_write00); 672219153c6SOswald Buddenhagen if (!emu->card_capabilities->emu_model && 673219153c6SOswald Buddenhagen (emu->card_capabilities->ca0151_chip || emu->card_capabilities->ca0108_chip)) { 67447f2769bSTakashi Iwai snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu, 67547f2769bSTakashi Iwai snd_emu_proc_ptr_reg_read20a, 67647f2769bSTakashi Iwai snd_emu_proc_ptr_reg_write20); 67747f2769bSTakashi Iwai snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu, 67847f2769bSTakashi Iwai snd_emu_proc_ptr_reg_read20b, 67947f2769bSTakashi Iwai snd_emu_proc_ptr_reg_write20); 680219153c6SOswald Buddenhagen if (emu->card_capabilities->ca0108_chip) 68147f2769bSTakashi Iwai snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu, 68247f2769bSTakashi Iwai snd_emu_proc_ptr_reg_read20c, 68347f2769bSTakashi Iwai snd_emu_proc_ptr_reg_write20); 684219153c6SOswald Buddenhagen } 6851da177e4SLinus Torvalds #endif 6861da177e4SLinus Torvalds 68747f2769bSTakashi Iwai snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read); 6881da177e4SLinus Torvalds 68947f2769bSTakashi Iwai if (emu->card_capabilities->emu10k2_chip) 69047f2769bSTakashi Iwai snd_card_ro_proc_new(emu->card, "spdif-in", emu, 69147f2769bSTakashi Iwai snd_emu10k1_proc_spdif_read); 69247f2769bSTakashi Iwai if (emu->card_capabilities->ca0151_chip) 69347f2769bSTakashi Iwai snd_card_ro_proc_new(emu->card, "capture-rates", emu, 69447f2769bSTakashi Iwai snd_emu10k1_proc_rates_read); 695df34140aSJames Courtier-Dutton 69647f2769bSTakashi Iwai snd_card_ro_proc_new(emu->card, "voices", emu, 69747f2769bSTakashi Iwai snd_emu10k1_proc_voices_read); 6981da177e4SLinus Torvalds 6991da177e4SLinus Torvalds if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) { 7001da177e4SLinus Torvalds entry->content = SNDRV_INFO_CONTENT_DATA; 7011da177e4SLinus Torvalds entry->private_data = emu; 7026a73cf46SJoe Perches entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 7031da177e4SLinus Torvalds entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR; 7041da177e4SLinus Torvalds entry->c.ops = &snd_emu10k1_proc_ops_fx8010; 7051da177e4SLinus Torvalds } 7061da177e4SLinus Torvalds if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) { 7071da177e4SLinus Torvalds entry->content = SNDRV_INFO_CONTENT_DATA; 7081da177e4SLinus Torvalds entry->private_data = emu; 7096a73cf46SJoe Perches entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 7101da177e4SLinus Torvalds entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ; 7111da177e4SLinus Torvalds entry->c.ops = &snd_emu10k1_proc_ops_fx8010; 7121da177e4SLinus Torvalds } 7131da177e4SLinus Torvalds if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) { 7141da177e4SLinus Torvalds entry->content = SNDRV_INFO_CONTENT_DATA; 7151da177e4SLinus Torvalds entry->private_data = emu; 7166a73cf46SJoe Perches entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 7171da177e4SLinus Torvalds entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ; 7181da177e4SLinus Torvalds entry->c.ops = &snd_emu10k1_proc_ops_fx8010; 7191da177e4SLinus Torvalds } 7201da177e4SLinus Torvalds if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) { 7211da177e4SLinus Torvalds entry->content = SNDRV_INFO_CONTENT_DATA; 7221da177e4SLinus Torvalds entry->private_data = emu; 7236a73cf46SJoe Perches entry->mode = S_IFREG | 0444 /*| S_IWUSR*/; 7241da177e4SLinus Torvalds entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE; 7251da177e4SLinus Torvalds entry->c.ops = &snd_emu10k1_proc_ops_fx8010; 7261da177e4SLinus Torvalds } 72747f2769bSTakashi Iwai snd_card_ro_proc_new(emu->card, "fx8010_acode", emu, 72847f2769bSTakashi Iwai snd_emu10k1_proc_acode_read); 7291da177e4SLinus Torvalds return 0; 7301da177e4SLinus Torvalds } 731