Added internal trigger support
authorDavid Schleef <ds@schleef.org>
Fri, 8 Jun 2001 22:33:44 +0000 (22:33 +0000)
committerDavid Schleef <ds@schleef.org>
Fri, 8 Jun 2001 22:33:44 +0000 (22:33 +0000)
comedi/comedi_fops.c
include/linux/comedi.h
include/linux/comedidev.h

index 24e65adba4cf0f855b1d0e95d978e3de3cb1927d..6662e26ec402ab4b1710341a993ebc07ccc0aebe 100644 (file)
@@ -593,6 +593,11 @@ static int do_insnlist_ioctl(comedi_device *dev,void *arg,void *file)
                        {
                                struct timeval tv;
 
+                               if(insn.n!=2){
+                                       ret=-EINVAL;
+                                       goto error;
+                               }
+
                                do_gettimeofday(&tv);
                                data[0]=tv.tv_sec;
                                data[1]=tv.tv_usec;
@@ -601,14 +606,29 @@ static int do_insnlist_ioctl(comedi_device *dev,void *arg,void *file)
                                break;
                        }
                        case INSN_WAIT:
-                               if(insn.n<1 || data[0]>=100000){
+                               if(insn.n!=1 || data[0]>=100000){
                                        ret=-EINVAL;
                                        break;
                                }
                                udelay(data[0]/1000);
                                ret=1;
                                break;
+                       case INSN_INTTRIG:
+                               if(insn.subdev>=dev->n_subdevices){
+                                       DPRINTK("%d not useable subdevice\n",insn.subdev);
+                                       ret=-EINVAL;
+                                       goto error;
+                               }
+                               s=dev->subdevices+insn.subdev;
+                               if(!s->async || !s->async->inttrig){
+                                       DPRINTK("no async or no inttrig\n");
+                                       ret=-EINVAL;
+                                       goto error;
+                               }
+                               ret = s->async->inttrig(dev,s,0);
+                               break;
                        default:
+                               DPRINTK("invalid insn\n");
                                ret=-EINVAL;
                        }
                }else{
index 95e61700d8614f6a0744084ecb2380c30cd9d699..a5175cfa5f96f86344fe4dccdfe786328317f5f6 100644 (file)
@@ -97,6 +97,7 @@ typedef unsigned short sampl_t;
 #define INSN_CONFIG            ( 3 | INSN_MASK_READ|INSN_MASK_WRITE)
 #define INSN_GTOD              ( 4 | INSN_MASK_READ|INSN_MASK_SPECIAL)
 #define INSN_WAIT              ( 5 | INSN_MASK_WRITE|INSN_MASK_SPECIAL)
+#define INSN_INTTRIG           ( 6 | INSN_MASK_WRITE|INSN_MASK_SPECIAL)
 
 /* trigger flags */
 
@@ -126,8 +127,6 @@ typedef unsigned short sampl_t;
 #define TRIG_EXT       0x00000040      /* trigger on external signal N */
 #define TRIG_INT       0x00000080      /* trigger on comedi-internal signal N */
 
-#define TRIG_INVAL     0x00000100      /* choice was invalid */
-
 /* subdevice flags */
 
 #define SDF_BUSY       0x0001          /* device is busy */
index dd58094bd2bd1ea5fbe6131f41e84737e1884ba5..cc8aecd8f4a9ee136e18ddeb5eaf2d73e3708143 100644 (file)
@@ -103,6 +103,8 @@ struct comedi_subdevice_struct{
        int (*do_lock)(comedi_device *,comedi_subdevice *);
        int (*do_unlock)(comedi_device *,comedi_subdevice *);
 
+       int (*buf_change)(comedi_device *,comedi_subdevice *s);
+
        unsigned int state;
 };
 
@@ -130,6 +132,8 @@ struct comedi_async_struct{
        unsigned int cb_mask;
        int (*cb_func)(unsigned int flags,void *);
        void *cb_arg;
+
+       int (*inttrig)(comedi_device *dev,comedi_subdevice *s,unsigned int x);
 };
 
 struct comedi_driver_struct{