4 Audio Excel DSP 16 software configuration routines
5 Copyright (C) 1995,1996,1997,1998 Riccardo Facchetti (fizban@tin.it)
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Include the main OSS Lite header file. It include all the os, OSS Lite, etc
24 * headers needed by this source.
26 #include <linux/delay.h>
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include "sound_config.h"
35 #if defined(CONFIG_SOUND_AEDSP16_SBPRO) && defined(CONFIG_SOUND_AEDSP16_MSS)
36 #error You have to enable only one of the MSS and SBPRO emulations.
43 This module started to configure the Audio Excel DSP 16 Sound Card.
44 Now works with the SC-6000 (old aedsp16) and new SC-6600 based cards.
46 NOTE: I have NO idea about Audio Excel DSP 16 III. If someone owns this
47 audio card and want to see the kernel support for it, please contact me.
49 Audio Excel DSP 16 is an SB pro II, Microsoft Sound System and MPU-401
51 It is software-only configurable (no jumpers to hard-set irq/dma/mpu-irq),
52 so before this module, the only way to configure the DSP under linux was
53 boot the MS-DOS loading the sound.sys device driver (this driver soft-
54 configure the sound board hardware by massaging someone of its registers),
55 and then ctrl-alt-del to boot linux with the DSP configured by the DOS
58 This module works configuring your Audio Excel DSP 16's irq, dma and
59 mpu-401-irq. The OSS Lite routines rely on the fact that if the
60 hardware is there, they can detect it. The problem with AEDSP16 is
61 that no hardware can be found by the probe routines if the sound card
62 is not configured properly. Sometimes the kernel probe routines can find
63 an SBPRO even when the card is not configured (this is the standard setup
64 of the card), but the SBPRO emulation don't work well if the card is not
65 properly initialized. For this reason
69 routine is called before the OSS Lite probe routines try to detect the
72 NOTE (READ THE NOTE TOO, IT CONTAIN USEFUL INFORMATIONS)
74 NOTE: Now it works with SC-6000 and SC-6600 based audio cards. The new cards
75 have no jumper switch at all. No more WSS or MPU-401 I/O port switches. They
76 have to be configured by software.
78 NOTE: The driver is merged with the new OSS Lite sound driver. It works
81 The Audio Excel DSP 16 Sound Card emulates both SBPRO and MSS;
82 the OSS Lite sound driver can be configured for SBPRO and MSS cards
83 at the same time, but the aedsp16 can't be two cards!!
84 When we configure it, we have to choose the SBPRO or the MSS emulation
85 for AEDSP16. We also can install a *REAL* card of the other type (see [1]).
87 NOTE: If someone can test the combination AEDSP16+MSS or AEDSP16+SBPRO
88 please let me know if it works.
90 The MPU-401 support can be compiled in together with one of the other
93 NOTE: This is something like plug-and-play: we have only to plug
94 the AEDSP16 board in the socket, and then configure and compile
95 a kernel that uses the AEDSP16 software configuration capability.
96 No jumper setting is needed!
98 For example, if you want AEDSP16 to be an SBPro, on irq 10, dma 3
99 you have just to make config the OSS Lite package, configuring
100 the AEDSP16 sound card, then activating the SBPro emulation mode
101 and at last configuring IRQ and DMA.
102 Compile the kernel and run it.
104 NOTE: This means for SC-6000 cards that you can choose irq and dma,
105 but not the I/O addresses. To change I/O addresses you have to set
106 them with jumpers. For SC-6600 cards you have no jumpers so you have
107 to set up your full card configuration in the make config.
109 You can change the irq/dma/mirq settings WITHOUT THE NEED to open
110 your computer and massage the jumpers (there are no irq/dma/mirq
111 jumpers to be configured anyway, only I/O BASE values have to be
112 configured with jumpers)
114 For some ununderstandable reason, the card default of irq 7, dma 1,
115 don't work for me. Seems to be an IRQ or DMA conflict. Under heavy
116 HDD work, the kernel start to erupt out a lot of messages like:
118 'Sound: DMA timed out - IRQ/DRQ config error?'
120 For what I can say, I have NOT any conflict at irq 7 (under linux I'm
121 using the lp polling driver), and dma line 1 is unused as stated by
122 /proc/dma. I can suppose this is a bug of AEDSP16. I know my hardware so
123 I'm pretty sure I have not any conflict, but may be I'm wrong. Who knows!
124 Anyway a setting of irq 10, dma 3 works really fine.
126 NOTE: if someone can use AEDSP16 with irq 7, dma 1, please let me know
127 the emulation mode, all the installed hardware and the hardware
128 configuration (irq and dma settings of all the hardware).
130 This init module should work with SBPRO+MSS, when one of the two is
131 the AEDSP16 emulation and the other the real card. (see [1])
134 AEDSP16 (0x220) in SBPRO emu (0x220) + real MSS + other
135 AEDSP16 (0x220) in MSS emu + real SBPRO (0x240) + other
137 MPU401 should work. (see [2])
141 Date: Mon, 29 Jul 1997 08:35:40 +0100
142 From: Mr S J Greenaway <sjg95@unixfe.rl.ac.uk>
145 Just to let you know got my Audio Excel (emulating a MSS) working
146 with my original SB16, thanks for the driver!
150 [2] Not tested by me for lack of hardware.
152 TODO, WISHES AND TECH
154 - About I/O ports allocation -
156 Request the 2x0h region (port base) in any case if we are using this card.
158 NOTE: the "aedsp16 (base)" string with which we are requesting the aedsp16
159 port base region (see code) does not mean necessarily that we are emulating
160 sbpro. Even if this region is the sbpro I/O ports region, we use this
161 region to access the control registers of the card, and if emulating
162 sbpro, I/O sbpro registers too. If we are emulating MSS, the sbpro
163 registers are not used, in no way, to emulate an sbpro: they are
164 used only for configuration purposes.
166 Started Fri Mar 17 16:13:18 MET 1995
168 v0.1 (ALPHA, was an user-level program called AudioExcelDSP16.c)
172 - Integrated with Linux voxware v 2.90-2 kernel sound driver.
173 - SoundBlaster Pro mode configuration.
174 - Microsoft Sound System mode configuration.
175 - MPU-401 mode configuration.
178 - Rearranged the code to let aedsp16_init_board be more general.
179 - Erased the REALLY_SLOW_IO. We don't need it. Erased the linux/io.h
180 inclusion too. We rely on os.h
181 - Used the to get a variable
182 len string (we are not sure about the len of Copyright string).
183 This works with any SB and compatible.
184 - Added the code to request_region at device init (should go in
185 the main body of voxware).
187 - Better configure.c patch for aedsp16 configuration (better
188 logic of inclusion of AEDSP16 support)
189 - Modified the conditional compilation to better support more than
190 one sound card of the emulated type (read the NOTES above)
191 - Moved the sb init routine from the attach to the very first
193 - Rearrangements and cleanups
194 - Wiped out some unnecessary code and variables: this is kernel
195 code so it is better save some TEXT and DATA
196 - Fixed the request_region code. We must allocate the aedsp16 (sbpro)
197 I/O ports in any case because they are used to access the DSP
198 configuration registers and we can not allow anyone to get them.
200 - cleanups on comments
201 - prep for diffs against v3.0-proto-950402
203 - removed the request_region()s when compiling the MODULE sound.o
204 because we are not allowed (by the actual voxware structure) to
206 v0.7 (pre ALPHA, not distributed)
207 - started porting this module to kernel 1.3.84. Dummy probe/attach
210 - attached all the init routines.
212 - Integrated with linux-pre2.0.7
213 - Integrated with configuration scripts.
214 - Cleaned up and beautyfied the code.
216 - Thanks to Piercarlo Grandi: corrected the conditonal compilation code.
217 Now only the code configured is compiled in, with some memory saving.
219 - Integration into the sound/lowlevel/ section of the sound driver.
220 - Re-organized the code.
221 v0.9.11 (not distributed)
222 - Rewritten the init interface-routines to initialize the AEDSP16 in
226 - More soft/hard configuration.
228 - Refined the v0.9.11 code with conditional compilation to distinguish
229 between SC-6000 and SC-6600 code.
231 - Prep for merging with OSS Lite and Linux kernel 2.1.13
232 - Corrected a bug in request/check/release region calls (thanks to the
233 new kernel exception handling).
235 - Revamped for integration with new modularized sound drivers: to enhance
236 the flexibility of modular version, I have removed all the conditional
237 compilation for SBPRO, MPU and MSS code. Now it is all managed with
238 the ae_config structure.
240 - Module informations added.
241 - Removed aedsp16_delay_10msec(), now using mdelay(10)
242 - All data and funcs moved to .*.init section.
244 Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/09/27
245 - got rid of check_region
248 - Audio Excel DSP 16 III don't work with this driver.
251 Many thanks to Gerald Britton <gbritton@CapAccess.org>. He helped me a
252 lot in testing the 0.9.11 and 0.9.12 versions of this driver.
257 #define VERSION "1.3" /* Version of Audio Excel DSP 16 driver */
259 #undef AEDSP16_DEBUG /* Define this to 1 to enable debug code */
260 #undef AEDSP16_DEBUG_MORE /* Define this to 1 to enable more debug */
261 #undef AEDSP16_INFO /* Define this to 1 to enable info code */
263 #if defined(AEDSP16_DEBUG)
264 # define DBG(x) printk x
265 # if defined(AEDSP16_DEBUG_MORE)
266 # define DBG1(x) printk x
282 * Region Size for request/check/release region.
284 #define IOBASE_REGION_SIZE 0x10
287 * Hardware related defaults
289 #define DEF_AEDSP16_IOB 0x220 /* 0x220(default) 0x240 */
290 #define DEF_AEDSP16_IRQ 7 /* 5 7(default) 9 10 11 */
291 #define DEF_AEDSP16_MRQ 0 /* 5 7 9 10 0(default), 0 means disable */
292 #define DEF_AEDSP16_DMA 1 /* 0 1(default) 3 */
295 * Commands of AEDSP16's DSP (SBPRO+special).
296 * Some of them are COMMAND_xx, in the future they may change.
298 #define WRITE_MDIRQ_CFG 0x50 /* Set M&I&DRQ mask (the real config) */
299 #define COMMAND_52 0x52 /* */
300 #define READ_HARD_CFG 0x58 /* Read Hardware Config (I/O base etc) */
301 #define COMMAND_5C 0x5c /* */
302 #define COMMAND_60 0x60 /* */
303 #define COMMAND_66 0x66 /* */
304 #define COMMAND_6C 0x6c /* */
305 #define COMMAND_6E 0x6e /* */
306 #define COMMAND_88 0x88 /* */
307 #define DSP_INIT_MSS 0x8c /* Enable Microsoft Sound System mode */
308 #define COMMAND_C5 0xc5 /* */
309 #define GET_DSP_VERSION 0xe1 /* Get DSP Version */
310 #define GET_DSP_COPYRIGHT 0xe3 /* Get DSP Copyright */
313 * Offsets of AEDSP16 DSP I/O ports. The offset is added to base I/O port
314 * to have the actual I/O port.
315 * Register permissions are:
321 #define DSP_RESET 0x06 /* offset of DSP RESET (wo) */
322 #define DSP_READ 0x0a /* offset of DSP READ (ro) */
323 #define DSP_WRITE 0x0c /* offset of DSP WRITE (w-) */
324 #define DSP_COMMAND 0x0c /* offset of DSP COMMAND (w-) */
325 #define DSP_STATUS 0x0c /* offset of DSP STATUS (r-) */
326 #define DSP_DATAVAIL 0x0e /* offset of DSP DATA AVAILABLE (ro) */
329 #define RETRY 10 /* Various retry values on I/O opera- */
330 #define STATUSRETRY 1000 /* tions. Sometimes we have to */
331 #define HARDRETRY 500000 /* wait for previous cmd to complete */
334 * Size of character arrays that store name and version of sound card
336 #define CARDNAMELEN 15 /* Size of the card's name in chars */
337 #define CARDVERLEN 2 /* Size of the card's version in chars */
339 #if defined(CONFIG_SC6600)
341 * Bitmapped flags of hard configuration
344 * Decode macros (xl == low byte, xh = high byte)
346 #define IOBASE(xl) ((xl & 0x01)?0x240:0x220)
347 #define JOY(xl) (xl & 0x02)
348 #define MPUADDR(xl) ( \
353 #define WSSADDR(xl) ((xl & 0x10)?0xE80:0x530)
354 #define CDROM(xh) (xh & 0x20)
355 #define CDROMADDR(xh) (((xh & 0x1F) << 4) + 0x200)
359 #define BLDIOBASE(xl, val) { \
364 #define BLDJOY(xl, val) { \
369 #define BLDMPUADDR(xl, val) { \
389 #define BLDWSSADDR(xl, val) { \
394 #define BLDCDROM(xh, val) { \
399 #define BLDCDROMADDR(xh, val) { \
408 #endif /* CONFIG_SC6600 */
411 * Bit mapped flags for calling aedsp16_init_board(), and saving the current
414 #define INIT_NONE (0 )
415 #define INIT_SBPRO (1<<0)
416 #define INIT_MSS (1<<1)
417 #define INIT_MPU401 (1<<2)
419 static int soft_cfg __initdata = 0; /* bitmapped config */
420 static int soft_cfg_mss __initdata = 0; /* bitmapped mss config */
421 static int ver[CARDVERLEN] __initdata = {0, 0}; /* DSP Ver:
422 hi->ver[0] lo->ver[1] */
424 #if defined(CONFIG_SC6600)
425 static int hard_cfg[2] /* lo<-hard_cfg[0] hi<-hard_cfg[1] */
426 __initdata = { 0, 0};
427 #endif /* CONFIG_SC6600 */
429 #if defined(CONFIG_SC6600)
430 /* Decoded hard configuration */
440 static struct d_hcfg decoded_hcfg __initdata = {0, };
442 #endif /* CONFIG_SC6600 */
444 /* orVals contain the values to be or'ed */
446 int val; /* irq|mirq|dma */
447 int or; /* soft_cfg |= TheStruct.or */
450 /* aedsp16_info contain the audio card configuration */
451 struct aedsp16_info {
452 int base_io; /* base I/O address for accessing card */
453 int irq; /* irq value for DSP I/O */
454 int mpu_irq; /* irq for mpu401 interface I/O */
455 int dma; /* dma value for DSP I/O */
456 int mss_base; /* base I/O for Microsoft Sound System */
457 int mpu_base; /* base I/O for MPU-401 emulation */
458 int init; /* Initialization status of the card */
462 * Magic values that the DSP will eat when configuring irq/mirq/dma
464 /* DSP IRQ conversion array */
465 static struct orVals orIRQ[] __initdata = {
474 /* MPU-401 IRQ conversion array */
475 static struct orVals orMIRQ[] __initdata = {
483 /* DMA Channels conversion array */
484 static struct orVals orDMA[] __initdata = {
491 static struct aedsp16_info ae_config = {
502 * Buffers to store audio card informations
504 static char DSPCopyright[CARDNAMELEN + 1] __initdata = {0, };
505 static char DSPVersion[CARDVERLEN + 1] __initdata = {0, };
507 static int __init aedsp16_wait_data(int port)
509 int loop = STATUSRETRY;
510 unsigned char ret = 0;
512 DBG1(("aedsp16_wait_data (0x%x): ", port));
515 ret = inb(port + DSP_DATAVAIL);
517 * Wait for data available (bit 7 of ret == 1)
519 } while (!(ret & 0x80) && loop--);
522 DBG1(("success.\n"));
526 DBG1(("failure.\n"));
530 static int __init aedsp16_read(int port)
534 DBG((" Read DSP Byte (0x%x): ", port));
536 if (aedsp16_wait_data(port) == FALSE) {
541 inbyte = inb(port + DSP_READ);
543 DBG(("read [0x%x]/{%c}.\n", inbyte, inbyte));
548 static int __init aedsp16_test_dsp(int port)
550 return ((aedsp16_read(port) == 0xaa) ? TRUE : FALSE);
553 static int __init aedsp16_dsp_reset(int port)
559 DBG(("Reset DSP:\n"));
561 outb(1, (port + DSP_RESET));
563 outb(0, (port + DSP_RESET));
566 if (aedsp16_test_dsp(port) == TRUE) {
574 static int __init aedsp16_write(int port, int cmd)
577 int loop = HARDRETRY;
579 DBG((" Write DSP Byte (0x%x) [0x%x]: ", port, cmd));
582 ret = inb(port + DSP_STATUS);
584 * DSP ready to receive data if bit 7 of ret == 0
587 outb(cmd, port + DSP_COMMAND);
594 printk("[AEDSP16] DSP Command (0x%x) timeout.\n", cmd);
599 #if defined(CONFIG_SC6600)
601 #if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)
602 void __init aedsp16_pinfo(void) {
603 DBG(("\n Base address: %x\n", decoded_hcfg.iobase));
604 DBG((" Joystick : %s present\n", decoded_hcfg.joystick?"":" not"));
605 DBG((" WSS addr : %x\n", decoded_hcfg.wssbase));
606 DBG((" MPU-401 addr: %x\n", decoded_hcfg.mpubase));
607 DBG((" CDROM : %s present\n", (decoded_hcfg.cdrom!=4)?"":" not"));
608 DBG((" CDROMADDR : %x\n\n", decoded_hcfg.cdrombase));
612 static void __init aedsp16_hard_decode(void) {
614 DBG((" aedsp16_hard_decode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));
619 decoded_hcfg.iobase = IOBASE(hard_cfg[0]);
620 decoded_hcfg.joystick = JOY(hard_cfg[0]);
621 decoded_hcfg.wssbase = WSSADDR(hard_cfg[0]);
622 decoded_hcfg.mpubase = MPUADDR(hard_cfg[0]);
623 decoded_hcfg.cdrom = CDROM(hard_cfg[1]);
624 decoded_hcfg.cdrombase = CDROMADDR(hard_cfg[1]);
626 #if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)
627 printk(" Original sound card configuration:\n");
632 * Now set up the real kernel configuration.
634 decoded_hcfg.iobase = ae_config.base_io;
635 decoded_hcfg.wssbase = ae_config.mss_base;
636 decoded_hcfg.mpubase = ae_config.mpu_base;
638 #if defined(CONFIG_SC6600_JOY)
639 decoded_hcfg.joystick = CONFIG_SC6600_JOY; /* Enable */
641 #if defined(CONFIG_SC6600_CDROM)
642 decoded_hcfg.cdrom = CONFIG_SC6600_CDROM; /* 4:N-3:I-2:G-1:P-0:S */
644 #if defined(CONFIG_SC6600_CDROMBASE)
645 decoded_hcfg.cdrombase = CONFIG_SC6600_CDROMBASE; /* 0 Disable */
648 #if defined(AEDSP16_DEBUG)
649 DBG((" New Values:\n"));
656 static void __init aedsp16_hard_encode(void) {
658 DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));
665 BLDIOBASE (hard_cfg[0], decoded_hcfg.iobase);
666 BLDWSSADDR(hard_cfg[0], decoded_hcfg.wssbase);
667 BLDMPUADDR(hard_cfg[0], decoded_hcfg.mpubase);
668 BLDJOY(hard_cfg[0], decoded_hcfg.joystick);
669 BLDCDROM(hard_cfg[1], decoded_hcfg.cdrom);
670 BLDCDROMADDR(hard_cfg[1], decoded_hcfg.cdrombase);
672 #if defined(AEDSP16_DEBUG)
676 DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));
681 static int __init aedsp16_hard_write(int port) {
683 DBG(("aedsp16_hard_write:\n"));
685 if (aedsp16_write(port, COMMAND_6C)) {
686 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6C);
690 if (aedsp16_write(port, COMMAND_5C)) {
691 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);
695 if (aedsp16_write(port, hard_cfg[0])) {
696 printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[0]);
700 if (aedsp16_write(port, hard_cfg[1])) {
701 printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[1]);
705 if (aedsp16_write(port, COMMAND_C5)) {
706 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_C5);
716 static int __init aedsp16_hard_read(int port) {
718 DBG(("aedsp16_hard_read:\n"));
720 if (aedsp16_write(port, READ_HARD_CFG)) {
721 printk("[AEDSP16] CMD 0x%x: failed!\n", READ_HARD_CFG);
726 if ((hard_cfg[0] = aedsp16_read(port)) == -1) {
727 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
732 if ((hard_cfg[1] = aedsp16_read(port)) == -1) {
733 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
738 if (aedsp16_read(port) == -1) {
739 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
750 static int __init aedsp16_ext_cfg_write(int port) {
754 if (aedsp16_write(port, COMMAND_66)) {
755 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_66);
760 if (decoded_hcfg.cdrom != 2)
762 if ((decoded_hcfg.cdrom == 4) ||
763 (decoded_hcfg.cdrom == 3))
765 if (decoded_hcfg.cdrombase == 0)
767 if (decoded_hcfg.mpubase == 0)
770 if (aedsp16_write(port, extcfg)) {
771 printk("[AEDSP16] Write extcfg: failed!\n");
774 if (aedsp16_write(port, 0)) {
775 printk("[AEDSP16] Write extcfg: failed!\n");
778 if (decoded_hcfg.cdrom == 3) {
779 if (aedsp16_write(port, COMMAND_52)) {
780 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52);
783 if ((val = aedsp16_read(port)) == -1) {
784 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n"
789 if (aedsp16_write(port, COMMAND_60)) {
790 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60);
793 if (aedsp16_write(port, val)) {
794 printk("[AEDSP16] Write val: failed!\n");
802 #endif /* CONFIG_SC6600 */
804 static int __init aedsp16_cfg_write(int port) {
805 if (aedsp16_write(port, WRITE_MDIRQ_CFG)) {
806 printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG);
809 if (aedsp16_write(port, soft_cfg)) {
810 printk("[AEDSP16] Initialization of (M)IRQ and DMA: failed!\n");
816 static int __init aedsp16_init_mss(int port)
818 DBG(("aedsp16_init_mss:\n"));
822 if (aedsp16_write(port, DSP_INIT_MSS)) {
823 printk("[AEDSP16] aedsp16_init_mss [0x%x]: failed!\n",
831 if (aedsp16_cfg_write(port) == FALSE)
834 outb(soft_cfg_mss, ae_config.mss_base);
841 static int __init aedsp16_setup_board(int port) {
844 #if defined(CONFIG_SC6600)
847 if (aedsp16_hard_read(port) == FALSE) {
848 printk("[AEDSP16] aedsp16_hard_read: failed!\n");
852 if (aedsp16_write(port, COMMAND_52)) {
853 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52);
857 if ((val = aedsp16_read(port)) == -1) {
858 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
865 if (aedsp16_write(port, COMMAND_88)) {
866 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_88);
870 } while ((aedsp16_wait_data(port) == FALSE) && loop--);
872 if (aedsp16_read(port) == -1) {
873 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
878 #if !defined(CONFIG_SC6600)
879 if (aedsp16_write(port, COMMAND_5C)) {
880 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);
885 if (aedsp16_cfg_write(port) == FALSE)
888 #if defined(CONFIG_SC6600)
889 if (aedsp16_write(port, COMMAND_60)) {
890 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60);
893 if (aedsp16_write(port, val)) {
894 printk("[AEDSP16] DATA 0x%x: failed!\n", val);
897 if (aedsp16_write(port, COMMAND_6E)) {
898 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6E);
901 if (aedsp16_write(port, ver[0])) {
902 printk("[AEDSP16] DATA 0x%x: failed!\n", ver[0]);
905 if (aedsp16_write(port, ver[1])) {
906 printk("[AEDSP16] DATA 0x%x: failed!\n", ver[1]);
910 if (aedsp16_hard_write(port) == FALSE) {
911 printk("[AEDSP16] aedsp16_hard_write: failed!\n");
915 if (aedsp16_write(port, COMMAND_5C)) {
916 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);
920 #if defined(THIS_IS_A_THING_I_HAVE_NOT_TESTED_YET)
921 if (aedsp16_cfg_write(port) == FALSE)
930 static int __init aedsp16_stdcfg(int port) {
931 if (aedsp16_write(port, WRITE_MDIRQ_CFG)) {
932 printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG);
936 * 0x0A == (IRQ 7, DMA 1, MIRQ 0)
938 if (aedsp16_write(port, 0x0A)) {
939 printk("[AEDSP16] aedsp16_stdcfg: failed!\n");
945 static int __init aedsp16_dsp_version(int port)
950 DBG(("Get DSP Version:\n"));
952 if (aedsp16_write(ae_config.base_io, GET_DSP_VERSION)) {
953 printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_VERSION);
959 if ((ret = aedsp16_read(port)) == -1) {
964 * We already know how many int are stored (2), so we know when the
965 * string is finished.
968 } while (len < CARDVERLEN);
969 sprintf(DSPVersion, "%d.%d", ver[0], ver[1]);
976 static int __init aedsp16_dsp_copyright(int port)
981 DBG(("Get DSP Copyright:\n"));
983 if (aedsp16_write(ae_config.base_io, GET_DSP_COPYRIGHT)) {
984 printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_COPYRIGHT);
990 if ((ret = aedsp16_read(port)) == -1) {
992 * If no more data available, return to the caller, no error if len>0.
993 * We have no other way to know when the string is finished.
1003 DSPCopyright[len++] = ret;
1005 } while (len < CARDNAMELEN);
1007 DBG(("success.\n"));
1012 static void __init aedsp16_init_tables(void)
1016 memset(DSPCopyright, 0, CARDNAMELEN + 1);
1017 memset(DSPVersion, 0, CARDVERLEN + 1);
1019 for (i = 0; orIRQ[i].or; i++)
1020 if (orIRQ[i].val == ae_config.irq) {
1021 soft_cfg |= orIRQ[i].or;
1022 soft_cfg_mss |= orIRQ[i].or;
1025 for (i = 0; orMIRQ[i].or; i++)
1026 if (orMIRQ[i].or == ae_config.mpu_irq)
1027 soft_cfg |= orMIRQ[i].or;
1029 for (i = 0; orDMA[i].or; i++)
1030 if (orDMA[i].val == ae_config.dma) {
1031 soft_cfg |= orDMA[i].or;
1032 soft_cfg_mss |= orDMA[i].or;
1036 static int __init aedsp16_init_board(void)
1038 aedsp16_init_tables();
1040 if (aedsp16_dsp_reset(ae_config.base_io) == FALSE) {
1041 printk("[AEDSP16] aedsp16_dsp_reset: failed!\n");
1044 if (aedsp16_dsp_copyright(ae_config.base_io) == FALSE) {
1045 printk("[AEDSP16] aedsp16_dsp_copyright: failed!\n");
1050 * My AEDSP16 card return SC-6000 in DSPCopyright, so
1051 * if we have something different, we have to be warned.
1053 if (strcmp("SC-6000", DSPCopyright))
1054 printk("[AEDSP16] Warning: non SC-6000 audio card!\n");
1056 if (aedsp16_dsp_version(ae_config.base_io) == FALSE) {
1057 printk("[AEDSP16] aedsp16_dsp_version: failed!\n");
1061 if (aedsp16_stdcfg(ae_config.base_io) == FALSE) {
1062 printk("[AEDSP16] aedsp16_stdcfg: failed!\n");
1066 #if defined(CONFIG_SC6600)
1067 if (aedsp16_hard_read(ae_config.base_io) == FALSE) {
1068 printk("[AEDSP16] aedsp16_hard_read: failed!\n");
1072 aedsp16_hard_decode();
1074 aedsp16_hard_encode();
1076 if (aedsp16_hard_write(ae_config.base_io) == FALSE) {
1077 printk("[AEDSP16] aedsp16_hard_write: failed!\n");
1081 if (aedsp16_ext_cfg_write(ae_config.base_io) == FALSE) {
1082 printk("[AEDSP16] aedsp16_ext_cfg_write: failed!\n");
1085 #endif /* CONFIG_SC6600 */
1087 if (aedsp16_setup_board(ae_config.base_io) == FALSE) {
1088 printk("[AEDSP16] aedsp16_setup_board: failed!\n");
1092 if (ae_config.mss_base != -1) {
1093 if (ae_config.init & INIT_MSS) {
1094 if (aedsp16_init_mss(ae_config.base_io) == FALSE) {
1095 printk("[AEDSP16] Can not initialize"
1096 "Microsoft Sound System mode.\n");
1102 #if !defined(MODULE) || defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)
1104 printk("Audio Excel DSP 16 init v%s (%s %s) [",
1105 VERSION, DSPCopyright,
1108 if (ae_config.mpu_base != -1) {
1109 if (ae_config.init & INIT_MPU401) {
1111 if ((ae_config.init & INIT_MSS) ||
1112 (ae_config.init & INIT_SBPRO))
1117 if (ae_config.mss_base == -1) {
1118 if (ae_config.init & INIT_SBPRO) {
1120 if (ae_config.init & INIT_MSS)
1125 if (ae_config.mss_base != -1)
1126 if (ae_config.init & INIT_MSS)
1130 #endif /* MODULE || AEDSP16_INFO || AEDSP16_DEBUG */
1137 static int __init init_aedsp16_sb(void)
1139 DBG(("init_aedsp16_sb: "));
1142 * If the card is already init'ed MSS, we can not init it to SBPRO too
1143 * because the board can not emulate simultaneously MSS and SBPRO.
1145 if (ae_config.init & INIT_MSS)
1147 if (ae_config.init & INIT_SBPRO)
1150 ae_config.init |= INIT_SBPRO;
1157 static void uninit_aedsp16_sb(void)
1159 DBG(("uninit_aedsp16_sb: "));
1161 ae_config.init &= ~INIT_SBPRO;
1166 static int __init init_aedsp16_mss(void)
1168 DBG(("init_aedsp16_mss: "));
1171 * If the card is already init'ed SBPRO, we can not init it to MSS too
1172 * because the board can not emulate simultaneously MSS and SBPRO.
1174 if (ae_config.init & INIT_SBPRO)
1176 if (ae_config.init & INIT_MSS)
1179 * We must allocate the CONFIG_AEDSP16_BASE region too because these are the
1180 * I/O ports to access card's control registers.
1182 if (!(ae_config.init & INIT_MPU401)) {
1183 if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE,
1184 "aedsp16 (base)")) {
1186 "AEDSP16 BASE I/O port region is already in use.\n");
1191 ae_config.init |= INIT_MSS;
1198 static void uninit_aedsp16_mss(void)
1200 DBG(("uninit_aedsp16_mss: "));
1202 if ((!(ae_config.init & INIT_MPU401)) &&
1203 (ae_config.init & INIT_MSS)) {
1204 release_region(ae_config.base_io, IOBASE_REGION_SIZE);
1205 DBG(("AEDSP16 base region released.\n"));
1208 ae_config.init &= ~INIT_MSS;
1212 static int __init init_aedsp16_mpu(void)
1214 DBG(("init_aedsp16_mpu: "));
1216 if (ae_config.init & INIT_MPU401)
1220 * We must request the CONFIG_AEDSP16_BASE region too because these are the I/O
1221 * ports to access card's control registers.
1223 if (!(ae_config.init & (INIT_MSS | INIT_SBPRO))) {
1224 if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE,
1225 "aedsp16 (base)")) {
1227 "AEDSP16 BASE I/O port region is already in use.\n");
1232 ae_config.init |= INIT_MPU401;
1239 static void uninit_aedsp16_mpu(void)
1241 DBG(("uninit_aedsp16_mpu: "));
1243 if ((!(ae_config.init & (INIT_MSS | INIT_SBPRO))) &&
1244 (ae_config.init & INIT_MPU401)) {
1245 release_region(ae_config.base_io, IOBASE_REGION_SIZE);
1246 DBG(("AEDSP16 base region released.\n"));
1249 ae_config.init &= ~INIT_MPU401;
1254 static int __init init_aedsp16(void)
1256 int initialized = FALSE;
1258 DBG(("Initializing BASE[0x%x] IRQ[%d] DMA[%d] MIRQ[%d]\n",
1259 ae_config.base_io,ae_config.irq,ae_config.dma,ae_config.mpu_irq));
1261 if (ae_config.mss_base == -1) {
1262 if (init_aedsp16_sb() == FALSE) {
1263 uninit_aedsp16_sb();
1269 if (ae_config.mpu_base != -1) {
1270 if (init_aedsp16_mpu() == FALSE) {
1271 uninit_aedsp16_mpu();
1278 * In the sequence of init routines, the MSS init MUST be the last!
1279 * This because of the special register programming the MSS mode needs.
1280 * A board reset would disable the MSS mode restoring the default SBPRO
1283 if (ae_config.mss_base != -1) {
1284 if (init_aedsp16_mss() == FALSE) {
1285 uninit_aedsp16_mss();
1292 initialized = aedsp16_init_board();
1296 static void __exit uninit_aedsp16(void)
1298 if (ae_config.mss_base != -1)
1299 uninit_aedsp16_mss();
1301 uninit_aedsp16_sb();
1302 if (ae_config.mpu_base != -1)
1303 uninit_aedsp16_mpu();
1306 static int __initdata io = -1;
1307 static int __initdata irq = -1;
1308 static int __initdata dma = -1;
1309 static int __initdata mpu_irq = -1;
1310 static int __initdata mss_base = -1;
1311 static int __initdata mpu_base = -1;
1313 module_param(io, int, 0);
1314 MODULE_PARM_DESC(io, "I/O base address (0x220 0x240)");
1315 module_param(irq, int, 0);
1316 MODULE_PARM_DESC(irq, "IRQ line (5 7 9 10 11)");
1317 module_param(dma, int, 0);
1318 MODULE_PARM_DESC(dma, "dma line (0 1 3)");
1319 module_param(mpu_irq, int, 0);
1320 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ line (5 7 9 10 0)");
1321 module_param(mss_base, int, 0);
1322 MODULE_PARM_DESC(mss_base, "MSS emulation I/O base address (0x530 0xE80)");
1323 module_param(mpu_base, int, 0);
1324 MODULE_PARM_DESC(mpu_base,"MPU-401 I/O base address (0x300 0x310 0x320 0x330)");
1325 MODULE_AUTHOR("Riccardo Facchetti <fizban@tin.it>");
1326 MODULE_DESCRIPTION("Audio Excel DSP 16 Driver Version " VERSION);
1327 MODULE_LICENSE("GPL");
1329 static int __init do_init_aedsp16(void) {
1330 printk("Audio Excel DSP 16 init driver Copyright (C) Riccardo Facchetti 1995-98\n");
1331 if (io == -1 || dma == -1 || irq == -1) {
1332 printk(KERN_INFO "aedsp16: I/O, IRQ and DMA are mandatory\n");
1336 ae_config.base_io = io;
1337 ae_config.irq = irq;
1338 ae_config.dma = dma;
1340 ae_config.mss_base = mss_base;
1341 ae_config.mpu_base = mpu_base;
1342 ae_config.mpu_irq = mpu_irq;
1344 if (init_aedsp16() == FALSE) {
1345 printk(KERN_ERR "aedsp16: initialization failed\n");
1348 * What error should we return here ?
1355 static void __exit cleanup_aedsp16(void) {
1359 module_init(do_init_aedsp16);
1360 module_exit(cleanup_aedsp16);
1363 static int __init setup_aedsp16(char *str)
1365 /* io, irq, dma, mss_io, mpu_io, mpu_irq */
1368 str = get_options(str, ARRAY_SIZE(ints), ints);
1379 __setup("aedsp16=", setup_aedsp16);