public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] opl3sa2 isapnp activation fix
@ 2002-06-04 15:57 Gerald Teschl
  2002-06-04 15:42 ` Zwane Mwaikambo
  2002-06-04 15:48 ` Zwane Mwaikambo
  0 siblings, 2 replies; 8+ messages in thread
From: Gerald Teschl @ 2002-06-04 15:57 UTC (permalink / raw)
  To: linux-kernel, linux-sound, torvalds; +Cc: zwane

Hi,

this is the final version of my patch which fixes the isapnp activation 
of opl3sa2 based
cards which require dma=0 as discussed with Zwane Mwaikambo.

Gerald

--- linux-2.4.18-4/drivers/sound/opl3sa2.c.orig    Thu May  2 23:36:45 2002
+++ linux-2.4.18-4/drivers/sound/opl3sa2.c    Tue Jun  4 16:09:50 2002
@@ -57,6 +57,7 @@
  *                         (Jan 7, 2001)
  * Zwane Mwaikambo       Added PM support. (Dec 4 2001)
  * Zwane Mwaikambo       Code, data structure cleanups. (Feb 15 2002)
+ * Gerald Teschl       Fixed ISA PnP activate. (Jun 02 2002)
  *
  */
 
@@ -869,10 +870,24 @@
     }
     else {
         if(dev->activate(dev) < 0) {
-            printk(KERN_WARNING PFX "ISA PnP activate failed\n");
-            opl3sa2_state[card].activated = 0;
-            return -ENODEV;
+            /*
+             * isapnp.c disallows dma=0 but some opl3sa2 cards need it.
+             * So we set dma by hand and try again
+             */
+            if (dma < 0 || dma > 7)
+                dma= 0;
+            if (dma2 < 0 || dma2 >7)
+                dma2= 1;
+            isapnp_resource_change(&dev->dma_resource[0], dma, 1);
+            isapnp_resource_change(&dev->dma_resource[1], dma2, 1);
         }
+        if(!dev->active)
+           if (dev->activate(dev) < 0) {
+                printk(KERN_WARNING PFX "ISA PnP activate failed.\n");
+                opl3sa2_state[card].activated = 0;
+                return -ENODEV;
+            }
+        opl3sa2_state[card].activated = 1;
 
         printk(KERN_DEBUG
                PFX "Activated ISA PnP card %d (active=%d)\n",


^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <Pine.LNX.4.44.0206051414200.26634-100000@netfinity.realnet.co.sz>]
* [PATCH] opl3sa2 isapnp activation fix
@ 2002-06-06 18:44 Gerald Teschl
  0 siblings, 0 replies; 8+ messages in thread
From: Gerald Teschl @ 2002-06-06 18:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: zwane, alan, linux-sound

Now here is the new version of the opl3sa2 activation fix. This new
version now adds the fix as a quirk to isapnp. Zwane Mwaikambo and
I have discussed this very carefully and we now both agree that this
is the best way to fix the problem. The patch is against 2.4.19-pre10
and requires the previous isapnp_dma0.patch.

It now loops over all acceptable dma_resources and only allows dma0
if dma channel 0 is the ONLY value accepted by the card. In
addition, it also fixes the problem that a card would not get
deactivated upon removal of the module.

Gerald

opl3sa2_dma0.patch:
-------------------------
--- linux.orig/drivers/pnp/quirks.c	Thu Jun  6 18:04:43 2002
+++ linux/drivers/pnp/quirks.c	Thu Jun  6 18:07:25 2002
@@ -102,6 +102,28 @@
 	return;
 }
 
+extern int isapnp_allow_dma0;
+static void __init quirk_opl3sax_resources(struct pci_dev *dev)
+{
+	/* This really isn't a device quirk but isapnp core code
+	 * doesn't allow a DMA channel of 0, afflicted card is an
+	 * OPL3Sax where x=4.
+	 */
+	struct isapnp_resources *res;
+	int max;
+	res = (struct isapnp_resources *)dev->sysdata;
+	max = res->dma->map;
+	for (res = res->alt; res; res = res->alt) {
+		if (res->dma->map > max)
+			max = res->dma->map;
+	}
+	if (max == 1 && isapnp_allow_dma0 == -1) {
+		printk(KERN_INFO "isapnp: opl3sa4 quirk: Allowing dma 0.\n");
+		isapnp_allow_dma0 = 1;
+	}
+	return;
+}
+
 /*
  *  ISAPnP Quirks
  *  Cards or devices that need some tweaking due to broken hardware
@@ -133,6 +155,8 @@
 		quirk_sb16audio_resources },
 	{ ISAPNP_VENDOR('C','T','L'), ISAPNP_DEVICE(0x0045),
 		quirk_sb16audio_resources },
+	{ ISAPNP_VENDOR('Y','M','H'), ISAPNP_DEVICE(0x0021),
+		quirk_opl3sax_resources },
 	{ 0 }
 };
 
--- linux.orig/drivers/sound/opl3sa2.c	Thu Jun  6 18:04:44 2002
+++ linux/drivers/sound/opl3sa2.c	Thu Jun  6 18:07:25 2002
@@ -57,6 +57,7 @@
  *                         (Jan 7, 2001)
  * Zwane Mwaikambo	   Added PM support. (Dec 4 2001)
  * Zwane Mwaikambo	   Code, data structure cleanups. (Feb 15 2002)
+ * Gerald Teschl	   ISA PnP activate fix. (Jun 02 2002)
  *
  */
 
@@ -873,10 +874,11 @@
 	}
 	else {
 		if(dev->activate(dev) < 0) {
-			printk(KERN_WARNING PFX "ISA PnP activate failed\n");
+			printk(KERN_WARNING PFX "ISA PnP activate failed.\n");
 			opl3sa2_state[card].activated = 0;
 			return -ENODEV;
 		}
+		opl3sa2_state[card].activated = 1;
 
 		printk(KERN_DEBUG
 		       PFX "Activated ISA PnP card %d (active=%d)\n",


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-06-06 18:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-04 15:57 [PATCH] opl3sa2 isapnp activation fix Gerald Teschl
2002-06-04 15:42 ` Zwane Mwaikambo
2002-06-04 15:55   ` Zwane Mwaikambo
2002-06-04 17:34     ` Gerald Teschl
2002-06-04 17:33       ` Zwane Mwaikambo
2002-06-04 15:48 ` Zwane Mwaikambo
     [not found] <Pine.LNX.4.44.0206051414200.26634-100000@netfinity.realnet.co.sz>
2002-06-05 15:05 ` Gerald Teschl
  -- strict thread matches above, loose matches on Subject: below --
2002-06-06 18:44 Gerald Teschl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox