Fix to make comedi_parport driver modular
authorDavid Schleef <ds@schleef.org>
Mon, 7 Feb 2000 23:08:29 +0000 (23:08 +0000)
committerDavid Schleef <ds@schleef.org>
Mon, 7 Feb 2000 23:08:29 +0000 (23:08 +0000)
comedi/drivers/Makefile
comedi/drivers/comedi_parport.c [new file with mode: 0644]

index 2cdd29393a7398f657cbe69d684d4f4ada520e77..d0112b930f2c1c159d54f9c866333a847842bbcb 100644 (file)
@@ -40,6 +40,8 @@ obj-$(CONFIG_COMEDI_PCL711)           += pcl711.o
 obj-$(CONFIG_COMEDI_PCL725)            += pcl725.o
 obj-$(CONFIG_COMEDI_PCL726)            += pcl726.o
 
+obj-$(CONFIG_COMEDI_PARPORT)           += comedi_parport.o
+
 obj-$(CONFIG_COMEDI_RTI800)            += rti800.o
 obj-$(CONFIG_COMEDI_RTI802)            += rti802.o
 
diff --git a/comedi/drivers/comedi_parport.c b/comedi/drivers/comedi_parport.c
new file mode 100644 (file)
index 0000000..3490507
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+    module/parport.c
+    hardware driver for standard parallel port
+
+    COMEDI - Linux Control and Measurement Device Interface
+    Copyright (C) 1998 David A. Schleef <ds@stm.lbl.gov>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/*
+
+   TODO:
+
+   - support bit mask ioctl
+   - EPP/ECP support
+
+   see http://www.senet.com.au/~cpeacock/parallel.htm for information.
+ */
+
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/malloc.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/timex.h>
+#include <linux/timer.h>
+#include <asm/io.h>
+#include <comedi_module.h>
+
+
+#define PARPORT_SIZE 3
+
+#define PARPORT_A 0
+#define PARPORT_B 1
+#define PARPORT_C 2
+
+static int parport_attach(comedi_device *dev,comedi_devconfig *it);
+static int parport_detach(comedi_device *dev);
+comedi_driver driver_parport={
+       driver_name:    "parport",
+       module:         &__this_module,
+       attach:         parport_attach,
+       detach:         parport_detach,
+};
+
+
+static int parport_dio_a(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+{
+       outb(it->data[0],dev->iobase+PARPORT_A);
+
+       return 1;
+}
+
+static int parport_dio_b(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+{
+       it->data[0]=(inb(dev->iobase+PARPORT_B)>>3);
+
+       return 1;
+}
+
+static int parport_dio_c(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+{
+       outb(it->data[0],dev->iobase+PARPORT_C);
+
+       return 1;
+}
+
+
+static int parport_attach(comedi_device *dev,comedi_devconfig *it)
+{
+       int ret;
+       comedi_subdevice *s;
+
+       dev->iobase=it->options[0];
+       printk("comedi%d: parport: 0x%04x ",dev->minor,dev->iobase);
+       if(check_region(dev->iobase,PARPORT_SIZE)<0){
+               printk("I/O port conflict\n");
+               return -EIO;
+       }
+       request_region(dev->iobase,PARPORT_SIZE,"parport (comedi)");
+       dev->iosize=PARPORT_SIZE;
+       dev->irq=0;
+       dev->board_name="parport";
+
+       dev->n_subdevices=3;
+       if((ret=alloc_subdevices(dev))<0)
+               return ret;
+
+       s=dev->subdevices+0;
+       s->type=COMEDI_SUBD_DO;
+       s->subdev_flags=SDF_WRITEABLE;
+       s->n_chan=8;
+       s->maxdata=1;
+       s->range_type=RANGE_digital;
+       s->trig[0]=parport_dio_a;
+
+       s=dev->subdevices+1;
+       s->type=COMEDI_SUBD_DI;
+       s->subdev_flags=SDF_READABLE;
+       s->n_chan=4;
+       s->maxdata=1;
+       s->range_type=RANGE_digital;
+       s->trig[0]=parport_dio_b;
+
+       s=dev->subdevices+2;
+       s->type=COMEDI_SUBD_DO;
+       s->subdev_flags=SDF_WRITEABLE;
+       s->n_chan=4;
+       s->maxdata=1;
+       s->range_type=RANGE_digital;
+       s->trig[0]=parport_dio_c;
+
+       printk("\n");
+       return 1;
+}
+
+
+static int parport_detach(comedi_device *dev)
+{
+       printk("comedi%d: parport: remove\n",dev->minor);
+       
+       release_region(dev->iobase,dev->iosize);
+
+       return 0;
+}
+
+#ifdef MODULE
+int init_module(void)
+{
+       comedi_driver_register(&driver_parport);
+
+       return 0;
+}
+
+void cleanup_module(void)
+{
+       comedi_driver_unregister(&driver_parport);
+}
+#endif
+