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

📄 aedsp16.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*   drivers/sound/lowlevel/aedsp16.c   Audio Excel DSP 16 software configuration routines   Copyright (C) 1995,1996,1997,1998  Riccardo Facchetti (fizban@tin.it)   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* * Include the main OSS Lite header file. It include all the os, OSS Lite, etc * headers needed by this source. */#include <linux/config.h>#include <linux/delay.h>#include <linux/module.h>#include <linux/init.h>#include "sound_config.h"/* * Sanity checks */#if defined(CONFIG_SOUND_AEDSP16_SBPRO) && defined(CONFIG_SOUND_AEDSP16_MSS)#error You have to enable only one of the MSS and SBPRO emulations.#endif/*   READ THIS   This module started to configure the Audio Excel DSP 16 Sound Card.   Now works with the SC-6000 (old aedsp16) and new SC-6600 based cards.   NOTE: I have NO idea about Audio Excel DSP 16 III. If someone owns this   audio card and want to see the kernel support for it, please contact me.   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-DOS 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 DOS   driver.   This module works configuring your Audio Excel DSP 16's irq, dma and   mpu-401-irq. The OSS Lite 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 configured properly. 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   aedsp16_init_board()   routine is called before the OSS Lite probe routines try to detect the   hardware.   NOTE (READ THE NOTE TOO, IT CONTAIN USEFUL INFORMATIONS)   NOTE: Now it works with SC-6000 and SC-6600 based audio cards. The new cards   have no jumper switch at all. No more WSS or MPU-401 I/O port switches. They   have to be configured by software.   NOTE: The driver is merged with the new OSS Lite sound driver. It works   as a lowlevel driver.   The Audio Excel DSP 16 Sound Card emulates both SBPRO and MSS;   the OSS Lite 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]).   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.   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 OSS Lite package, configuring   the AEDSP16 sound card, then activating the SBPro emulation mode   and at last configuring IRQ and DMA.   Compile the kernel and run it.   NOTE: This means for SC-6000 cards 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. For SC-6600 cards you have no jumpers so you have   to set up your full card configuration in the make config.   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 BASE values 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 [2])   [1]       ---       Date: Mon, 29 Jul 1997 08:35:40 +0100       From: Mr S J Greenaway <sjg95@unixfe.rl.ac.uk>       [...]       Just to let you know got my Audio Excel (emulating a MSS) working       with my original SB16, thanks for the driver!       [...]       ---   [2] Not tested by me for lack of hardware.   TODO, WISHES AND TECH   - About I/O ports allocation -   Request the 2x0h region (port base) in any case if we are using this card.   NOTE: the "aedsp16 (base)" string with which we are requesting the aedsp16   port base region (see code) does not mean necessarily that we are emulating   sbpro.  Even if this 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 purposes.   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 aedsp16_init_board 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  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   - Rearrangements 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   v0.6   - removed the request_region()s when compiling the MODULE sound.o   because we are not allowed (by the actual voxware structure) to   release_region()   v0.7 (pre ALPHA, not distributed)   - started porting this module to kernel 1.3.84. Dummy probe/attach   routines.   v0.8 (ALPHA)   - attached all the init routines.   v0.9 (BETA)   - Integrated with linux-pre2.0.7   - Integrated with configuration scripts.   - Cleaned up and beautyfied the code.   v0.9.9 (BETA)   - Thanks to Piercarlo Grandi: corrected the conditonal compilation code.     Now only the code configured is compiled in, with some memory saving.   v0.9.10   - Integration into the sound/lowlevel/ section of the sound driver.   - Re-organized the code.   v0.9.11 (not distributed)   - Rewritten the init interface-routines to initialize the AEDSP16 in     one shot.   - More cosmetics.   - SC-6600 support.   - More soft/hard configuration.   v0.9.12   - Refined the v0.9.11 code with conditional compilation to distinguish     between SC-6000 and SC-6600 code.   v1.0.0   - Prep for merging with OSS Lite and Linux kernel 2.1.13   - Corrected a bug in request/check/release region calls (thanks to the     new kernel exception handling).   v1.1   - Revamped for integration with new modularized sound drivers: to enhance     the flexibility of modular version, I have removed all the conditional     compilation for SBPRO, MPU and MSS code. Now it is all managed with     the ae_config structure.   v1.2   - Module informations added.   - Removed aedsp16_delay_10msec(), now using mdelay(10)   - All data and funcs moved to .*.init section.   v1.3   Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/09/27   - got rid of check_region   Known Problems:   - Audio Excel DSP 16 III don't work with this driver.   Credits:   Many thanks to Gerald Britton <gbritton@CapAccess.org>. He helped me a   lot in testing the 0.9.11 and 0.9.12 versions of this driver. */#define VERSION "1.3"		/* Version of Audio Excel DSP 16 driver */#undef	AEDSP16_DEBUG 1		/* Define this to enable debug code     */#undef	AEDSP16_DEBUG_MORE 1	/* Define this to enable more debug     */#undef	AEDSP16_INFO  1		/* Define this to enable info code      */#if defined(AEDSP16_DEBUG)# define DBG(x)  printk x# if defined(AEDSP16_DEBUG_MORE)#  define DBG1(x) printk x# else#  define DBG1(x)# endif#else# define DBG(x)# define DBG1(x)#endif/* * Misc definitions */#define TRUE	1#define FALSE	0/* * Region Size for request/check/release region. */#define IOBASE_REGION_SIZE	0x10/* * Hardware related defaults */#define DEF_AEDSP16_IOB 0x220   /* 0x220(default) 0x240                 */#define DEF_AEDSP16_IRQ 7	/* 5 7(default) 9 10 11                 */#define DEF_AEDSP16_MRQ 0	/* 5 7 9 10 0(default), 0 means disable */#define DEF_AEDSP16_DMA 1	/* 0 1(default) 3                       *//* * Commands of AEDSP16's DSP (SBPRO+special). * Some of them are COMMAND_xx, in the future they may change. */#define WRITE_MDIRQ_CFG   0x50	/* Set M&I&DRQ mask (the real config)   */#define COMMAND_52        0x52	/*                                      */#define READ_HARD_CFG     0x58	/* Read Hardware Config (I/O base etc)  */#define COMMAND_5C        0x5c	/*                                      */#define COMMAND_60        0x60	/*                                      */#define COMMAND_66        0x66	/*                                      */#define COMMAND_6C        0x6c	/*                                      */#define COMMAND_6E        0x6e	/*                                      */#define COMMAND_88        0x88	/*                                      */#define DSP_INIT_MSS      0x8c	/* Enable Microsoft Sound System mode   */#define COMMAND_C5        0xc5	/*                                      */#define GET_DSP_VERSION   0xe1	/* Get DSP Version                      */#define GET_DSP_COPYRIGHT 0xe3	/* Get DSP Copyright                    *//* * Offsets of AEDSP16 DSP I/O ports. The offset is added to base I/O port * 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  */#if defined(CONFIG_SC6600)/* * Bitmapped flags of hard configuration *//* * Decode macros (xl == low byte, xh = high byte) */#define IOBASE(xl)		((xl & 0x01)?0x240:0x220)#define JOY(xl)  		(xl & 0x02)#define MPUADDR(xl)		( 			\				(xl & 0x0C)?0x330:	\				(xl & 0x08)?0x320:	\				(xl & 0x04)?0x310:	\						0x300)#define WSSADDR(xl)		((xl & 0x10)?0xE80:0x530)#define CDROM(xh)		(xh & 0x20)#define CDROMADDR(xh)		(((xh & 0x1F) << 4) + 0x200)/* * Encode macros */#define BLDIOBASE(xl, val) {		\	xl &= ~0x01; 			\	if (val == 0x240)		\		xl |= 0x01;		\	}#define BLDJOY(xl, val) {		\	xl &= ~0x02; 			\	if (val == 1)			\		xl |= 0x02;		\	}#define BLDMPUADDR(xl, val) {		\	xl &= ~0x0C;			\	switch (val) {			\		case 0x330:		\			xl |= 0x0C;	\			break;		\		case 0x320:		\			xl |= 0x08;	\			break;		\		case 0x310:		\			xl |= 0x04;	\			break;		\		case 0x300:		\			xl |= 0x00;	\			break;		\		default:		\			xl |= 0x00;	\			break;		\		}			\	}#define BLDWSSADDR(xl, val) {		\	xl &= ~0x10; 			\	if (val == 0xE80)		\		xl |= 0x10;		\	}#define BLDCDROM(xh, val) {		\	xh &= ~0x20; 			\	if (val == 1)			\		xh |= 0x20;		\	}#define BLDCDROMADDR(xh, val) {		\	int tmp = val;			\	tmp -= 0x200;			\	tmp >>= 4;			\	tmp &= 0x1F;			\	xh |= tmp;			\	xh &= 0x7F;			\	xh |= 0x40;			\	}#endif /* CONFIG_SC6600 *//* * Bit mapped flags for calling aedsp16_init_board(), 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)static int      soft_cfg __initdata = 0;	/* bitmapped config */static int      soft_cfg_mss __initdata = 0;	/* bitmapped mss config */static int      ver[CARDVERLEN] __initdata = {0, 0};	/* DSP Ver:						   hi->ver[0] lo->ver[1] */#if defined(CONFIG_SC6600)static int	hard_cfg[2]     /* lo<-hard_cfg[0] hi<-hard_cfg[1]      */                     __initdata = { 0, 0};#endif /* CONFIG_SC6600 */#if defined(CONFIG_SC6600)/* Decoded hard configuration */struct	d_hcfg {	int iobase;	int joystick;	int mpubase;	int wssbase;	int cdrom;	int cdrombase;};struct d_hcfg decoded_hcfg __initdata = {0, };#endif /* CONFIG_SC6600 *//* orVals contain the values to be or'ed       				*/struct orVals {	int	val;		/* irq|mirq|dma                         */	int	or;		/* soft_cfg |= TheStruct.or             */};/* aedsp16_info contain the audio card configuration                  */struct aedsp16_info {	int base_io;            /* base I/O address for accessing card  */	int irq;                /* irq value for DSP I/O                */	int mpu_irq;            /* irq for mpu401 interface I/O         */	int dma;                /* dma value for DSP I/O                */	int mss_base;           /* base I/O for Microsoft Sound System  */	int mpu_base;           /* base I/O for MPU-401 emulation       */	int init;               /* Initialization status of the card    */};

⌨️ 快捷键说明

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