Wrapped all trig related code in CONFIG_COMEDI_TRIG.
Added config option for CONFIG_COMEDI_TRIG.
comment 'Comedi Features'
-define_bool CONFIG_COMEDI_MODES y
-define_bool CONFIG_COMEDI_MODE0 y
-define_bool CONFIG_COMEDI_MODE_CORE y
-
-#bool 'Backwards compatibility' CONFIG_COMEDI_BACKWARDS
+bool 'Trig compatibility (say yes)' CONFIG_COMEDI_TRIG
if [ "$CONFIG_RTL" = "y" ];then
bool 'Real-time support' CONFIG_COMEDI_RT
fi
bool 'Verbose Debugging' CONFIG_COMEDI_DEBUG
-#bool 'Version 0.8 support' CONFIG_COMEDI_VER08
dep_tristate 'Kernel Comedilib' CONFIG_COMEDI_KLIB $CONFIG_COMEDI
O_TARGET := comedi.o
O_OBJS := comedi_fops.o proc.o range.o drivers.o kvmem.o
OX_OBJS := comedi_ksyms.o
+ ifeq ($(CONFIG_COMEDI_TRIG),y)
+ MI_OBJS += trig.o
+ endif
else
ifeq ($(CONFIG_COMEDI),m)
M_OBJS := comedi.o
MI_OBJS := comedi_fops.o proc.o range.o drivers.o kvmem.o
MIX_OBJS := comedi_ksyms.o
+ ifeq ($(CONFIG_COMEDI_TRIG),y)
+ MI_OBJS += trig.o
+ endif
endif
endif
-
ifeq ($(CONFIG_COMEDI_RT),y)
MI_OBJS += rt.o
endif
static int do_subdinfo_ioctl(comedi_device *dev,comedi_subdinfo *arg,void *file);
static int do_chaninfo_ioctl(comedi_device *dev,comedi_chaninfo *arg);
static int do_bufinfo_ioctl(comedi_device *dev,void *arg);
-#ifdef CONFIG_COMEDI_MODE_CORE
+#ifdef CONFIG_COMEDI_TRIG
static int do_trig_ioctl(comedi_device *dev,void *arg,void *file);
#endif
static int do_cmd_ioctl(comedi_device *dev,void *arg,void *file);
return do_rangeinfo_ioctl(dev,(void *)arg);
case COMEDI_BUFINFO:
return do_bufinfo_ioctl(dev,(void*)arg);
-#ifdef CONFIG_COMEDI_MODE_CORE
+#ifdef CONFIG_COMEDI_TRIG
case COMEDI_TRIG:
return do_trig_ioctl(dev,(void *)arg,file);
#endif
us->subd_flags |= SDF_FLAGS;
if(s->range_table_list)
us->subd_flags |= SDF_RANGETYPE;
-#ifdef CONFIG_COMEDI_MODE_CORE
+#ifdef CONFIG_COMEDI_TRIG
if(s->trig[0])
us->subd_flags |= SDF_MODE0;
if(s->trig[1])
return 0;
}
-#ifdef CONFIG_COMEDI_MODE_CORE
+#ifdef CONFIG_COMEDI_TRIG
/*
COMEDI_TRIG
trigger ioctl
n-=m;
// check for buffer overrun
- if(async->buf_int_count - async->buf_user_count > async->data_len){ /* XXX MODE */
+ if(async->buf_int_count - async->buf_user_count > async->data_len){
async->buf_user_count = async->buf_int_count;
async->buf_user_ptr = async->buf_int_ptr;
retval=-EINVAL;
}
#endif
+#ifdef CONFIG_COMEDI_TRIG
if(s->cur_trig.chanlist){ /* XXX wrong? */
kfree(s->cur_trig.chanlist);
s->cur_trig.chanlist=NULL;
}
+#endif
if(async){
async->buf_user_ptr=0;
#include <linux/malloc.h>
#include <asm/io.h>
+#ifdef CONFIG_COMEDI_TRIG
+/* in comedi/trig.c */
+int command_trig(comedi_device *dev,comedi_subdevice *s,comedi_trig *it);
+int mode_to_command(comedi_cmd *cmd,comedi_trig *it);
+int mode0_emulate(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig);
+int mode0_emulate_config(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig);
+#endif
+
static int postconfig(comedi_device *dev);
-static int command_trig(comedi_device *dev,comedi_subdevice *s,comedi_trig *it);
-static int mode_to_command(comedi_cmd *cmd,comedi_trig *it);
static int insn_rw_emulate_bits(comedi_device *dev,comedi_subdevice *s,
comedi_insn *insn,lsampl_t *data);
static int insn_inval(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-#if 0
-static int mode0_emulate(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig);
-static int mode0_emulate_config(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig);
-#endif
static void *comedi_recognize(comedi_driver *driv, const char *name);
static void comedi_report_boards(comedi_driver *driv);
static int poll_invalid(comedi_device *dev,comedi_subdevice *s);
if(s->len_chanlist==0)
s->len_chanlist=1;
+#ifdef CONFIG_COMEDI_TRIG
if(s->do_cmd){
s->trig[1]=command_trig;
s->trig[2]=command_trig;
s->trig[3]=command_trig;
s->trig[4]=command_trig;
}
+#endif
- if(s->do_cmd || s->trig[1] || s->trig[2] || s->trig[3] ||s->trig[4]){
+ if(s->do_cmd
+#ifdef CONFIG_COMEDI_TRIG
+ || s->trig[1] || s->trig[2] || s->trig[3] ||s->trig[4]
+#endif
+ ){
async = kmalloc(sizeof(comedi_async), GFP_KERNEL);
if(async == NULL)
{
return 1;
}
-#define SUPPORT_TRIG
-#define SUPPORT_TRIG0
-#ifdef SUPPORT_TRIG
-#if 0
-static int mode0_emulate(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig)
-{
- comedi_insn insn;
- lsampl_t ldata;
- int ret;
-
- insn.subdev=trig->subdev;
- insn.data=&ldata;
- insn.n=1;
- insn.chanspec=trig->chanlist[0];
-
- if(trig->flags&TRIG_CONFIG)
- return mode0_emulate_config(dev,s,trig);
-
- if(s->subdev_flags & SDF_WRITEABLE){
- if(s->subdev_flags & SDF_READABLE){
- if(trig->flags&TRIG_WRITE){
- insn.insn=INSN_WRITE;
- }else{
- insn.insn=INSN_READ;
- }
- }else{
- insn.insn=INSN_WRITE;
- }
- }else{
- insn.insn=INSN_READ;
- }
-
- switch(insn.insn){
- case INSN_READ:
- ret=s->insn_read(dev,s,&insn,&ldata);
- if(s->subdev_flags&SDF_LSAMPL){
- *(lsampl_t *)trig->data=ldata;
- }else{
- trig->data[0]=ldata;
- }
- return ret;
- case INSN_WRITE:
- if(s->subdev_flags&SDF_LSAMPL){
- ldata=*(lsampl_t *)trig->data;
- }else{
- ldata=trig->data[0];
- }
- return s->insn_write(dev,s,&insn,&ldata);
- default:
- }
-
- return -EINVAL;
-}
-#endif
-#endif
-
-#ifdef SUPPORT_TRIG0
-#if 0
-static int mode0_emulate_config(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig)
-{
- comedi_insn insn;
- lsampl_t ldata;
-
- insn.subdev=trig->subdev;
- insn.data=&ldata;
- insn.n=1;
- insn.chanspec=trig->chanlist[0];
-
- ldata = trig->data[0];
-
- return s->insn_config(dev,s,&insn,&ldata);
-}
-#endif
-#endif
-
-#ifdef SUPPORT_TRIG
-static int command_trig(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
-{
- int ret;
- comedi_async *async = s->async;
-
- ret=mode_to_command(&async->cmd,it);
- if(ret)return ret;
-
- ret=s->do_cmdtest(dev,s,&async->cmd);
- if(ret)return -EINVAL;
-
- ret=s->do_cmd(dev,s);
- if(ret>0)return -EINVAL;
- return ret;
-}
-#endif
-
-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;
-}
-
-
#define REG(x) {extern comedi_driver (x);comedi_driver_register(&(x));}
void init_drivers(void)
return s->do_cmdtest(dev,s,cmd);
}
+#ifdef CONFIG_COMEDI_TRIG
/*
COMEDI_TRIG
trigger ioctl
return ret;
}
+#endif
/*
* COMEDI_INSN
--- /dev/null
+/*
+ module/trig.c
+ back-compatibility functions
+
+ COMEDI - Linux Control and Measurement Device Interface
+ Copyright (C) 1997-2001 David A. Schleef <ds@schleef.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <linux/comedidev.h>
+#include <kvmem.h>
+
+#define __NO_VERSION__
+#include <linux/module.h>
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/fcntl.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/malloc.h>
+#include <asm/io.h>
+
+int command_trig(comedi_device *dev,comedi_subdevice *s,comedi_trig *it);
+int mode_to_command(comedi_cmd *cmd,comedi_trig *it);
+int mode0_emulate(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig);
+int mode0_emulate_config(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig);
+
+
+
+int mode0_emulate(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig)
+{
+ comedi_insn insn;
+ lsampl_t ldata;
+ int ret;
+
+ insn.subdev=trig->subdev;
+ insn.data=&ldata;
+ insn.n=1;
+ insn.chanspec=trig->chanlist[0];
+
+ if(trig->flags&TRIG_CONFIG)
+ return mode0_emulate_config(dev,s,trig);
+
+ if(s->subdev_flags & SDF_WRITEABLE){
+ if(s->subdev_flags & SDF_READABLE){
+ if(trig->flags&TRIG_WRITE){
+ insn.insn=INSN_WRITE;
+ }else{
+ insn.insn=INSN_READ;
+ }
+ }else{
+ insn.insn=INSN_WRITE;
+ }
+ }else{
+ insn.insn=INSN_READ;
+ }
+
+ switch(insn.insn){
+ case INSN_READ:
+ ret=s->insn_read(dev,s,&insn,&ldata);
+ if(s->subdev_flags&SDF_LSAMPL){
+ *(lsampl_t *)trig->data=ldata;
+ }else{
+ trig->data[0]=ldata;
+ }
+ return ret;
+ case INSN_WRITE:
+ if(s->subdev_flags&SDF_LSAMPL){
+ ldata=*(lsampl_t *)trig->data;
+ }else{
+ ldata=trig->data[0];
+ }
+ return s->insn_write(dev,s,&insn,&ldata);
+ default:
+ }
+
+ return -EINVAL;
+}
+
+int mode0_emulate_config(comedi_device *dev,comedi_subdevice *s,comedi_trig *trig)
+{
+ comedi_insn insn;
+ lsampl_t ldata;
+
+ insn.subdev=trig->subdev;
+ insn.data=&ldata;
+ insn.n=1;
+ insn.chanspec=trig->chanlist[0];
+
+ ldata = trig->data[0];
+
+ return s->insn_config(dev,s,&insn,&ldata);
+}
+
+int command_trig(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+{
+ int ret;
+ comedi_async *async = s->async;
+
+ ret=mode_to_command(&async->cmd,it);
+ if(ret)return ret;
+
+ ret=s->do_cmdtest(dev,s,&async->cmd);
+ if(ret)return -EINVAL;
+
+ ret=s->do_cmd(dev,s);
+ if(ret>0)return -EINVAL;
+ return ret;
+}
+
+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;
+}
+
unsigned int *chanlist; /* driver-owned chanlist (not used) */
-#ifdef CONFIG_COMEDI_MODE_CORE
+#ifdef CONFIG_COMEDI_TRIG
comedi_trig cur_trig; /* current trig structure */
int (*trig[5])(comedi_device *,comedi_subdevice *,comedi_trig *);
#endif
void comedi_proc_init(void);
void comedi_proc_cleanup(void);
-#ifdef CONFIG_COMEDI_MODE_CORE
+#ifdef CONFIG_COMEDI_TRIG
int di_unpack(unsigned int bits,comedi_trig *it);
int do_pack(unsigned int *bits,comedi_trig *it);
#endif