patch-2.2.0-pre6 linux/drivers/sound/opl3sa2.c

Next file: linux/drivers/sound/sb.h
Previous file: linux/drivers/sound/mad16.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.0-pre5/linux/drivers/sound/opl3sa2.c linux/drivers/sound/opl3sa2.c
@@ -4,7 +4,7 @@
  * A low level driver for Yamaha OPL3-SA2 and SA3 cards.
  * SAx cards should work, as they are just variants of the SA3.
  *
- * Copyright 1998 Scott Murray <scottm@interlog.com>
+ * Copyright 1998, 1999 Scott Murray <scottm@interlog.com>
  *
  * Originally based on the CS4232 driver (in cs4232.c) by Hannu Savolainen
  * and others.  Now incorporates code/ideas from pss.c, also by Hannu
@@ -29,6 +29,9 @@
  * Scott Murray            Changed detection code to be more forgiving,
  *                         added force option as last resort,
  *                         fixed ioctl return values. (Dec 30, 1998)
+ * Scott Murray            Simpler detection code should work all the time now
+ *                         (with thanks to Ben Hutchings for the heuristic),
+ *                         removed now unnecessary force option. (Jan 5, 1999)
  *
  */
 
@@ -53,12 +56,12 @@
 #define DEFAULT_MIC    50
 #define DEFAULT_TIMBRE 0
 
+#define CHIPSET_UNKNOWN -1
+
 /*
- * NOTE: CHIPSET_UNKNOWN should match the default value of
- *       CONFIG_OPL3SA2_CHIPSET in Config.in to make everything
- *       work right in all situations.
+ * These are used both as masks against what the card returns,
+ * and as constants.
  */
-#define CHIPSET_UNKNOWN -1
 #define CHIPSET_OPL3SA2  1
 #define CHIPSET_OPL3SA3  2
 #define CHIPSET_OPL3SAX  4
@@ -67,12 +70,7 @@
 #ifdef CONFIG_OPL3SA2
 
 /* What's my version? */
-#ifdef CONFIG_OPL3SA2_CHIPSET
-/* Set chipset if compiled into the kernel */
-static int chipset = CONFIG_OPL3SA2_CHIPSET;
-#else
 static int chipset = CHIPSET_UNKNOWN;
-#endif
 
 /* Oh well, let's just cache the name */
 static char chipset_name[16];
@@ -526,14 +524,6 @@
 
 int probe_opl3sa2(struct address_info *hw_config)
 {
-	unsigned char chipsets[8] = { CHIPSET_UNKNOWN, /* 0 */
-				      CHIPSET_OPL3SA2, /* 1 */
-				      CHIPSET_OPL3SA3, /* 2 */
-				      CHIPSET_UNKNOWN, /* 3 */
-				      CHIPSET_OPL3SAX, /* 4 */
-				      CHIPSET_OPL3SAX, /* 5 */
-				      CHIPSET_UNKNOWN, /* 6 */
-				      CHIPSET_OPL3SA3, /* 7 */ };
 	unsigned char version = 0;
 	char tag;
 
@@ -551,107 +541,55 @@
 
 	/*
 	 * Determine chipset type (SA2, SA3, or SAx)
-	 *
-	 * Have to handle two possible override situations:
-	 * 1) User compiled driver into the kernel and forced chipset type
-	 * 2) User built a module, but wants to override the chipset type
 	 */
-	if(chipset == CHIPSET_UNKNOWN)
+
+	/*
+	 * Look at chipset version in lower 3 bits of index 0x0A, miscellaneous
+	 */
+	opl3sa2_read(hw_config->io_base,
+		     OPL3SA2_MISC,
+		     (unsigned char*) &version);
+	version &= 0x07;
+
+	/* Match version number to appropiate chipset */
+	if(version & CHIPSET_OPL3SAX)
+	{
+		chipset = CHIPSET_OPL3SAX;
+		tag = 'x';
+		printk(KERN_INFO "Found OPL3-SAx (YMF719)\n");
+	}
+	else
 	{
-		if(hw_config->card_subtype == CHIPSET_UNKNOWN)
+ 		if(version & CHIPSET_OPL3SA3)
 		{
-			/*
-			 * Look at chipset version in lower 3 bits of index 0x0A, miscellaneous
-			 */
-			opl3sa2_read(hw_config->io_base,
-				     OPL3SA2_MISC,
-				     (unsigned char*) &version);
-			version &= 0x07;
-
-			/* Match version number to appropiate chipset */
-			chipset = chipsets[version];
+			chipset = CHIPSET_OPL3SA3;
+			tag = '3';
+			printk(KERN_INFO "Found OPL3-SA3 (YMF715)\n");
 		}
 		else
 		{
-			/* Use user specified chipset */
-			switch(hw_config->card_subtype)
+			if(version & CHIPSET_OPL3SA2)
 			{
-				case 2:
-					chipset = CHIPSET_OPL3SA2;
-					break;
-
-				case 3:
-					chipset = CHIPSET_OPL3SA3;
-					break;
-
-				default:
-					printk(KERN_ERR "%s: Unknown chipset %d\n",
-					       __FILE__,
-					       hw_config->card_subtype);
-					chipset = CHIPSET_UNKNOWN;
-					break;
-			}
-		}
-	}
-	else
-	{
-		/* Use user compiled in chipset */
-		switch(chipset)
-		{
-			case 2:
 				chipset = CHIPSET_OPL3SA2;
-				break;
-				
-			case 3:
-				chipset = CHIPSET_OPL3SA3;
-				break;
-
-			default:
-				printk(KERN_ERR "%s: Unknown chipset %d\n",
-				       __FILE__,
-				       chipset);
-				chipset = CHIPSET_UNKNOWN;
-				break;
-		}
-	}
-
-	/* Do chipset specific stuff: */
-	switch(chipset)
-	{
-		case CHIPSET_OPL3SA2:
-			printk(KERN_INFO "Found OPL3-SA2 (YMF711)\n");
-			tag = '2';
-			break;
-
-		case CHIPSET_OPL3SA3:
-			printk(KERN_INFO "Found OPL3-SA3 (YMF715)\n");
-			tag = '3';
-			break;
-
-		case CHIPSET_OPL3SAX:
-			printk(KERN_INFO "Found OPL3-SAx (YMF719)\n");
-			tag = 'x';
-			break;
-
-		default:
-			printk(KERN_ERR "No Yamaha audio controller found\n");
-
-			/* If we've actually checked the version, print it out */
-			if(version)
+				tag = '2';
+				printk(KERN_INFO "Found OPL3-SA2 (YMF711)\n");
+			}
+			else
 			{
+				chipset = CHIPSET_UNKNOWN;
+				tag = '?';
+				printk(KERN_ERR
+				       "Unknown Yamaha audio controller version\n");
 				printk(KERN_INFO
 				       "%s: chipset version = %x\n",
 				       __FILE__,
 				       version);
 			}
-			
-			/* Set some sane values */
-			chipset = CHIPSET_UNKNOWN;
-			tag = '?';
-			break;
+		}
 	}
 
-	if(chipset != CHIPSET_UNKNOWN) {
+	if(chipset != CHIPSET_UNKNOWN)
+	{
 		/* Generate a pretty name */
 		sprintf(chipset_name, "OPL3-SA%c", tag);
 		return 1;
@@ -687,7 +625,6 @@
 int irq     = -1;
 int dma     = -1;
 int dma2    = -1;
-int force   = -1;
 
 MODULE_PARM(io, "i");
 MODULE_PARM_DESC(io, "Set i/o base of OPL3-SA2 or SA3 card (usually 0x370)");
@@ -707,9 +644,6 @@
 MODULE_PARM(dma2, "i");
 MODULE_PARM_DESC(dma2, "Set MSS (audio) second DMA channel (0, 1, 3)");
 
-MODULE_PARM(force, "i");
-MODULE_PARM_DESC(force, "Force audio controller chipset (2, 3)");
-
 MODULE_DESCRIPTION("Module for OPL3-SA2 and SA3 sound cards (uses AD1848 MSS driver).");
 MODULE_AUTHOR("Scott Murray <scottm@interlog.com>");
 
@@ -731,7 +665,8 @@
 
 	if(io == -1 || irq == -1 || dma == -1 || dma2 == -1 || mss_io == -1)
 	{
-		printk(KERN_ERR "%s: io, mss_io, irq, dma, and dma2 must be set.\n",
+		printk(KERN_ERR
+		       "%s: io, mss_io, irq, dma, and dma2 must be set.\n",
 		       __FILE__);
 		return -EINVAL;
 	}
@@ -742,12 +677,6 @@
 	cfg.dma     = dma;
 	cfg.dma2    = dma2;
 	
-	/* Does the user want to override the chipset type? */
-	if(force != -1)
-		cfg.card_subtype = force;
-	else
-		cfg.card_subtype = CHIPSET_UNKNOWN;
-
         /* The MSS config: */
 	mss_cfg.io_base      = mss_io;
 	mss_cfg.irq          = irq;

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