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 if ( check_region( ai->io_base, 8 ) ) {
90 printk(KERN_ERR "sgalaxy: WSS IO port 0x%03x not available\n", ai->io_base);
94 if ( ad1848_detect( ai->io_base+4, NULL, ai->osp ) )
95 return probe_ms_sound(ai); /* The card is already active, check irq etc... */
97 if ( check_region( ai->ai_sgbase, 0x10 ) ) {
98 printk(KERN_ERR "sgalaxy: SB IO port 0x%03x not available\n", ai->ai_sgbase);
102 /* switch to MSS/WSS mode */
104 sb_rst( ai->ai_sgbase );
106 sb_cmd( ai->ai_sgbase, 9 );
107 sb_cmd( ai->ai_sgbase, 0 );
111 return probe_ms_sound(ai);
114 static void __init attach_sgalaxy( struct address_info *ai )
118 request_region( ai->ai_sgbase, 0x10, "SoundGalaxy SB" );
120 attach_ms_sound(ai, THIS_MODULE);
123 if (n!=-1 && audio_devs[n]->mixer_dev != -1 ) {
124 AD1848_REROUTE( SOUND_MIXER_LINE1, SOUND_MIXER_LINE ); /* Line-in */
125 AD1848_REROUTE( SOUND_MIXER_LINE2, SOUND_MIXER_SYNTH ); /* FM+Wavetable*/
126 AD1848_REROUTE( SOUND_MIXER_LINE3, SOUND_MIXER_CD ); /* CD */
130 static void __exit unload_sgalaxy( struct address_info *ai )
132 unload_ms_sound( ai );
133 release_region( ai->ai_sgbase, 0x10 );
136 static struct address_info cfg;
138 static int __initdata io = -1;
139 static int __initdata irq = -1;
140 static int __initdata dma = -1;
141 static int __initdata dma2 = -1;
142 static int __initdata sgbase = -1;
145 MODULE_PARM(irq,"i");
146 MODULE_PARM(dma,"i");
147 MODULE_PARM(dma2,"i");
148 MODULE_PARM(sgbase,"i");
150 static int __init init_sgalaxy(void)
156 cfg.ai_sgbase = sgbase;
158 if (cfg.io_base == -1 || cfg.irq == -1 || cfg.dma == -1 || cfg.ai_sgbase == -1 ) {
159 printk(KERN_ERR "sgalaxy: io, irq, dma and sgbase must be set.\n");
163 if ( probe_sgalaxy(&cfg) == 0 )
166 attach_sgalaxy(&cfg);
171 static void __exit cleanup_sgalaxy(void)
173 unload_sgalaxy(&cfg);
176 module_init(init_sgalaxy);
177 module_exit(cleanup_sgalaxy);
180 static int __init setup_sgalaxy(char *str)
182 /* io, irq, dma, dma2, sgbase */
185 str = get_options(str, ARRAY_SIZE(ints), ints);
195 __setup("sgalaxy=", setup_sgalaxy);
197 MODULE_LICENSE("GPL");