4 * Low level driver for Aztech Sound Galaxy cards.
5 * Copyright 1998 Artur Skawina <skawina@geocities.com>
8 * Aztech Sound Galaxy Waverider Pro 32 - 3D
9 * Aztech Sound Galaxy Washington 16
11 * Based on cs4232.c by Hannu Savolainen and Alan Cox.
14 * Copyright (C) by Hannu Savolainen 1993-1997
16 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
17 * Version 2 (June 1991). See the "COPYING" file distributed with this software
21 * 11-10-2000 Bartlomiej Zolnierkiewicz <bkz@linux-ide.org>
22 * Added __init to sb_rst() and sb_cmd()
25 #include <linux/init.h>
26 #include <linux/module.h>
28 #include "sound_config.h"
31 static void sleep( unsigned howlong
)
33 current
->state
= TASK_INTERRUPTIBLE
;
34 schedule_timeout(howlong
);
39 /* Sound Blaster regs */
41 #define SBDSP_RESET 0x6
42 #define SBDSP_READ 0xA
43 #define SBDSP_COMMAND 0xC
44 #define SBDSP_STATUS SBDSP_COMMAND
45 #define SBDSP_DATA_AVAIL 0xE
47 static int __init
sb_rst(int base
)
51 outb( 1, base
+SBDSP_RESET
); /* reset the DSP */
52 outb( 0, base
+SBDSP_RESET
);
54 for ( i
=0; i
<500; i
++ ) /* delay */
57 for ( i
=0; i
<100000; i
++ )
59 if ( inb( base
+SBDSP_DATA_AVAIL
)&0x80 )
63 if ( inb( base
+SBDSP_READ
)!=0xAA )
69 static int __init
sb_cmd( int base
, unsigned char val
)
73 for ( i
=100000; i
; i
-- )
75 if ( (inb( base
+SBDSP_STATUS
)&0x80)==0 )
77 outb( val
, base
+SBDSP_COMMAND
);
81 return i
; /* i>0 == success */
85 #define ai_sgbase driver_use_1
87 static int __init
probe_sgalaxy( struct address_info
*ai
)
89 struct resource
*ports
;
92 if (!request_region(ai
->io_base
, 4, "WSS config")) {
93 printk(KERN_ERR
"sgalaxy: WSS IO port 0x%03x not available\n", ai
->io_base
);
97 ports
= request_region(ai
->io_base
+ 4, 4, "ad1848");
99 printk(KERN_ERR
"sgalaxy: WSS IO port 0x%03x not available\n", ai
->io_base
);
100 release_region(ai
->io_base
, 4);
104 if (!request_region( ai
->ai_sgbase
, 0x10, "SoundGalaxy SB")) {
105 printk(KERN_ERR
"sgalaxy: SB IO port 0x%03x not available\n", ai
->ai_sgbase
);
106 release_region(ai
->io_base
+ 4, 4);
107 release_region(ai
->io_base
, 4);
111 if (ad1848_detect(ports
, NULL
, ai
->osp
))
112 goto out
; /* The card is already active, check irq etc... */
114 /* switch to MSS/WSS mode */
116 sb_rst( ai
->ai_sgbase
);
118 sb_cmd( ai
->ai_sgbase
, 9 );
119 sb_cmd( ai
->ai_sgbase
, 0 );
124 if (!probe_ms_sound(ai
, ports
)) {
125 release_region(ai
->io_base
+ 4, 4);
126 release_region(ai
->io_base
, 4);
127 release_region(ai
->ai_sgbase
, 0x10);
131 attach_ms_sound(ai
, ports
, THIS_MODULE
);
134 if (n
!=-1 && audio_devs
[n
]->mixer_dev
!= -1 ) {
135 AD1848_REROUTE( SOUND_MIXER_LINE1
, SOUND_MIXER_LINE
); /* Line-in */
136 AD1848_REROUTE( SOUND_MIXER_LINE2
, SOUND_MIXER_SYNTH
); /* FM+Wavetable*/
137 AD1848_REROUTE( SOUND_MIXER_LINE3
, SOUND_MIXER_CD
); /* CD */
142 static void __exit
unload_sgalaxy( struct address_info
*ai
)
144 unload_ms_sound( ai
);
145 release_region( ai
->ai_sgbase
, 0x10 );
148 static struct address_info cfg
;
150 static int __initdata io
= -1;
151 static int __initdata irq
= -1;
152 static int __initdata dma
= -1;
153 static int __initdata dma2
= -1;
154 static int __initdata sgbase
= -1;
156 module_param(io
, int, 0);
157 module_param(irq
, int, 0);
158 module_param(dma
, int, 0);
159 module_param(dma2
, int, 0);
160 module_param(sgbase
, int, 0);
162 static int __init
init_sgalaxy(void)
168 cfg
.ai_sgbase
= sgbase
;
170 if (cfg
.io_base
== -1 || cfg
.irq
== -1 || cfg
.dma
== -1 || cfg
.ai_sgbase
== -1 ) {
171 printk(KERN_ERR
"sgalaxy: io, irq, dma and sgbase must be set.\n");
175 if ( probe_sgalaxy(&cfg
) == 0 )
181 static void __exit
cleanup_sgalaxy(void)
183 unload_sgalaxy(&cfg
);
186 module_init(init_sgalaxy
);
187 module_exit(cleanup_sgalaxy
);
190 static int __init
setup_sgalaxy(char *str
)
192 /* io, irq, dma, dma2, sgbase */
195 str
= get_options(str
, ARRAY_SIZE(ints
), ints
);
205 __setup("sgalaxy=", setup_sgalaxy
);
207 MODULE_LICENSE("GPL");