range modularization
authorDavid Schleef <ds@schleef.org>
Tue, 15 Feb 2000 08:02:10 +0000 (08:02 +0000)
committerDavid Schleef <ds@schleef.org>
Tue, 15 Feb 2000 08:02:10 +0000 (08:02 +0000)
30 files changed:
comedi/Makefile
comedi/comedi_fops.c
comedi/comedi_ksyms.c
comedi/comedi_module.h
comedi/drivers.c
comedi/drivers/8255.c
comedi/drivers/Makefile
comedi/drivers/comedi_parport.c
comedi/drivers/das08.c
comedi/drivers/das08jr.c
comedi/drivers/das1600.c
comedi/drivers/das6402.c
comedi/drivers/dt2801.c
comedi/drivers/dt2811.c
comedi/drivers/dt2814.c
comedi/drivers/dt2815.c
comedi/drivers/dt2817.c
comedi/drivers/dt282x.c
comedi/drivers/dt3000.c
comedi/drivers/multiq3.c
comedi/drivers/ni_pcidio.c
comedi/drivers/pcl711.c
comedi/drivers/pcl725.c
comedi/drivers/pcl726.c
comedi/drivers/rti800.c
comedi/drivers/rti802.c
comedi/dummy.c
comedi/mk_range.c [deleted file]
comedi/range.c
include/comedi.h

index 129ab3e2959b8b4ada0703243688f24ae4432995..90396b3e01c48ddcb5c89e3cd9640696ab3edf92 100644 (file)
@@ -1,8 +1,8 @@
 
 
 SUB_DIRS     := drivers realtime
-ALL_SUB_DIRS := kcomedilib drivers realtime
-MOD_SUB_DIRS := drivers realtime
+ALL_SUB_DIRS := kcomedilib drivers
+MOD_SUB_DIRS := drivers
 MOD_IN_SUB_DIRS :=
 
 ifneq ($(CONFIG_COMEDI_KLIB),n)
@@ -10,6 +10,11 @@ ifneq ($(CONFIG_COMEDI_KLIB),n)
        SUB_DIRS += kcomedilib
 endif
 
+ifeq ($(CONFIG_COMEDI_RT),y)
+       MOD_SUB_DIRS += realtime
+       SUB_DIRS += realtime
+endif
+
 MOD_LIST_NAME := MISC_MODULES
 
 M_OBJS := comedi.o
@@ -33,20 +38,20 @@ ifeq ($(CONFIG_COMEDI_RTL_V1),y)
 MI_OBJS += rtl_v1.o
 endif
 
-range-y := range.c
-range-$(CONFIG_COMEDI_DT2801)          += drivers/dt2801.c
-range-$(CONFIG_COMEDI_DT2811)          += drivers/dt2811.c
-range-$(CONFIG_COMEDI_DT2815)          += drivers/dt2815.c
-range-$(CONFIG_COMEDI_DT282x)          += drivers/dt282x.c
-range-$(CONFIG_COMEDI_DT3000)          += drivers/dt3000.c
-range-$(CONFIG_COMEDI_NI_ATMIO)                += drivers/ni_mio_common.c
-ifndef CONFIG_COMEDI_NI_ATMIO
-range-$(CONFIG_COMEDI_NI_PCIMIO)       += drivers/ni_mio_common.c
-endif
+#range-y := range.c
+#range-$(CONFIG_COMEDI_DT2801)         += drivers/dt2801.c
+#range-$(CONFIG_COMEDI_DT2811)         += drivers/dt2811.c
+#range-$(CONFIG_COMEDI_DT2815)         += drivers/dt2815.c
+#range-$(CONFIG_COMEDI_DT282x)         += drivers/dt282x.c
+#range-$(CONFIG_COMEDI_DT3000)         += drivers/dt3000.c
+#range-$(CONFIG_COMEDI_NI_ATMIO)               += drivers/ni_mio_common.c
+#ifndef CONFIG_COMEDI_NI_ATMIO
+#range-$(CONFIG_COMEDI_NI_PCIMIO)      += drivers/ni_mio_common.c
+#endif
 
-range-$(CONFIG_COMEDI_PCL711)          += drivers/pcl711.c
-range-$(CONFIG_COMEDI_RTI800)          += drivers/rti800.c
-range-$(CONFIG_COMEDI_DAS1600)         += drivers/das1600.c
+#range-$(CONFIG_COMEDI_PCL711)         += drivers/pcl711.c
+#range-$(CONFIG_COMEDI_RTI800)         += drivers/rti800.c
+#range-$(CONFIG_COMEDI_DAS1600)                += drivers/das1600.c
 
 
 
@@ -58,18 +63,3 @@ include $(TOPDIR)/Rules.make
 comedi.o: $(MI_OBJS) $(MIX_OBJS)
        $(LD) -r -o $@ $(MI_OBJS) $(MIX_OBJS)
 
-range.h: mk_range $(TOPDIR)/.config
-       -rm -f range.h
-       set -e ; for i in $(range-y) $(range-m) ; do \
-       grep -A 99999 -e '^--BEGIN-RANGE-DEFS--' $$i | \
-       grep -B 99999 -e '^---END-RANGE-DEFS---' | \
-       grep -v -e 'RANGE-DEFS' ; done >range.def
-       ./mk_range source <range.def >range.h
-       ./mk_range include <range.def >>range.h
-
-mk_range: mk_range.c
-       $(CC) -Wall mk_range.c -o mk_range
-
-$(MIX_OBJS) $(MI_OBJS):        range.h
-
-
index aa6fd023aca6c28fdf1945c7fef6baf194fdadcd..a565050ff1b778f8ae912d67602e55ba01cfa035 100644 (file)
@@ -43,7 +43,6 @@
 
 comedi_device *comedi_devices;
 
-
 static int do_devconfig_ioctl(comedi_device *dev,comedi_devconfig *arg,kdev_t minor);
 static int do_devinfo_ioctl(comedi_device *dev,comedi_devinfo *arg);
 static int do_subdinfo_ioctl(comedi_device *dev,comedi_subdinfo *arg,void *file);
@@ -201,7 +200,8 @@ static int do_subdinfo_ioctl(comedi_device *dev,comedi_subdinfo *arg,void *file)
                us->timer_type          = s->timer_type;
                us->len_chanlist        = s->len_chanlist;
                us->maxdata             = s->maxdata;
-               us->range_type          = s->range_type;
+               us->range_type          = (dev->minor<<24)|(i<<20)|(0<<16)|
+                       (s->range_table->length);
                us->flags               = s->flags;
                
                if(s->busy)
@@ -216,7 +216,7 @@ static int do_subdinfo_ioctl(comedi_device *dev,comedi_subdinfo *arg,void *file)
                        us->subd_flags |= SDF_MAXDATA;
                if(s->flaglist)
                        us->subd_flags |= SDF_FLAGS;
-               if(s->range_type_list)
+               if(s->range_table_list)
                        us->subd_flags |= SDF_RANGETYPE;
                if(s->trig[0])
                        us->subd_flags |= SDF_MODE0;
@@ -278,9 +278,18 @@ static int do_chaninfo_ioctl(comedi_device *dev,comedi_chaninfo *arg)
        }
                        
        if(it.rangelist){
-               if(!s->range_type_list)return -EINVAL;
-               if(copy_to_user(it.rangelist,s->range_type_list,s->n_chan*sizeof(unsigned int)))
-                       return -EFAULT;
+               int i;
+
+               if(!s->range_table_list)return -EINVAL;
+               for(i=0;i<s->n_chan;i++){
+                       int x;
+
+                       x=(dev->minor<<24)|(it.subdev<<20)|(i<<16)|
+                               (s->range_table_list[i]->length);
+                       put_user(x,it.rangelist+i);
+               }
+               //if(copy_to_user(it.rangelist,s->range_type_list,s->n_chan*sizeof(unsigned int)))
+               //      return -EFAULT;
        }
        
        return 0;
@@ -1345,161 +1354,3 @@ void comedi_eobuf(comedi_device *dev,comedi_subdevice *s)
        }
 }
 
-
-int di_unpack(unsigned int bits,comedi_trig *it)
-{
-       int chan;
-       int i;
-
-       for(i=0;i<it->n_chan;i++){
-               chan=CR_CHAN(it->chanlist[i]);
-               it->data[i]=(bits>>chan)&1;
-       }
-
-       return i;
-}
-
-int do_pack(unsigned int *bits,comedi_trig *it)
-{
-       int chan;
-       int mask;
-       int i;
-
-       for(i=0;i<it->n_chan;i++){
-               chan=CR_CHAN(it->chanlist[i]);
-               mask=1<<chan;
-               (*bits) &= ~mask;
-               if(it->data[i])
-                       (*bits) |=mask;
-       }
-
-       return i;
-}
-
-int mode_to_command(comedi_cmd *cmd,comedi_trig *it)
-{
-       memset(cmd,0,sizeof(comedi_cmd));
-       cmd->subdev=it->subdev;
-       cmd->chanlist_len=it->n_chan;
-       cmd->chanlist=it->chanlist;
-       cmd->data=it->data;
-       cmd->data_len=it->data_len;
-
-       cmd->start_src=TRIG_NOW;
-
-       switch(it->mode){
-       case 1:
-               cmd->scan_begin_src=TRIG_FOLLOW;
-               cmd->convert_src=TRIG_TIMER;
-               cmd->convert_arg=it->trigvar;
-               cmd->scan_end_src=TRIG_COUNT;
-               cmd->scan_end_arg=it->n_chan;
-               cmd->stop_src=TRIG_COUNT;
-               cmd->stop_arg=it->n;
-               
-               break;
-       case 2:
-               cmd->scan_begin_src=TRIG_TIMER;
-               cmd->scan_begin_arg=it->trigvar;
-               cmd->convert_src=TRIG_TIMER;
-               cmd->convert_arg=it->trigvar1;
-               cmd->scan_end_src=TRIG_COUNT;
-               cmd->scan_end_arg=it->n_chan;
-               cmd->stop_src=TRIG_COUNT;
-               cmd->stop_arg=it->n;
-               
-               break;
-       case 3:
-               cmd->scan_begin_src=TRIG_FOLLOW;
-               cmd->convert_src=TRIG_EXT;
-               cmd->convert_arg=it->trigvar;
-               cmd->scan_end_src=TRIG_COUNT;
-               cmd->scan_end_arg=it->n_chan;
-               cmd->stop_src=TRIG_COUNT;
-               cmd->stop_arg=it->n;
-
-               break;
-       case 4:
-               cmd->scan_begin_src=TRIG_EXT;
-               cmd->scan_begin_arg=it->trigvar;
-               cmd->convert_src=TRIG_TIMER;
-               cmd->convert_arg=it->trigvar1;
-               cmd->scan_end_src=TRIG_COUNT;
-               cmd->scan_end_arg=it->n_chan;
-               cmd->stop_src=TRIG_COUNT;
-               cmd->stop_arg=it->n;
-
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-int command_to_mode(comedi_trig *it,comedi_cmd *cmd)
-{
-       it->subdev=cmd->subdev;
-       it->flags=0;
-       it->n_chan=cmd->chanlist_len;
-       it->chanlist=cmd->chanlist;
-       it->data=cmd->data;
-       it->data_len=cmd->data_len;
-
-       if(cmd->start_src==TRIG_NOW &&
-          cmd->scan_begin_src==TRIG_FOLLOW &&
-          cmd->convert_src==TRIG_TIMER &&
-          cmd->scan_end_src==TRIG_COUNT &&
-          cmd->stop_src==TRIG_COUNT){
-               /* mode 1 */
-
-               it->mode=1;
-               it->trigsrc=0;
-               it->trigvar=0;
-               it->n=cmd->stop_arg;
-
-               return 0;
-       }
-       if(cmd->start_src==TRIG_NOW &&
-          cmd->scan_begin_src==TRIG_TIMER &&
-          cmd->convert_src==TRIG_TIMER &&
-          cmd->scan_end_src==TRIG_COUNT &&
-          cmd->stop_src==TRIG_COUNT){
-               /* mode 2 */
-
-               it->mode=2;
-               it->trigsrc=0;
-               it->trigvar=cmd->scan_begin_arg;
-               it->trigvar1=cmd->convert_arg;
-               it->n=cmd->stop_arg;
-
-               return 0;
-       }
-       if(cmd->start_src==TRIG_NOW &&
-          cmd->scan_begin_src==TRIG_FOLLOW &&
-          cmd->convert_src==TRIG_EXT &&
-          cmd->scan_end_src==TRIG_COUNT &&
-          cmd->stop_src==TRIG_COUNT){
-               /* mode 3 */
-               /* nobody actually uses mode 3, so... */
-
-               return -EINVAL;
-       }
-       if(cmd->start_src==TRIG_NOW &&
-          cmd->scan_begin_src==TRIG_EXT &&
-          cmd->convert_src==TRIG_TIMER &&
-          cmd->scan_end_src==TRIG_COUNT &&
-          cmd->stop_src==TRIG_COUNT){
-               /* mode 4 */
-
-               it->mode=4;
-               it->trigsrc=0;
-               it->trigvar=cmd->scan_begin_arg;
-               it->trigvar1=cmd->convert_arg;
-               it->n=cmd->stop_arg;
-
-               return 0;
-       }
-       return -EINVAL;
-}
-
index e9962ad9eda2ba8871041d9391c99cbb2e55733a..a213081f99022e7a4a788abd8719c108678f08d0 100644 (file)
@@ -66,6 +66,12 @@ EXPORT_SYMBOL(do_pack);
 EXPORT_SYMBOL(di_unpack);
 EXPORT_SYMBOL(comedi_eobuf);
 EXPORT_SYMBOL(comedi_eos);
+EXPORT_SYMBOL(range_bipolar10);
+EXPORT_SYMBOL(range_bipolar5);
+EXPORT_SYMBOL(range_bipolar2_5);
+EXPORT_SYMBOL(range_unipolar10);
+EXPORT_SYMBOL(range_unipolar5);
+EXPORT_SYMBOL(range_unknown);
 #ifdef CONFIG_COMEDI_RT
 EXPORT_SYMBOL(comedi_change_irq_flags);
 EXPORT_SYMBOL(comedi_free_irq);
index cd04e73398216f068c54b2036b6b96528a7d4918..a3c5a10a7753e7b18e0bb17ed75149ed9677e3a3 100644 (file)
@@ -96,6 +96,7 @@ void comedi_rtl_v1_cleanup(void);
 typedef struct comedi_device_struct comedi_device;
 typedef struct comedi_subdevice_struct comedi_subdevice;
 typedef struct comedi_driver_struct comedi_driver;
+typedef struct comedi_lrange_struct comedi_lrange;
 
 
 struct comedi_subdevice_struct{
@@ -119,8 +120,8 @@ struct comedi_subdevice_struct{
        unsigned int flags;
        unsigned int *flaglist;
 
-       unsigned int range_type;
-       unsigned int *range_type_list;
+       comedi_lrange *range_table;
+       comedi_lrange **range_table_list;
        
        unsigned int *chanlist;         /* driver-owned chanlist (not used) */
        
@@ -240,12 +241,26 @@ extern int rtcomedi_lock_semaphore;
 
 /* range stuff */
 
-#include <range.h>
 
-#define RANGE_digital                  RANGE_unipolar5
+#define RANGE(a,b)             {(a)*1e6,(b)*1e6,0}
+#define RANGE_ext(a,b)         {(a)*1e6,(b)*1e6,RF_EXTERNAL}
+#define RANGE_unitless(a,b)    {(a)*1e6,(b)*1e6,0}     /* XXX */
+#define BIP_RANGE(a)           {-(a)*1e6,(a)*1e6,0}
+#define UNI_RANGE(a)           {0,(a)*1e6,0}
 
-extern unsigned int comedi_max_range;
-extern comedi_krange comedi_kranges[];
+extern comedi_lrange range_bipolar10;
+extern comedi_lrange range_bipolar5;
+extern comedi_lrange range_bipolar2_5;
+extern comedi_lrange range_unipolar10;
+extern comedi_lrange range_unipolar5;
+extern comedi_lrange range_unknown;
+
+#define range_digital          range_unipolar5
+
+struct comedi_lrange_struct{
+       int length;
+       comedi_krange range[0];
+};
 
 
 /* timer types */
index b123ea489e15c28a382658fce151d6a8ab0d9fd4..59f5757207831ce16c662630ca07a872ba4bb9f0 100644 (file)
 #include <asm/io.h>
 
 static void postconfig(comedi_device *dev);
+#ifdef CONFIG_COMEDI_VER08
+static int command_trig(comedi_device *dev,comedi_subdevice *s,comedi_trig *it);
+static int mode_to_command(comedi_cmd *cmd,comedi_trig *it);
+#endif
 
 comedi_driver *comedi_drivers;
 
@@ -163,6 +167,7 @@ int comedi_driver_unregister(comedi_driver *driver)
 static void postconfig(comedi_device *dev)
 {
        int i;
+       int have_trig;
        comedi_subdevice *s;
 
        for(i=0;i<dev->n_subdevices;i++){
@@ -174,8 +179,17 @@ static void postconfig(comedi_device *dev)
                if(s->len_chanlist==0)
                        s->len_chanlist=1;
 
-               /* XXX */
-               if(s->trig[1] || s->trig[2] || s->trig[3] ||s->trig[4]){
+               have_trig=0;
+               if(s->trig[1] || s->trig[2] || s->trig[3] ||s->trig[4])
+                       have_trig=1;
+
+               if(s->do_cmd && !have_trig){
+                       s->trig[1]=command_trig;
+                       s->trig[2]=command_trig;
+                       s->trig[3]=command_trig;
+                       s->trig[4]=command_trig;
+               }
+               if(s->do_cmd || have_trig){
                        s->prealloc_bufsz=1024*128;
                }else{
                        s->prealloc_bufsz=0;
@@ -189,11 +203,122 @@ static void postconfig(comedi_device *dev)
                        }
                }
 
-               if(!s->range_type && !s->range_type_list)
-                       s->range_type=RANGE_unknown;
+               if(!s->range_table && !s->range_table_list)
+                       s->range_table=&range_unknown;
+       }
+
+}
+
+/* helper functions for drivers */
+
+int di_unpack(unsigned int bits,comedi_trig *it)
+{
+       int chan;
+       int i;
+
+       for(i=0;i<it->n_chan;i++){
+               chan=CR_CHAN(it->chanlist[i]);
+               it->data[i]=(bits>>chan)&1;
+       }
+
+       return i;
+}
+
+int do_pack(unsigned int *bits,comedi_trig *it)
+{
+       int chan;
+       int mask;
+       int i;
+
+       for(i=0;i<it->n_chan;i++){
+               chan=CR_CHAN(it->chanlist[i]);
+               mask=1<<chan;
+               (*bits) &= ~mask;
+               if(it->data[i])
+                       (*bits) |=mask;
+       }
+
+       return i;
+}
+
+#ifdef CONFIG_COMEDI_VER08
+static int command_trig(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+{
+       int ret;
+
+       ret=mode_to_command(&s->cmd,it);
+       if(ret)return ret;
+
+       ret=s->do_cmdtest(dev,s,&s->cmd);
+       if(ret)return ret;
+
+       ret=s->do_cmd(dev,s);
+       if(ret)return ret;
+
+       return ret;
+}
+
+static int mode_to_command(comedi_cmd *cmd,comedi_trig *it)
+{
+       memset(cmd,0,sizeof(comedi_cmd));
+       cmd->subdev=it->subdev;
+       cmd->chanlist_len=it->n_chan;
+       cmd->chanlist=it->chanlist;
+       cmd->data=it->data;
+       cmd->data_len=it->data_len;
+
+       cmd->start_src=TRIG_NOW;
+
+       switch(it->mode){
+       case 1:
+               cmd->scan_begin_src=TRIG_FOLLOW;
+               cmd->convert_src=TRIG_TIMER;
+               cmd->convert_arg=it->trigvar;
+               cmd->scan_end_src=TRIG_COUNT;
+               cmd->scan_end_arg=it->n_chan;
+               cmd->stop_src=TRIG_COUNT;
+               cmd->stop_arg=it->n;
+               
+               break;
+       case 2:
+               cmd->scan_begin_src=TRIG_TIMER;
+               cmd->scan_begin_arg=it->trigvar;
+               cmd->convert_src=TRIG_TIMER;
+               cmd->convert_arg=it->trigvar1;
+               cmd->scan_end_src=TRIG_COUNT;
+               cmd->scan_end_arg=it->n_chan;
+               cmd->stop_src=TRIG_COUNT;
+               cmd->stop_arg=it->n;
+               
+               break;
+       case 3:
+               cmd->scan_begin_src=TRIG_FOLLOW;
+               cmd->convert_src=TRIG_EXT;
+               cmd->convert_arg=it->trigvar;
+               cmd->scan_end_src=TRIG_COUNT;
+               cmd->scan_end_arg=it->n_chan;
+               cmd->stop_src=TRIG_COUNT;
+               cmd->stop_arg=it->n;
+
+               break;
+       case 4:
+               cmd->scan_begin_src=TRIG_EXT;
+               cmd->scan_begin_arg=it->trigvar;
+               cmd->convert_src=TRIG_TIMER;
+               cmd->convert_arg=it->trigvar1;
+               cmd->scan_end_src=TRIG_COUNT;
+               cmd->scan_end_arg=it->n_chan;
+               cmd->stop_src=TRIG_COUNT;
+               cmd->stop_arg=it->n;
+
+               break;
+       default:
+               return -EINVAL;
        }
 
+       return 0;
 }
+#endif
 
 
 #define REG(x) {extern comedi_driver (x);comedi_driver_register(&(x));}
index 2c217550c174e8feaa5e748e5c3d90f2d1ee3609..182d595827324780e81b37b4a7bdbf74a0b575c7 100644 (file)
@@ -149,7 +149,7 @@ int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,in
        s->type=COMEDI_SUBD_DIO;
        s->subdev_flags=SDF_READABLE|SDF_WRITEABLE|SDF_RT;
        s->n_chan=24;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->maxdata=1;
 
        /* commandeer range_list */
index d0112b930f2c1c159d54f9c866333a847842bbcb..2394850a40cf58e5ea0db58ba33079fe3dda74dc 100644 (file)
@@ -62,7 +62,7 @@ include $(TOPDIR)/Rules.make
 drivers.o:     $(obj-y)
        $(LD) -r -o $@ $(obj-y)
 
-ni_pcimio.c:   ni_mio_common.c
-ni_atmio.c:    ni_mio_common.c
+ni_pcimio.o:   ni_mio_common.c
+ni_atmio.o:    ni_mio_common.c
 
 
index c59c1145cb3e2cb4f99660e7b7cb4713831dc936..3e7a6b42ff9a5983ab2d50bfeb846ef38489d831 100644 (file)
@@ -109,7 +109,7 @@ static int parport_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_WRITEABLE;
        s->n_chan=8;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->trig[0]=parport_dio_a;
 
        s=dev->subdevices+1;
@@ -117,7 +117,7 @@ static int parport_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_READABLE;
        s->n_chan=4;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->trig[0]=parport_dio_b;
 
        s=dev->subdevices+2;
@@ -125,7 +125,7 @@ static int parport_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_WRITEABLE;
        s->n_chan=4;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->trig[0]=parport_dio_c;
 
        printk("\n");
index 2be3bf210695b57d1185be11643a60aa0d9fc09d..6687d736c6c3b7c267ea4d612243e3295ac241ea 100644 (file)
@@ -325,7 +325,7 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_READABLE;
        s->n_chan=8;
        s->maxdata=0xfff;
-       s->range_type=RANGE_unknown;    /* XXX */
+       s->range_table=&range_unknown;  /* XXX */
        s->trig[0]=das08_ai;
 
        s=dev->subdevices+1;
@@ -335,7 +335,7 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it)
                s->subdev_flags=SDF_WRITEABLE;
                s->n_chan=2;
                s->maxdata=0xfff;
-               s->range_type=RANGE_unknown;    /* XXX */
+               s->range_table=&range_unknown;  /* XXX */
        }else{
                s->type=COMEDI_SUBD_UNUSED;
        }
@@ -350,7 +350,7 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_READABLE;
        s->n_chan=3;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->trig[0]=das08_di;
 
        s=dev->subdevices+4;
@@ -359,7 +359,7 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_WRITEABLE;
        s->n_chan=4;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->trig[0]=das08_do;
 
        devpriv->dio=0;
index f2b1ce1e44b13f929989c9d01ddc6a0303a90c57..be72f765230b1695250fbf8a6a7c5b4a9fc133d8 100644 (file)
@@ -261,7 +261,7 @@ static int das08jr_attach(comedi_device * dev, comedi_devconfig * it)
        s->subdev_flags = SDF_READABLE;
        s->n_chan = 8;
        s->maxdata = 0xfff;
-       s->range_type = RANGE_unknown;
+       s->range_table = &range_unknown;
        s->trig[0] = das08jr_ai;
 
        s = dev->subdevices + 1;
@@ -270,7 +270,7 @@ static int das08jr_attach(comedi_device * dev, comedi_devconfig * it)
        s->subdev_flags = SDF_WRITEABLE;
        s->n_chan = 2;
        s->maxdata = 0xfff;
-       s->range_type = RANGE_unknown;
+       s->range_table = &range_unknown;
        s->trig[0] = das08jr_ao;
 
        s = dev->subdevices + 2;
@@ -279,7 +279,7 @@ static int das08jr_attach(comedi_device * dev, comedi_devconfig * it)
        s->subdev_flags = SDF_READABLE;
        s->n_chan = 8;
        s->maxdata = 1;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
        s->trig[0] = das08jr_di;
 
        s = dev->subdevices + 3;
@@ -288,7 +288,7 @@ static int das08jr_attach(comedi_device * dev, comedi_devconfig * it)
        s->subdev_flags = SDF_WRITEABLE;
        s->n_chan = 8;
        s->maxdata = 1;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
        s->trig[0] = das08jr_do;
 
        return 0;
index 6f8881f94167d7e4411fa09b7b6a1186b368e56d..64530c43821d6644ed9b5a3b40febc89ed85e949 100644 (file)
 
 static void das1600_release_resources(comedi_device * dev);
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_das1601_ai_10_bipolar
-        -10     10
-        -1      1
-        -0.1    0.1
-        -0.01   0.01
-RANGE_das1601_ai_10_unipolar
-        0       10
-        0       1
-        0       0.1
-        0       0.01
-RANGE_das1602_ai_10_bipolar
-        -10     10
-        -5      5
-        -2.5    2.5
-        -1.25   1.25
-RANGE_das1602_ai_10_unipolar
-        0       10
-        0       5
-        0       2.5
-        0       1.25
-RANGE_das1600_ao_extern_bipolar
-       -1      1       ext
-RANGE_das1600_ao_extern_unipolar
-       0       1       ext
----END-RANGE-DEFS---
-*/
+static comedi_lrange range_das1601_ai_10_bipolar = { 4, {
+       RANGE( -10,     10 ),
+       RANGE( -1,      1 ),
+       RANGE( -0.1,    0.1 ),
+       RANGE( -0.01,   0.01 )
+}};
+static comedi_lrange range_das1601_ai_10_unipolar = { 4, {
+       RANGE( 0,       10 ),
+       RANGE( 0,       1 ),
+       RANGE( 0,       0.1 ),
+       RANGE( 0,       0.01 )
+}};
+static comedi_lrange range_das1602_ai_10_bipolar = { 4, {
+       RANGE( -10,     10 ),
+       RANGE( -5,      5 ),
+       RANGE( -2.5,    2.5 ),
+       RANGE( -1.25,   1.25 )
+}};
+static comedi_lrange range_das1602_ai_10_unipolar = { 4, {
+       RANGE( 0,       10 ),
+       RANGE( 0,       5 ),
+       RANGE( 0,       2.5 ),
+       RANGE( 0,       1.25 )
+}};
+static comedi_lrange range_das1600_ao_extern_bipolar = { 1, {
+       RANGE_ext( -1,  1 )
+}};
+static comedi_lrange range_das1600_ao_extern_unipolar = { 1, {
+       RANGE_ext( -1,  1 )
+}};
+static comedi_lrange _range_bipolar10 = { 1, {
+       RANGE( -10,     10 )
+}};
+static comedi_lrange _range_bipolar5 = { 1, {
+       RANGE( -5,      5 )
+}};
+static comedi_lrange _range_unipolar10 = { 1, {
+       RANGE( 0,       10 )
+}};
+static comedi_lrange _range_unipolar5 = { 1, {
+       RANGE( 0,       5 )
+}};
 
 static int das1600_attach(comedi_device *dev,comedi_devconfig *it);
 static int das1600_detach(comedi_device *dev);
@@ -125,19 +139,19 @@ typedef struct {
                dac_bipolar10, dac_bipolar5, dac_bipolaruser,
                dac_unipolar10, dac_unipolar5, dac_unipolaruser,
        } dac_range[2];
-       int range_type_list[2];
+       comedi_lrange *range_type_list[2];
 } das1600_private;
 
 #define devpriv ((das1600_private *)dev->private)
 
-static int range_types[] =
+static comedi_lrange *range_types[] =
 {
-       RANGE_bipolar10,
-       RANGE_bipolar5,
-       RANGE_das1600_ao_extern_bipolar,
-       RANGE_unipolar10,
-       RANGE_unipolar5,
-       RANGE_das1600_ao_extern_unipolar
+       &_range_bipolar10,
+       &_range_bipolar5,
+       &range_das1600_ao_extern_bipolar,
+       &_range_unipolar10,
+       &_range_unipolar5,
+       &range_das1600_ao_extern_unipolar
 };
 
 #define DAS1600_TIMEOUT 100
@@ -365,10 +379,10 @@ static int das1600_attach(comedi_device * dev, comedi_devconfig * it)
        case card_1601_12:
                switch (devpriv->adc_range) {
                case adc_bipolar10:
-                       s->range_type = RANGE_das1601_ai_10_bipolar;
+                       s->range_table = &range_das1601_ai_10_bipolar;
                        break;
                case adc_unipolar10:
-                       s->range_type = RANGE_das1601_ai_10_unipolar;
+                       s->range_table = &range_das1601_ai_10_unipolar;
                        break;
                };
                break;
@@ -376,10 +390,10 @@ static int das1600_attach(comedi_device * dev, comedi_devconfig * it)
        case card_1602_16:
                switch (devpriv->adc_range) {
                case adc_bipolar10:
-                       s->range_type = RANGE_das1602_ai_10_bipolar;
+                       s->range_table = &range_das1602_ai_10_bipolar;
                        break;
                case adc_unipolar10:
-                       s->range_type = RANGE_das1602_ai_10_unipolar;
+                       s->range_table = &range_das1602_ai_10_unipolar;
                        break;
                };
                break;
@@ -392,7 +406,7 @@ static int das1600_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan = 2;
        s->maxdata = 0xfff;
        s->trig[0] = das1600_ao;
-       s->range_type_list = devpriv->range_type_list;
+       s->range_table_list = devpriv->range_type_list;
        devpriv->range_type_list[0] = range_types[devpriv->dac_range[0]];
        devpriv->range_type_list[1] = range_types[devpriv->dac_range[1]];
 
@@ -403,7 +417,7 @@ static int das1600_attach(comedi_device * dev, comedi_devconfig * it)
        s->trig[0] = das1600_di;
        s->n_chan = 4;
        s->maxdata = 1;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
 
        s++;
        /* do subdevice */
@@ -412,7 +426,7 @@ static int das1600_attach(comedi_device * dev, comedi_devconfig * it)
        s->trig[0] = das1600_do;
        s->n_chan = 4;
        s->maxdata = 1;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
 
        s++;
        /* 8255 subdevice */
index 89081dd94db5b338d437663ee33b96cfdbbb72a5..a589256e04f837024988c2bf5a7efa707f956bef 100644 (file)
@@ -362,7 +362,7 @@ static int das6402_attach(comedi_device *dev,comedi_devconfig *it)
        s->cancel=das6402_ai_cancel;
        s->maxdata=(1<<12)-1;
        s->len_chanlist=16;     /* ? */
-       s->range_type = RANGE_unknown;
+       s->range_table = &range_unknown;
        s->timer_type = TIMER_nanosec;
 
        board_init(dev);
index 57a994158ae504add3399d8a0fe3446caeaaa146..aca399e5915cf08ff13517a06f8362136cf5d6d4 100644 (file)
@@ -77,30 +77,30 @@ comedi_driver driver_dt2801={
        detach:         dt2801_detach,
 };
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_dt2801_ai_pgh_bipolar
-       -10     10
-       -5      5
-       -2.5    2.5
-       -1.25   1.25
-RANGE_dt2801_ai_pgl_bipolar
-       -10     10
-       -1      1
-       -0.1    0.1
-       -0.02   0.02
-RANGE_dt2801_ai_pgh_unipolar
-       0       10
-       0       5
-       0       2.5
-       0       1.25
-RANGE_dt2801_ai_pgl_unipolar
-       0       10
-       0       1
-       0       0.1
-       0       0.02
----END-RANGE-DEFS---
-*/
+static comedi_lrange range_dt2801_ai_pgh_bipolar={ 4, {
+       RANGE( -10,     10 ),
+       RANGE( -5,      5 ),
+       RANGE( -2.5,    2.5 ),
+       RANGE( -1.25,   1.25 ),
+}};
+static comedi_lrange range_dt2801_ai_pgl_bipolar={ 4, {
+       RANGE( -10,     10 ),
+       RANGE( -1,      1 ),
+       RANGE( -0.1,    0.1 ),
+       RANGE( -0.02,   0.02 ),
+}};
+static comedi_lrange range_dt2801_ai_pgh_unipolar={ 4, {
+       RANGE( 0,       10 ),
+       RANGE( 0,       5 ),
+       RANGE( 0,       2.5 ),
+       RANGE( 0,       1.25 ),
+}};
+static comedi_lrange range_dt2801_ai_pgl_unipolar={ 4, {
+       RANGE( 0,       10 ),
+       RANGE( 0,       1 ),
+       RANGE( 0,       0.1 ),
+       RANGE( 0,       0.02 ),
+}};
 
 typedef struct{
        char *name;
@@ -195,7 +195,7 @@ static boardtype_t boardtypes[] =
 
 typedef struct{
        boardtype_t *board;
-       unsigned int dac_range_types[2];
+       comedi_lrange *dac_range_types[2];
 }dt2801_private;
 #define devpriv ((dt2801_private *)dev->private)
 #define boardtype (*devpriv->board)
@@ -406,42 +406,42 @@ static int probe_number_of_ai_chans(comedi_device *dev)
 }
 
 
-int dac_range_table[]={
-       RANGE_bipolar10,
-       RANGE_bipolar5,
-       RANGE_bipolar2_5,
-       RANGE_unipolar10,
-       RANGE_unipolar5
+comedi_lrange *dac_range_table[]={
+       &range_bipolar10,
+       &range_bipolar5,
+       &range_bipolar2_5,
+       &range_unipolar10,
+       &range_unipolar5
 };
 
-int dac_range_lkup(int opt)
+comedi_lrange *dac_range_lkup(int opt)
 {
-       if(opt<0 || opt>5)return RANGE_unknown;
+       if(opt<0 || opt>5)return &range_unknown;
        return dac_range_table[opt];
 }
 
-int ai_range_table[]={
-       RANGE_dt2801_ai_pgl_bipolar,
-       RANGE_bipolar5,
-       RANGE_bipolar2_5,
-       RANGE_unipolar10,
-       RANGE_unipolar5
+comedi_lrange *ai_range_table[]={
+       &range_dt2801_ai_pgl_bipolar,
+       &range_bipolar5,
+       &range_bipolar2_5,
+       &range_unipolar10,
+       &range_unipolar5
 };
-int ai_range_lkup(int type,int opt)
+comedi_lrange *ai_range_lkup(int type,int opt)
 {
        switch(type){
        case 0:
                return (opt)?
-                       RANGE_dt2801_ai_pgl_unipolar:
-                       RANGE_dt2801_ai_pgl_bipolar;
+                       &range_dt2801_ai_pgl_unipolar:
+                       &range_dt2801_ai_pgl_bipolar;
        case 1:
                return (opt)?
-                       RANGE_unipolar10:
-                       RANGE_bipolar10;
+                       &range_unipolar10:
+                       &range_bipolar10;
        case 2:
-               return RANGE_unipolar5;
+               return &range_unipolar5;
        }
-       return RANGE_unknown;
+       return &range_unknown;
 }
 
 
@@ -513,7 +513,7 @@ havetype:
        else s->n_chan=boardtype.ad_chan/2;
 #endif
        s->maxdata=(1<<boardtype.adbits)-1;
-       s->range_type=ai_range_lkup(boardtype.adrangetype,it->options[3]);
+       s->range_table=ai_range_lkup(boardtype.adrangetype,it->options[3]);
        s->trig[0]=dt2801_ai_mode0;
 
        s++;
@@ -522,7 +522,7 @@ havetype:
        s->subdev_flags=SDF_WRITEABLE;
        s->n_chan=2;
        s->maxdata=(1<<boardtype.dabits)-1;
-       s->range_type_list=devpriv->dac_range_types;
+       s->range_table_list=devpriv->dac_range_types;
        devpriv->dac_range_types[0]=dac_range_lkup(it->options[4]);
        devpriv->dac_range_types[1]=dac_range_lkup(it->options[5]);
        s->trig[0]=dt2801_ao_mode0;
@@ -533,7 +533,7 @@ havetype:
        s->subdev_flags=SDF_READABLE|SDF_WRITEABLE;
        s->n_chan=8;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->trig[0]=dt2801_dio;
 
        s++;
@@ -542,7 +542,7 @@ havetype:
        s->subdev_flags=SDF_READABLE|SDF_WRITEABLE;
        s->n_chan=8;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->trig[0]=dt2801_dio;
 
        ret = 0;
index be12eb84cb77e52d0547e1d9cc2e7e0849ce2e29..3635f13acb67c4b7cd4f04f9b3dc52a9e449c7e0 100644 (file)
 
 static char *driver_name = "dt2811";
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_dt2811_pgh_ai_5_unipolar
-        0         5
-        0         2.5
-        0         1.25
-        0         0.625
-RANGE_dt2811_pgh_ai_2_5_bipolar
-        -2.5      2.5
-        -1.25     1.25
-        -0.625    0.625
-        -0.3125   0.3125
-RANGE_dt2811_pgh_ai_5_bipolar
-        -5        5
-        -2.5      2.5
-        -1.25     1.25
-        -0.625    0.625
-RANGE_dt2811_pgl_ai_5_unipolar
-        0         5
-        0         0.5
-        0         0.05
-        0         0.01
-RANGE_dt2811_pgl_ai_2_5_bipolar
-        -2.5      2.5
-        -0.25     0.25
-        -0.025    0.025
-        -0.005    0.005
-RANGE_dt2811_pgl_ai_5_bipolar
-        -5        5
-        -0.5      0.5
-        -0.05     0.05
-        -0.01     0.01
-RANGE_dt2811_ao_5_bipolar
-        -5        5
-RANGE_dt2811_ao_2_5_bipolar
-        -2.5      2.5
-RANGE_dt2811_ao_5_uniipolar
-        0         5
----END-RANGE-DEFS---
-*/
+comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, {
+       RANGE( 0,       5 ),
+       RANGE( 0,       2.5 ),
+       RANGE( 0,       1.25 ),
+       RANGE( 0,       0.625 )
+}};
+comedi_lrange range_dt2811_pgh_ai_2_5_bipolar = { 4, {
+       RANGE( -2.5,    2.5 ),
+       RANGE( -1.25,   1.25 ),
+       RANGE( -0.625,  0.625 ),
+       RANGE( -0.3125, 0.3125 )
+}};
+comedi_lrange range_dt2811_pgh_ai_5_bipolar = { 4, {
+       RANGE( -5,      5 ),
+       RANGE( -2.5,    2.5 ),
+       RANGE( -1.25,   1.25 ),
+       RANGE( -0.625,  0.625 )
+}};
+comedi_lrange range_dt2811_pgl_ai_5_unipolar = { 4, {
+       RANGE( 0,       5 ),
+       RANGE( 0,       0.5 ),
+       RANGE( 0,       0.05 ),
+       RANGE( 0,       0.01 )
+}};
+comedi_lrange range_dt2811_pgl_ai_2_5_bipolar = { 4, {
+       RANGE( -2.5,    2.5 ),
+       RANGE( -0.25,   0.25 ),
+       RANGE( -0.025,  0.025 ),
+       RANGE( -0.005,  0.005 )
+}};
+comedi_lrange range_dt2811_pgl_ai_5_bipolar = { 4, {
+       RANGE( -5,      5 ),
+       RANGE( -0.5,    0.5 ),
+       RANGE( -0.05,   0.05 ),
+       RANGE( -0.01,   0.01 )
+}};
 
 /*
 
@@ -208,23 +204,23 @@ typedef struct {
         enum {
          dac_bipolar_5, dac_bipolar_2_5, dac_unipolar_5
        } dac_range[2];
-        int range_type_list[2];
+        comedi_lrange * range_type_list[2];
 } dt2811_private;
 
 #define devpriv ((dt2811_private *)dev->private)
 
-static int adc_range_types[][2] =
+static comedi_lrange *adc_range_types[][2] =
 {
   /*     dt2811-pgh                       dt2811-pgl */
-  { RANGE_dt2811_pgh_ai_5_bipolar,   RANGE_dt2811_pgl_ai_5_bipolar },
-  { RANGE_dt2811_pgh_ai_2_5_bipolar, RANGE_dt2811_pgl_ai_2_5_bipolar },
-  { RANGE_dt2811_pgh_ai_5_unipolar,  RANGE_dt2811_pgl_ai_5_unipolar }
+  { &range_dt2811_pgh_ai_5_bipolar,   &range_dt2811_pgl_ai_5_bipolar },
+  { &range_dt2811_pgh_ai_2_5_bipolar, &range_dt2811_pgl_ai_2_5_bipolar },
+  { &range_dt2811_pgh_ai_5_unipolar,  &range_dt2811_pgl_ai_5_unipolar }
 };
-static int dac_range_types[] =
+static comedi_lrange *dac_range_types[] =
 {
-  RANGE_dt2811_ao_5_bipolar,
-  RANGE_dt2811_ao_2_5_bipolar,
-  RANGE_dt2811_ao_5_uniipolar
+  &range_bipolar5,
+  &range_bipolar2_5,
+  &range_unipolar5
 };
 
 #define DT2811_TIMEOUT 5
@@ -378,7 +374,7 @@ static int dt2811_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan = devpriv->adc_mux == adc_diff ? 8 : 16;
        s->trig[0] = dt2811_ai;
        s->maxdata = 0xfff;
-       s->range_type = adc_range_types[devpriv->adc_range][board];
+       s->range_table = adc_range_types[devpriv->adc_range][board];
 
        s = dev->subdevices + 1;
        /* ao subdevice */
@@ -387,7 +383,7 @@ static int dt2811_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan = 2;
        s->trig[0] = dt2811_ao;
        s->maxdata = 0xfff;
-        s->range_type_list = devpriv->range_type_list;
+        s->range_table_list = devpriv->range_type_list;
         devpriv->range_type_list[0] = dac_range_types[devpriv->dac_range[0]];
         devpriv->range_type_list[1] = dac_range_types[devpriv->dac_range[1]];
 
@@ -398,7 +394,7 @@ static int dt2811_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan = 8;
        s->trig[0] = dt2811_di;
        s->maxdata = 1;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
 
        s = dev->subdevices + 3;
        /* do subdevice */
@@ -408,7 +404,7 @@ static int dt2811_attach(comedi_device * dev, comedi_devconfig * it)
        s->trig[0] = dt2811_do;
        s->maxdata = 1;
        s->state = 0;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
 
        return 0;
 }
index 134de7ec7576a3e2a64655f4c55a69c03c7a42d2..88abd96e140707713fe7cfe1c8343415dd9e989e 100644 (file)
@@ -177,7 +177,7 @@ static int dt2814_attach(comedi_device *dev,comedi_devconfig *it)
        s->trig[0]=dt2814_ai_mode0;
        s->trig[1]=dt2814_ai_mode1;
        s->maxdata=0xfff;
-       s->range_type=RANGE_unknown;    /* XXX */
+       s->range_table=&range_unknown;  /* XXX */
        s->timer_type=0;                /* XXX */
 
        return 0;
index 39f72442747d7e2e1d97fb1e5f2862df2b894238..87fce6e6b33e8237b11c6d96cf84e2ec8bfc0ec8 100644 (file)
 #include <comedi_module.h>
 
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_dt2815_ao_32_current
-        0         32       mA
-RANGE_dt2815_ao_20_current
-        4         20       mA
----END-RANGE-DEFS---
-*/
-
-#define RANGE_dt2815_ao_5_unipolar     RANGE_unipolar5
-#define RANGE_dt2815_ao_5_bipolar      RANGE_bipolar5
+static comedi_lrange range_dt2815_ao_32_current = { 1, {
+       RANGE( 0,       32 )    /* XXX mA */
+}};
+static comedi_lrange range_dt2815_ao_20_current = { 1, {
+       RANGE( 4,       20 )
+}};
 
 #define DT2815_SIZE 2
 
@@ -65,7 +60,7 @@ comedi_driver driver_dt2815={
 static void dt2815_free_resources(comedi_device * dev);
 
 typedef struct {
-  unsigned int range_type_list[8];
+  comedi_lrange * range_type_list[8];
 } dt2815_private;
 
 #define devpriv ((dt2815_private *)dev->private)
@@ -138,7 +133,7 @@ static int dt2815_attach(comedi_device * dev, comedi_devconfig * it)
 {
   comedi_subdevice *s;
   int i;
-  unsigned int current_range_type,voltage_range_type;
+  comedi_lrange *current_range_type, *voltage_range_type;
 
   dev->iobase = it->options[0];
   printk("comedi%d: dt2815: 0x%04x ", dev->minor, dev->iobase);
@@ -163,14 +158,14 @@ static int dt2815_attach(comedi_device * dev, comedi_devconfig * it)
   s->maxdata=0xfff;
   s->n_chan=8;
   s->trig[0] = dt2815_ao;
-  s->range_type_list=devpriv->range_type_list;
+  s->range_table_list=devpriv->range_type_list;
 
   current_range_type = (it->options[3])
-             ? RANGE_dt2815_ao_20_current
-             : RANGE_dt2815_ao_32_current;
+             ? &range_dt2815_ao_20_current
+             : &range_dt2815_ao_32_current;
   voltage_range_type = (it->options[2])
-             ? RANGE_dt2815_ao_5_bipolar
-             : RANGE_dt2815_ao_5_unipolar;
+             ? &range_bipolar5
+             : &range_unipolar5;
   for (i = 0; i < 8; i++) {
     devpriv->range_type_list[i] = (it->options[5+i])
            ? current_range_type
index 3e3a6ec272166cc3d5e7c9a678e565cb389007c0..d2e6c994250a529c24ffe620b218ebe52795807a 100644 (file)
@@ -127,7 +127,7 @@ static int dt2817_attach(comedi_device *dev,comedi_devconfig *it)
        s->n_chan=32;
        s->type=COMEDI_SUBD_DIO;
        s->subdev_flags=SDF_READABLE|SDF_WRITEABLE;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
        s->maxdata=1;
        s->trig[0]=dt2817_dio;
 
index 7d5c67b80e62515192a62a51ec3d94d67c42a3a9..785bdca93cee807ab7e60c0569ea19dab7a61d25 100644 (file)
 #define DT2821_XCLK    0x0002  /* (R/W) external clock enable            */
 #define DT2821_BDINIT  0x0001  /* (W)   initialize board         */
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_dt282x_ai_lo_bipolar
-        -10     10
-        -5      5
-        -2.5    2.5
-        -1.25   1.25
-RANGE_dt282x_ai_lo_unipolar
-        0       10
-        0       5
-        0       2.5
-        0       1.25
-RANGE_dt282x_ai_5_bipolar
-       -5      5
-       -2.5    2.5
-       -1.25   1.25
-       -0.625  0.625
-RANGE_dt282x_ai_5_unipolar
-        0       5
-        0       2.5
-        0       1.25
-        0       0.625
-RANGE_dt282x_ai_hi_bipolar
-        -10     10
-        -1      1
-        -0.1    0.1
-        -0.02   0.02
-RANGE_dt282x_ai_hi_unipolar
-        0       10
-        0       1
-        0       0.1
-        0       0.02
----END-RANGE-DEFS---
-*/
+static comedi_lrange range_dt282x_ai_lo_bipolar = { 4, {
+       RANGE( -10,     10 ),
+       RANGE( -5,      5 ),
+       RANGE( -2.5,    2.5 ),
+       RANGE( -1.25,   1.25 )
+}};
+static comedi_lrange range_dt282x_ai_lo_unipolar = { 4, {
+       RANGE( 0,       10 ),
+       RANGE( 0,       5 ),
+       RANGE( 0,       2.5 ),
+       RANGE( 0,       1.25 )
+}};
+static comedi_lrange range_dt282x_ai_5_bipolar = { 4, {
+       RANGE( -5,      5 ),
+       RANGE( -2.5,    2.5 ),
+       RANGE( -1.25,   1.25 ),
+       RANGE( -0.625,  0.625 ),
+}};
+static comedi_lrange range_dt282x_ai_5_unipolar = { 4, {
+       RANGE( 0,       5 ),
+       RANGE( 0,       2.5 ),
+       RANGE( 0,       1.25 ),
+       RANGE( 0,       0.625 ),
+}};
+static comedi_lrange range_dt282x_ai_hi_bipolar = { 4, {
+       RANGE( -10,     10 ),
+       RANGE( -1,      1 ),
+       RANGE( -0.1,    0.1 ),
+       RANGE( -0.02,   0.02 )
+}};
+static comedi_lrange range_dt282x_ai_hi_unipolar = { 4, {
+       RANGE( 0,       10 ),
+       RANGE( 0,       1 ),
+       RANGE( 0,       0.1 ),
+       RANGE( 0,       0.02 )
+}};
+
 
 typedef struct {
        char *name;
        int adbits;
        int adchan_se;
        int adchan_di;
+       int ai_speed;
        int ispgl;
        int dachan;
        int dabits;
@@ -180,6 +184,7 @@ static boardtype_t boardtypes[] =
                adbits:         12,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         2,
                dabits:         12,
@@ -188,6 +193,7 @@ static boardtype_t boardtypes[] =
                adbits:         16,
                adchan_se:      0,
                adchan_di:      4,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         2,
                dabits:         16,
@@ -196,6 +202,7 @@ static boardtype_t boardtypes[] =
                adbits:         16,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         0,
                dabits:         0,
@@ -204,6 +211,7 @@ static boardtype_t boardtypes[] =
                adbits:         16,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          1,
                dachan:         0,
                dabits:         0,
@@ -212,6 +220,7 @@ static boardtype_t boardtypes[] =
                adbits:         12,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         2,
                dabits:         12,
@@ -220,6 +229,7 @@ static boardtype_t boardtypes[] =
                adbits:         16,
                adchan_se:      0,
                adchan_di:      4,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         2,
                dabits:         12,
@@ -228,6 +238,7 @@ static boardtype_t boardtypes[] =
                adbits:         12,
                adchan_se:      4,
                adchan_di:      0,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         2,
                dabits:         12,
@@ -236,6 +247,7 @@ static boardtype_t boardtypes[] =
                adbits:         12,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         2,
                dabits:         12,
@@ -244,6 +256,7 @@ static boardtype_t boardtypes[] =
                adbits:         16,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         0,
                dabits:         0,
@@ -252,6 +265,7 @@ static boardtype_t boardtypes[] =
                adbits:         12,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          0,
                dachan:         0,
                dabits:         0,
@@ -260,6 +274,7 @@ static boardtype_t boardtypes[] =
                adbits:         12,
                adchan_se:      16,
                adchan_di:      8,
+               ai_speed:       4000,
                ispgl:          1,
                dachan:         0,
                dabits:         0,
@@ -273,7 +288,7 @@ typedef struct {
        int da0_2scomp;         /* same, for DAC0               */
        int da1_2scomp;         /* same, for DAC1               */
 
-       int darangelist[2];
+       comedi_lrange *darangelist[2];
 
        int dacsr;              /* software copies of registers */
        int adcsr;
@@ -336,7 +351,7 @@ static int prep_ai_dma(comedi_device * dev,int chan,int size);
 static int prep_ao_dma(comedi_device * dev,int chan,int size);
 static int dt282x_ai_cancel(comedi_device * dev, comedi_subdevice * s);
 static int dt282x_ao_cancel(comedi_device * dev, comedi_subdevice * s);
-static int dt282x_ns_to_timer(int *nanosec);
+static int dt282x_ns_to_timer(int *nanosec,int round_mode);
 
 
 static int dt282x_grab_dma(comedi_device *dev,int dma1,int dma2);
@@ -657,34 +672,95 @@ static int dt282x_ai_mode0(comedi_device * dev, comedi_subdevice * s, comedi_tri
 static int dt282x_ai_cmdtest(comedi_device * dev, comedi_subdevice * s,comedi_cmd *cmd)
 {
        int err=0;
+       int tmp;
+
+       /* step 1: make sure trigger sources are trivially valid */
+
+       tmp=cmd->start_src;
+       cmd->start_src &= TRIG_NOW;
+       if(!cmd->start_src && tmp!=cmd->start_src)err++;
+
+       tmp=cmd->scan_begin_src;
+       cmd->scan_begin_src &= TRIG_FOLLOW|TRIG_EXT;
+       if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++;
+
+       tmp=cmd->convert_src;
+       cmd->convert_src &= TRIG_TIMER;
+       if(!cmd->convert_src && tmp!=cmd->convert_src)err++;
+
+       tmp=cmd->scan_end_src;
+       cmd->scan_end_src &= TRIG_COUNT;
+       if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++;
+
+       tmp=cmd->stop_src;
+       cmd->stop_src &= TRIG_COUNT|TRIG_NONE;
+       if(!cmd->stop_src && tmp!=cmd->stop_src)err++;
 
-       if(cmd->start_src!=TRIG_NOW ||
-          cmd->start_arg!=0 ||
-          cmd->scan_begin_arg!=0 ||
-          cmd->convert_src!=TRIG_TIMER ||
-          cmd->scan_end_src!=TRIG_COUNT ||
-          cmd->scan_end_arg!=cmd->chanlist_len){
-               err=1;
-               cmd->start_src=TRIG_NOW;
+       if(err)return 1;
+
+       /* step 2: make sure trigger sources are unique and mutually compatible */
+
+       /* note that mutual compatiblity is not an issue here */
+       if(cmd->scan_begin_src!=TRIG_FOLLOW &&
+          cmd->scan_begin_src!=TRIG_EXT)err++;
+       if(cmd->stop_src!=TRIG_COUNT &&
+          cmd->stop_src!=TRIG_NONE)err++;
+
+       if(err)return 2;
+
+       /* step 3: make sure arguments are trivially compatible */
+
+       if(cmd->start_arg!=0){
                cmd->start_arg=0;
-               cmd->scan_begin_arg=0;
-               cmd->convert_src=TRIG_TIMER;
-               cmd->scan_end_src=TRIG_COUNT;
-               cmd->scan_end_arg=cmd->chanlist_len;
+               err++;
        }
-       if(cmd->scan_begin_src!=TRIG_FOLLOW && cmd->scan_begin_src!=TRIG_EXT){
-               err=1;
-               cmd->scan_begin_src=TRIG_INVAL;
+       if(cmd->scan_begin_src==TRIG_FOLLOW){
+               /* internal trigger */
+               if(cmd->scan_begin_arg!=0){
+                       cmd->scan_begin_arg=0;
+                       err++;
+               }
+       }else{
+               /* external trigger */
+               /* should be level/edge, hi/lo specification here */
+               if(cmd->scan_begin_arg!=0){
+                       cmd->scan_begin_arg=0;
+                       err++;
+               }
        }
        if(cmd->convert_arg<4000){
-               err=1;
+               /* XXX board dependent */
                cmd->convert_arg=4000;
+               err++;
        }
-       if(cmd->stop_src!=TRIG_COUNT && cmd->stop_src!=TRIG_NONE){
-               err=1;
+#define SLOWEST_TIMER  (250*(1<<15)*255)
+       if(cmd->convert_arg>SLOWEST_TIMER){
+               cmd->convert_arg=SLOWEST_TIMER;
+               err++;
+       }
+       if(cmd->scan_end_arg!=cmd->chanlist_len){
+               cmd->scan_end_arg=cmd->chanlist_len;
+               err++;
+       }
+       if(cmd->stop_src==TRIG_COUNT){
+               /* any count is allowed */
+       }else{
+               /* TRIG_NONE */
+               if(cmd->stop_arg!=0){
+                       cmd->stop_arg=0;
+                       err++;
+               }
        }
 
-       if(err)return -EINVAL;
+       if(err)return 3;
+
+       /* step 4: fix up any arguments */
+
+       tmp=cmd->convert_arg;
+       dt282x_ns_to_timer(&cmd->convert_arg,cmd->flags&TRIG_ROUND_MASK);
+       if(tmp!=cmd->convert_arg)err++;
+
+       if(err)return 4;
 
        return 0;
 }
@@ -694,7 +770,7 @@ static int dt282x_ai_cmd(comedi_device * dev, comedi_subdevice * s)
        comedi_cmd *cmd=&s->cmd;
        int timer;
 
-       timer=dt282x_ns_to_timer(&cmd->convert_arg);
+       timer=dt282x_ns_to_timer(&cmd->convert_arg,TRIG_ROUND_NEAREST);
        outw(timer, dev->iobase + DT2821_TMRCTR);
 
        if(cmd->scan_begin_src==TRIG_FOLLOW){
@@ -756,7 +832,7 @@ static int dt282x_ai_mode1(comedi_device * dev, comedi_subdevice * s, comedi_tri
                devpriv->ntrig=it->n*it->n_chan;
                devpriv->nread=devpriv->ntrig;
 
-               timer=dt282x_ns_to_timer(&it->trigvar);
+               timer=dt282x_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST);
                outw(timer, dev->iobase + DT2821_TMRCTR);
 
                devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE;
@@ -773,7 +849,7 @@ static int dt282x_ai_mode1(comedi_device * dev, comedi_subdevice * s, comedi_tri
 
                return 0;
        } else {
-               timer=dt282x_ns_to_timer(&it->trigvar);
+               timer=dt282x_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST);
                outw(timer, dev->iobase + DT2821_TMRCTR);
 
                devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0;
@@ -823,7 +899,7 @@ static int dt282x_ai_mode4(comedi_device * dev, comedi_subdevice * s, comedi_tri
                devpriv->ntrig=it->n*it->n_chan;
                devpriv->nread=devpriv->ntrig;
 
-               timer=dt282x_ns_to_timer(&it->trigvar1);
+               timer=dt282x_ns_to_timer(&it->trigvar1,TRIG_ROUND_NEAREST);
                outw(timer, dev->iobase + DT2821_TMRCTR);
 
                devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE;
@@ -840,7 +916,7 @@ static int dt282x_ai_mode4(comedi_device * dev, comedi_subdevice * s, comedi_tri
 
                return 0;
        } else {
-               timer=dt282x_ns_to_timer(&it->trigvar1);
+               timer=dt282x_ns_to_timer(&it->trigvar1,TRIG_ROUND_NEAREST);
                outw(timer, dev->iobase + DT2821_TMRCTR);
 
                devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0 | DT2821_DS1;
@@ -893,14 +969,25 @@ static int dt282x_ai_cancel(comedi_device * dev, comedi_subdevice * s)
 }
 
 
-static int dt282x_ns_to_timer(int *nanosec)
+static int dt282x_ns_to_timer(int *nanosec,int round_mode)
 {
        int prescale,base,divider;
 
        for(prescale=0;prescale<16;prescale++){
                if(prescale==1)continue;
                base=250*(1<<prescale);
-               divider=(*nanosec+base/2)/base;
+               switch(round_mode){
+               case TRIG_ROUND_NEAREST:
+               default:
+                       divider=(*nanosec+base/2)/base;
+                       break;
+               case TRIG_ROUND_DOWN:
+                       divider=(*nanosec)/base;
+                       break;
+               case TRIG_ROUND_UP:
+                       divider=(*nanosec+base-1)/base;
+                       break;
+               }
                if(divider<256){
                        *nanosec=divider*base;
                        return (prescale<<8)|(255-divider);
@@ -971,7 +1058,7 @@ static int dt282x_ao_mode2(comedi_device *dev,comedi_subdevice *s,comedi_trig *i
        prep_ao_dma(dev,1,size/2);
        enable_dma(devpriv->dma[1].chan);
        
-       timer=dt282x_ns_to_timer(&it->trigvar);
+       timer=dt282x_ns_to_timer(&it->trigvar,TRIG_ROUND_NEAREST);
        outw(timer, dev->iobase + DT2821_TMRCTR);
 
        devpriv->dacsr = DT2821_SSEL| DT2821_DACLK | DT2821_IDARDY;
@@ -1025,25 +1112,35 @@ static int dt282x_dio(comedi_device * dev, comedi_subdevice * s, comedi_trig * i
 }
 
 
-static int ai_range_table[]={ RANGE_dt282x_ai_lo_bipolar,
-       RANGE_dt282x_ai_lo_unipolar, RANGE_dt282x_ai_5_bipolar,
-       RANGE_dt282x_ai_5_unipolar };
-static int ai_range_pgl_table[]={ RANGE_dt282x_ai_hi_bipolar,
-       RANGE_dt282x_ai_hi_unipolar };
-static inline int opt_ai_range_lkup(int ispgl,int x)
+static comedi_lrange *ai_range_table[]={
+       &range_dt282x_ai_lo_bipolar,
+       &range_dt282x_ai_lo_unipolar,
+       &range_dt282x_ai_5_bipolar,
+       &range_dt282x_ai_5_unipolar };
+static comedi_lrange *ai_range_pgl_table[]={
+       &range_dt282x_ai_hi_bipolar,
+       &range_dt282x_ai_hi_unipolar };
+static comedi_lrange *opt_ai_range_lkup(int ispgl,int x)
 {
        if(ispgl){
-               if(x<0 || x>=2)return RANGE_unknown;
+               if(x<0 || x>=2)return &range_unknown;
                return ai_range_pgl_table[x];
        }else{
-               if(x<0 || x>=4)return RANGE_unknown;
+               if(x<0 || x>=4)return &range_unknown;
                return ai_range_table[x];
        }
 }
-static int ao_range_table[]={ RANGE_bipolar10, RANGE_unipolar10, RANGE_bipolar5,
-       RANGE_unipolar5, RANGE_bipolar2_5 };
-static inline int opt_ao_range_lkup(int x)
-       { if(x<0)x=0; if(x>=5)x=0; return ao_range_table[x]; }
+static comedi_lrange *ao_range_table[]={
+       &range_bipolar10,
+       &range_unipolar10,
+       &range_bipolar5,
+       &range_unipolar5,
+       &range_bipolar2_5 };
+static comedi_lrange *opt_ao_range_lkup(int x)
+{
+       if(x<0 || x>=5)return &range_unknown;
+       return ao_range_table[x];
+}
 
 enum{  opt_iobase=0, opt_irq, opt_dma1, opt_dma2,      /* i/o base, irq, dma channels */
        opt_diff,                                       /* differential */
@@ -1182,7 +1279,7 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it)
        s->cancel=dt282x_ai_cancel;
        s->maxdata=(1<<boardtype.adbits)-1;
        s->len_chanlist=16;
-       s->range_type = opt_ai_range_lkup(boardtype.ispgl,it->options[opt_ai_range]);
+       s->range_table = opt_ai_range_lkup(boardtype.ispgl,it->options[opt_ai_range]);
        s->timer_type=TIMER_nanosec;
        devpriv->ad_2scomp=it->options[opt_ai_twos];
 
@@ -1196,7 +1293,7 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it)
                s->cancel=dt282x_ao_cancel;
                s->maxdata=(1<<boardtype.dabits)-1;
                s->len_chanlist=1;                      /* XXX could do 2 */
-               s->range_type_list=devpriv->darangelist;
+               s->range_table_list=devpriv->darangelist;
                s->timer_type=TIMER_nanosec;
                devpriv->darangelist[0]=
                        opt_ao_range_lkup(it->options[opt_ao0_range]);
@@ -1215,7 +1312,7 @@ static int dt282x_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan=16;
        s->trig[0]=dt282x_dio;
        s->maxdata=1;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
 
        printk("\n");
 
index d234c09647493d5eecdff3394dc14eb3eac36159..71778227a7fdda93d282f0478eb202d0012588e2 100644 (file)
 
 #define PCI_VENDOR_ID_DT       0x1116
 
+static comedi_lrange range_dt3000_ai = { 4, {
+       RANGE( -10,     10 ),
+       RANGE( -5,      5 ),
+       RANGE( -2.5,    2.5 ),
+       RANGE( -1.25,   1.25 )
+}};
+static comedi_lrange range_dt3000_ai_pgl = { 4, {
+       RANGE( -10,     10 ),
+       RANGE( -1,      1 ),
+       RANGE( -0.1,    0.1 ),
+       RANGE( -0.02,   0.02 )
+}};
+
 typedef struct{
        char *name;
        unsigned int device_id;
        int adchan;
        int adbits;
-       int adrange;
+       comedi_lrange *adrange;
        int dachan;
        int dabits;
 }dt3k_boardtype;
@@ -61,7 +74,7 @@ static dt3k_boardtype dt3k_boardtypes[]={
                device_id:      0x22,
                adchan:         16,
                adbits:         12,
-               adrange:        RANGE_dt3000_ai,
+               adrange:        &range_dt3000_ai,
                dachan:         2,
                dabits:         12,
        },
@@ -69,7 +82,7 @@ static dt3k_boardtype dt3k_boardtypes[]={
                device_id:      0x27,
                adchan:         16,
                adbits:         12,
-               adrange:        RANGE_dt3000_ai_pgl,
+               adrange:        &range_dt3000_ai_pgl,
                dachan:         2,
                dabits:         12,
        },
@@ -77,7 +90,7 @@ static dt3k_boardtype dt3k_boardtypes[]={
                device_id:      0x23,
                adchan:         32,
                adbits:         12,
-               adrange:        RANGE_dt3000_ai,
+               adrange:        &range_dt3000_ai,
                dachan:         0,
                dabits:         0,
        },
@@ -85,7 +98,7 @@ static dt3k_boardtype dt3k_boardtypes[]={
                device_id:      0x24,
                adchan:         64,
                adbits:         12,
-               adrange:        RANGE_dt3000_ai,
+               adrange:        &range_dt3000_ai,
                dachan:         2,
                dabits:         12,
        },
@@ -93,7 +106,7 @@ static dt3k_boardtype dt3k_boardtypes[]={
                device_id:      0x28,
                adchan:         64,
                adbits:         12,
-               adrange:        RANGE_dt3000_ai_pgl,
+               adrange:        &range_dt3000_ai_pgl,
                dachan:         2,
                dabits:         12,
        },
@@ -101,7 +114,7 @@ static dt3k_boardtype dt3k_boardtypes[]={
                device_id:      0x25,
                adchan:         16,
                adbits:         16,
-               adrange:        RANGE_dt3000_ai,
+               adrange:        &range_dt3000_ai,
                dachan:         2,
                dabits:         12,
        },
@@ -109,7 +122,7 @@ static dt3k_boardtype dt3k_boardtypes[]={
                device_id:      0x26,
                adchan:         16,
                adbits:         16,
-               adrange:        RANGE_dt3000_ai,
+               adrange:        &range_dt3000_ai,
                dachan:         2,
                dabits:         12,
        },
@@ -200,21 +213,6 @@ static int n_dt3k_boards=sizeof(dt3k_boardtypes)/sizeof(dt3k_boardtype);
 #define DT3000_CHANNEL_MODE_SE         0
 #define DT3000_CHANNEL_MODE_DI         1
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_dt3000_ai
-       -10     10
-       -5      5
-       -2.5    2.5
-       -1.25   1.25
-RANGE_dt3000_ai_pgl
-       -10     10
-       -1      1
-       -0.1    0.1
-       -0.02   0.02
----END-RANGE-DEFS---
-*/
-
 typedef struct{
        struct pci_dev *pci_dev;
        unsigned long phys_addr;
@@ -440,7 +438,7 @@ static int dt3000_attach(comedi_device *dev,comedi_devconfig *it)
        s->trig[0]=dt3k_ai_mode0;
        s->maxdata=(1<<dt3k_boardtypes[dev->board].adbits)-1;
        s->len_chanlist=512;
-       s->range_type=RANGE_dt3000_ai;
+       s->range_table=&range_dt3000_ai; /* XXX */
        s->timer_type=TIMER_nanosec;
 
        s++;
@@ -451,7 +449,7 @@ static int dt3000_attach(comedi_device *dev,comedi_devconfig *it)
        s->trig[0]=dt3k_ao_mode0;
        s->maxdata=(1<<dt3k_boardtypes[dev->board].dabits)-1;
        s->len_chanlist=1;
-       s->range_type=RANGE_bipolar10;
+       s->range_table=&range_bipolar10;
 
        s++;
        /* dio subsystem */
@@ -461,7 +459,7 @@ static int dt3000_attach(comedi_device *dev,comedi_devconfig *it)
        s->trig[0]=dt3k_dio;
        s->maxdata=1;
        s->len_chanlist=8;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
 
        s++;
        /* mem subsystem */
@@ -471,7 +469,7 @@ static int dt3000_attach(comedi_device *dev,comedi_devconfig *it)
        s->trig[0]=dt3k_readmem;
        s->maxdata=0xff;
        s->len_chanlist=1;
-       s->range_type=RANGE_unknown;
+       s->range_table=&range_unknown;
 
 #if 0
        s++;
index c8d7dfca1ce042d0c8b11fd0eb1d073d462c4fd5..df3c878cea9e848fc0f47a4a331b01d3603e2070 100644 (file)
@@ -243,7 +243,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it)
       s->n_chan = 8;
       s->trig[0] = multiq3_ai;
       s->maxdata = 0x1fff;
-      s->range_type = RANGE_bipolar5;
+      s->range_table = &range_bipolar5;
 
       s = dev->subdevices + 1;
       /* ao subdevice */
@@ -252,7 +252,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it)
       s->n_chan = 8;
       s->trig[0] = multiq3_ao;
       s->maxdata = 0xfff;
-      s->range_type = RANGE_bipolar5;
+      s->range_table = &range_bipolar5;
 
       s = dev->subdevices + 2;
       /* di subdevice */
@@ -261,7 +261,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it)
       s->n_chan = 16;
       s->trig[0] = multiq3_di;
       s->maxdata = 1;
-      s->range_type = RANGE_digital;
+      s->range_table = &range_digital;
 
       s = dev->subdevices + 3;
       /* do subdevice */
@@ -270,7 +270,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it)
       s->n_chan = 16;
       s->trig[0] = multiq3_do;
       s->maxdata = 1;
-      s->range_type = RANGE_digital;
+      s->range_table = &range_digital;
       s->state = 0;
 
       s = dev->subdevices + 4;
@@ -280,7 +280,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it)
       s->n_chan = it->options[2] * 2;
       s->trig[0] = multiq3_ei;
       s->maxdata = 0xffffff;
-      s->range_type = RANGE_unknown;
+      s->range_table = &range_unknown;
 
       encoder_reset(dev);
 
index 3edb64a4aaaaab24cfcf1172716ef18d1a55eff7..75e13c054cf82125c0cb1766fb20d9c056fd3769 100644 (file)
@@ -358,7 +358,7 @@ static int nidio_attach(comedi_device *dev,comedi_devconfig *it)
                s->type=COMEDI_SUBD_DIO;
                s->subdev_flags=SDF_READABLE|SDF_WRITEABLE|SDF_RT;
                s->n_chan=32;
-               s->range_type=RANGE_digital;
+               s->range_table=&range_digital;
                s->maxdata=1;
                s->trig[0]=nidio_dio;
                s->trig[2]=nidio_dio_mode2;
index b76ac640910b7893f2f6607c41875bf36679444c..5975cbc8e7bb06db26adc4fb364bb6da7454dbc4 100644 (file)
 #define PCL711_DO_LO 13
 #define PCL711_DO_HI 14
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_pcl711b_ai
-        -5      5
-        -2.5    2.5
-        -1.25   1.25
-        -0.625  0.625
-        -0.3125 0.3125
-RANGE_acl8112hg_ai
-        -5      5
-        -0.5    0.5
-        -0.05   0.05
-        -0.005  0.005
-        0       10
-        0       1
-        0       0.1
-        0       0.01
-        -10     10
-        -1      1
-        -0.1    0.1
-        -0.01   0.01
-RANGE_acl8112dg_ai
-        -5      5
-        -2.5    2.5
-        -1.25   1.25
-        -0.625  0.625
-        0       10
-        0       5
-        0       2.5
-        0       1.25
-        -10     10
----END-RANGE-DEFS---
-*/
+static comedi_lrange range_pcl711b_ai = { 5, {
+        BIP_RANGE( 5 ),
+        BIP_RANGE( 2.5 ),
+        BIP_RANGE( 1.25 ),
+        BIP_RANGE( 0.625 ),
+        BIP_RANGE( 0.3125 )
+}};
+static comedi_lrange range_acl8112hg_ai = { 12, {
+       BIP_RANGE( 5 ),
+       BIP_RANGE( 0.5 ),
+       BIP_RANGE( 0.05 ),
+       BIP_RANGE( 0.005 ),
+       UNI_RANGE( 10 ),
+       UNI_RANGE( 1 ),
+       UNI_RANGE( 0.1 ),
+       UNI_RANGE( 0.01 ),
+       BIP_RANGE( 10 ),
+       BIP_RANGE( 1 ),
+       BIP_RANGE( 0.1 ),
+       BIP_RANGE( 0.01 )
+}};
+static comedi_lrange range_acl8112dg_ai = { 9, {
+        BIP_RANGE( 5 ),
+        BIP_RANGE( 2.5 ),
+        BIP_RANGE( 1.25 ),
+        BIP_RANGE( 0.625 ),
+       UNI_RANGE( 10 ),
+       UNI_RANGE( 5 ),
+       UNI_RANGE( 2.5 ),
+       UNI_RANGE( 1.25 ),
+       BIP_RANGE( 10 )
+}};
 
 static int pcl711_attach(comedi_device *dev,comedi_devconfig *it);
 static int pcl711_detach(comedi_device *dev);
@@ -148,18 +147,18 @@ typedef struct {
        int n_aichan;
        int n_aochan;
        int maxirq;
-       int ai_range_type;
+       comedi_lrange * ai_range_type;
        int ai_timer_type;
 } boardtype;
 
 static boardtype boardtypes[] =
 {
-       {"pcl711", 0, 0, 0, 5, 8, 1, 0, RANGE_bipolar5, 0},
-       {"pcl711b", 1, 0, 0, 5, 8, 1, 7, RANGE_pcl711b_ai,
+       {"pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5, 0},
+       {"pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai,
         TIMER_acl8112},
-       {"acl8112hg", 0, 1, 0, 12, 16, 2, 15, RANGE_acl8112hg_ai,
+       {"acl8112hg", 0, 1, 0, 12, 16, 2, 15, &range_acl8112hg_ai,
         TIMER_acl8112},
-       {"acl8112dg", 0, 1, 1, 9, 16, 2, 15, RANGE_acl8112dg_ai,
+       {"acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai,
         TIMER_acl8112},
 };
 #define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
@@ -459,7 +458,7 @@ static int pcl711_attach(comedi_device * dev, comedi_devconfig * it)
        s->maxdata = 0xfff;
        s->len_chanlist = 1;
        s->timer_type = this_board->ai_timer_type;
-       s->range_type = this_board->ai_range_type;
+       s->range_table = this_board->ai_range_type;
        s->trig[0] = pcl711_ai_mode0;
        s->trig[1] = pcl711_ai_mode1;
        s->trig[4] = pcl711_ai_mode4;
@@ -471,7 +470,7 @@ static int pcl711_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan = this_board->n_aochan;
        s->maxdata = 0xfff;
        s->len_chanlist = 1;
-       s->range_type = RANGE_bipolar5;
+       s->range_table = &range_bipolar5;
        s->trig[0] = pcl711_ao;
 
        s++;
@@ -481,7 +480,7 @@ static int pcl711_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan = 16;
        s->maxdata = 1;
        s->len_chanlist = 16;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
        s->trig[0] = pcl711_di;
 
        s++;
@@ -491,7 +490,7 @@ static int pcl711_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan = 16;
        s->maxdata = 1;
        s->len_chanlist = 16;
-       s->range_type = RANGE_digital;
+       s->range_table = &range_digital;
        s->state=0;
        s->trig[0] = pcl711_do;
 
index daf9249f94b11dae882e89fb5d469c1a93cbb68a..36e1e799e3187f3ec9d8a45efc6aa8b99c34189e 100644 (file)
@@ -82,7 +82,7 @@ static int pcl725_attach(comedi_device *dev,comedi_devconfig *it)
        s->maxdata=1;
        s->n_chan=8;
        s->trig[0]=pcl725_do;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
 
        s=dev->subdevices+1;
        /* do */
@@ -91,7 +91,7 @@ static int pcl725_attach(comedi_device *dev,comedi_devconfig *it)
        s->maxdata=1;
        s->n_chan=8;
        s->trig[0]=pcl725_di;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
 
        printk("\n");
 
index c3dd430e88f76c7cf1a1bb6e1f71496034a3855a..952e87bd65f4f9e0a1fc4432acb6786e23d00109 100644 (file)
@@ -160,7 +160,7 @@ static int pcl726_attach(comedi_device *dev,comedi_devconfig *it)
        s->n_chan=6;
        s->maxdata=0xfff;
        s->trig[0]=pcl726_ao;
-       s->range_type=RANGE_unknown;    /* XXX */
+       s->range_table=&range_unknown;  /* XXX */
 
        s=dev->subdevices+1;
        /* di */
@@ -169,7 +169,7 @@ static int pcl726_attach(comedi_device *dev,comedi_devconfig *it)
        s->n_chan=16;
        s->maxdata=1;
        s->trig[0]=pcl726_di;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
 
        s=dev->subdevices+2;
        /* do */
@@ -178,7 +178,7 @@ static int pcl726_attach(comedi_device *dev,comedi_devconfig *it)
        s->n_chan=16;
        s->maxdata=1;
        s->trig[0]=pcl726_do;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
 
        printk("\n");
        
index 316576081c2069b7f7d4658a60ec07ccf18fce78..f2f1f68c1eb3d9ebb3e2113c938a2c510fc253fb 100644 (file)
 
 #include <am9513.h>
 
-/*
---BEGIN-RANGE-DEFS--
-RANGE_rti800_ai_10_bipolar
-        -10     10
-        -1      1
-        -0.1    0.1
-        -0.02   0.02
-RANGE_rti800_ai_5_bipolar
-        -5      5
-        -0.5    0.5
-        -0.05   0.05
-        -0.01   0.01
-RANGE_rti800_ai_10_unipolar
-        0       10
-        0       1
-        0       0.1
-        0       0.02
----END-RANGE-DEFS---
-*/
+static comedi_lrange range_rti800_ai_10_bipolar = { 4, {
+       BIP_RANGE( 10 ),
+       BIP_RANGE( 1 ),
+       BIP_RANGE( 0.1 ),
+       BIP_RANGE( 0.02 )
+}};
+static comedi_lrange range_rti800_ai_5_bipolar = { 4, {
+       BIP_RANGE( 5 ),
+       BIP_RANGE( 0.5 ),
+       BIP_RANGE( 0.05 ),
+       BIP_RANGE( 0.01 )
+}};
+static comedi_lrange range_rti800_ai_unipolar = { 4, {
+       UNI_RANGE( 10 ),
+       UNI_RANGE( 1 ),
+       UNI_RANGE( 0.1 ),
+       UNI_RANGE( 0.02 )
+}};
 
 static int rti800_attach(comedi_device *dev,comedi_devconfig *it);
 static int rti800_detach(comedi_device *dev);
@@ -126,7 +125,7 @@ typedef struct {
        enum {
                dac_2comp, dac_straight
        } dac0_coding, dac1_coding;
-       int ao_range_type_list[2];
+       comedi_lrange * ao_range_type_list[2];
 } rti800_private;
 
 #define devpriv ((rti800_private *)dev->private)
@@ -353,13 +352,13 @@ static int rti800_attach(comedi_device * dev, comedi_devconfig * it)
        s->maxdata=0xfff;
        switch (devpriv->adc_range) {
        case adc_bipolar10:
-               s->range_type = RANGE_rti800_ai_10_bipolar;
+               s->range_table = &range_rti800_ai_10_bipolar;
                break;
        case adc_bipolar5:
-               s->range_type = RANGE_rti800_ai_5_bipolar;
+               s->range_table = &range_rti800_ai_5_bipolar;
                break;
        case adc_unipolar10:
-               s->range_type = RANGE_rti800_ai_10_unipolar;
+               s->range_table = &range_rti800_ai_unipolar;
                break;
        }
 
@@ -371,22 +370,21 @@ static int rti800_attach(comedi_device * dev, comedi_devconfig * it)
                s->n_chan=2;
                s->trig[0]=rti800_ao;
                s->maxdata=0xfff;
-               s->range_type=0;
-               s->range_type_list=devpriv->ao_range_type_list;
+               s->range_table_list=devpriv->ao_range_type_list;
                switch (devpriv->dac0_range) {
                case dac_bipolar10:
-                       devpriv->ao_range_type_list[0] = RANGE_bipolar10;
+                       devpriv->ao_range_type_list[0] = &range_bipolar10;
                        break;
                case dac_unipolar10:
-                       devpriv->ao_range_type_list[0] = RANGE_unipolar10;
+                       devpriv->ao_range_type_list[0] = &range_unipolar10;
                        break;
                }
                switch (devpriv->dac1_range) {
                case dac_bipolar10:
-                       devpriv->ao_range_type_list[1] = RANGE_bipolar10;
+                       devpriv->ao_range_type_list[1] = &range_bipolar10;
                        break;
                case dac_unipolar10:
-                       devpriv->ao_range_type_list[1] = RANGE_unipolar10;
+                       devpriv->ao_range_type_list[1] = &range_unipolar10;
                        break;
                }
        }
@@ -398,7 +396,7 @@ static int rti800_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan=8;
        s->trig[0]=rti800_di;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
 
        s++;
        /* do */
@@ -407,7 +405,7 @@ static int rti800_attach(comedi_device * dev, comedi_devconfig * it)
        s->n_chan=8;
        s->trig[0]=rti800_do;
        s->maxdata=1;
-       s->range_type=RANGE_digital;
+       s->range_table=&range_digital;
 
 
 /* don't yet know how to deal with counter/timers */
index 8b52dad72be49f9e4223da321ccb1f8b2c84b942..3cf022c569bc62677376271e72d035cb7efb72a4 100644 (file)
@@ -57,7 +57,7 @@ typedef struct {
        enum {
                dac_2comp, dac_straight
        } dac_coding[8];
-       unsigned int range_type_list[8];
+       comedi_lrange * range_type_list[8];
 } rti802_private;
 
 #define devpriv ((rti802_private *)dev->private)
@@ -117,15 +117,15 @@ static int rti802_attach(comedi_device * dev, comedi_devconfig * it)
        s->maxdata=0xfff;
        s->n_chan=8;
        s->trig[0] = rti802_ao;
-       s->range_type_list=devpriv->range_type_list;
+       s->range_table_list=devpriv->range_type_list;
 
        for (i = 0; i < 8; i++) {
                devpriv->dac_coding[i] = (it->options[3 + 2 * i])
                    ? (dac_straight)
                    : (dac_2comp);
                devpriv->range_type_list[i] = (it->options[2 + 2 * i])
-                       ? RANGE_unipolar10
-                       : RANGE_bipolar10;
+                       ? &range_unipolar10
+                       : &range_bipolar10;
        }
 
        printk("\n");
index 44a71a8b622bccd48f940d89dcf50f894aae6333..b72874dc1cc0c52a3bf4add42ada564a4871ed76 100644 (file)
@@ -86,7 +86,7 @@ static int dummy_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_READABLE;
        s->n_chan=1;
        s->maxdata=0xffff;
-       s->range_type=RANGE_unknown;
+       s->range_table=&range_unknown;
        s->trig[0]=dummy_ai;
        
        /* analog output subdevice */
@@ -95,7 +95,7 @@ static int dummy_attach(comedi_device *dev,comedi_devconfig *it)
        s->subdev_flags=SDF_WRITEABLE;
        s->n_chan=1;
        s->maxdata=0xffff;
-       s->range_type=RANGE_unknown;
+       s->range_table=&range_unknown;
        s->trig[0]=dummy_ao;
        
        return 1;
diff --git a/comedi/mk_range.c b/comedi/mk_range.c
deleted file mode 100644 (file)
index aa85587..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "../include/comedi.h"
-
-char s[100];
-char name[100];
-
-int get_flags(char *p);
-
-#define skip_white(a)  {while(*(a) && isspace(*(a)))(a)++;}
-
-void help(void)
-{
-       fprintf(stderr, "Use the source, dumbass\n");
-       exit(1);
-}
-
-int main(int argc, char *argv[])
-{
-       char *p;
-       double a, b;
-       int i = 0, j = 0, ln = 0;
-       int mode = 0;
-       int flags = 0;
-       int n;
-
-       if (argc != 2)
-               help();
-       if (!strcmp(argv[1], "include")) {
-               mode = 1;
-       } else if (!strcmp(argv[1], "source")) {
-               mode = 2;
-       } else
-               help();
-
-       if(mode==1){
-       }else{
-               printf("#ifdef RANGE_C\n");
-               printf("comedi_krange comedi_kranges[]={\n");
-       }
-       while (1) {
-               fgets(s, 100, stdin);
-               ln++;
-               if (feof(stdin))
-                       break;
-
-               s[strlen(s) - 1] = 0;
-               p = s;
-               skip_white(p);
-               if(p==s){
-                       if (mode == 1) {
-                               if (i)
-                                       printf("%d)\n", j);
-                               printf("#define %s __RANGE(%d,", p, i);
-                       } else {
-                               printf("/* %s */\n", p);
-                       }
-                       j = 0;
-               }else{
-                       if (isdigit(*p) || (*p) == '-') {
-                               sscanf(p, "%lf %lf%n", &a, &b , &n);
-                               p+=n;
-
-                               flags=get_flags(p);
-                               if(flags<0){
-                                       printf("\n\n#error while running scripts/mk_range, line %d, unknown flag\n", ln);
-                                       return 1;
-                               }
-
-                               if (mode == 2) {
-                                       printf("\t{%d,%d,%d},\n", (int)(1e6*a), (int)(1e6*b),flags);
-                               }
-                               i++;
-                               j++;
-                       } else {
-                               printf("\n\n#error while running scripts/mk_range, line %d\n", ln);
-                               return 1;
-                       }
-               }
-       }
-       if(mode==1){
-               printf("%d)\n", j);
-       }else{
-               printf("};\n");
-               printf("unsigned int comedi_max_range=%d;\n",i);
-               printf("#endif\n");
-       }
-       return 0;
-}
-
-int get_flags(char *p)
-{
-       int flags=0;
-
-       while(*p){
-               skip_white(p);
-               if(!strncmp(p,"ext",3)){
-                       flags|=RF_EXTERNAL;
-                       p+=3;
-                       continue;
-               }
-               if(!strncmp(p,"mA",2)){
-                       flags|=UNIT_mA;
-                       p+=2;
-                       continue;
-               }
-               if(!strncmp(p,"volt",4)){
-                       flags|=UNIT_volt;
-                       p+=4;
-                       continue;
-               }
-               if(!strncmp(p,"none",4)){
-                       flags|=UNIT_none;
-                       p+=4;
-                       continue;
-               }
-               if(!strncmp(p,"unitless",8)){
-                       flags|=UNIT_none;
-                       p+=8;
-                       continue;
-               }
-               return -1;
-       }
-       return flags;
-}
-
index 398a56681313b34ecde2940ca3b325bdc7cd01b4..3c3a8d9f5c32e2183996d4284ecacdeb0c35d924 100644 (file)
 
 */
 
-#define RANGE_C
-
 #include <comedi_module.h>
 #ifdef LINUX_V22
 #include <asm/uaccess.h>
 #endif
 
 
-
-/*
---BEGIN-RANGE-DEFS--
-RANGE_bipolar10
-       -10     10
-RANGE_bipolar5
-       -5      5
-RANGE_bipolar2_5
-       -2.5    2.5
-RANGE_unipolar10
-       0       10
-RANGE_unipolar5
-       0       5
-RANGE_unknown
-       0       1       unitless
----END-RANGE-DEFS---
-*/
+comedi_lrange range_bipolar10={ 1, {BIP_RANGE(10)}};
+comedi_lrange range_bipolar5={ 1, {BIP_RANGE(5)}};
+comedi_lrange range_bipolar2_5={ 1, {BIP_RANGE(2.5)}};
+comedi_lrange range_unipolar10={ 1, {UNI_RANGE(10)}};
+comedi_lrange range_unipolar5={ 1, {UNI_RANGE(5)}};
+comedi_lrange range_unknown={ 1, {0,1,0}};     /* XXX */
 
 /*
        COMEDI_RANGEINFO
@@ -63,15 +50,34 @@ RANGE_unknown
 int do_rangeinfo_ioctl(comedi_device *dev,comedi_rangeinfo *arg)
 {
        comedi_rangeinfo it;
+       int minor,subd,chan;
+       comedi_lrange *lr;
+       comedi_subdevice *s;
 
        if(copy_from_user(&it,arg,sizeof(comedi_rangeinfo)))
                return -EFAULT;
 
-       if(RANGE_OFFSET(it.range_type)+RANGE_LENGTH(it.range_type)>comedi_max_range)
+       minor=(it.range_type>>24)&0xf;
+       subd=(it.range_type>>20)&0xf;
+       chan=(it.range_type>>16)&0xff;
+
+       if(minor>COMEDI_NDEVICES)
+               return -EINVAL;
+       dev=comedi_devices+minor;
+       if(!dev->attached)return -EINVAL;
+       if(subd>=dev->n_subdevices)return -EINVAL;
+       s=dev->subdevices+subd;
+       if(s->range_table){
+               lr=s->range_table;
+       }else if(s->range_table_list){
+               if(chan>=s->n_chan)return -EINVAL;
+               lr=s->range_table_list[chan];
+       }else{
                return -EINVAL;
+       }
 
-       if(copy_to_user(it.range_ptr,comedi_kranges+RANGE_OFFSET(it.range_type),
-               sizeof(comedi_krange)*RANGE_LENGTH(it.range_type)))
+       if(copy_to_user(it.range_ptr,lr->range,
+               sizeof(comedi_krange)*lr->length))
                return -EFAULT;
        
        return 0;
@@ -88,12 +94,12 @@ int check_chanlist(comedi_subdevice *s,int n,unsigned int *chanlist)
        int chan;
 
 
-       if(s->range_type){
+       if(s->range_table){
                for(i=0;i<n;i++)
                        if(CR_CHAN(chanlist[i])>=s->n_chan || 
-                          CR_RANGE(chanlist[i])>=RANGE_LENGTH(s->range_type)){
+                          CR_RANGE(chanlist[i])>=s->range_table->length){
                                rt_printk("bad chanlist[%d]=0x%08x n_chan=%d range length=%d\n",
-                                       i,chanlist[i],s->n_chan,RANGE_LENGTH(s->range_type));
+                                       i,chanlist[i],s->n_chan,s->range_table->length);
 #if 0
 for(i=0;i<n;i++){
        printk("[%d]=0x%08x\n",i,chanlist[i]);
@@ -101,11 +107,11 @@ for(i=0;i<n;i++){
 #endif
                                return -EINVAL;
                        }
-       }else if(s->range_type_list){
+       }else if(s->range_table_list){
                for(i=0;i<n;i++){
                        chan=CR_CHAN(chanlist[i]);
                        if(chan>=s->n_chan ||
-                          CR_RANGE(chanlist[i])>=RANGE_LENGTH(s->range_type_list[chan])){
+                          CR_RANGE(chanlist[i])>=s->range_table_list[chan]->length){
                                rt_printk("bad chanlist[%d]=0x%08x\n",i,chanlist[i]);
                                return -EINVAL;
                        }
index d9d9921e4f613108ea6ea2207f82e75b826c295f..468772784efc55d2057327bc52f5554d75901a9f 100644 (file)
@@ -72,6 +72,12 @@ typedef unsigned short sampl_t;
 #define TRIG_WAKE_EOS  0x0020          /* wake up on end-of-scan events */
 #define TRIG_WRITE     0x0040          /* write to bidirectional devices */
 
+#define TRIG_ROUND_MASK                0x00030000
+#define TRIG_ROUND_NEAREST     0x00000000
+#define TRIG_ROUND_DOWN                0x00010000
+#define TRIG_ROUND_UP          0x00020000
+#define TRIG_ROUND_UP_NEXT     0x00030000
+
 /* trigger sources */
 
 #define TRIG_ANY       0xffffffff