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 #include <linux/init.h>
22 #include <linux/module.h>
24 #include "sound_config.h"
27 static void sleep( unsigned howlong
)
29 current
->state
= TASK_INTERRUPTIBLE
;
30 schedule_timeout(howlong
);
35 /* Sound Blaster regs */
37 #define SBDSP_RESET 0x6
38 #define SBDSP_READ 0xA
39 #define SBDSP_COMMAND 0xC
40 #define SBDSP_STATUS SBDSP_COMMAND
41 #define SBDSP_DATA_AVAIL 0xE
43 static int sb_rst(int base
)
47 outb( 1, base
+SBDSP_RESET
); /* reset the DSP */
48 outb( 0, base
+SBDSP_RESET
);
50 for ( i
=0; i
<500; i
++ ) /* delay */
53 for ( i
=0; i
<100000; i
++ )
55 if ( inb( base
+SBDSP_DATA_AVAIL
)&0x80 )
59 if ( inb( base
+SBDSP_READ
)!=0xAA )
65 static int sb_cmd( int base
, unsigned char val
)
69 for ( i
=100000; i
; i
-- )
71 if ( (inb( base
+SBDSP_STATUS
)&0x80)==0 )
73 outb( val
, base
+SBDSP_COMMAND
);
77 return i
; /* i>0 == success */
81 #define ai_sgbase driver_use_1
83 static int __init
probe_sgalaxy( struct address_info
*ai
)
85 if ( check_region( ai
->io_base
, 8 ) ) {
86 printk(KERN_ERR
"sgalaxy: WSS IO port 0x%03x not available\n", ai
->io_base
);
90 if ( ad1848_detect( ai
->io_base
+4, NULL
, ai
->osp
) )
91 return probe_ms_sound(ai
); /* The card is already active, check irq etc... */
93 if ( check_region( ai
->ai_sgbase
, 0x10 ) ) {
94 printk(KERN_ERR
"sgalaxy: SB IO port 0x%03x not available\n", ai
->ai_sgbase
);
98 /* switch to MSS/WSS mode */
100 sb_rst( ai
->ai_sgbase
);
102 sb_cmd( ai
->ai_sgbase
, 9 );
103 sb_cmd( ai
->ai_sgbase
, 0 );
107 return probe_ms_sound(ai
);
110 static void __init
attach_sgalaxy( struct address_info
*ai
)
114 request_region( ai
->ai_sgbase
, 0x10, "SoundGalaxy SB" );
116 attach_ms_sound(ai
, THIS_MODULE
);
119 if (n
!=-1 && audio_devs
[n
]->mixer_dev
!= -1 ) {
120 AD1848_REROUTE( SOUND_MIXER_LINE1
, SOUND_MIXER_LINE
); /* Line-in */
121 AD1848_REROUTE( SOUND_MIXER_LINE2
, SOUND_MIXER_SYNTH
); /* FM+Wavetable*/
122 AD1848_REROUTE( SOUND_MIXER_LINE3
, SOUND_MIXER_CD
); /* CD */
126 static void __exit
unload_sgalaxy( struct address_info
*ai
)
128 unload_ms_sound( ai
);
129 release_region( ai
->ai_sgbase
, 0x10 );
132 static struct address_info cfg
;
134 static int __initdata io
= -1;
135 static int __initdata irq
= -1;
136 static int __initdata dma
= -1;
137 static int __initdata dma2
= -1;
138 static int __initdata sgbase
= -1;
141 MODULE_PARM(irq
,"i");
142 MODULE_PARM(dma
,"i");
143 MODULE_PARM(dma2
,"i");
144 MODULE_PARM(sgbase
,"i");
146 static int __init
init_sgalaxy(void)
152 cfg
.ai_sgbase
= sgbase
;
154 if (cfg
.io_base
== -1 || cfg
.irq
== -1 || cfg
.dma
== -1 || cfg
.ai_sgbase
== -1 ) {
155 printk(KERN_ERR
"sgalaxy: io, irq, dma and sgbase must be set.\n");
159 if ( probe_sgalaxy(&cfg
) == 0 )
162 attach_sgalaxy(&cfg
);
167 static void __exit
cleanup_sgalaxy(void)
169 unload_sgalaxy(&cfg
);
172 module_init(init_sgalaxy
);
173 module_exit(cleanup_sgalaxy
);
176 static int __init
setup_sgalaxy(char *str
)
178 /* io, irq, dma, dma2, sgbase */
181 str
= get_options(str
, ARRAY_SIZE(ints
), ints
);
191 __setup("sgalaxy=", setup_sgalaxy
);