From d0450005c5ea6896f01bfb55110bd8a3ee1b4e99 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 16 Aug 2012 19:54:32 -0700 Subject: [PATCH] --- yaml --- r: 324599 b: refs/heads/master c: aee815b53bca1cfa092ecd742fc59512b8030336 h: refs/heads/master i: 324597: d7d928a89a1b6378164ae54c8d91ac6517f970aa 324595: 5240c38275edf32d8a441c7e296137d102187eeb 324591: 3ba5790bb8f9482c865f887d2c0469fe4006d6b4 v: v3 --- [refs] | 2 +- .../staging/comedi/drivers/cb_pcimdda.c | 63 ++++++++----------- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/[refs] b/[refs] index 03879ccb31d1..ef5b146db59c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b9616b18c1dbbc3bfad9c1801fb96f41c26449e2 +refs/heads/master: aee815b53bca1cfa092ecd742fc59512b8030336 diff --git a/trunk/drivers/staging/comedi/drivers/cb_pcimdda.c b/trunk/drivers/staging/comedi/drivers/cb_pcimdda.c index a5e055f0a5ff..350c8078cded 100644 --- a/trunk/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/trunk/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -110,62 +110,51 @@ static int cb_pcimdda_ao_winsn(struct comedi_device *dev, unsigned int *data) { struct cb_pcimdda_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned long offset = dev->iobase + PCIMDDA_DA_CHAN(chan); + unsigned int val = 0; int i; - int chan = CR_CHAN(insn->chanspec); - unsigned long offset = dev->iobase + chan * 2; - /* Writing a list of values to an AO channel is probably not - * very useful, but that's how the interface is defined. */ for (i = 0; i < insn->n; i++) { - /* first, load the low byte */ - outb((char)(data[i] & 0x00ff), offset); - /* next, write the high byte -- only after this is written is - the channel voltage updated in the DAC, unless - we're in simultaneous xfer mode (jumper on card) - then a rinsn is necessary to actually update the DAC -- - see cb_pcimdda_ao_rinsn() below... */ - outb((char)(data[i] >> 8 & 0x00ff), offset + 1); - - /* for testing only.. the actual rinsn SHOULD do an inw! - (see the stuff about simultaneous XFER mode on this board) */ - devpriv->ao_readback[chan] = data[i]; + val = data[i]; + + /* + * Write the LSB then MSB. + * + * If the simultaneous xfer mode is selected by the + * jumper on the card, a read instruction is needed + * in order to initiate the simultaneous transfer. + * Otherwise, the DAC will be updated when the MSB + * is written. + */ + outb(val & 0x00ff, offset); + outb((val >> 8) & 0x00ff, offset + 1); } - /* return the number of samples read/written */ - return i; -} + /* Cache the last value for readback */ + devpriv->ao_readback[chan] = val; -/* AO subdevices should have a read insn as well as a write insn. + return insn->n; +} - Usually this means copying a value stored in devpriv->ao_readback. - However, since this board has this jumper setting called "Simultaneous - Xfer mode" (off by default), we will support it. Simultaneaous xfer - mode is accomplished by loading ALL the values you want for AO in all the - channels, then READing off one of the AO registers to initiate the - instantaneous simultaneous update of all DAC outputs, which makes - all AO channels update simultaneously. This is useful for some control - applications, I would imagine. -*/ static int cb_pcimdda_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { struct cb_pcimdda_private *devpriv = dev->private; - int i; int chan = CR_CHAN(insn->chanspec); + unsigned long offset = dev->iobase + PCIMDDA_DA_CHAN(chan); + int i; for (i = 0; i < insn->n; i++) { - inw(dev->iobase + chan * 2); - /* - * should I set data[i] to the result of the actual read - * on the register or the cached unsigned int in - * devpriv->ao_readback[]? - */ + /* Initiate the simultaneous transfer */ + inw(offset); + data[i] = devpriv->ao_readback[chan]; } - return i; + return insn->n; } static struct pci_dev *cb_pcimdda_probe(struct comedi_device *dev,