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/config.h>
27 #include <linux/delay.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include "sound_config.h"
36 #if defined(CONFIG_SOUND_AEDSP16_SBPRO) && defined(CONFIG_SOUND_AEDSP16_MSS)
37 #error You have to enable only one of the MSS and SBPRO emulations.
44 This module started to configure the Audio Excel DSP 16 Sound Card.
45 Now works with the SC-6000 (old aedsp16) and new SC-6600 based cards.
47 NOTE: I have NO idea about Audio Excel DSP 16 III. If someone owns this
48 audio card and want to see the kernel support for it, please contact me.
50 Audio Excel DSP 16 is an SB pro II, Microsoft Sound System and MPU-401
52 It is software-only configurable (no jumpers to hard-set irq/dma/mpu-irq),
53 so before this module, the only way to configure the DSP under linux was
54 boot the MS-DOS loading the sound.sys device driver (this driver soft-
55 configure the sound board hardware by massaging someone of its registers),
56 and then ctrl-alt-del to boot linux with the DSP configured by the DOS
59 This module works configuring your Audio Excel DSP 16's irq, dma and
60 mpu-401-irq. The OSS Lite routines rely on the fact that if the
61 hardware is there, they can detect it. The problem with AEDSP16 is
62 that no hardware can be found by the probe routines if the sound card
63 is not configured properly. Sometimes the kernel probe routines can find
64 an SBPRO even when the card is not configured (this is the standard setup
65 of the card), but the SBPRO emulation don't work well if the card is not
66 properly initialized. For this reason
70 routine is called before the OSS Lite probe routines try to detect the
73 NOTE (READ THE NOTE TOO, IT CONTAIN USEFUL INFORMATIONS)
75 NOTE: Now it works with SC-6000 and SC-6600 based audio cards. The new cards
76 have no jumper switch at all. No more WSS or MPU-401 I/O port switches. They
77 have to be configured by software.
79 NOTE: The driver is merged with the new OSS Lite sound driver. It works
82 The Audio Excel DSP 16 Sound Card emulates both SBPRO and MSS;
83 the OSS Lite sound driver can be configured for SBPRO and MSS cards
84 at the same time, but the aedsp16 can't be two cards!!
85 When we configure it, we have to choose the SBPRO or the MSS emulation
86 for AEDSP16. We also can install a *REAL* card of the other type (see [1]).
88 NOTE: If someone can test the combination AEDSP16+MSS or AEDSP16+SBPRO
89 please let me know if it works.
91 The MPU-401 support can be compiled in together with one of the other
94 NOTE: This is something like plug-and-play: we have only to plug
95 the AEDSP16 board in the socket, and then configure and compile
96 a kernel that uses the AEDSP16 software configuration capability.
97 No jumper setting is needed!
99 For example, if you want AEDSP16 to be an SBPro, on irq 10, dma 3
100 you have just to make config the OSS Lite package, configuring
101 the AEDSP16 sound card, then activating the SBPro emulation mode
102 and at last configuring IRQ and DMA.
103 Compile the kernel and run it.
105 NOTE: This means for SC-6000 cards that you can choose irq and dma,
106 but not the I/O addresses. To change I/O addresses you have to set
107 them with jumpers. For SC-6600 cards you have no jumpers so you have
108 to set up your full card configuration in the make config.
110 You can change the irq/dma/mirq settings WITHOUT THE NEED to open
111 your computer and massage the jumpers (there are no irq/dma/mirq
112 jumpers to be configured anyway, only I/O BASE values have to be
113 configured with jumpers)
115 For some ununderstandable reason, the card default of irq 7, dma 1,
116 don't work for me. Seems to be an IRQ or DMA conflict. Under heavy
117 HDD work, the kernel start to erupt out a lot of messages like:
119 'Sound: DMA timed out - IRQ/DRQ config error?'
121 For what I can say, I have NOT any conflict at irq 7 (under linux I'm
122 using the lp polling driver), and dma line 1 is unused as stated by
123 /proc/dma. I can suppose this is a bug of AEDSP16. I know my hardware so
124 I'm pretty sure I have not any conflict, but may be I'm wrong. Who knows!
125 Anyway a setting of irq 10, dma 3 works really fine.
127 NOTE: if someone can use AEDSP16 with irq 7, dma 1, please let me know
128 the emulation mode, all the installed hardware and the hardware
129 configuration (irq and dma settings of all the hardware).
131 This init module should work with SBPRO+MSS, when one of the two is
132 the AEDSP16 emulation and the other the real card. (see [1])
135 AEDSP16 (0x220) in SBPRO emu (0x220) + real MSS + other
136 AEDSP16 (0x220) in MSS emu + real SBPRO (0x240) + other
138 MPU401 should work. (see [2])
142 Date: Mon, 29 Jul 1997 08:35:40 +0100
143 From: Mr S J Greenaway <sjg95@unixfe.rl.ac.uk>
146 Just to let you know got my Audio Excel (emulating a MSS) working
147 with my original SB16, thanks for the driver!
151 [2] Not tested by me for lack of hardware.
153 TODO, WISHES AND TECH
155 - About I/O ports allocation -
157 Request the 2x0h region (port base) in any case if we are using this card.
159 NOTE: the "aedsp16 (base)" string with which we are requesting the aedsp16
160 port base region (see code) does not mean necessarily that we are emulating
161 sbpro. Even if this region is the sbpro I/O ports region, we use this
162 region to access the control registers of the card, and if emulating
163 sbpro, I/O sbpro registers too. If we are emulating MSS, the sbpro
164 registers are not used, in no way, to emulate an sbpro: they are
165 used only for configuration purposes.
167 Started Fri Mar 17 16:13:18 MET 1995
169 v0.1 (ALPHA, was an user-level program called AudioExcelDSP16.c)
173 - Integrated with Linux voxware v 2.90-2 kernel sound driver.
174 - SoundBlaster Pro mode configuration.
175 - Microsoft Sound System mode configuration.
176 - MPU-401 mode configuration.
179 - Rearranged the code to let aedsp16_init_board be more general.
180 - Erased the REALLY_SLOW_IO. We don't need it. Erased the linux/io.h
181 inclusion too. We rely on os.h
182 - Used the to get a variable
183 len string (we are not sure about the len of Copyright string).
184 This works with any SB and compatible.
185 - Added the code to request_region at device init (should go in
186 the main body of voxware).
188 - Better configure.c patch for aedsp16 configuration (better
189 logic of inclusion of AEDSP16 support)
190 - Modified the conditional compilation to better support more than
191 one sound card of the emulated type (read the NOTES above)
192 - Moved the sb init routine from the attach to the very first
194 - Rearrangements and cleanups
195 - Wiped out some unnecessary code and variables: this is kernel
196 code so it is better save some TEXT and DATA
197 - Fixed the request_region code. We must allocate the aedsp16 (sbpro)
198 I/O ports in any case because they are used to access the DSP
199 configuration registers and we can not allow anyone to get them.
201 - cleanups on comments
202 - prep for diffs against v3.0-proto-950402
204 - removed the request_region()s when compiling the MODULE sound.o
205 because we are not allowed (by the actual voxware structure) to
207 v0.7 (pre ALPHA, not distributed)
208 - started porting this module to kernel 1.3.84. Dummy probe/attach
211 - attached all the init routines.
213 - Integrated with linux-pre2.0.7
214 - Integrated with configuration scripts.
215 - Cleaned up and beautyfied the code.
217 - Thanks to Piercarlo Grandi: corrected the conditonal compilation code.
218 Now only the code configured is compiled in, with some memory saving.
220 - Integration into the sound/lowlevel/ section of the sound driver.
221 - Re-organized the code.
222 v0.9.11 (not distributed)
223 - Rewritten the init interface-routines to initialize the AEDSP16 in
227 - More soft/hard configuration.
229 - Refined the v0.9.11 code with conditional compilation to distinguish
230 between SC-6000 and SC-6600 code.
232 - Prep for merging with OSS Lite and Linux kernel 2.1.13
233 - Corrected a bug in request/check/release region calls (thanks to the
234 new kernel exception handling).
236 - Revamped for integration with new modularized sound drivers: to enhance
237 the flexibility of modular version, I have removed all the conditional
238 compilation for SBPRO, MPU and MSS code. Now it is all managed with
239 the ae_config structure.
241 - Module informations added.
242 - Removed aedsp16_delay_10msec(), now using mdelay(10)
243 - All data and funcs moved to .*.init section.
245 Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/09/27
246 - got rid of check_region
249 - Audio Excel DSP 16 III don't work with this driver.
252 Many thanks to Gerald Britton <gbritton@CapAccess.org>. He helped me a
253 lot in testing the 0.9.11 and 0.9.12 versions of this driver.
258 #define VERSION "1.3" /* Version of Audio Excel DSP 16 driver */
260 #undef AEDSP16_DEBUG /* Define this to 1 to enable debug code */
261 #undef AEDSP16_DEBUG_MORE /* Define this to 1 to enable more debug */
262 #undef AEDSP16_INFO /* Define this to 1 to enable info code */
264 #if defined(AEDSP16_DEBUG)
265 # define DBG(x) printk x
266 # if defined(AEDSP16_DEBUG_MORE)
267 # define DBG1(x) printk x
283 * Region Size for request/check/release region.
285 #define IOBASE_REGION_SIZE 0x10
288 * Hardware related defaults
290 #define DEF_AEDSP16_IOB 0x220 /* 0x220(default) 0x240 */
291 #define DEF_AEDSP16_IRQ 7 /* 5 7(default) 9 10 11 */
292 #define DEF_AEDSP16_MRQ 0 /* 5 7 9 10 0(default), 0 means disable */
293 #define DEF_AEDSP16_DMA 1 /* 0 1(default) 3 */
296 * Commands of AEDSP16's DSP (SBPRO+special).
297 * Some of them are COMMAND_xx, in the future they may change.
299 #define WRITE_MDIRQ_CFG 0x50 /* Set M&I&DRQ mask (the real config) */
300 #define COMMAND_52 0x52 /* */
301 #define READ_HARD_CFG 0x58 /* Read Hardware Config (I/O base etc) */
302 #define COMMAND_5C 0x5c /* */
303 #define COMMAND_60 0x60 /* */
304 #define COMMAND_66 0x66 /* */
305 #define COMMAND_6C 0x6c /* */
306 #define COMMAND_6E 0x6e /* */
307 #define COMMAND_88 0x88 /* */
308 #define DSP_INIT_MSS 0x8c /* Enable Microsoft Sound System mode */
309 #define COMMAND_C5 0xc5 /* */
310 #define GET_DSP_VERSION 0xe1 /* Get DSP Version */
311 #define GET_DSP_COPYRIGHT 0xe3 /* Get DSP Copyright */
314 * Offsets of AEDSP16 DSP I/O ports. The offset is added to base I/O port
315 * to have the actual I/O port.
316 * Register permissions are:
322 #define DSP_RESET 0x06 /* offset of DSP RESET (wo) */
323 #define DSP_READ 0x0a /* offset of DSP READ (ro) */
324 #define DSP_WRITE 0x0c /* offset of DSP WRITE (w-) */
325 #define DSP_COMMAND 0x0c /* offset of DSP COMMAND (w-) */
326 #define DSP_STATUS 0x0c /* offset of DSP STATUS (r-) */
327 #define DSP_DATAVAIL 0x0e /* offset of DSP DATA AVAILABLE (ro) */
330 #define RETRY 10 /* Various retry values on I/O opera- */
331 #define STATUSRETRY 1000 /* tions. Sometimes we have to */
332 #define HARDRETRY 500000 /* wait for previous cmd to complete */
335 * Size of character arrays that store name and version of sound card
337 #define CARDNAMELEN 15 /* Size of the card's name in chars */
338 #define CARDVERLEN 2 /* Size of the card's version in chars */
340 #if defined(CONFIG_SC6600)
342 * Bitmapped flags of hard configuration
345 * Decode macros (xl == low byte, xh = high byte)
347 #define IOBASE(xl) ((xl & 0x01)?0x240:0x220)
348 #define JOY(xl) (xl & 0x02)
349 #define MPUADDR(xl) ( \
354 #define WSSADDR(xl) ((xl & 0x10)?0xE80:0x530)
355 #define CDROM(xh) (xh & 0x20)
356 #define CDROMADDR(xh) (((xh & 0x1F) << 4) + 0x200)
360 #define BLDIOBASE(xl, val) { \
365 #define BLDJOY(xl, val) { \
370 #define BLDMPUADDR(xl, val) { \
390 #define BLDWSSADDR(xl, val) { \
395 #define BLDCDROM(xh, val) { \
400 #define BLDCDROMADDR(xh, val) { \
409 #endif /* CONFIG_SC6600 */
412 * Bit mapped flags for calling aedsp16_init_board(), and saving the current
415 #define INIT_NONE (0 )
416 #define INIT_SBPRO (1<<0)
417 #define INIT_MSS (1<<1)
418 #define INIT_MPU401 (1<<2)
420 static int soft_cfg __initdata = 0; /* bitmapped config */
421 static int soft_cfg_mss __initdata = 0; /* bitmapped mss config */
422 static int ver[CARDVERLEN] __initdata = {0, 0}; /* DSP Ver:
423 hi->ver[0] lo->ver[1] */
425 #if defined(CONFIG_SC6600)
426 static int hard_cfg[2] /* lo<-hard_cfg[0] hi<-hard_cfg[1] */
427 __initdata = { 0, 0};
428 #endif /* CONFIG_SC6600 */
430 #if defined(CONFIG_SC6600)
431 /* Decoded hard configuration */
441 static struct d_hcfg decoded_hcfg __initdata = {0, };
443 #endif /* CONFIG_SC6600 */
445 /* orVals contain the values to be or'ed */
447 int val; /* irq|mirq|dma */
448 int or; /* soft_cfg |= TheStruct.or */
451 /* aedsp16_info contain the audio card configuration */
452 struct aedsp16_info {
453 int base_io; /* base I/O address for accessing card */
454 int irq; /* irq value for DSP I/O */
455 int mpu_irq; /* irq for mpu401 interface I/O */
456 int dma; /* dma value for DSP I/O */
457 int mss_base; /* base I/O for Microsoft Sound System */
458 int mpu_base; /* base I/O for MPU-401 emulation */
459 int init; /* Initialization status of the card */
463 * Magic values that the DSP will eat when configuring irq/mirq/dma
465 /* DSP IRQ conversion array */
466 static struct orVals orIRQ[] __initdata = {
475 /* MPU-401 IRQ conversion array */
476 static struct orVals orMIRQ[] __initdata = {
484 /* DMA Channels conversion array */
485 static struct orVals orDMA[] __initdata = {
492 static struct aedsp16_info ae_config = {
503 * Buffers to store audio card informations
505 static char DSPCopyright[CARDNAMELEN + 1] __initdata = {0, };
506 static char DSPVersion[CARDVERLEN + 1] __initdata = {0, };
508 static int __init aedsp16_wait_data(int port)
510 int loop = STATUSRETRY;
511 unsigned char ret = 0;
513 DBG1(("aedsp16_wait_data (0x%x): ", port));
516 ret = inb(port + DSP_DATAVAIL);
518 * Wait for data available (bit 7 of ret == 1)
520 } while (!(ret & 0x80) && loop--);
523 DBG1(("success.\n"));
527 DBG1(("failure.\n"));
531 static int __init aedsp16_read(int port)
535 DBG((" Read DSP Byte (0x%x): ", port));
537 if (aedsp16_wait_data(port) == FALSE) {
542 inbyte = inb(port + DSP_READ);
544 DBG(("read [0x%x]/{%c}.\n", inbyte, inbyte));
549 static int __init aedsp16_test_dsp(int port)
551 return ((aedsp16_read(port) == 0xaa) ? TRUE : FALSE);
554 static int __init aedsp16_dsp_reset(int port)
560 DBG(("Reset DSP:\n"));
562 outb(1, (port + DSP_RESET));
564 outb(0, (port + DSP_RESET));
567 if (aedsp16_test_dsp(port) == TRUE) {
575 static int __init aedsp16_write(int port, int cmd)
578 int loop = HARDRETRY;
580 DBG((" Write DSP Byte (0x%x) [0x%x]: ", port, cmd));
583 ret = inb(port + DSP_STATUS);
585 * DSP ready to receive data if bit 7 of ret == 0
588 outb(cmd, port + DSP_COMMAND);
595 printk("[AEDSP16] DSP Command (0x%x) timeout.\n", cmd);
600 #if defined(CONFIG_SC6600)
602 #if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)
603 void __init aedsp16_pinfo(void) {
604 DBG(("\n Base address: %x\n", decoded_hcfg.iobase));
605 DBG((" Joystick : %s present\n", decoded_hcfg.joystick?"":" not"));
606 DBG((" WSS addr : %x\n", decoded_hcfg.wssbase));
607 DBG((" MPU-401 addr: %x\n", decoded_hcfg.mpubase));
608 DBG((" CDROM : %s present\n", (decoded_hcfg.cdrom!=4)?"":" not"));
609 DBG((" CDROMADDR : %x\n\n", decoded_hcfg.cdrombase));
613 static void __init aedsp16_hard_decode(void) {
615 DBG((" aedsp16_hard_decode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));
620 decoded_hcfg.iobase = IOBASE(hard_cfg[0]);
621 decoded_hcfg.joystick = JOY(hard_cfg[0]);
622 decoded_hcfg.wssbase = WSSADDR(hard_cfg[0]);
623 decoded_hcfg.mpubase = MPUADDR(hard_cfg[0]);
624 decoded_hcfg.cdrom = CDROM(hard_cfg[1]);
625 decoded_hcfg.cdrombase = CDROMADDR(hard_cfg[1]);
627 #if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)
628 printk(" Original sound card configuration:\n");
633 * Now set up the real kernel configuration.
635 decoded_hcfg.iobase = ae_config.base_io;
636 decoded_hcfg.wssbase = ae_config.mss_base;
637 decoded_hcfg.mpubase = ae_config.mpu_base;
639 #if defined(CONFIG_SC6600_JOY)
640 decoded_hcfg.joystick = CONFIG_SC6600_JOY; /* Enable */
642 #if defined(CONFIG_SC6600_CDROM)
643 decoded_hcfg.cdrom = CONFIG_SC6600_CDROM; /* 4:N-3:I-2:G-1:P-0:S */
645 #if defined(CONFIG_SC6600_CDROMBASE)
646 decoded_hcfg.cdrombase = CONFIG_SC6600_CDROMBASE; /* 0 Disable */
649 #if defined(AEDSP16_DEBUG)
650 DBG((" New Values:\n"));
657 static void __init aedsp16_hard_encode(void) {
659 DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));
666 BLDIOBASE (hard_cfg[0], decoded_hcfg.iobase);
667 BLDWSSADDR(hard_cfg[0], decoded_hcfg.wssbase);
668 BLDMPUADDR(hard_cfg[0], decoded_hcfg.mpubase);
669 BLDJOY(hard_cfg[0], decoded_hcfg.joystick);
670 BLDCDROM(hard_cfg[1], decoded_hcfg.cdrom);
671 BLDCDROMADDR(hard_cfg[1], decoded_hcfg.cdrombase);
673 #if defined(AEDSP16_DEBUG)
677 DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1]));
682 static int __init aedsp16_hard_write(int port) {
684 DBG(("aedsp16_hard_write:\n"));
686 if (aedsp16_write(port, COMMAND_6C)) {
687 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6C);
691 if (aedsp16_write(port, COMMAND_5C)) {
692 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);
696 if (aedsp16_write(port, hard_cfg[0])) {
697 printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[0]);
701 if (aedsp16_write(port, hard_cfg[1])) {
702 printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[1]);
706 if (aedsp16_write(port, COMMAND_C5)) {
707 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_C5);
717 static int __init aedsp16_hard_read(int port) {
719 DBG(("aedsp16_hard_read:\n"));
721 if (aedsp16_write(port, READ_HARD_CFG)) {
722 printk("[AEDSP16] CMD 0x%x: failed!\n", READ_HARD_CFG);
727 if ((hard_cfg[0] = aedsp16_read(port)) == -1) {
728 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
733 if ((hard_cfg[1] = aedsp16_read(port)) == -1) {
734 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
739 if (aedsp16_read(port) == -1) {
740 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
751 static int __init aedsp16_ext_cfg_write(int port) {
755 if (aedsp16_write(port, COMMAND_66)) {
756 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_66);
761 if (decoded_hcfg.cdrom != 2)
763 if ((decoded_hcfg.cdrom == 4) ||
764 (decoded_hcfg.cdrom == 3))
766 if (decoded_hcfg.cdrombase == 0)
768 if (decoded_hcfg.mpubase == 0)
771 if (aedsp16_write(port, extcfg)) {
772 printk("[AEDSP16] Write extcfg: failed!\n");
775 if (aedsp16_write(port, 0)) {
776 printk("[AEDSP16] Write extcfg: failed!\n");
779 if (decoded_hcfg.cdrom == 3) {
780 if (aedsp16_write(port, COMMAND_52)) {
781 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52);
784 if ((val = aedsp16_read(port)) == -1) {
785 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n"
790 if (aedsp16_write(port, COMMAND_60)) {
791 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60);
794 if (aedsp16_write(port, val)) {
795 printk("[AEDSP16] Write val: failed!\n");
803 #endif /* CONFIG_SC6600 */
805 static int __init aedsp16_cfg_write(int port) {
806 if (aedsp16_write(port, WRITE_MDIRQ_CFG)) {
807 printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG);
810 if (aedsp16_write(port, soft_cfg)) {
811 printk("[AEDSP16] Initialization of (M)IRQ and DMA: failed!\n");
817 static int __init aedsp16_init_mss(int port)
819 DBG(("aedsp16_init_mss:\n"));
823 if (aedsp16_write(port, DSP_INIT_MSS)) {
824 printk("[AEDSP16] aedsp16_init_mss [0x%x]: failed!\n",
832 if (aedsp16_cfg_write(port) == FALSE)
835 outb(soft_cfg_mss, ae_config.mss_base);
842 static int __init aedsp16_setup_board(int port) {
845 #if defined(CONFIG_SC6600)
848 if (aedsp16_hard_read(port) == FALSE) {
849 printk("[AEDSP16] aedsp16_hard_read: failed!\n");
853 if (aedsp16_write(port, COMMAND_52)) {
854 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52);
858 if ((val = aedsp16_read(port)) == -1) {
859 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
866 if (aedsp16_write(port, COMMAND_88)) {
867 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_88);
871 } while ((aedsp16_wait_data(port) == FALSE) && loop--);
873 if (aedsp16_read(port) == -1) {
874 printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n",
879 #if !defined(CONFIG_SC6600)
880 if (aedsp16_write(port, COMMAND_5C)) {
881 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);
886 if (aedsp16_cfg_write(port) == FALSE)
889 #if defined(CONFIG_SC6600)
890 if (aedsp16_write(port, COMMAND_60)) {
891 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60);
894 if (aedsp16_write(port, val)) {
895 printk("[AEDSP16] DATA 0x%x: failed!\n", val);
898 if (aedsp16_write(port, COMMAND_6E)) {
899 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6E);
902 if (aedsp16_write(port, ver[0])) {
903 printk("[AEDSP16] DATA 0x%x: failed!\n", ver[0]);
906 if (aedsp16_write(port, ver[1])) {
907 printk("[AEDSP16] DATA 0x%x: failed!\n", ver[1]);
911 if (aedsp16_hard_write(port) == FALSE) {
912 printk("[AEDSP16] aedsp16_hard_write: failed!\n");
916 if (aedsp16_write(port, COMMAND_5C)) {
917 printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C);
921 #if defined(THIS_IS_A_THING_I_HAVE_NOT_TESTED_YET)
922 if (aedsp16_cfg_write(port) == FALSE)
931 static int __init aedsp16_stdcfg(int port) {
932 if (aedsp16_write(port, WRITE_MDIRQ_CFG)) {
933 printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG);
937 * 0x0A == (IRQ 7, DMA 1, MIRQ 0)
939 if (aedsp16_write(port, 0x0A)) {
940 printk("[AEDSP16] aedsp16_stdcfg: failed!\n");
946 static int __init aedsp16_dsp_version(int port)
951 DBG(("Get DSP Version:\n"));
953 if (aedsp16_write(ae_config.base_io, GET_DSP_VERSION)) {
954 printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_VERSION);
960 if ((ret = aedsp16_read(port)) == -1) {
965 * We already know how many int are stored (2), so we know when the
966 * string is finished.
969 } while (len < CARDVERLEN);
970 sprintf(DSPVersion, "%d.%d", ver[0], ver[1]);
977 static int __init aedsp16_dsp_copyright(int port)
982 DBG(("Get DSP Copyright:\n"));
984 if (aedsp16_write(ae_config.base_io, GET_DSP_COPYRIGHT)) {
985 printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_COPYRIGHT);
991 if ((ret = aedsp16_read(port)) == -1) {
993 * If no more data available, return to the caller, no error if len>0.
994 * We have no other way to know when the string is finished.
1004 DSPCopyright[len++] = ret;
1006 } while (len < CARDNAMELEN);
1008 DBG(("success.\n"));
1013 static void __init aedsp16_init_tables(void)
1017 memset(DSPCopyright, 0, CARDNAMELEN + 1);
1018 memset(DSPVersion, 0, CARDVERLEN + 1);
1020 for (i = 0; orIRQ[i].or; i++)
1021 if (orIRQ[i].val == ae_config.irq) {
1022 soft_cfg |= orIRQ[i].or;
1023 soft_cfg_mss |= orIRQ[i].or;
1026 for (i = 0; orMIRQ[i].or; i++)
1027 if (orMIRQ[i].or == ae_config.mpu_irq)
1028 soft_cfg |= orMIRQ[i].or;
1030 for (i = 0; orDMA[i].or; i++)
1031 if (orDMA[i].val == ae_config.dma) {
1032 soft_cfg |= orDMA[i].or;
1033 soft_cfg_mss |= orDMA[i].or;
1037 static int __init aedsp16_init_board(void)
1039 aedsp16_init_tables();
1041 if (aedsp16_dsp_reset(ae_config.base_io) == FALSE) {
1042 printk("[AEDSP16] aedsp16_dsp_reset: failed!\n");
1045 if (aedsp16_dsp_copyright(ae_config.base_io) == FALSE) {
1046 printk("[AEDSP16] aedsp16_dsp_copyright: failed!\n");
1051 * My AEDSP16 card return SC-6000 in DSPCopyright, so
1052 * if we have something different, we have to be warned.
1054 if (strcmp("SC-6000", DSPCopyright))
1055 printk("[AEDSP16] Warning: non SC-6000 audio card!\n");
1057 if (aedsp16_dsp_version(ae_config.base_io) == FALSE) {
1058 printk("[AEDSP16] aedsp16_dsp_version: failed!\n");
1062 if (aedsp16_stdcfg(ae_config.base_io) == FALSE) {
1063 printk("[AEDSP16] aedsp16_stdcfg: failed!\n");
1067 #if defined(CONFIG_SC6600)
1068 if (aedsp16_hard_read(ae_config.base_io) == FALSE) {
1069 printk("[AEDSP16] aedsp16_hard_read: failed!\n");
1073 aedsp16_hard_decode();
1075 aedsp16_hard_encode();
1077 if (aedsp16_hard_write(ae_config.base_io) == FALSE) {
1078 printk("[AEDSP16] aedsp16_hard_write: failed!\n");
1082 if (aedsp16_ext_cfg_write(ae_config.base_io) == FALSE) {
1083 printk("[AEDSP16] aedsp16_ext_cfg_write: failed!\n");
1086 #endif /* CONFIG_SC6600 */
1088 if (aedsp16_setup_board(ae_config.base_io) == FALSE) {
1089 printk("[AEDSP16] aedsp16_setup_board: failed!\n");
1093 if (ae_config.mss_base != -1) {
1094 if (ae_config.init & INIT_MSS) {
1095 if (aedsp16_init_mss(ae_config.base_io) == FALSE) {
1096 printk("[AEDSP16] Can not initialize"
1097 "Microsoft Sound System mode.\n");
1103 #if !defined(MODULE) || defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG)
1105 printk("Audio Excel DSP 16 init v%s (%s %s) [",
1106 VERSION, DSPCopyright,
1109 if (ae_config.mpu_base != -1) {
1110 if (ae_config.init & INIT_MPU401) {
1112 if ((ae_config.init & INIT_MSS) ||
1113 (ae_config.init & INIT_SBPRO))
1118 if (ae_config.mss_base == -1) {
1119 if (ae_config.init & INIT_SBPRO) {
1121 if (ae_config.init & INIT_MSS)
1126 if (ae_config.mss_base != -1)
1127 if (ae_config.init & INIT_MSS)
1131 #endif /* MODULE || AEDSP16_INFO || AEDSP16_DEBUG */
1138 static int __init init_aedsp16_sb(void)
1140 DBG(("init_aedsp16_sb: "));
1143 * If the card is already init'ed MSS, we can not init it to SBPRO too
1144 * because the board can not emulate simultaneously MSS and SBPRO.
1146 if (ae_config.init & INIT_MSS)
1148 if (ae_config.init & INIT_SBPRO)
1151 ae_config.init |= INIT_SBPRO;
1158 static void uninit_aedsp16_sb(void)
1160 DBG(("uninit_aedsp16_sb: "));
1162 ae_config.init &= ~INIT_SBPRO;
1167 static int __init init_aedsp16_mss(void)
1169 DBG(("init_aedsp16_mss: "));
1172 * If the card is already init'ed SBPRO, we can not init it to MSS too
1173 * because the board can not emulate simultaneously MSS and SBPRO.
1175 if (ae_config.init & INIT_SBPRO)
1177 if (ae_config.init & INIT_MSS)
1180 * We must allocate the CONFIG_AEDSP16_BASE region too because these are the
1181 * I/O ports to access card's control registers.
1183 if (!(ae_config.init & INIT_MPU401)) {
1184 if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE,
1185 "aedsp16 (base)")) {
1187 "AEDSP16 BASE I/O port region is already in use.\n");
1192 ae_config.init |= INIT_MSS;
1199 static void uninit_aedsp16_mss(void)
1201 DBG(("uninit_aedsp16_mss: "));
1203 if ((!(ae_config.init & INIT_MPU401)) &&
1204 (ae_config.init & INIT_MSS)) {
1205 release_region(ae_config.base_io, IOBASE_REGION_SIZE);
1206 DBG(("AEDSP16 base region released.\n"));
1209 ae_config.init &= ~INIT_MSS;
1213 static int __init init_aedsp16_mpu(void)
1215 DBG(("init_aedsp16_mpu: "));
1217 if (ae_config.init & INIT_MPU401)
1221 * We must request the CONFIG_AEDSP16_BASE region too because these are the I/O
1222 * ports to access card's control registers.
1224 if (!(ae_config.init & (INIT_MSS | INIT_SBPRO))) {
1225 if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE,
1226 "aedsp16 (base)")) {
1228 "AEDSP16 BASE I/O port region is already in use.\n");
1233 ae_config.init |= INIT_MPU401;
1240 static void uninit_aedsp16_mpu(void)
1242 DBG(("uninit_aedsp16_mpu: "));
1244 if ((!(ae_config.init & (INIT_MSS | INIT_SBPRO))) &&
1245 (ae_config.init & INIT_MPU401)) {
1246 release_region(ae_config.base_io, IOBASE_REGION_SIZE);
1247 DBG(("AEDSP16 base region released.\n"));
1250 ae_config.init &= ~INIT_MPU401;
1255 static int __init init_aedsp16(void)
1257 int initialized = FALSE;
1259 DBG(("Initializing BASE[0x%x] IRQ[%d] DMA[%d] MIRQ[%d]\n",
1260 ae_config.base_io,ae_config.irq,ae_config.dma,ae_config.mpu_irq));
1262 if (ae_config.mss_base == -1) {
1263 if (init_aedsp16_sb() == FALSE) {
1264 uninit_aedsp16_sb();
1270 if (ae_config.mpu_base != -1) {
1271 if (init_aedsp16_mpu() == FALSE) {
1272 uninit_aedsp16_mpu();
1279 * In the sequence of init routines, the MSS init MUST be the last!
1280 * This because of the special register programming the MSS mode needs.
1281 * A board reset would disable the MSS mode restoring the default SBPRO
1284 if (ae_config.mss_base != -1) {
1285 if (init_aedsp16_mss() == FALSE) {
1286 uninit_aedsp16_mss();
1293 initialized = aedsp16_init_board();
1297 static void __exit uninit_aedsp16(void)
1299 if (ae_config.mss_base != -1)
1300 uninit_aedsp16_mss();
1302 uninit_aedsp16_sb();
1303 if (ae_config.mpu_base != -1)
1304 uninit_aedsp16_mpu();
1307 static int __initdata io = -1;
1308 static int __initdata irq = -1;
1309 static int __initdata dma = -1;
1310 static int __initdata mpu_irq = -1;
1311 static int __initdata mss_base = -1;
1312 static int __initdata mpu_base = -1;
1314 module_param(io, int, 0);
1315 MODULE_PARM_DESC(io, "I/O base address (0x220 0x240)");
1316 module_param(irq, int, 0);
1317 MODULE_PARM_DESC(irq, "IRQ line (5 7 9 10 11)");
1318 module_param(dma, int, 0);
1319 MODULE_PARM_DESC(dma, "dma line (0 1 3)");
1320 module_param(mpu_irq, int, 0);
1321 MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ line (5 7 9 10 0)");
1322 module_param(mss_base, int, 0);
1323 MODULE_PARM_DESC(mss_base, "MSS emulation I/O base address (0x530 0xE80)");
1324 module_param(mpu_base, int, 0);
1325 MODULE_PARM_DESC(mpu_base,"MPU-401 I/O base address (0x300 0x310 0x320 0x330)");
1326 MODULE_AUTHOR("Riccardo Facchetti <fizban@tin.it>");
1327 MODULE_DESCRIPTION("Audio Excel DSP 16 Driver Version " VERSION);
1328 MODULE_LICENSE("GPL");
1330 static int __init do_init_aedsp16(void) {
1331 printk("Audio Excel DSP 16 init driver Copyright (C) Riccardo Facchetti 1995-98\n");
1332 if (io == -1 || dma == -1 || irq == -1) {
1333 printk(KERN_INFO "aedsp16: I/O, IRQ and DMA are mandatory\n");
1337 ae_config.base_io = io;
1338 ae_config.irq = irq;
1339 ae_config.dma = dma;
1341 ae_config.mss_base = mss_base;
1342 ae_config.mpu_base = mpu_base;
1343 ae_config.mpu_irq = mpu_irq;
1345 if (init_aedsp16() == FALSE) {
1346 printk(KERN_ERR "aedsp16: initialization failed\n");
1349 * What error should we return here ?
1356 static void __exit cleanup_aedsp16(void) {
1360 module_init(do_init_aedsp16);
1361 module_exit(cleanup_aedsp16);
1364 static int __init setup_aedsp16(char *str)
1366 /* io, irq, dma, mss_io, mpu_io, mpu_irq */
1369 str = get_options(str, ARRAY_SIZE(ints), ints);
1380 __setup("aedsp16=", setup_aedsp16);