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)
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
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
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
-
-
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);
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)
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;
}
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;
}
}
-
-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;
-}
-
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);
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{
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) */
/* 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 */
#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;
static void postconfig(comedi_device *dev)
{
int i;
+ int have_trig;
comedi_subdevice *s;
for(i=0;i<dev->n_subdevices;i++){
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;
}
}
- 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));}
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 */
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
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;
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;
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");
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;
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;
}
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;
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;
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;
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;
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;
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;
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);
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
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;
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;
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]];
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 */
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 */
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);
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;
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)
}
-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;
}
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++;
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;
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++;
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;
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 )
+}};
/*
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
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 */
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]];
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 */
s->trig[0] = dt2811_do;
s->maxdata = 1;
s->state = 0;
- s->range_type = RANGE_digital;
+ s->range_table = &range_digital;
return 0;
}
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;
#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
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)
{
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);
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
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;
#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;
adbits: 12,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 0,
dachan: 2,
dabits: 12,
adbits: 16,
adchan_se: 0,
adchan_di: 4,
+ ai_speed: 4000,
ispgl: 0,
dachan: 2,
dabits: 16,
adbits: 16,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 0,
dachan: 0,
dabits: 0,
adbits: 16,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 1,
dachan: 0,
dabits: 0,
adbits: 12,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 0,
dachan: 2,
dabits: 12,
adbits: 16,
adchan_se: 0,
adchan_di: 4,
+ ai_speed: 4000,
ispgl: 0,
dachan: 2,
dabits: 12,
adbits: 12,
adchan_se: 4,
adchan_di: 0,
+ ai_speed: 4000,
ispgl: 0,
dachan: 2,
dabits: 12,
adbits: 12,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 0,
dachan: 2,
dabits: 12,
adbits: 16,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 0,
dachan: 0,
dabits: 0,
adbits: 12,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 0,
dachan: 0,
dabits: 0,
adbits: 12,
adchan_se: 16,
adchan_di: 8,
+ ai_speed: 4000,
ispgl: 1,
dachan: 0,
dabits: 0,
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;
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);
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;
}
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){
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;
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;
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;
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;
}
-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);
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;
}
-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 */
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];
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]);
s->n_chan=16;
s->trig[0]=dt282x_dio;
s->maxdata=1;
- s->range_type = RANGE_digital;
+ s->range_table = &range_digital;
printk("\n");
#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;
device_id: 0x22,
adchan: 16,
adbits: 12,
- adrange: RANGE_dt3000_ai,
+ adrange: &range_dt3000_ai,
dachan: 2,
dabits: 12,
},
device_id: 0x27,
adchan: 16,
adbits: 12,
- adrange: RANGE_dt3000_ai_pgl,
+ adrange: &range_dt3000_ai_pgl,
dachan: 2,
dabits: 12,
},
device_id: 0x23,
adchan: 32,
adbits: 12,
- adrange: RANGE_dt3000_ai,
+ adrange: &range_dt3000_ai,
dachan: 0,
dabits: 0,
},
device_id: 0x24,
adchan: 64,
adbits: 12,
- adrange: RANGE_dt3000_ai,
+ adrange: &range_dt3000_ai,
dachan: 2,
dabits: 12,
},
device_id: 0x28,
adchan: 64,
adbits: 12,
- adrange: RANGE_dt3000_ai_pgl,
+ adrange: &range_dt3000_ai_pgl,
dachan: 2,
dabits: 12,
},
device_id: 0x25,
adchan: 16,
adbits: 16,
- adrange: RANGE_dt3000_ai,
+ adrange: &range_dt3000_ai,
dachan: 2,
dabits: 12,
},
device_id: 0x26,
adchan: 16,
adbits: 16,
- adrange: RANGE_dt3000_ai,
+ adrange: &range_dt3000_ai,
dachan: 2,
dabits: 12,
},
#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;
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++;
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 */
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 */
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++;
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 */
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 */
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 */
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;
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);
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;
#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);
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))
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;
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++;
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++;
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;
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 */
s->maxdata=1;
s->n_chan=8;
s->trig[0]=pcl725_di;
- s->range_type=RANGE_digital;
+ s->range_table=&range_digital;
printk("\n");
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 */
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 */
s->n_chan=16;
s->maxdata=1;
s->trig[0]=pcl726_do;
- s->range_type=RANGE_digital;
+ s->range_table=&range_digital;
printk("\n");
#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);
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)
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;
}
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;
}
}
s->n_chan=8;
s->trig[0]=rti800_di;
s->maxdata=1;
- s->range_type=RANGE_digital;
+ s->range_table=&range_digital;
s++;
/* do */
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 */
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)
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");
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 */
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;
+++ /dev/null
-
-
-#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;
-}
-
*/
-#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
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;
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]);
#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;
}
#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