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