unsigned int dma_buf_size; /* size of buffers currently used, depends on sampling frequency */
int iobase2; /* secondary io address used for analog out on 'ao' boards */
short ao_update_bits; /* remembers the last write to the 'update' dac */
- spinlock_t spinlock; /* used to protect indirect addressing */
}das1800_private;
#define devpriv ((das1800_private *)dev->private)
/* allocate and initialize dev->private */
if(alloc_private(dev, sizeof(das1800_private)) < 0)
return -ENOMEM;
- devpriv->spinlock = SPIN_LOCK_UNLOCKED;
printk("comedi%d: %s: io 0x%x", dev->minor, driver_das1800.driver_name, iobase);
if(irq)
{
return;
}
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(ADC, dev->iobase + DAS1800_SELECT);
// dma buffer full or about-triggering (stop_src == TRIG_EXT)
if(devpriv->irq_dma_bits & DMA_ENABLED)
/* clear interrupt */
outb(FNE, dev->iobase + DAS1800_STATUS);
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
comedi_bufcheck(dev, s);
/* if the card's fifo has overflowed */
if(status & OVF)
const int range_bitshift = 8;
n = cmd.chanlist_len;
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */
outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS); /*set QRAM address start */
/* make channel / gain list */
outw(chan_range, dev->iobase + DAS1800_QRAM);
}
outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS); /*finish write to QRAM */
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return;
}
/* mask of unipolar/bipolar bit from range */
range = CR_RANGE(insn->chanspec) & 0x3;
chan_range = chan | (range << 8);
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(QRAM, dev->iobase + DAS1800_SELECT); /* select QRAM for baseAddress + 0x0 */
outb(0x0, dev->iobase + DAS1800_QRAM_ADDRESS); /* set QRAM address start */
outw(chan_range, dev->iobase + DAS1800_QRAM);
dpnt += 1 << (thisboard->resolution - 1);
data[n] = dpnt;
}
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return n;
}
if(chan == update_chan)
devpriv->ao_update_bits = output;
// write to channel
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(DAC(chan), dev->iobase + DAS1800_SELECT); /* select dac channel for baseAddress + 0x0 */
outw(output, dev->iobase + DAS1800_DAC);
// now we need to write to 'update' channel to update all dac channels
outb(DAC(update_chan), dev->iobase + DAS1800_SELECT); /* select 'update' channel for baseAddress + 0x0 */
outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC);
}
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return 1;
}
unsigned int divisor1; /* value to load into board's counter 1 for timed conversions */
unsigned int divisor2; /* value to load into board's counter 2 for timed conversions */
int do_bits; /* digital output bits */
- spinlock_t spinlock;
}das800_private;
#define devpriv ((das800_private *)dev->private)
int board;
// 'comedi spin lock irqsave' disables even rt interrupts, we use them to protect indirect addressing
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(ID, dev->iobase + DAS800_GAIN); /* select base address + 7 to be ID register */
id_bits = inb(dev->iobase + DAS800_ID) & 0x3; /* get id bits */
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
board = thisboard - das800_boards;
return;
// if hardware conversions are not enabled, then quit
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select base address + 7 to be STATUS2 register */
status = inb(dev->iobase + DAS800_STATUS2) & STATUS2_HCEN;
/* don't release spinlock yet since we want to make sure noone else disables hardware conversions */
if(status == 0)
{
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return;
}
dataPoint += inb(dev->iobase + DAS800_MSB) << 8;
}
/* we can release spinlock now since we dont case if hardware conversions are enabled anymore */
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
if(i == max_loops)
comedi_error(dev, "possible problem with loop in interrupt handler");
if(devpriv->count > 0 || devpriv->forever == 1)
{
/* Re-enable card's interrupt */
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
/* otherwise, stop taking data */
} else
{
/* allocate and initialize dev->private */
if(alloc_private(dev, sizeof(das800_private)) < 0)
return -ENOMEM;
- devpriv->spinlock = SPIN_LOCK_UNLOCKED;
dev->n_subdevices = 3;
if(alloc_subdevices(dev) < 0)
disable_das800(dev);
/* initialize digital out channels */
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return 0;
};
void enable_das800(comedi_device *dev)
{
unsigned long irq_flags;
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */
outb(CONV_HCEN, dev->iobase + DAS800_CONV_CONTROL); /* enable hardware triggering */
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(CONTROL1_INTE | devpriv->do_bits, dev->iobase + DAS800_CONTROL1); /* enable card's interrupt */
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
}
/* disable_das800 stops hardware triggered conversions */
void disable_das800(comedi_device *dev)
{
unsigned long irq_flags;
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */
outb(0x0, dev->iobase + DAS800_CONV_CONTROL); /* disable hardware triggering of conversions */
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
}
static int das800_ai_do_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_cmd *cmd)
endChan = (startChan + async->cmd.chanlist_len - 1) % 8;
scan = (endChan << 3) | startChan;
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(SCAN_LIMITS, dev->iobase + DAS800_GAIN); /* select base address + 2 to be scan limits register */
outb(scan, dev->iobase + DAS800_SCAN_LIMITS); /* set scan limits */
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
/* set gain */
gain = CR_RANGE(async->cmd.chanlist[0]);
break;
}
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONV_CONTROL, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be conversion control register */
outb(conv_bits, dev->iobase + DAS800_CONV_CONTROL);
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
enable_das800(dev);
return 0;
/* set multiplexer */
chan = CR_CHAN(insn->chanspec);
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(chan | devpriv->do_bits, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
/* set gain / range */
range = CR_RANGE(insn->chanspec);
else
devpriv->do_bits &= ~(1 << (chan + 4));
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(devpriv->do_bits | CONTROL1_INTE, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
return 1;
}
wbits |= data[0] & data[1];
devpriv->do_bits = wbits << 4;
- comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
+ comedi_spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(CONTROL1, dev->iobase + DAS800_GAIN); /* select dev->iobase + 2 to be control register 1 */
outb(devpriv->do_bits | CONTROL1_INTE, dev->iobase + DAS800_CONTROL1);
- comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ comedi_spin_unlock_irqrestore(&dev->spinlock, irq_flags);
data[1] = wbits;