Support for this card is currently broken for people whose BIOS used
to activate it with ISA PnP, as the kernel now decides to deactivate
it. On 27 Oct 2000 21:48:44 +0100, I sent the maintainer
<[email protected]> and the mailing list
<[email protected]> this patch, but I didn't get any
replies. Other people have written (no doubt better) patches to
accomplish the same thing, but somehow none have appeared in the Linus
tree.
This patch implements ISA PnP probe and activate/deactivate for the
OPL3-SAx. As I don't have the specs for this card, I only know that it
works for me; nevertheless, it should not break any configurations as
the PnP probe only kicks in if the resource parameters are not given
as module arguments.
It should now be possible to compile the driver directly into the
kernel.
The patch is against 2.4.0-test10-pre6, but still applies cleanly to
test12-pre3.
--- linux-orig/drivers/sound/opl3sa2.c Fri Aug 11 16:26:43 2000
+++ linux/drivers/sound/opl3sa2.c Fri Oct 27 21:27:16 2000
@@ -33,13 +33,15 @@
* (with thanks to Ben Hutchings for the heuristic),
* removed now unnecessary force option. (Jan 5, 1999)
* Christoph Hellwig Adapted to module_init/module_exit (Mar 4, 2000)
- *
+ * John Fremlin Do ISA PnP (Oct 27, 2000)
*/
#include <linux/config.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/isapnp.h>
+
#include "sound_config.h"
#include "ad1848.h"
@@ -92,6 +94,10 @@
unsigned int treble;
} opl3sa2_mixerdata;
+#if defined CONFIG_ISAPNP || defined CONFIG_ISAPNP_MODULE
+static struct pci_dev *pnp_dev;
+#endif
+
#ifdef CONFIG_OPL3SA2_CTRL_BASE
/* Set control port if compiled into the kernel */
static opl3sa2_mixerdata opl3sa2_data = { CONFIG_OPL3SA2_CTRL_BASE, };
@@ -517,11 +523,63 @@
}
+static inline void opl3sa2_pnp_deactivate()
+{
+#if defined CONFIG_ISAPNP || defined CONFIG_ISAPNP_MODULE
+ if(pnp_dev){
+ pnp_dev->deactivate(pnp_dev);
+ pnp_dev=0;
+ }
+#endif
+}
+
+
+static inline int opl3sa2_pnp_activate(struct address_info *sa2_cfg,
+ struct address_info *mss_cfg,
+ struct address_info *mpu_cfg)
+{
+#if defined CONFIG_ISAPNP || defined CONFIG_ISAPNP_MODULE
+ int ret;
+
+ opl3sa2_pnp_deactivate();
+
+ pnp_dev = isapnp_find_dev(NULL,
+ ISAPNP_VENDOR('Y','M','H'),
+ ISAPNP_FUNCTION(0x0021),
+ NULL);
+ if (!pnp_dev)
+ return -ENODEV;
+ if (pnp_dev->active)
+ return -EBUSY;
+ if (pnp_dev->prepare(pnp_dev)<0)
+ return -EAGAIN;
+ if ((ret = pnp_dev->activate(pnp_dev))) {
+ if(ret == -EBUSY){
+ /*already activated*/
+ } else {
+ printk(KERN_ERR "opl3sa2: isapnp configure failed (out of resources?)\n");
+ return -ENOMEM;
+ }
+ }
+
+ sa2_cfg->io_base = pnp_dev->resource[0].start;
+ mss_cfg->io_base = pnp_dev->resource[1].start;
+ /* pnp_dev->resource[2].start is for OPL3 FM*/
+ mpu_cfg->io_base = pnp_dev->resource[3].start;
+
+ mss_cfg->irq = sa2_cfg->irq = pnp_dev->irq_resource[0].start;
+ mss_cfg->dma = sa2_cfg->dma = pnp_dev->dma_resource[0].start;
+ mss_cfg->dma2 = sa2_cfg->dma2 = pnp_dev->dma_resource[1].start;
+#endif /* defined CONFIG_ISAPNP || defined CONFIG_ISAPNP_MODULE */
+ return 0;
+}
+
+
static int __init probe_opl3sa2(struct address_info *hw_config)
{
unsigned char version = 0;
char tag;
-
+
/*
* Verify that the I/O port range is free.
*/
@@ -605,6 +663,7 @@
{
/* Release control ports */
release_region(hw_config->io_base, 2);
+ opl3sa2_pnp_deactivate();
/* Unload mixer */
if(opl3sa2_mixer >= 0)
@@ -671,8 +730,8 @@
cfg_mpu.always_detect = 1; /* It's there, so use shared IRQs */
if(cfg.io_base == -1 || cfg.irq == -1 || cfg.dma == -1 || cfg.dma2 == -1 || cfg2.io_base == -1) {
- printk(KERN_ERR "opl3sa2: io, mss_io, irq, dma, and dma2 must be set.\n");
- return -EINVAL;
+ if(opl3sa2_pnp_activate(&cfg,&cfg2,&cfg_mpu)) /* Have a bash at PnP */
+ return -EINVAL;
}
/* Call me paranoid: */
--
http://www.penguinpowered.com/~vii
On 29 Nov 2000, John Fremlin wrote:
>
> Support for this card is currently broken for people whose BIOS used
> to activate it with ISA PnP, as the kernel now decides to deactivate
> it. On 27 Oct 2000 21:48:44 +0100, I sent the maintainer
> <[email protected]> and the mailing list
> <[email protected]> this patch, but I didn't get any
> replies. Other people have written (no doubt better) patches to
> accomplish the same thing, but somehow none have appeared in the Linus
> tree.
As the maintainer in question, I apologize. I've been remiss in getting
a patch into 2.4 due to being focused on a new job. My current plan is
to take Friday off and work on getting all of the various fixes people
have sent me glued together into one patch. I must admit, though, that
I've been running 2.4.0-test kernels for quite some time and have not
had any problems activating my OPL3-SA3 card the old-fashioned way with
isapnp.
> This patch implements ISA PnP probe and activate/deactivate for the
> OPL3-SAx. As I don't have the specs for this card, I only know that it
> works for me; nevertheless, it should not break any configurations as
> the PnP probe only kicks in if the resource parameters are not given
> as module arguments.
I'd rather that this patch not be applied in its current form, as there are
a few issues to be cleaned up. For one, the following:
> + sa2_cfg->io_base = pnp_dev->resource[0].start;
is incorrect. The first value reported back by the ISA PnP driver is
the port for the unused SoundBlaster Pro implementation, not the SA2/3
control port (which is the 5th value). Using a port in the SB port range
as the control port probably works most of the time, but there are some
weird laptops with this chipset, and there's a chance some of them might
not work.
Another overlooked issue (common to all the PnP patches I've been sent, I
think) is handling more than one card, as the SB PnP code does. It would
be a bit of a pain to have to resort back to isapnp and module parms to
configure a second card.
Anyways, as I mentioned above, I'll try to get a more comprehensive patch
done and posted for testing sometime on Friday.
Scott
--
=============================================================================
Scott Murray email: [email protected]
http://www.interlog.com/~scottm ICQ: 10602428
-----------------------------------------------------------------------------
"Good, bad ... I'm the guy with the gun." - Ash, "Army of Darkness"