Messages in this thread Patch in this message | | | From | Andrey Panin <> | Subject | [PATCH] ISA PnP for joy-analog.c | Date | Tue, 7 Mar 2000 10:39:18 +0300 |
| |
Hi all,
this small patch provides game port autodetection for ISA PnP cards. I hope it will be useful.
Best wishes, Andrey diff -r -u -N /mnt/d/linux-2.3.48/drivers/char/joystick/joy-analog.c /linux/drivers/char/joystick/joy-analog.c --- /mnt/d/linux-2.3.48/drivers/char/joystick/joy-analog.c Mon Feb 28 20:32:32 2000 +++ /linux/drivers/char/joystick/joy-analog.c Sat Mar 4 20:06:07 2000 @@ -45,6 +45,11 @@ #include <linux/string.h> #include <linux/init.h> +#if defined(CONFIG_ISAPNP) || defined(CONFIG_ISAPNP_MODULE) +#define JOYSTICK_ISAPNP +#include <linux/isapnp.h> +#endif + #define JS_AN_MAX_TIME 3000 /* 3 ms */ #define JS_AN_LOOP_TIME 2000 /* 2 t */ @@ -272,6 +277,12 @@ __setup("js_an=", js_an_setup); #endif +#if defined(JOYSTICK_ISAPNP) && defined(MODULE) +#define NR_PNP_DEVICES 4 +static struct pci_dev *pnp_devs[NR_PNP_DEVICES]; +static int pnp_dev_idx = 0; +#endif + #ifdef MODULE int init_module(void) #else @@ -279,7 +290,9 @@ #endif { int i; - +#ifdef JOYSTICK_ISAPNP + struct pci_dev *dev = NULL; +#endif if (js_an[0] >= 0) { for (i = 0; (js_an[i*3] >= 0) && i < 8; i++) js_an_port = js_an_probe(js_an[i*3], js_an[i*3+1], js_an[i*3+2], js_an_port); @@ -287,6 +300,31 @@ for (i = 0; js_an_port_list[i]; i++) js_an_port = js_an_probe(js_an_port_list[i], 0, 0, js_an_port); } +#ifdef JOYSTICK_ISAPNP + while ((dev = isapnp_find_dev(NULL, ISAPNP_VENDOR('P', 'N', 'P'), + ISAPNP_DEVICE(0xB02F), dev))) { + + if (dev->active) + continue; +#ifdef MODULE + if (pnp_dev_idx >= NR_PNP_DEVICES) + break; + pnp_devs[pnp_dev_idx++] = dev; +#endif + if (dev->prepare(dev) < 0) { + printk(KERN_WARNING "joy-analog: %s prepare failed\n", + dev->bus->name); + continue; + } + + if (dev->activate(dev) < 0) { + printk(KERN_WARNING "joy-analog: %s activate failed\n", + dev->bus->name); + continue; + } + js_an_port = js_an_probe(dev->resource[0].start, 0, 0, js_an_port); + } +#endif if (js_an_port) return 0; #ifdef MODULE @@ -310,6 +348,11 @@ release_region(info->io, 1); js_an_port = js_unregister_port(js_an_port); } - +#ifdef JOYSTICK_ISAPNP + for (i = 0; i < pnp_dev_idx; i++) { + if (pnp_devs[i]->deactivate) + pnp_devs[i]->deactivate(pnp_devs[i]); + } +#endif } #endif
| |