Commit d1d24cb6 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: das6402: read analog input samples in interrupt handler

Currently the interrupt handler just clears the interrupt.

Add the code necessary to read the analog input samples when running
an async command.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3e0a7380
......@@ -193,12 +193,46 @@ static void das6402_enable_counter(struct comedi_device *dev, bool load)
}
}
static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
struct comedi_subdevice *s)
{
unsigned int val;
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
if (s->maxdata == 0x0fff)
val >>= 4;
return val;
}
static irqreturn_t das6402_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int status;
status = inb(dev->iobase + DAS6402_STATUS_REG);
if ((status & DAS6402_STATUS_INT) == 0)
return IRQ_NONE;
if (status & DAS6402_STATUS_FFULL) {
async->events |= COMEDI_CB_OVERFLOW;
} else if (status & DAS6402_STATUS_FFNE) {
unsigned int val;
val = das6402_ai_read_sample(dev, s);
comedi_buf_write_samples(s, &val, 1);
if (cmd->stop_src == TRIG_COUNT &&
async->scans_done >= cmd->stop_arg)
async->events |= COMEDI_CB_EOA;
}
das6402_clear_all_interrupts(dev);
comedi_handle_events(dev, s);
return IRQ_HANDLED;
}
......@@ -367,7 +401,6 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int aref = CR_AREF(insn->chanspec);
unsigned int val;
int ret;
int i;
......@@ -391,12 +424,7 @@ static int das6402_ai_insn_read(struct comedi_device *dev,
if (ret)
break;
val = inw(dev->iobase + DAS6402_AI_DATA_REG);
if (s->maxdata == 0x0fff)
val >>= 4;
data[i] = val;
data[i] = das6402_ai_read_sample(dev, s);
}
das6402_ai_clear_eoc(dev);
......
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