patch-2.1.94 linux/drivers/sound/trix.c

Next file: linux/drivers/sound/uart401.c
Previous file: linux/drivers/sound/soundcard.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.93/linux/drivers/sound/trix.c linux/drivers/sound/trix.c
@@ -3,14 +3,18 @@
  *
  * Low level driver for the MediaTrix AudioTrix Pro
  * (MT-0002-PC Control Chip)
- */
-/*
+ *
+ *
  * Copyright (C) by Hannu Savolainen 1993-1997
  *
  * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
  * Version 2 (June 1991). See the "COPYING" file distributed with this software
  * for more info.
+ *
+ * Changes
+ *	Alan Cox		Modularisation, cleanup.
  */
+ 
 #include <linux/config.h>
 #include <linux/module.h>
 
@@ -35,30 +39,27 @@
 #endif
 
 
-static int      kilroy_was_here = 0;	/* Don't detect twice */
-static int      sb_initialized = 0;
-static int      mpu_initialized = 0;
+static int kilroy_was_here = 0;	/* Don't detect twice */
+static int sb_initialized = 0;
+static int mpu_initialized = 0;
 
-static int     *trix_osp = NULL;
+static int *trix_osp = NULL;
 
-static unsigned char
-trix_read(int addr)
+static unsigned char trix_read(int addr)
 {
 	outb(((unsigned char) addr), 0x390);	/* MT-0002-PC ASIC address */
 	return inb(0x391);	/* MT-0002-PC ASIC data */
 }
 
-static void
-trix_write(int addr, int data)
+static void trix_write(int addr, int data)
 {
 	outb(((unsigned char) addr), 0x390);	/* MT-0002-PC ASIC address */
 	outb(((unsigned char) data), 0x391);	/* MT-0002-PC ASIC data */
 }
 
-static void
-download_boot(int base)
+static void download_boot(int base)
 {
-	int             i = 0, n = trix_boot_len;
+	int i = 0, n = trix_boot_len;
 
 	if (trix_boot_len == 0)
 		return;
@@ -83,24 +84,23 @@
 
 }
 
-static int
-trix_set_wss_port(struct address_info *hw_config)
+static int trix_set_wss_port(struct address_info *hw_config)
 {
 	unsigned char   addr_bits;
 
 	if (check_region(0x390, 2))
-	  {
-		  printk(KERN_ERR "AudioTrix: Config port I/O conflict\n");
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: Config port I/O conflict\n");
+		return 0;
+	}
 	if (kilroy_was_here)	/* Already initialized */
 		return 0;
 
 	if (trix_read(0x15) != 0x71)	/* No ASIC signature */
-	  {
-		  MDB(printk("No AudioTrix ASIC signature found\n"));
-		  return 0;
-	  }
+	{
+		MDB(printk(KERN_ERR "No AudioTrix ASIC signature found\n"));
+		return 0;
+	}
 	kilroy_was_here = 1;
 
 	/*
@@ -111,26 +111,26 @@
 	trix_write(0x14, 0);
 
 	/*
-	   * Configure the ASIC to place the codec to the proper I/O location
+	 * Configure the ASIC to place the codec to the proper I/O location
 	 */
 
 	switch (hw_config->io_base)
-	  {
-	  case 0x530:
-		  addr_bits = 0;
-		  break;
-	  case 0x604:
-		  addr_bits = 1;
-		  break;
-	  case 0xE80:
-		  addr_bits = 2;
-		  break;
-	  case 0xF40:
-		  addr_bits = 3;
-		  break;
-	  default:
-		  return 0;
-	  }
+	{
+		case 0x530:
+			addr_bits = 0;
+			break;
+		case 0x604:
+			addr_bits = 1;
+			break;
+		case 0xE80:
+			addr_bits = 2;
+			break;
+		case 0xF40:
+			addr_bits = 3;
+			break;
+		default:
+			return 0;
+	}
 
 	trix_write(0x19, (trix_read(0x19) & 0x03) | addr_bits);
 	return 1;
@@ -141,120 +141,123 @@
  *      AudioTrix Pro
  */
 
-int
-probe_trix_wss(struct address_info *hw_config)
+int probe_trix_wss(struct address_info *hw_config)
 {
-	int             ret;
+	int ret;
 
 	/*
-	   * Check if the IO port returns valid signature. The original MS Sound
-	   * system returns 0x04 while some cards (AudioTrix Pro for example)
-	   * return 0x00.
+	 * Check if the IO port returns valid signature. The original MS Sound
+	 * system returns 0x04 while some cards (AudioTrix Pro for example)
+	 * return 0x00.
 	 */
 	if (check_region(hw_config->io_base, 8))
-	  {
-		  printk("AudioTrix: MSS I/O port conflict (%x)\n", hw_config->io_base);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: MSS I/O port conflict (%x)\n", hw_config->io_base);
+		return 0;
+	}
 	trix_osp = hw_config->osp;
 
 	if (!trix_set_wss_port(hw_config))
 		return 0;
 
 	if ((inb(hw_config->io_base + 3) & 0x3f) != 0x00)
-	  {
-		  MDB(printk("No MSS signature detected on port 0x%x\n", hw_config->io_base));
-		  return 0;
-	  }
+	{
+		MDB(printk(KERN_ERR "No MSS signature detected on port 0x%x\n", hw_config->io_base));
+		return 0;
+	}
 	if (hw_config->irq > 11)
-	  {
-		  printk("AudioTrix: Bad WSS IRQ %d\n", hw_config->irq);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: Bad WSS IRQ %d\n", hw_config->irq);
+		return 0;
+	}
 	if (hw_config->dma != 0 && hw_config->dma != 1 && hw_config->dma != 3)
-	  {
-		  printk("AudioTrix: Bad WSS DMA %d\n", hw_config->dma);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: Bad WSS DMA %d\n", hw_config->dma);
+		return 0;
+	}
 	if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
 		if (hw_config->dma2 != 0 && hw_config->dma2 != 1 && hw_config->dma2 != 3)
-		  {
-			  printk("AudioTrix: Bad capture DMA %d\n", hw_config->dma2);
+		{
+			  printk(KERN_ERR "AudioTrix: Bad capture DMA %d\n", hw_config->dma2);
 			  return 0;
-		  }
+		}
 	/*
-	   * Check that DMA0 is not in use with a 8 bit board.
+	 * Check that DMA0 is not in use with a 8 bit board.
 	 */
 
 	if (hw_config->dma == 0 && inb(hw_config->io_base + 3) & 0x80)
-	  {
-		  printk("AudioTrix: Can't use DMA0 with a 8 bit card slot\n");
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: Can't use DMA0 with a 8 bit card slot\n");
+		return 0;
+	}
 	if (hw_config->irq > 7 && hw_config->irq != 9 && inb(hw_config->io_base + 3) & 0x80)
-	  {
-		  printk("AudioTrix: Can't use IRQ%d with a 8 bit card slot\n", hw_config->irq);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: Can't use IRQ%d with a 8 bit card slot\n", hw_config->irq);
+		return 0;
+	}
 	ret = ad1848_detect(hw_config->io_base + 4, NULL, hw_config->osp);
 
 	if (ret)
-	  {
+	{
 #ifdef TRIX_ENABLE_JOYSTICK
-		  trix_write(0x15, 0x80);
+		trix_write(0x15, 0x80);
 #endif
-		  request_region(0x390, 2, "AudioTrix");
-	  }
+		request_region(0x390, 2, "AudioTrix");
+	}
 	return ret;
 }
 
 void
 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};
-	char            bits;
-
-	static unsigned char dma_bits[4] =
-	{1, 2, 0, 3};
-
-	int             config_port = hw_config->io_base + 0;
-	int             dma1 = hw_config->dma, dma2 = hw_config->dma2;
-	int             old_num_mixers = num_mixers;
+	static unsigned char interrupt_bits[12] = {
+		0, 0, 0, 0, 0, 0, 0, 0x08, 0, 0x10, 0x18, 0x20
+	};
+	char bits;
+
+	static unsigned char dma_bits[4] = {
+		1, 2, 0, 3
+	};
+
+	int config_port = hw_config->io_base + 0;
+	int dma1 = hw_config->dma, dma2 = hw_config->dma2;
+	int old_num_mixers = num_mixers;
 
 	trix_osp = hw_config->osp;
 
 	if (!kilroy_was_here)
-	  {
-		  DDB(printk("AudioTrix: Attach called but not probed yet???\n"));
-		  return;
-	  }
+	{
+		DDB(printk("AudioTrix: Attach called but not probed yet???\n"));
+		return;
+	}
+	
 	/*
-	   * Set the IRQ and DMA addresses.
+	 * Set the IRQ and DMA addresses.
 	 */
 
 	bits = interrupt_bits[hw_config->irq];
 	if (bits == 0)
-	  {
-		  printk("AudioTrix: Bad IRQ (%d)\n", hw_config->irq);
-		  return;
-	  }
+	{
+		printk("AudioTrix: Bad IRQ (%d)\n", hw_config->irq);
+		return;
+	}
 	outb((bits | 0x40), config_port);
 
 	if (hw_config->dma2 == -1 || hw_config->dma2 == hw_config->dma)
-	  {
+	{
 		  bits |= dma_bits[dma1];
 		  dma2 = dma1;
-	} else
-	  {
-		  unsigned char   tmp;
-
-		  tmp = trix_read(0x13) & ~30;
-		  trix_write(0x13, tmp | 0x80 | (dma1 << 4));
-
-		  tmp = trix_read(0x14) & ~30;
-		  trix_write(0x14, tmp | 0x80 | (dma2 << 4));
-	  }
+	}
+	else
+	{
+		unsigned char tmp;
+
+		tmp = trix_read(0x13) & ~30;
+		trix_write(0x13, tmp | 0x80 | (dma1 << 4));
+
+		tmp = trix_read(0x14) & ~30;
+		trix_write(0x14, tmp | 0x80 | (dma2 << 4));
+	}
 
 	outb((bits), config_port);	/* Write IRQ+DMA setup */
 
@@ -267,22 +270,22 @@
 	request_region(hw_config->io_base, 4, "MSS config");
 
 	if (num_mixers > old_num_mixers)	/* Mixer got installed */
-	  {
-		  AD1848_REROUTE(SOUND_MIXER_LINE1, SOUND_MIXER_LINE);	/* Line in */
-		  AD1848_REROUTE(SOUND_MIXER_LINE2, SOUND_MIXER_CD);
-		  AD1848_REROUTE(SOUND_MIXER_LINE3, SOUND_MIXER_SYNTH);		/* OPL4 */
-		  AD1848_REROUTE(SOUND_MIXER_SPEAKER, SOUND_MIXER_ALTPCM);	/* SB */
-	  }
-}
-
-int
-probe_trix_sb(struct address_info *hw_config)
-{
-
-	int             tmp;
-	unsigned char   conf;
-	static char     irq_translate[] =
-	{-1, -1, -1, 0, 1, 2, -1, 3};
+	{
+		AD1848_REROUTE(SOUND_MIXER_LINE1, SOUND_MIXER_LINE);	/* Line in */
+		AD1848_REROUTE(SOUND_MIXER_LINE2, SOUND_MIXER_CD);
+		AD1848_REROUTE(SOUND_MIXER_LINE3, SOUND_MIXER_SYNTH);		/* OPL4 */
+		AD1848_REROUTE(SOUND_MIXER_SPEAKER, SOUND_MIXER_ALTPCM);	/* SB */
+	}
+}
+
+int probe_trix_sb(struct address_info *hw_config)
+{
+
+	int tmp;
+	unsigned char conf;
+	static char irq_translate[] = {
+		-1, -1, -1, 0, 1, 2, -1, 3
+	};
 
 	if (trix_boot_len == 0)
 		return 0;	/* No boot code -> no fun */
@@ -294,10 +297,10 @@
 		return 0;
 
 	if (check_region(hw_config->io_base, 16))
-	  {
-		  printk("AudioTrix: SB I/O port conflict (%x)\n", hw_config->io_base);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: SB I/O port conflict (%x)\n", hw_config->io_base);
+		return 0;
+	}
 	if ((hw_config->io_base & 0xffffff8f) != 0x200)
 		return 0;
 
@@ -329,11 +332,10 @@
 #endif
 }
 
-void
-attach_trix_sb(struct address_info *hw_config)
+void attach_trix_sb(struct address_info *hw_config)
 {
-	extern int      sb_be_quiet;
-	int             old_quiet;
+	extern int sb_be_quiet;
+	int old_quiet;
 
 #ifdef CONFIG_SBDSP
 	hw_config->driver_use_1 = SB_NO_MIDI | SB_NO_MIXER | SB_NO_RECORDING;
@@ -348,8 +350,7 @@
 #endif
 }
 
-void
-attach_trix_mpu(struct address_info *hw_config)
+void attach_trix_mpu(struct address_info *hw_config)
 {
 #if defined(CONFIG_UART401) && defined(CONFIG_MIDI)
 	hw_config->name = "AudioTrix Pro";
@@ -357,78 +358,74 @@
 #endif
 }
 
-int
-probe_trix_mpu(struct address_info *hw_config)
+int probe_trix_mpu(struct address_info *hw_config)
 {
 #ifdef DO_MIDI
-	unsigned char   conf;
-	static char     irq_bits[] =
-	{-1, -1, -1, 1, 2, 3, -1, 4, -1, 5};
+	unsigned char conf;
+	static char irq_bits[] = {
+		-1, -1, -1, 1, 2, 3, -1, 4, -1, 5
+	};
 
 	if (!kilroy_was_here)
-	  {
-		  DDB(printk("Trix: WSS and SB modes must be initialized before MPU\n"));
-		  return 0;	/* AudioTrix Pro has not been detected earlier */
-	  }
+	{
+		DDB(printk("Trix: WSS and SB modes must be initialized before MPU\n"));
+		return 0;	/* AudioTrix Pro has not been detected earlier */
+	}
 	if (!sb_initialized)
-	  {
-		  DDB(printk("Trix: SB mode must be initialized before MPU\n"));
-		  return 0;
-	  }
+	{
+		DDB(printk("Trix: SB mode must be initialized before MPU\n"));
+		return 0;
+	}
 	if (mpu_initialized)
-	  {
-		  DDB(printk("Trix: MPU mode already initialized\n"));
-		  return 0;
-	  }
+	{
+		DDB(printk("Trix: MPU mode already initialized\n"));
+		return 0;
+	}
 	if (check_region(hw_config->io_base, 4))
-	  {
-		  printk("AudioTrix: MPU I/O port conflict (%x)\n", hw_config->io_base);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: MPU I/O port conflict (%x)\n", hw_config->io_base);
+		return 0;
+	}
 	if (hw_config->irq > 9)
-	  {
-		  printk("AudioTrix: Bad MPU IRQ %d\n", hw_config->irq);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: Bad MPU IRQ %d\n", hw_config->irq);
+		return 0;
+	}
 	if (irq_bits[hw_config->irq] == -1)
-	  {
-		  printk("AudioTrix: Bad MPU IRQ %d\n", hw_config->irq);
-		  return 0;
-	  }
+	{
+		printk(KERN_ERR "AudioTrix: Bad MPU IRQ %d\n", hw_config->irq);
+		return 0;
+	}
 	switch (hw_config->io_base)
-	  {
-	  case 0x330:
-		  conf = 0x00;
-		  break;
-	  case 0x370:
-		  conf = 0x04;
-		  break;
-	  case 0x3b0:
-		  conf = 0x08;
-		  break;
-	  case 0x3f0:
-		  conf = 0x0c;
-		  break;
-	  default:
-		  return 0;	/* Invalid port */
-	  }
+	{
+		case 0x330:
+			conf = 0x00;
+			break;
+		case 0x370:
+			conf = 0x04;
+			break;
+		case 0x3b0:
+			conf = 0x08;
+			break;
+		case 0x3f0:
+			conf = 0x0c;
+			break;
+		default:
+			return 0;	/* Invalid port */
+	}
 
 	conf |= irq_bits[hw_config->irq] << 4;
-
 	trix_write(0x19, (trix_read(0x19) & 0x83) | conf);
-
 	mpu_initialized = 1;
-
 	return probe_uart401(hw_config);
 #else
 	return 0;
 #endif
 }
 
-void
-unload_trix_wss(struct address_info *hw_config)
+void unload_trix_wss(struct address_info *hw_config)
 {
-	int             dma2 = hw_config->dma2;
+	int dma2 = hw_config->dma2;
 
 	if (dma2 == -1)
 		dma2 = hw_config->dma;
@@ -444,15 +441,14 @@
 	sound_unload_audiodev(hw_config->slots[0]);
 }
 
-void
-unload_trix_mpu(struct address_info *hw_config)
+void unload_trix_mpu(struct address_info *hw_config)
 {
 #ifdef DO_MIDI
 	unload_uart401(hw_config);
 #endif
 }
-void
-unload_trix_sb(struct address_info *hw_config)
+
+void unload_trix_sb(struct address_info *hw_config)
 {
 #ifdef CONFIG_SBDSP
 	sb_dsp_unload(hw_config);
@@ -473,6 +469,18 @@
 int             mpu_io = -1;
 int             mpu_irq = -1;
 
+EXPORT_NO_SYMBOLS;
+
+MODULE_PARM(io,"i");
+MODULE_PARM(irq,"i");
+MODULE_PARM(dma,"i");
+MODULE_PARM(dma2,"i");
+MODULE_PARM(sb_io,"i");
+MODULE_PARM(sb_dma,"i");
+MODULE_PARM(sb_irq,"i");
+MODULE_PARM(mpu_io,"i");
+MODULE_PARM(mpu_irq,"i");
+
 struct address_info config;
 struct address_info sb_config;
 struct address_info mpu_config;
@@ -482,16 +490,15 @@
 
 static int      fw_load;
 
-int 
-init_module(void)
+int init_module(void)
 {
-	printk("MediaTrix audio driver Copyright (C) by Hannu Savolainen 1993-1996\n");
+	printk(KERN_INFO "MediaTrix audio driver Copyright (C) by Hannu Savolainen 1993-1996\n");
 
 	if (io == -1 || dma == -1 || irq == -1)
-	  {
-		  printk(KERN_INFO "I/O, IRQ, DMA and type are mandatory\n");
-		  return -EINVAL;
-	  }
+	{
+		printk(KERN_INFO "I/O, IRQ, DMA and type are mandatory\n");
+		return -EINVAL;
+	}
 	config.io_base = io;
 	config.irq = irq;
 	config.dma = dma;
@@ -505,21 +512,21 @@
 	mpu_config.irq = mpu_irq;
 
 	if (sb_io != -1 && (sb_irq == -1 || sb_dma == -1))
-	  {
-		  printk(KERN_INFO "CONFIG_SB_IRQ and CONFIG_SB_DMA must be specified if SB_IO is set.\n");
-		  return -EINVAL;
-	  }
+	{
+		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)
-	  {
-		  printk(KERN_INFO "CONFIG_MPU_IRQ must be specified if MPU_IO is set.\n");
-		  return -EINVAL;
-	  }
+	{
+		printk(KERN_INFO "CONFIG_MPU_IRQ must be specified if MPU_IO is set.\n");
+		return -EINVAL;
+	}
 	if (!trix_boot)
-	  {
-		  fw_load = 1;
-		  trix_boot_len = mod_firmware_load("/etc/sound/trxpro.bin",
+	{
+		fw_load = 1;
+		trix_boot_len = mod_firmware_load("/etc/sound/trxpro.bin",
 						    (char **) &trix_boot);
-	  }
+	}
 	if (!probe_trix_wss(&config))
 		return -ENODEV;
 	attach_trix_wss(&config);
@@ -530,26 +537,26 @@
 	 */
 
 	if (sb_io != -1)
-	  {
-		  sb = probe_trix_sb(&sb_config);
-		  if (sb)
-			  attach_trix_sb(&sb_config);
-	  }
+	{
+		sb = probe_trix_sb(&sb_config);
+		if (sb)
+			attach_trix_sb(&sb_config);
+	}
+	
 	if (mpu_io != -1)
-	  {
-		  mpu = probe_trix_mpu(&mpu_config);
-		  if (mpu)
-			  attach_trix_mpu(&mpu_config);
-	  }
+	{
+		mpu = probe_trix_mpu(&mpu_config);
+		if (mpu)
+			attach_trix_mpu(&mpu_config);
+	}
 	SOUND_LOCK;
 	return 0;
 }
 
-void 
-cleanup_module(void)
+void cleanup_module(void)
 {
 	if (fw_load && trix_boot)
-		kfree(trix_boot);
+		vfree(trix_boot);
 	if (sb)
 		unload_trix_sb(&sb_config);
 	if (mpu)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov