staging: comedi: das08: Support read-back of AO subdevice
Stash the last value written to each AO channel in private data and support the INSN_READ instruction to read it back. Don't bother setting the SDF_READABLE subdevice flag though as the hardware isn't really readable - we're just faking it. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8432eb35a9
commit
f0ba1d6e19
2 changed files with 20 additions and 1 deletions
|
@ -373,6 +373,7 @@ static void das08_ao_set_data(struct comedi_device *dev,
|
||||||
unsigned int chan, unsigned int data)
|
unsigned int chan, unsigned int data)
|
||||||
{
|
{
|
||||||
const struct das08_board_struct *thisboard = comedi_board(dev);
|
const struct das08_board_struct *thisboard = comedi_board(dev);
|
||||||
|
struct das08_private_struct *devpriv = dev->private;
|
||||||
unsigned char lsb;
|
unsigned char lsb;
|
||||||
unsigned char msb;
|
unsigned char msb;
|
||||||
|
|
||||||
|
@ -389,6 +390,7 @@ static void das08_ao_set_data(struct comedi_device *dev,
|
||||||
/* load DACs */
|
/* load DACs */
|
||||||
inb(dev->iobase + DAS08AO_AO_UPDATE);
|
inb(dev->iobase + DAS08AO_AO_UPDATE);
|
||||||
}
|
}
|
||||||
|
devpriv->ao_readback[chan] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void das08_ao_initialize(struct comedi_device *dev,
|
static void das08_ao_initialize(struct comedi_device *dev,
|
||||||
|
@ -417,6 +419,22 @@ static int das08_ao_winsn(struct comedi_device *dev,
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int das08_ao_rinsn(struct comedi_device *dev,
|
||||||
|
struct comedi_subdevice *s,
|
||||||
|
struct comedi_insn *insn, unsigned int *data)
|
||||||
|
{
|
||||||
|
struct das08_private_struct *devpriv = dev->private;
|
||||||
|
unsigned int n;
|
||||||
|
unsigned int chan;
|
||||||
|
|
||||||
|
chan = CR_CHAN(insn->chanspec);
|
||||||
|
|
||||||
|
for (n = 0; n < insn->n; n++)
|
||||||
|
data[n] = devpriv->ao_readback[chan];
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static void i8254_initialize(struct comedi_device *dev)
|
static void i8254_initialize(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
const struct das08_board_struct *thisboard = comedi_board(dev);
|
const struct das08_board_struct *thisboard = comedi_board(dev);
|
||||||
|
@ -670,12 +688,12 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
|
||||||
/* ao */
|
/* ao */
|
||||||
if (thisboard->ao_nbits) {
|
if (thisboard->ao_nbits) {
|
||||||
s->type = COMEDI_SUBD_AO;
|
s->type = COMEDI_SUBD_AO;
|
||||||
/* XXX lacks read-back insn */
|
|
||||||
s->subdev_flags = SDF_WRITABLE;
|
s->subdev_flags = SDF_WRITABLE;
|
||||||
s->n_chan = 2;
|
s->n_chan = 2;
|
||||||
s->maxdata = (1 << thisboard->ao_nbits) - 1;
|
s->maxdata = (1 << thisboard->ao_nbits) - 1;
|
||||||
s->range_table = &range_bipolar5;
|
s->range_table = &range_bipolar5;
|
||||||
s->insn_write = das08_ao_winsn;
|
s->insn_write = das08_ao_winsn;
|
||||||
|
s->insn_read = das08_ao_rinsn;
|
||||||
das08_ao_initialize(dev, s);
|
das08_ao_initialize(dev, s);
|
||||||
} else {
|
} else {
|
||||||
s->type = COMEDI_SUBD_UNUSED;
|
s->type = COMEDI_SUBD_UNUSED;
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct das08_private_struct {
|
||||||
unsigned int do_bits; /* bits for do register on boards with register dedicated to digital out only */
|
unsigned int do_bits; /* bits for do register on boards with register dedicated to digital out only */
|
||||||
const unsigned int *pg_gainlist;
|
const unsigned int *pg_gainlist;
|
||||||
struct pci_dev *pdev; /* struct for pci-das08 */
|
struct pci_dev *pdev; /* struct for pci-das08 */
|
||||||
|
unsigned int ao_readback[2]; /* assume 2 AO channels */
|
||||||
};
|
};
|
||||||
|
|
||||||
int das08_common_attach(struct comedi_device *dev, unsigned long iobase);
|
int das08_common_attach(struct comedi_device *dev, unsigned long iobase);
|
||||||
|
|
Loading…
Add table
Reference in a new issue