patch-2.3.50 linux/drivers/sound/trix.c
Next file: linux/drivers/sound/uart401.c
Previous file: linux/drivers/sound/trident.h
Back to the patch index
Back to the overall index
- Lines: 289
- Date:
Tue Mar 7 13:40:24 2000
- Orig file:
v2.3.49/linux/drivers/sound/trix.c
- Orig date:
Sat Feb 26 22:31:50 2000
diff -u --recursive --new-file v2.3.49/linux/drivers/sound/trix.c linux/drivers/sound/trix.c
@@ -13,9 +13,11 @@
*
* Changes
* Alan Cox Modularisation, cleanup.
+ * Christoph Hellwig Adapted to module_init/module_exit
*/
#include <linux/config.h>
+#include <linux/init.h>
#include <linux/module.h>
#include "sound_config.h"
@@ -23,9 +25,10 @@
#include "sb.h"
#include "sound_firmware.h"
-#include <linux/init.h>
-#include "trix_boot.h"
+#include "ad1848.h"
+#include "mpu401.h"
+#include "trix_boot.h"
static int kilroy_was_here = 0; /* Don't detect twice */
static int sb_initialized = 0;
@@ -35,11 +38,7 @@
static int mpu = 0;
-#ifdef TRIX_JOYSTICK
-static int joystick=1;
-#else
static int joystick=0;
-#endif
static unsigned char trix_read(int addr)
{
@@ -137,7 +136,7 @@
* AudioTrix Pro
*/
-int probe_trix_wss(struct address_info *hw_config)
+static int __init probe_trix_wss(struct address_info *hw_config)
{
int ret;
@@ -202,8 +201,7 @@
return ret;
}
-void
-attach_trix_wss(struct address_info *hw_config)
+static void __init attach_trix_wss(struct address_info *hw_config)
{
static unsigned char interrupt_bits[12] = {
0, 0, 0, 0, 0, 0, 0, 0x08, 0, 0x10, 0x18, 0x20
@@ -273,7 +271,7 @@
}
}
-int probe_trix_sb(struct address_info *hw_config)
+static int __init probe_trix_sb(struct address_info *hw_config)
{
int tmp;
@@ -323,7 +321,7 @@
return sb_dsp_detect(hw_config, 0, 0);
}
-void attach_trix_sb(struct address_info *hw_config)
+static void __init attach_trix_sb(struct address_info *hw_config)
{
extern int sb_be_quiet;
int old_quiet;
@@ -339,13 +337,13 @@
sb_be_quiet = old_quiet;
}
-void attach_trix_mpu(struct address_info *hw_config)
+static void __init attach_trix_mpu(struct address_info *hw_config)
{
hw_config->name = "AudioTrix Pro";
attach_uart401(hw_config);
}
-int probe_trix_mpu(struct address_info *hw_config)
+static int __init probe_trix_mpu(struct address_info *hw_config)
{
unsigned char conf;
static char irq_bits[] = {
@@ -406,7 +404,7 @@
return probe_uart401(hw_config);
}
-void unload_trix_wss(struct address_info *hw_config)
+static void __exit unload_trix_wss(struct address_info *hw_config)
{
int dma2 = hw_config->dma2;
@@ -424,31 +422,32 @@
sound_unload_audiodev(hw_config->slots[0]);
}
-void unload_trix_mpu(struct address_info *hw_config)
+static inline void __exit unload_trix_mpu(struct address_info *hw_config)
{
unload_uart401(hw_config);
}
-void unload_trix_sb(struct address_info *hw_config)
+static inline void __exit unload_trix_sb(struct address_info *hw_config)
{
sb_dsp_unload(hw_config, mpu);
}
-#ifdef MODULE
-
-int io = -1;
-int irq = -1;
-int dma = -1;
-int dma2 = -1; /* Set this for modules that need it */
-
-int sb_io = -1;
-int sb_dma = -1;
-int sb_irq = -1;
-
-int mpu_io = -1;
-int mpu_irq = -1;
-
-EXPORT_NO_SYMBOLS;
+static struct address_info cfg;
+static struct address_info cfg2;
+static struct address_info cfg_mpu;
+
+static int sb = 0;
+static int fw_load;
+
+static int __initdata io = -1;
+static int __initdata irq = -1;
+static int __initdata dma = -1;
+static int __initdata dma2 = -1; /* Set this for modules that need it */
+static int __initdata sb_io = -1;
+static int __initdata sb_dma = -1;
+static int __initdata sb_irq = -1;
+static int __initdata mpu_io = -1;
+static int __initdata mpu_irq = -1;
MODULE_PARM(io,"i");
MODULE_PARM(irq,"i");
@@ -460,42 +459,33 @@
MODULE_PARM(mpu_io,"i");
MODULE_PARM(mpu_irq,"i");
MODULE_PARM(joystick, "i");
-struct address_info config;
-struct address_info sb_config;
-struct address_info mpu_config;
-
-static int sb = 0;
-
-static int fw_load;
-int init_module(void)
+static int __init init_trix(void)
{
printk(KERN_INFO "MediaTrix audio driver Copyright (C) by Hannu Savolainen 1993-1996\n");
- if (io == -1 || dma == -1 || irq == -1)
- {
+ cfg.io_base = io;
+ cfg.irq = irq;
+ cfg.dma = dma;
+ cfg.dma2 = dma2;
+
+ cfg2.io_base = sb_io;
+ cfg2.irq = sb_irq;
+ cfg2.dma = sb_dma;
+
+ cfg_mpu.io_base = mpu_io;
+ cfg_mpu.irq = mpu_irq;
+
+ if (cfg.io_base == -1 || cfg.dma == -1 || cfg.irq == -1) {
printk(KERN_INFO "I/O, IRQ, DMA and type are mandatory\n");
return -EINVAL;
}
- config.io_base = io;
- config.irq = irq;
- config.dma = dma;
- config.dma2 = dma2;
-
- sb_config.io_base = sb_io;
- sb_config.irq = sb_irq;
- sb_config.dma = sb_dma;
- mpu_config.io_base = mpu_io;
- mpu_config.irq = mpu_irq;
-
- if (sb_io != -1 && (sb_irq == -1 || sb_dma == -1))
- {
+ if (cfg2.io_base != -1 && (cfg2.irq == -1 || cfg2.dma == -1)) {
printk(KERN_INFO "CONFIG_SB_IRQ and CONFIG_SB_DMA must be specified if SB_IO is set.\n");
return -EINVAL;
}
- if (mpu_io != -1 && mpu_irq == -1)
- {
+ if (cfg_mpu.io_base != -1 && cfg_mpu.irq == -1) {
printk(KERN_INFO "CONFIG_MPU_IRQ must be specified if MPU_IO is set.\n");
return -EINVAL;
}
@@ -505,42 +495,65 @@
trix_boot_len = mod_firmware_load("/etc/sound/trxpro.bin",
(char **) &trix_boot);
}
- if (!probe_trix_wss(&config))
+ if (!probe_trix_wss(&cfg))
return -ENODEV;
- attach_trix_wss(&config);
+ attach_trix_wss(&cfg);
/*
* We must attach in the right order to get the firmware
* loaded up in time.
*/
- if (sb_io != -1)
- {
- sb = probe_trix_sb(&sb_config);
+ if (cfg2.io_base != -1) {
+ sb = probe_trix_sb(&cfg2);
if (sb)
- attach_trix_sb(&sb_config);
+ attach_trix_sb(&cfg2);
}
- if (mpu_io != -1)
- {
- mpu = probe_trix_mpu(&mpu_config);
+ if (cfg_mpu.io_base != -1) {
+ mpu = probe_trix_mpu(&cfg_mpu);
if (mpu)
- attach_trix_mpu(&mpu_config);
+ attach_trix_mpu(&cfg_mpu);
}
SOUND_LOCK;
return 0;
}
-void cleanup_module(void)
+static void __exit cleanup_trix(void)
{
if (fw_load && trix_boot)
vfree(trix_boot);
if (sb)
- unload_trix_sb(&sb_config);
+ unload_trix_sb(&cfg2);
if (mpu)
- unload_trix_mpu(&mpu_config);
- unload_trix_wss(&config);
+ unload_trix_mpu(&cfg_mpu);
+ unload_trix_wss(&cfg);
SOUND_LOCK_END;
}
-#endif /* MODULE */
+module_init(init_trix);
+module_exit(cleanup_trix);
+
+#ifndef MODULE
+static int __init setup_trix (char *str)
+{
+ /* io, irq, dma, dma2, sb_io, sb_irq, sb_dma, mpu_io, mpu_irq */
+ int ints[9];
+
+ str = get_options(str, ARRAY_SIZE(ints), ints);
+
+ io = ints[1];
+ irq = ints[2];
+ dma = ints[3];
+ dma2 = ints[4];
+ sb_io = ints[5];
+ sb_irq = ints[6];
+ sb_dma = ints[6];
+ mpu_io = ints[7];
+ mpu_irq = ints[8];
+
+ return 1;
+}
+
+__setup("trix=", setup_trix);
+#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)