Commit 2ce4e57b authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: pcl711: handle cmd->stop_src and stop_arg

The interrupt handler used to support asynchronous commands on the AI
subdevice currently marks the command as finished (setting the "end of
acquisition" event flag and returning to software-triggered acquisition
mode) once it has decremented `devpriv->ntrig` to 0.  However, nothing
sets `devpriv->ntrig`, as noted in the "FIXME" comment.

If the `stop_src` setting of the asynchronous command is `TRIG_COUNT`,
then the `stop_arg` setting indicates the number of scans to be
performed in the overall acquisition.  (Otherwise, `stop_src` will be
`TRIG_NONE`, meaning the acquisition should run indefinitely until
cancelled.)  When starting the acquisition in `pcl711_ai_cmd()`, set
`devpriv->ntrig` to the number of scans to be performed (`stop_arg`) if
`stop_src` is `TRIG_COUNT`.  In the interrupt handler, don't decrement
`devpriv->ntrig` or handle end of acquision unless `stop_src` is
`TRIG_COUNT`.

Also check for an empty acquisition in `pcl711_ai_cmd()`, i.e. one where
`stop_src` is `TRIG_COUNT` and `stop_arg` is zero and just mark end of
acquisition without actually setting up the interrupts in this case.

Also change the type of the `ntrig` member of the private data structure
to `unsigned int` as it should be (same type as `stop_arg`).
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b7ea391c
...@@ -156,7 +156,7 @@ static const struct pcl711_board boardtypes[] = { ...@@ -156,7 +156,7 @@ static const struct pcl711_board boardtypes[] = {
}; };
struct pcl711_private { struct pcl711_private {
int ntrig; unsigned int ntrig;
unsigned int ao_readback[2]; unsigned int ao_readback[2];
unsigned int divisor1; unsigned int divisor1;
unsigned int divisor2; unsigned int divisor2;
...@@ -213,10 +213,8 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) ...@@ -213,10 +213,8 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG); outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG);
/* FIXME! Nothing else sets ntrig! */ if (s->async->cmd.stop_src == TRIG_COUNT && !(--devpriv->ntrig)) {
if (!(--devpriv->ntrig)) {
pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG); pcl711_ai_set_mode(dev, PCL711_MODE_SOFTTRIG);
s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_EOA;
} }
comedi_event(dev, s); comedi_event(dev, s);
...@@ -367,6 +365,16 @@ static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -367,6 +365,16 @@ static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
pcl711_set_changain(dev, s, cmd->chanlist[0]); pcl711_set_changain(dev, s, cmd->chanlist[0]);
if (cmd->stop_src == TRIG_COUNT) {
if (cmd->stop_arg == 0) {
/* an empty acquisition */
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
return 0;
}
devpriv->ntrig = cmd->stop_arg;
}
if (cmd->scan_begin_src == TRIG_TIMER) { if (cmd->scan_begin_src == TRIG_TIMER) {
i8254_load(dev->iobase + PCL711_TIMER_BASE, 0, i8254_load(dev->iobase + PCL711_TIMER_BASE, 0,
1, devpriv->divisor1, I8254_MODE2 | I8254_BINARY); 1, devpriv->divisor1, I8254_MODE2 | I8254_BINARY);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment