From: David Schleef Date: Mon, 7 Feb 2000 23:08:29 +0000 (+0000) Subject: Fix to make comedi_parport driver modular X-Git-Tag: r0_7_38~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fc23abaa9fd95813e38a817e3a8c9eb0bc962357;p=comedi.git Fix to make comedi_parport driver modular --- diff --git a/comedi/drivers/Makefile b/comedi/drivers/Makefile index 2cdd2939..d0112b93 100644 --- a/comedi/drivers/Makefile +++ b/comedi/drivers/Makefile @@ -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 index 00000000..3490507e --- /dev/null +++ b/comedi/drivers/comedi_parport.c @@ -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 + + 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#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 +