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