Skip to contentSkip to conversation

opl3sa2 isapnp activation fix

PATCH In review Gerald Teschl 2 participants 6 messages Jun 4, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opl3sa2 isapnp activation fix

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

drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 renamed from drivers/sound/opl3sa2.c.orig Thu May 2 23:36:45 2002 +18 -3
@@ -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",
#1 lore raw
Quoted 15 lines · Gerald Teschl
drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 renamed from drivers/sound/opl3sa2.c.orig Thu May 2 23:36:45 2002 +1 -1
@@ -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");

drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 line 880

Quoted 10 lines
drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 renamed from drivers/sound/opl3sa2.c.orig Thu May 2 23:36:45 2002 +8 -2
-            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;

Oops, that won't work on isapnp since dma = dma2 = -1 at this stage, how about;

if ((dma != -1) && (dma2 != -1)) frob();

you shouldn't hard set 0,1

drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 line 893

Quoted 13 lines
drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 renamed from drivers/sound/opl3sa2.c.orig Thu May 2 23:36:45 2002 +9 -0
+            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",

The rest looks ok.

Cheers,
Zwane

Signature · 1 line
http://function.linuxpower.ca
#2 lore raw
Quoted 13 lines · Zwane Mwaikambo

drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 line 880

Quoted 12 lines
         if(dev->activate(dev) < 0) {
drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 renamed from drivers/sound/opl3sa2.c.orig Thu May 2 23:36:45 2002 +8 -3
-            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;
Quoted 6 lines

Oops, that won't work on isapnp since dma = dma2 = -1 at this stage, how about;

if ((dma != -1) && (dma2 != -1)) frob();

you shouldn't hard set 0,1

You can move the check earlier on so that you do the first activate with the supplied dma settings, therefore avoiding the double take. That way you'd also not add any additional frobbing for the normal case.

Signature · 1 line
http://function.linuxpower.ca
#3 lore raw
Quoted 18 lines · Zwane Mwaikambo
Quoted 14 lines · Zwane Mwaikambo
Quoted 14 lines
        if(dev->activate(dev) < 0) {
drivers/sound/opl3sa2.c Tue Jun 4 16:09:50 2002 renamed from drivers/sound/opl3sa2.c.orig Thu May 2 23:36:45 2002 +8 -3
-            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;
Quoted 4 lines
Quoted 4 lines

Oops, that won't work on isapnp since dma = dma2 = -1 at this stage, how about;

if ((dma != -1) && (dma2 != -1)) frob();

I don't get what you mean? I tested this, if I do "modprobe opl3sa2 dma=1 dma2=3" it will activate the card with dma 1,3 (according to /proc/isapnp). However, my card will not work with these values.

Quoted 3 lines
Quoted 3 lines

you shouldn't hard set 0,1

The idea is that I first try to activate the card without assigning fixed values to dma. If this works, then fine. If not, use whatever the user wants for dma respectively take 0,1 as default value. If I do not choose default values, then it will not work automatically unless the user specifies dma. But if the user has to specify values, this is not PnP IMHO.

From your previous message I figured that my patch is fine with you?

Gerald

#4 lore raw
Quoted 9 lines · Gerald Teschl
Quoted 5 lines
Quoted 5 lines

Oops, that won't work on isapnp since dma = dma2 = -1 at this stage, how about;

if ((dma != -1) && (dma2 != -1)) frob();

I don't get what you mean? I tested this, if I do "modprobe opl3sa2 dma=1 dma2=3" it will activate
the card with dma 1,3 (according to /proc/isapnp). However, my card will not work with these values.

How about this, you check if the resource register reads 0 for the DMA value and you reassign it using the resource registers, that way you skip on using magic values.

Cheers,
Zwane

Signature · 1 line
http://function.linuxpower.ca
#5 lore raw
In reply to Gerald Teschl

Hi Gerald,

I forgot to mention, Marcelo is the more likely target for this one, but since he's going for -rc you can either wait for 2.4.20-pre or you can send it to Alan (who probably has the latest version). 2.5 needs a merge from 2.4-ac which i'll send later on.

Cheers,
Zwane

Signature · 1 line
http://function.linuxpower.ca