⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aedsp16.c

📁 freebsd v4.4内核源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*   sound/aedsp16.c   Audio Excel DSP 16 software configuration routines   Copyright (C) 1995  Riccardo Facchetti (riccardo@cdc8g5.cdc.polimi.it)   Redistribution and use in source and binary forms, with or without   modification, are permitted provided that the following conditions are   met: 1. Redistributions of source code must retain the above copyright   notice, this list of conditions and the following disclaimer. 2.   Redistributions in binary form must reproduce the above copyright notice,   this list of conditions and the following disclaimer in the documentation   and/or other materials provided with the distribution.   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE   DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   SUCH DAMAGE.   READ THIS   This module is intended for Audio Excel DSP 16 Sound Card.   Audio Excel DSP 16 is an SB pro II, Microsoft Sound System   and MPU-401 compatible card.   It is software-only configurable (no jumpers to hard-set irq/dma/mpu-irq),   so before this module, the only way to configure the DSP under linux was   boot the MS-BAU loading the sound.sys device driver (this driver soft-   configure the sound board hardware by massaging someone of its registers),   and then ctrl-alt-del to boot linux with the DSP configured by the DOG   driver.   This module works configuring your Audio Excel DSP 16's   irq, dma and mpu-401-irq. The voxware probe routines rely on the   fact that if the hardware is there, they can detect it. The problem   with AEDSP16 is that no hardware can be found by the probe routines   if the sound card is not well configured. Sometimes the kernel probe   routines can find an SBPRO even when the card is not configured (this   is the standard setup of the card), but the SBPRO emulation don't work   well if the card is not properly initialized. For this reason   InitAEDSP16_...()   routines are called before the voxware probe routines try to detect the   hardware.   NOTE (READ THE NOTE TOO, IT CONTAIN USEFUL INFORMATIONS)   The Audio Excel DSP 16 Sound Card emulates both SBPRO and MSS;   the voxware sound driver can be configured for SBPRO and MSS cards   at the same time, but the aedsp16 can't be two cards!!   When we configure it, we have to choose the SBPRO or the MSS emulation   for AEDSP16. We also can install a *REAL* card of the other type   (see [1], not tested but I can't see any reason for it to fail).   NOTE: If someone can test the combination AEDSP16+MSS or AEDSP16+SBPRO   please let me know if it works.   The MPU-401 support can be compiled in together with one of the other   two operating modes.   The board configuration calls, are in the probe_...() routines because   we have to configure the board before probing it for a particular   hardware. After card configuration, we can probe the hardware.   NOTE: This is something like plug-and-play: we have only to plug   the AEDSP16 board in the socket, and then configure and compile   a kernel that uses the AEDSP16 software configuration capability.   No jumper setting is needed!   For example, if you want AEDSP16 to be an SBPro, on irq 10, dma 3   you have just to make config the voxware package, configuring   the SBPro sound card with that parameters, then when configure   asks if you have an AEDSP16, answer yes. That's it.   Compile the kernel and run it.   NOTE: This means that you can choose irq and dma, but not the   I/O addresses. To change I/O addresses you have to set them   with jumpers.   NOTE: InitAEDSP16_...() routines get as parameter the hw_config,   the hardware configuration of the - to be configured - board.   The InitAEDSP16() routine, configure the board following our   wishes, that are in the hw_config structure.   You can change the irq/dma/mirq settings WITHOUT THE NEED to open   your computer and massage the jumpers (there are no irq/dma/mirq   jumpers to be configured anyway, only I/O port ones have to be   configured with jumpers)   For some ununderstandable reason, the card default of irq 7, dma 1,   don't work for me. Seems to be an IRQ or DMA conflict. Under heavy   HDD work, the kernel start to erupt out a lot of messages like:   'Sound: DMA timed out - IRQ/DRQ config error?'   For what I can say, I have NOT any conflict at irq 7 (under linux I'm   using the lp polling driver), and dma line 1 is unused as stated by   /proc/dma. I can suppose this is a bug of AEDSP16. I know my hardware so   I'm pretty sure I have not any conflict, but may be I'm wrong. Who knows!   Anyway a setting of irq 10, dma 3 works really fine.   NOTE: if someone can use AEDSP16 with irq 7, dma 1, please let me know   the emulation mode, all the installed hardware and the hardware   configuration (irq and dma settings of all the hardware).   This init module should work with SBPRO+MSS, when one of the two is   the AEDSP16 emulation and the other the real card. (see [1])   For example:   AEDSP16 (0x220) in SBPRO emu (0x220) + real MSS + other   AEDSP16 (0x220) in MSS emu + real SBPRO (0x240) + other   MPU401 should work. (see [1])   [1] Not tested by me for lack of hardware.   TODO, WISHES AND TECH   May be there's lot of redundant delays, but for now I want to leave it   this way.   Should be interesting eventually write down a new ioctl for the   aedsp16, to let the suser() change the irq/dma/mirq on the fly.   The thing is not trivial.   In the real world, there's no need to have such an ioctl because   when we configure the kernel for compile, we can choose the config   parameters. If we change our mind, we can easily re-config the kernel   and re-compile.   Why let the suser() change the config parameters on the fly ?   If anyone have a reasonable answer to this question, I will write down   the code to do it.   More integration with voxware, using voxware low level routines to   read-write dsp is not possible because you may want to have MSS   support and in that case we can not rely on the functions included   in sb_dsp.c to control 0x2yy I/O ports. I will continue to use my   own I/O functions.   - About I/O ports allocation -   The request_region should be done at device probe in every sound card   module. This module is not the best site for requesting regions.   When the request_region code will be added to the main modules such as   sb, adlib, gus, ad1848, etc, the requesting code in this module should   go away.   I think the request regions should be done this way:   if (check_region(...))   return ERR; // I/O region alredy reserved   device_probe(...);   device_attach(...);   request_region(...); // reserve only when we are sure all is okay   Request the 2x0h region in any case if we are using this card.   NOTE: the "(sbpro)" string with which we are requesting the aedsp16 region   (see code) does not mean necessarly that we are emulating sbpro.   It mean that the region is the sbpro I/O ports region. We use this   region to access the control registers of the card, and if emulating   sbpro, I/O sbpro registers too. If we are emulating MSS, the sbpro   registers are not used, in no way, to emulate an sbpro: they are   used only for configuration pourposes.   Someone pointed out that should be possible use both the SBPRO and MSS   modes because the sound card have all the two chipsets, supposing that   the card is really two cards. I have tried something to have the two   modes work together, but, for some reason unknown to me, without success.   I think all the soft-config only cards have an init sequence similar to   this. If you have a card that is not an aedsp16, you can try to start   with this module changing it (mainly in the CMD? I think) to fit your   needs.   Started Fri Mar 17 16:13:18 MET 1995   v0.1 (ALPHA, was an user-level program called AudioExcelDSP16.c)   - Initial code.   v0.2 (ALPHA)   - Cleanups.   - Integrated with Linux voxware v 2.90-2 kernel sound driver.   - SoundBlaster Pro mode configuration.   - Microsoft Sound System mode configuration.   - MPU-401 mode configuration.   v0.3 (ALPHA)   - Cleanups.   - Rearranged the code to let InitAEDSP16 be more general.   - Erased the REALLY_SLOW_IO. We don't need it. Erased the linux/io.h   inclusion too. We rely on os.h   - Used the INB and OUTB #defined in os.h instead of inb and outb.   - Corrected the code for GetCardName (DSP Copyright) to get a variable   len string (we are not sure about the len of Copyright string).   This works with any SB and compatible.   - Added the code to request_region at device init (should go in   the main body of voxware).   v0.4 (BETA)   - Better configure.c patch for aedsp16 configuration (better   logic of inclusion of AEDSP16 support)   - Modified the conditional compilation to better support more than   one sound card of the emulated type (read the NOTES above)   - Moved the sb init routine from the attach to the very first   probe in sb_card.c   - Rearrangemens and cleanups   - Wiped out some unnecessary code and variables: this is kernel   code so it is better save some TEXT and DATA   - Fixed the request_region code. We must allocate the aedsp16 (sbpro)   I/O ports in any case because they are used to access the DSP   configuration registers and we can not allow anyone to get them.   v0.5   - cleanups on comments   - prep for diffs against v3.0-proto-950402 *//* * Include the main voxware header file. It include all the os/voxware/etc * headers needed by this source. */#include <i386/isa/sound/sound_config.h>/* * all but ioport.h :) */#include <linux/ioport.h>#if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_AEDSP16)#define VERSION "0.5"		/* Version of Audio Excel DSP 16 driver */#undef AEDSP16_DEBUG		/* Define this to enable debug code     *//* Actually no debug code is activated  *//* * Hardware related defaults */#define IRQ  7			/* 5 7(default) 9 10 11                 */#define MIRQ 0			/* 5 7 9 10 0(default), 0 means disable */#define DMA  1			/* 0 1(default) 3                       *//* * Commands of AEDSP16's DSP (SBPRO+special). * For now they are CMDn, in the future they may change. */#define CMD1 0xe3		/* Get DSP Copyright                    */#define CMD2 0xe1		/* Get DSP Version                      */#define CMD3 0x88		/*                                      */#define CMD4 0x5c		/*                                      */#define CMD5 0x50		/* Set M&I&DRQ mask (the real config)   */#define CMD6 0x8c		/* Enable Microsoft Sound System mode   *//* * Offsets of AEDSP16 DSP I/O ports. The offest is added to portbase * to have the actual I/O port. * Register permissions are: * (wo) == Write Only * (ro) == Read  Only * (w-) == Write * (r-) == Read */#define DSP_RESET    0x06	/* offset of DSP RESET             (wo) */#define DSP_READ     0x0a	/* offset of DSP READ              (ro) */#define DSP_WRITE    0x0c	/* offset of DSP WRITE             (w-) */#define DSP_COMMAND  0x0c	/* offset of DSP COMMAND           (w-) */#define DSP_STATUS   0x0c	/* offset of DSP STATUS            (r-) */#define DSP_DATAVAIL 0x0e	/* offset of DSP DATA AVAILABLE    (ro) */#define RETRY           10	/* Various retry values on I/O opera-   */#define STATUSRETRY   1000	/* tions. Sometimes we have to          */#define HARDRETRY   500000	/* wait for previous cmd to complete    *//* * Size of character arrays that store name and version of sound card */#define CARDNAMELEN 15		/* Size of the card's name in chars     */#define CARDVERLEN  2		/* Size of the card's version in chars  *//* * Bit mapped flags for calling InitAEDSP16(), and saving the current * emulation mode. */#define INIT_NONE   (0   )#define INIT_SBPRO  (1<<0)#define INIT_MSS    (1<<1)#define INIT_MPU401 (1<<2)#define RESET_DSP16 (1<<3)/* Base HW Port for Audio Card          */static int      portbase = AEDSP16_BASE;static int      irq = IRQ;	/* irq for DSP I/O                      */static int      mirq = MIRQ;	/* irq for MPU-401 I/O                  */static int      dma = DMA;	/* dma for DSP I/O                      *//* Init status of the card              */static int      ae_init = INIT_NONE;	/* (bitmapped variable)                 */static int      oredparams = 0;	/* Will contain or'ed values of params  */static int      gc = 0;		/* generic counter (utility counter)    */struct orVals  {				/* Contain the values to be or'ed       */    int             val;	/* irq|mirq|dma                         */    int             or;		/* oredparams |= TheStruct.or           */  };/* * Magic values that the DSP will eat when configuring irq/mirq/dma *//* DSP IRQ conversion array             */static struct orVals orIRQ[] ={  {0x05, 0x28},  {0x07, 0x08},  {0x09, 0x10},  {0x0a, 0x18},  {0x0b, 0x20},  {0x00, 0x00}};/* MPU-401 IRQ conversion array         */static struct orVals orMIRQ[] ={  {0x05, 0x04},  {0x07, 0x44},  {0x09, 0x84},  {0x0a, 0xc4},  {0x00, 0x00}};/* DMA Channels conversion array        */static struct orVals orDMA[] ={  {0x00, 0x01},  {0x01, 0x02},  {0x03, 0x03},  {0x00, 0x00}};/* * Buffers to store audio card informations */static char     AudioExcelName[CARDNAMELEN + 1];static char     AudioExcelVersion[CARDVERLEN + 1];static voidtenmillisec (void){  for (gc = 0; gc < 1000; gc++)    tenmicrosec ();}static intWaitForDataAvail (int port){  int             loop = STATUSRETRY;  unsigned char   ret = 0;  do    {      ret = INB (port + DSP_DATAVAIL);      /*         * Wait for data available (bit 7 of ret == 1)       */    }  while (!(ret & 0x80) && loop--);  if (ret & 0x80)    return 0;  return -1;}static intReadData (int port){  if (WaitForDataAvail (port))    return -1;  return INB (port + DSP_READ);}static intCheckDSPOkay (int port){  return ((ReadData (port) == 0xaa) ? 0 : -1);}static intResetBoard (int port){  /*     * Reset DSP   */  OUTB (1, (port + DSP_RESET));  tenmicrosec ();  OUTB (0, (port + DSP_RESET));  tenmicrosec ();  tenmicrosec ();  return CheckDSPOkay (port);}static intWriteDSPCommand (int port, int cmd){  unsigned char   ret;  int             loop = HARDRETRY;  do    {      ret = INB (port + DSP_STATUS);      /*         * DSP ready to receive data if bit 7 of ret == 0       */      if (!(ret & 0x80))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -