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