Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
0004  *                   Creative Labs, Inc.
0005  *  Routines for control of EMU10K1 chips / proc interface routines
0006  *
0007  *  Copyright (c) by James Courtier-Dutton <James@superbug.co.uk>
0008  *      Added EMU 1010 support.
0009  *
0010  *  BUGS:
0011  *    --
0012  *
0013  *  TODO:
0014  *    --
0015  */
0016 
0017 #include <linux/slab.h>
0018 #include <linux/init.h>
0019 #include <sound/core.h>
0020 #include <sound/emu10k1.h>
0021 #include "p16v.h"
0022 
0023 static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu,
0024                       struct snd_info_buffer *buffer,
0025                       char *title,
0026                       int status_reg,
0027                       int rate_reg)
0028 {
0029     static const char * const clkaccy[4] = { "1000ppm", "50ppm", "variable", "unknown" };
0030     static const int samplerate[16] = { 44100, 1, 48000, 32000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
0031     static const char * const channel[16] = { "unspec", "left", "right", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
0032     static const char * const emphasis[8] = { "none", "50/15 usec 2 channel", "2", "3", "4", "5", "6", "7" };
0033     unsigned int status, rate = 0;
0034     
0035     status = snd_emu10k1_ptr_read(emu, status_reg, 0);
0036 
0037     snd_iprintf(buffer, "\n%s\n", title);
0038 
0039     if (status != 0xffffffff) {
0040         snd_iprintf(buffer, "Professional Mode     : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no");
0041         snd_iprintf(buffer, "Not Audio Data        : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no");
0042         snd_iprintf(buffer, "Copyright             : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no");
0043         snd_iprintf(buffer, "Emphasis              : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]);
0044         snd_iprintf(buffer, "Mode                  : %i\n", (status & SPCS_MODEMASK) >> 6);
0045         snd_iprintf(buffer, "Category Code         : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8);
0046         snd_iprintf(buffer, "Generation Status     : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy");
0047         snd_iprintf(buffer, "Source Mask           : %i\n", (status & SPCS_SOURCENUMMASK) >> 16);
0048         snd_iprintf(buffer, "Channel Number        : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]);
0049         snd_iprintf(buffer, "Sample Rate           : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]);
0050         snd_iprintf(buffer, "Clock Accuracy        : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]);
0051 
0052         if (rate_reg > 0) {
0053             rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
0054             snd_iprintf(buffer, "S/PDIF Valid          : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off");
0055             snd_iprintf(buffer, "S/PDIF Locked         : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off");
0056             snd_iprintf(buffer, "Rate Locked           : %s\n", rate & SRCS_RATELOCKED ? "on" : "off");
0057             /* From ((Rate * 48000 ) / 262144); */
0058             snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11); 
0059         }
0060     } else {
0061         snd_iprintf(buffer, "No signal detected.\n");
0062     }
0063 
0064 }
0065 
0066 static void snd_emu10k1_proc_read(struct snd_info_entry *entry, 
0067                   struct snd_info_buffer *buffer)
0068 {
0069     /* FIXME - output names are in emufx.c too */
0070     static const char * const creative_outs[32] = {
0071         /* 00 */ "AC97 Left",
0072         /* 01 */ "AC97 Right",
0073         /* 02 */ "Optical IEC958 Left",
0074         /* 03 */ "Optical IEC958 Right",
0075         /* 04 */ "Center",
0076         /* 05 */ "LFE",
0077         /* 06 */ "Headphone Left",
0078         /* 07 */ "Headphone Right",
0079         /* 08 */ "Surround Left",
0080         /* 09 */ "Surround Right",
0081         /* 10 */ "PCM Capture Left",
0082         /* 11 */ "PCM Capture Right",
0083         /* 12 */ "MIC Capture",
0084         /* 13 */ "AC97 Surround Left",
0085         /* 14 */ "AC97 Surround Right",
0086         /* 15 */ "???",
0087         /* 16 */ "???",
0088         /* 17 */ "Analog Center",
0089         /* 18 */ "Analog LFE",
0090         /* 19 */ "???",
0091         /* 20 */ "???",
0092         /* 21 */ "???",
0093         /* 22 */ "???",
0094         /* 23 */ "???",
0095         /* 24 */ "???",
0096         /* 25 */ "???",
0097         /* 26 */ "???",
0098         /* 27 */ "???",
0099         /* 28 */ "???",
0100         /* 29 */ "???",
0101         /* 30 */ "???",
0102         /* 31 */ "???"
0103     };
0104 
0105     static const char * const audigy_outs[64] = {
0106         /* 00 */ "Digital Front Left",
0107         /* 01 */ "Digital Front Right",
0108         /* 02 */ "Digital Center",
0109         /* 03 */ "Digital LEF",
0110         /* 04 */ "Headphone Left",
0111         /* 05 */ "Headphone Right",
0112         /* 06 */ "Digital Rear Left",
0113         /* 07 */ "Digital Rear Right",
0114         /* 08 */ "Front Left",
0115         /* 09 */ "Front Right",
0116         /* 10 */ "Center",
0117         /* 11 */ "LFE",
0118         /* 12 */ "???",
0119         /* 13 */ "???",
0120         /* 14 */ "Rear Left",
0121         /* 15 */ "Rear Right",
0122         /* 16 */ "AC97 Front Left",
0123         /* 17 */ "AC97 Front Right",
0124         /* 18 */ "ADC Capture Left",
0125         /* 19 */ "ADC Capture Right",
0126         /* 20 */ "???",
0127         /* 21 */ "???",
0128         /* 22 */ "???",
0129         /* 23 */ "???",
0130         /* 24 */ "???",
0131         /* 25 */ "???",
0132         /* 26 */ "???",
0133         /* 27 */ "???",
0134         /* 28 */ "???",
0135         /* 29 */ "???",
0136         /* 30 */ "???",
0137         /* 31 */ "???",
0138         /* 32 */ "FXBUS2_0",
0139         /* 33 */ "FXBUS2_1",
0140         /* 34 */ "FXBUS2_2",
0141         /* 35 */ "FXBUS2_3",
0142         /* 36 */ "FXBUS2_4",
0143         /* 37 */ "FXBUS2_5",
0144         /* 38 */ "FXBUS2_6",
0145         /* 39 */ "FXBUS2_7",
0146         /* 40 */ "FXBUS2_8",
0147         /* 41 */ "FXBUS2_9",
0148         /* 42 */ "FXBUS2_10",
0149         /* 43 */ "FXBUS2_11",
0150         /* 44 */ "FXBUS2_12",
0151         /* 45 */ "FXBUS2_13",
0152         /* 46 */ "FXBUS2_14",
0153         /* 47 */ "FXBUS2_15",
0154         /* 48 */ "FXBUS2_16",
0155         /* 49 */ "FXBUS2_17",
0156         /* 50 */ "FXBUS2_18",
0157         /* 51 */ "FXBUS2_19",
0158         /* 52 */ "FXBUS2_20",
0159         /* 53 */ "FXBUS2_21",
0160         /* 54 */ "FXBUS2_22",
0161         /* 55 */ "FXBUS2_23",
0162         /* 56 */ "FXBUS2_24",
0163         /* 57 */ "FXBUS2_25",
0164         /* 58 */ "FXBUS2_26",
0165         /* 59 */ "FXBUS2_27",
0166         /* 60 */ "FXBUS2_28",
0167         /* 61 */ "FXBUS2_29",
0168         /* 62 */ "FXBUS2_30",
0169         /* 63 */ "FXBUS2_31"
0170     };
0171 
0172     struct snd_emu10k1 *emu = entry->private_data;
0173     unsigned int val, val1;
0174     int nefx = emu->audigy ? 64 : 32;
0175     const char * const *outputs = emu->audigy ? audigy_outs : creative_outs;
0176     int idx;
0177     
0178     snd_iprintf(buffer, "EMU10K1\n\n");
0179     snd_iprintf(buffer, "Card                  : %s\n",
0180             emu->audigy ? "Audigy" : (emu->card_capabilities->ecard ? "EMU APS" : "Creative"));
0181     snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
0182     snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2);
0183     snd_iprintf(buffer, "\n");
0184     snd_iprintf(buffer, "Effect Send Routing   :\n");
0185     for (idx = 0; idx < NUM_G; idx++) {
0186         val = emu->audigy ?
0187             snd_emu10k1_ptr_read(emu, A_FXRT1, idx) :
0188             snd_emu10k1_ptr_read(emu, FXRT, idx);
0189         val1 = emu->audigy ?
0190             snd_emu10k1_ptr_read(emu, A_FXRT2, idx) :
0191             0;
0192         if (emu->audigy) {
0193             snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i, ",
0194                 idx,
0195                 val & 0x3f,
0196                 (val >> 8) & 0x3f,
0197                 (val >> 16) & 0x3f,
0198                 (val >> 24) & 0x3f);
0199             snd_iprintf(buffer, "E=%i, F=%i, G=%i, H=%i\n",
0200                 val1 & 0x3f,
0201                 (val1 >> 8) & 0x3f,
0202                 (val1 >> 16) & 0x3f,
0203                 (val1 >> 24) & 0x3f);
0204         } else {
0205             snd_iprintf(buffer, "Ch%i: A=%i, B=%i, C=%i, D=%i\n",
0206                 idx,
0207                 (val >> 16) & 0x0f,
0208                 (val >> 20) & 0x0f,
0209                 (val >> 24) & 0x0f,
0210                 (val >> 28) & 0x0f);
0211         }
0212     }
0213     snd_iprintf(buffer, "\nCaptured FX Outputs   :\n");
0214     for (idx = 0; idx < nefx; idx++) {
0215         if (emu->efx_voices_mask[idx/32] & (1 << (idx%32)))
0216             snd_iprintf(buffer, "  Output %02i [%s]\n", idx, outputs[idx]);
0217     }
0218     snd_iprintf(buffer, "\nAll FX Outputs        :\n");
0219     for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++)
0220         snd_iprintf(buffer, "  Output %02i [%s]\n", idx, outputs[idx]);
0221 }
0222 
0223 static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, 
0224                   struct snd_info_buffer *buffer)
0225 {
0226     struct snd_emu10k1 *emu = entry->private_data;
0227     u32 value;
0228     u32 value2;
0229     u32 rate;
0230 
0231     if (emu->card_capabilities->emu_model) {
0232         snd_emu1010_fpga_read(emu, 0x38, &value);
0233         if ((value & 0x1) == 0) {
0234             snd_emu1010_fpga_read(emu, 0x2a, &value);
0235             snd_emu1010_fpga_read(emu, 0x2b, &value2);
0236             rate = 0x1770000 / (((value << 5) | value2)+1); 
0237             snd_iprintf(buffer, "ADAT Locked : %u\n", rate);
0238         } else {
0239             snd_iprintf(buffer, "ADAT Unlocked\n");
0240         }
0241         snd_emu1010_fpga_read(emu, 0x20, &value);
0242         if ((value & 0x4) == 0) {
0243             snd_emu1010_fpga_read(emu, 0x28, &value);
0244             snd_emu1010_fpga_read(emu, 0x29, &value2);
0245             rate = 0x1770000 / (((value << 5) | value2)+1); 
0246             snd_iprintf(buffer, "SPDIF Locked : %d\n", rate);
0247         } else {
0248             snd_iprintf(buffer, "SPDIF Unlocked\n");
0249         }
0250     } else {
0251         snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
0252         snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
0253     }
0254 #if 0
0255     val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
0256     snd_iprintf(buffer, "\nZoomed Video\n");
0257     snd_iprintf(buffer, "Rate Locked           : %s\n", val & SRCS_RATELOCKED ? "on" : "off");
0258     snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
0259 #endif
0260 }
0261 
0262 static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry, 
0263                   struct snd_info_buffer *buffer)
0264 {
0265     static const int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
0266     struct snd_emu10k1 *emu = entry->private_data;
0267     unsigned int val, tmp, n;
0268     val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
0269     for (n = 0; n < 4; n++) {
0270         tmp = val >> (16 + (n*4));
0271         if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
0272         else snd_iprintf(buffer, "Channel %d: No input\n", n);
0273     }
0274 }
0275 
0276 static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry, 
0277                         struct snd_info_buffer *buffer)
0278 {
0279     u32 pc;
0280     struct snd_emu10k1 *emu = entry->private_data;
0281 
0282     snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name);
0283     snd_iprintf(buffer, "  Code dump      :\n");
0284     for (pc = 0; pc < (emu->audigy ? 1024 : 512); pc++) {
0285         u32 low, high;
0286             
0287         low = snd_emu10k1_efx_read(emu, pc * 2);
0288         high = snd_emu10k1_efx_read(emu, pc * 2 + 1);
0289         if (emu->audigy)
0290             snd_iprintf(buffer, "    OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
0291                     (high >> 24) & 0x0f,
0292                     (high >> 12) & 0x7ff,
0293                     (high >> 0) & 0x7ff,
0294                     (low >> 12) & 0x7ff,
0295                     (low >> 0) & 0x7ff,
0296                     pc,
0297                     high, low);
0298         else
0299             snd_iprintf(buffer, "    OP(0x%02x, 0x%03x, 0x%03x, 0x%03x, 0x%03x) /* 0x%04x: 0x%08x%08x */\n",
0300                     (high >> 20) & 0x0f,
0301                     (high >> 10) & 0x3ff,
0302                     (high >> 0) & 0x3ff,
0303                     (low >> 10) & 0x3ff,
0304                     (low >> 0) & 0x3ff,
0305                     pc,
0306                     high, low);
0307     }
0308 }
0309 
0310 #define TOTAL_SIZE_GPR      (0x100*4)
0311 #define A_TOTAL_SIZE_GPR    (0x200*4)
0312 #define TOTAL_SIZE_TANKMEM_DATA (0xa0*4)
0313 #define TOTAL_SIZE_TANKMEM_ADDR (0xa0*4)
0314 #define A_TOTAL_SIZE_TANKMEM_DATA (0x100*4)
0315 #define A_TOTAL_SIZE_TANKMEM_ADDR (0x100*4)
0316 #define TOTAL_SIZE_CODE     (0x200*8)
0317 #define A_TOTAL_SIZE_CODE   (0x400*8)
0318 
0319 static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
0320                        void *file_private_data,
0321                        struct file *file, char __user *buf,
0322                        size_t count, loff_t pos)
0323 {
0324     struct snd_emu10k1 *emu = entry->private_data;
0325     unsigned int offset;
0326     int tram_addr = 0;
0327     unsigned int *tmp;
0328     long res;
0329     unsigned int idx;
0330     
0331     if (!strcmp(entry->name, "fx8010_tram_addr")) {
0332         offset = TANKMEMADDRREGBASE;
0333         tram_addr = 1;
0334     } else if (!strcmp(entry->name, "fx8010_tram_data")) {
0335         offset = TANKMEMDATAREGBASE;
0336     } else if (!strcmp(entry->name, "fx8010_code")) {
0337         offset = emu->audigy ? A_MICROCODEBASE : MICROCODEBASE;
0338     } else {
0339         offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
0340     }
0341 
0342     tmp = kmalloc(count + 8, GFP_KERNEL);
0343     if (!tmp)
0344         return -ENOMEM;
0345     for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
0346         unsigned int val;
0347         val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
0348         if (tram_addr && emu->audigy) {
0349             val >>= 11;
0350             val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
0351         }
0352         tmp[idx] = val;
0353     }
0354     if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
0355         res = -EFAULT;
0356     else
0357         res = count;
0358     kfree(tmp);
0359     return res;
0360 }
0361 
0362 static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry, 
0363                   struct snd_info_buffer *buffer)
0364 {
0365     struct snd_emu10k1 *emu = entry->private_data;
0366     struct snd_emu10k1_voice *voice;
0367     int idx;
0368     
0369     snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n");
0370     for (idx = 0; idx < NUM_G; idx++) {
0371         voice = &emu->voices[idx];
0372         snd_iprintf(buffer, "%i\t%i\t%i\t%i\t%i\t%i\n",
0373             idx,
0374             voice->use,
0375             voice->pcm,
0376             voice->efx,
0377             voice->synth,
0378             voice->midi);
0379     }
0380 }
0381 
0382 #ifdef CONFIG_SND_DEBUG
0383 static void snd_emu_proc_emu1010_reg_read(struct snd_info_entry *entry,
0384                      struct snd_info_buffer *buffer)
0385 {
0386     struct snd_emu10k1 *emu = entry->private_data;
0387     u32 value;
0388     int i;
0389     snd_iprintf(buffer, "EMU1010 Registers:\n\n");
0390 
0391     for(i = 0; i < 0x40; i+=1) {
0392         snd_emu1010_fpga_read(emu, i, &value);
0393         snd_iprintf(buffer, "%02X: %08X, %02X\n", i, value, (value >> 8) & 0x7f);
0394     }
0395 }
0396 
0397 static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry,
0398                      struct snd_info_buffer *buffer)
0399 {
0400     struct snd_emu10k1 *emu = entry->private_data;
0401     unsigned long value;
0402     unsigned long flags;
0403     int i;
0404     snd_iprintf(buffer, "IO Registers:\n\n");
0405     for(i = 0; i < 0x40; i+=4) {
0406         spin_lock_irqsave(&emu->emu_lock, flags);
0407         value = inl(emu->port + i);
0408         spin_unlock_irqrestore(&emu->emu_lock, flags);
0409         snd_iprintf(buffer, "%02X: %08lX\n", i, value);
0410     }
0411 }
0412 
0413 static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry,
0414                                       struct snd_info_buffer *buffer)
0415 {
0416     struct snd_emu10k1 *emu = entry->private_data;
0417     unsigned long flags;
0418     char line[64];
0419     u32 reg, val;
0420     while (!snd_info_get_line(buffer, line, sizeof(line))) {
0421         if (sscanf(line, "%x %x", &reg, &val) != 2)
0422             continue;
0423         if (reg < 0x40 && val <= 0xffffffff) {
0424             spin_lock_irqsave(&emu->emu_lock, flags);
0425             outl(val, emu->port + (reg & 0xfffffffc));
0426             spin_unlock_irqrestore(&emu->emu_lock, flags);
0427         }
0428     }
0429 }
0430 
0431 static unsigned int snd_ptr_read(struct snd_emu10k1 * emu,
0432                  unsigned int iobase,
0433                  unsigned int reg,
0434                  unsigned int chn)
0435 {
0436     unsigned long flags;
0437     unsigned int regptr, val;
0438 
0439     regptr = (reg << 16) | chn;
0440 
0441     spin_lock_irqsave(&emu->emu_lock, flags);
0442     outl(regptr, emu->port + iobase + PTR);
0443     val = inl(emu->port + iobase + DATA);
0444     spin_unlock_irqrestore(&emu->emu_lock, flags);
0445     return val;
0446 }
0447 
0448 static void snd_ptr_write(struct snd_emu10k1 *emu,
0449               unsigned int iobase,
0450               unsigned int reg,
0451               unsigned int chn,
0452               unsigned int data)
0453 {
0454     unsigned int regptr;
0455     unsigned long flags;
0456 
0457     regptr = (reg << 16) | chn;
0458 
0459     spin_lock_irqsave(&emu->emu_lock, flags);
0460     outl(regptr, emu->port + iobase + PTR);
0461     outl(data, emu->port + iobase + DATA);
0462     spin_unlock_irqrestore(&emu->emu_lock, flags);
0463 }
0464 
0465 
0466 static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry,
0467                       struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices)
0468 {
0469     struct snd_emu10k1 *emu = entry->private_data;
0470     unsigned long value;
0471     int i,j;
0472     if (offset+length > 0xa0) {
0473         snd_iprintf(buffer, "Input values out of range\n");
0474         return;
0475     }
0476     snd_iprintf(buffer, "Registers 0x%x\n", iobase);
0477     for(i = offset; i < offset+length; i++) {
0478         snd_iprintf(buffer, "%02X: ",i);
0479         for (j = 0; j < voices; j++) {
0480             if(iobase == 0)
0481                         value = snd_ptr_read(emu, 0, i, j);
0482             else
0483                         value = snd_ptr_read(emu, 0x20, i, j);
0484             snd_iprintf(buffer, "%08lX ", value);
0485         }
0486         snd_iprintf(buffer, "\n");
0487     }
0488 }
0489 
0490 static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry,
0491                        struct snd_info_buffer *buffer, int iobase)
0492 {
0493     struct snd_emu10k1 *emu = entry->private_data;
0494     char line[64];
0495     unsigned int reg, channel_id , val;
0496     while (!snd_info_get_line(buffer, line, sizeof(line))) {
0497         if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
0498             continue;
0499         if (reg < 0xa0 && val <= 0xffffffff && channel_id <= 3)
0500             snd_ptr_write(emu, iobase, reg, channel_id, val);
0501     }
0502 }
0503 
0504 static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry,
0505                      struct snd_info_buffer *buffer)
0506 {
0507     snd_emu_proc_ptr_reg_write(entry, buffer, 0);
0508 }
0509 
0510 static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry,
0511                      struct snd_info_buffer *buffer)
0512 {
0513     snd_emu_proc_ptr_reg_write(entry, buffer, 0x20);
0514 }
0515     
0516 
0517 static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry,
0518                      struct snd_info_buffer *buffer)
0519 {
0520     snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64);
0521 }
0522 
0523 static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry,
0524                      struct snd_info_buffer *buffer)
0525 {
0526     snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64);
0527 }
0528 
0529 static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry,
0530                      struct snd_info_buffer *buffer)
0531 {
0532     snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4);
0533 }
0534 
0535 static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry,
0536                      struct snd_info_buffer *buffer)
0537 {
0538     snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4);
0539 }
0540 
0541 static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry,
0542                      struct snd_info_buffer * buffer)
0543 {
0544     snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4);
0545 }
0546 #endif
0547 
0548 static const struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = {
0549     .read = snd_emu10k1_fx8010_read,
0550 };
0551 
0552 int snd_emu10k1_proc_init(struct snd_emu10k1 *emu)
0553 {
0554     struct snd_info_entry *entry;
0555 #ifdef CONFIG_SND_DEBUG
0556     if (emu->card_capabilities->emu_model) {
0557         snd_card_ro_proc_new(emu->card, "emu1010_regs",
0558                      emu, snd_emu_proc_emu1010_reg_read);
0559     }
0560     snd_card_rw_proc_new(emu->card, "io_regs", emu,
0561                  snd_emu_proc_io_reg_read,
0562                  snd_emu_proc_io_reg_write);
0563     snd_card_rw_proc_new(emu->card, "ptr_regs00a", emu,
0564                  snd_emu_proc_ptr_reg_read00a,
0565                  snd_emu_proc_ptr_reg_write00);
0566     snd_card_rw_proc_new(emu->card, "ptr_regs00b", emu,
0567                  snd_emu_proc_ptr_reg_read00b,
0568                  snd_emu_proc_ptr_reg_write00);
0569     snd_card_rw_proc_new(emu->card, "ptr_regs20a", emu,
0570                  snd_emu_proc_ptr_reg_read20a,
0571                  snd_emu_proc_ptr_reg_write20);
0572     snd_card_rw_proc_new(emu->card, "ptr_regs20b", emu,
0573                  snd_emu_proc_ptr_reg_read20b,
0574                  snd_emu_proc_ptr_reg_write20);
0575     snd_card_rw_proc_new(emu->card, "ptr_regs20c", emu,
0576                  snd_emu_proc_ptr_reg_read20c,
0577                  snd_emu_proc_ptr_reg_write20);
0578 #endif
0579     
0580     snd_card_ro_proc_new(emu->card, "emu10k1", emu, snd_emu10k1_proc_read);
0581 
0582     if (emu->card_capabilities->emu10k2_chip)
0583         snd_card_ro_proc_new(emu->card, "spdif-in", emu,
0584                      snd_emu10k1_proc_spdif_read);
0585     if (emu->card_capabilities->ca0151_chip)
0586         snd_card_ro_proc_new(emu->card, "capture-rates", emu,
0587                      snd_emu10k1_proc_rates_read);
0588 
0589     snd_card_ro_proc_new(emu->card, "voices", emu,
0590                  snd_emu10k1_proc_voices_read);
0591 
0592     if (! snd_card_proc_new(emu->card, "fx8010_gpr", &entry)) {
0593         entry->content = SNDRV_INFO_CONTENT_DATA;
0594         entry->private_data = emu;
0595         entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
0596         entry->size = emu->audigy ? A_TOTAL_SIZE_GPR : TOTAL_SIZE_GPR;
0597         entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
0598     }
0599     if (! snd_card_proc_new(emu->card, "fx8010_tram_data", &entry)) {
0600         entry->content = SNDRV_INFO_CONTENT_DATA;
0601         entry->private_data = emu;
0602         entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
0603         entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_DATA : TOTAL_SIZE_TANKMEM_DATA ;
0604         entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
0605     }
0606     if (! snd_card_proc_new(emu->card, "fx8010_tram_addr", &entry)) {
0607         entry->content = SNDRV_INFO_CONTENT_DATA;
0608         entry->private_data = emu;
0609         entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
0610         entry->size = emu->audigy ? A_TOTAL_SIZE_TANKMEM_ADDR : TOTAL_SIZE_TANKMEM_ADDR ;
0611         entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
0612     }
0613     if (! snd_card_proc_new(emu->card, "fx8010_code", &entry)) {
0614         entry->content = SNDRV_INFO_CONTENT_DATA;
0615         entry->private_data = emu;
0616         entry->mode = S_IFREG | 0444 /*| S_IWUSR*/;
0617         entry->size = emu->audigy ? A_TOTAL_SIZE_CODE : TOTAL_SIZE_CODE;
0618         entry->c.ops = &snd_emu10k1_proc_ops_fx8010;
0619     }
0620     snd_card_ro_proc_new(emu->card, "fx8010_acode", emu,
0621                  snd_emu10k1_proc_acode_read);
0622     return 0;
0623 }