#include "comedi_fc.h"
#undef DEBUG
-//#define DEBUG
+/* #define DEBUG */
#ifdef DEBUG
#define DEBUG_PRINT(format, args...) rt_printk("das16: " format, ## args)
#define DEBUG_PRINT(format, args...)
#endif
-#define DAS16_SIZE 20 // number of ioports
-#define DAS16_DMA_SIZE 0xff00 // size in bytes of allocated dma buffer
+#define DAS16_SIZE 20 /* number of ioports */
+#define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */
/*
cio-das16.pdf
*/
-static const int sample_size = 2; // size in bytes of a sample from board
+static const int sample_size = 2; /* size in bytes of a sample from board */
#define DAS16_TRIG 0
#define DAS16_AI_LSB 0
}
};
static const struct comedi_lrange range_das16jr = { 9, {
- // also used by 16/330
+ /* also used by 16/330 */
BIP_RANGE(10),
BIP_RANGE(5),
BIP_RANGE(2.5),
const char *name;
void *ai;
unsigned int ai_nbits;
- unsigned int ai_speed; // max conversion speed in nanosec
+ unsigned int ai_speed; /* max conversion speed in nanosec */
unsigned int ai_pg;
void *ao;
unsigned int ao_nbits;
id: 0x00,
},
{
- name: "cio-das16", // cio-das16.pdf
+ name: "cio-das16", /* cio-das16.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:20000,
id: 0x80,
},
{
- name: "cio-das16/f", // das16.pdf
+ name: "cio-das16/f", /* das16.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:10000,
id: 0x80,
},
{
- name: "cio-das16/jr", // cio-das16jr.pdf
+ name: "cio-das16/jr", /* cio-das16jr.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:7692,
id: 0x00,
},
{
- name: "pc104-das16jr", // pc104-das16jr_xx.pdf
+ name: "pc104-das16jr", /* pc104-das16jr_xx.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:3300,
id: 0x00,
},
{
- name: "cio-das16jr/16", // cio-das16jr_16.pdf
+ name: "cio-das16jr/16", /* cio-das16jr_16.pdf */
ai: das16_ai_rinsn,
ai_nbits:16,
ai_speed:10000,
id: 0x00,
},
{
- name: "pc104-das16jr/16", // pc104-das16jr_xx.pdf
+ name: "pc104-das16jr/16", /* pc104-das16jr_xx.pdf */
ai: das16_ai_rinsn,
ai_nbits:16,
ai_speed:10000,
id: 0x00,
},
{
- name: "das-1201", // 4924.pdf (keithley user's manual)
+ name: "das-1201", /* 4924.pdf (keithley user's manual) */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:20000,
id: 0x20,
},
{
- name: "das-1202", // 4924.pdf (keithley user's manual)
+ name: "das-1202", /* 4924.pdf (keithley user's manual) */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:10000,
id: 0x20,
},
{
- name: "das-1401", // 4919.pdf and 4922.pdf (keithley user's manual)
+ name: "das-1401", /* 4919.pdf and 4922.pdf (keithley user's manual) */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:10000,
i8255_offset:0x0,
i8254_offset:0x0c,
size: 0x408,
- id: 0xc0 // 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0
+ id: 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */
},
{
- name: "das-1402", // 4919.pdf and 4922.pdf (keithley user's manual)
+ name: "das-1402", /* 4919.pdf and 4922.pdf (keithley user's manual) */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:10000,
i8255_offset:0x0,
i8254_offset:0x0c,
size: 0x408,
- id: 0xc0 // 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0
+ id: 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */
},
{
- name: "das-1601", // 4919.pdf
+ name: "das-1601", /* 4919.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:10000,
size: 0x408,
id: 0xc0},
{
- name: "das-1602", // 4919.pdf
+ name: "das-1602", /* 4919.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:10000,
size: 0x408,
id: 0xc0},
{
- name: "cio-das1401/12", // cio-das1400_series.pdf
+ name: "cio-das1401/12", /* cio-das1400_series.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:6250,
size: 0x408,
id: 0xc0},
{
- name: "cio-das1402/12", // cio-das1400_series.pdf
+ name: "cio-das1402/12", /* cio-das1400_series.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:6250,
size: 0x408,
id: 0xc0},
{
- name: "cio-das1402/16", // cio-das1400_series.pdf
+ name: "cio-das1402/16", /* cio-das1400_series.pdf */
ai: das16_ai_rinsn,
ai_nbits:16,
ai_speed:10000,
size: 0x408,
id: 0xc0},
{
- name: "cio-das1601/12", // cio-das160x-1x.pdf
+ name: "cio-das1601/12", /* cio-das160x-1x.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:6250,
size: 0x408,
id: 0xc0},
{
- name: "cio-das1602/12", // cio-das160x-1x.pdf
+ name: "cio-das1602/12", /* cio-das160x-1x.pdf */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:10000,
size: 0x408,
id: 0xc0},
{
- name: "cio-das1602/16", // cio-das160x-1x.pdf
+ name: "cio-das1602/16", /* cio-das160x-1x.pdf */
ai: das16_ai_rinsn,
ai_nbits:16,
ai_speed:10000,
size: 0x408,
id: 0xc0},
{
- name: "cio-das16/330", // ?
+ name: "cio-das16/330", /* ? */
ai: das16_ai_rinsn,
ai_nbits:12,
ai_speed:3030,
id: 0xf0},
#if 0
{
- name: "das16/330i", // ?
+ name: "das16/330i", /* ? */
},
{
- name: "das16/jr/ctr5", // ?
+ name: "das16/jr/ctr5", /* ? */
},
{
- name: "cio-das16/m1/16", // cio-das16_m1_16.pdf, this board is a bit quirky, no dma
+ name: "cio-das16/m1/16", /* cio-das16_m1_16.pdf, this board is a bit quirky, no dma */
},
#endif
};
return HZ / 20;
}
struct das16_private_struct {
- unsigned int ai_unipolar; // unipolar flag
- unsigned int ai_singleended; // single ended flag
- unsigned int clockbase; // master clock speed in ns
- volatile unsigned int control_state; // dma, interrupt and trigger control bits
- volatile unsigned long adc_byte_count; // number of bytes remaining
- unsigned int divisor1; // divisor dividing master clock to get conversion frequency
- unsigned int divisor2; // divisor dividing master clock to get conversion frequency
- unsigned int dma_chan; // dma channel
+ unsigned int ai_unipolar; /* unipolar flag */
+ unsigned int ai_singleended; /* single ended flag */
+ unsigned int clockbase; /* master clock speed in ns */
+ volatile unsigned int control_state; /* dma, interrupt and trigger control bits */
+ volatile unsigned long adc_byte_count; /* number of bytes remaining */
+ unsigned int divisor1; /* divisor dividing master clock to get conversion frequency */
+ unsigned int divisor2; /* divisor dividing master clock to get conversion frequency */
+ unsigned int dma_chan; /* dma channel */
uint16_t *dma_buffer[2];
dma_addr_t dma_buffer_addr[2];
unsigned int current_buffer;
- volatile unsigned int dma_transfer_size; // target number of bytes to transfer per dma shot
- // user-defined analog input and output ranges defined from config options
+ volatile unsigned int dma_transfer_size; /* target number of bytes to transfer per dma shot */
+ /* user-defined analog input and output ranges defined from config options */
struct comedi_lrange *user_ai_range_table;
struct comedi_lrange *user_ao_range_table;
- struct timer_list timer; // for timed interrupt
+ struct timer_list timer; /* for timed interrupt */
volatile short timer_running;
- volatile short timer_mode; // true if using timer mode
+ volatile short timer_mode; /* true if using timer mode */
};
#define devpriv ((struct das16_private_struct *)(dev->private))
#define thisboard ((struct das16_board *)(dev->board_ptr))
tmp = cmd->scan_begin_src;
mask = TRIG_FOLLOW;
- // if board supports burst mode
+ /* if board supports burst mode */
if (thisboard->size > 0x400)
mask |= TRIG_TIMER | TRIG_EXT;
cmd->scan_begin_src &= mask;
tmp = cmd->convert_src;
mask = TRIG_TIMER | TRIG_EXT;
- // if board supports burst mode
+ /* if board supports burst mode */
if (thisboard->size > 0x400)
mask |= TRIG_NOW;
cmd->convert_src &= mask;
if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT)
err++;
- // make sure scan_begin_src and convert_src dont conflict
+ /* make sure scan_begin_src and convert_src dont conflict */
if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW)
err++;
if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_NOW)
cmd->scan_end_arg = cmd->chanlist_len;
err++;
}
- // check against maximum frequency
+ /* check against maximum frequency */
if (cmd->scan_begin_src == TRIG_TIMER) {
if (cmd->scan_begin_arg <
thisboard->ai_speed * cmd->chanlist_len) {
if (err)
return 3;
- // step 4: fix up arguments
+ /* step 4: fix up arguments */
if (cmd->scan_begin_src == TRIG_TIMER) {
unsigned int tmp = cmd->scan_begin_arg;
- // set divisors, correct timing arguments
+ /* set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
&(devpriv->divisor1), &(devpriv->divisor2),
&(cmd->scan_begin_arg), cmd->flags & TRIG_ROUND_MASK);
}
if (cmd->convert_src == TRIG_TIMER) {
unsigned int tmp = cmd->convert_arg;
- // set divisors, correct timing arguments
+ /* set divisors, correct timing arguments */
i8253_cascade_ns_to_timer_2div(devpriv->clockbase,
&(devpriv->divisor1), &(devpriv->divisor2),
&(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
if (err)
return 4;
- // check channel/gain list against card's limitations
+ /* check channel/gain list against card's limitations */
if (cmd->chanlist) {
gain = CR_RANGE(cmd->chanlist[0]);
start_chan = CR_CHAN(cmd->chanlist[0]);
devpriv->adc_byte_count =
cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t);
- // disable conversions for das1600 mode
+ /* disable conversions for das1600 mode */
if (thisboard->size > 0x400) {
outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV);
}
- // set scan limits
+ /* set scan limits */
byte = CR_CHAN(cmd->chanlist[0]);
byte |= CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]) << 4;
outb(byte, dev->iobase + DAS16_MUX);
if (thisboard->size > 0x400) {
if (cmd->convert_src == TRIG_NOW) {
outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST);
- // set burst length
+ /* set burst length */
byte |= BURST_LEN_BITS(cmd->chanlist_len - 1);
} else {
outb(0, dev->iobase + DAS1600_BURST);
}
outb(byte, dev->iobase + DAS16_PACER);
- // set up dma transfer
+ /* set up dma transfer */
flags = claim_dma_lock();
disable_dma(devpriv->dma_chan);
/* clear flip-flop to make sure 2-byte registers for
devpriv->current_buffer = 0;
set_dma_addr(devpriv->dma_chan,
devpriv->dma_buffer_addr[devpriv->current_buffer]);
- // set appropriate size of transfer
+ /* set appropriate size of transfer */
devpriv->dma_transfer_size = das16_suggest_transfer_size(dev, *cmd);
set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_chan);
release_dma_lock(flags);
- // set up interrupt
+ /* set up interrupt */
if (devpriv->timer_mode) {
devpriv->timer_running = 1;
devpriv->timer.expires = jiffies + timer_period();
if (devpriv->dma_chan)
disable_dma(devpriv->dma_chan);
- // disable SW timer
+ /* disable SW timer */
if (devpriv->timer_mode && devpriv->timer_running) {
devpriv->timer_running = 0;
del_timer(&devpriv->timer);
int chan;
int msb, lsb;
- // disable interrupts and pacing
+ /* disable interrupts and pacing */
devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK;
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
{
unsigned int wbits;
- // only set bits that have been masked
+ /* only set bits that have been masked */
data[0] &= 0xf;
wbits = s->state;
- // zero bits that have been masked
+ /* zero bits that have been masked */
wbits &= ~data[0];
- // set masked bits
+ /* set masked bits */
wbits |= data[0] & data[1];
s->state = wbits;
data[1] = wbits;
comedi_error(dev, "premature interrupt");
return;
}
- // initialize async here to make sure it is not NULL
+ /* initialize async here to make sure it is not NULL */
async = s->async;
cmd = &async->cmd;
clear_dma_ff(devpriv->dma_chan);
residue = disable_dma_on_even(dev);
- // figure out how many points to read
+ /* figure out how many points to read */
if (residue > devpriv->dma_transfer_size) {
comedi_error(dev, "residue > transfer size!\n");
async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
devpriv->current_buffer = (devpriv->current_buffer + 1) % 2;
devpriv->adc_byte_count -= num_bytes;
- // figure out how many bytes for next transfer
+ /* figure out how many bytes for next transfer */
if (cmd->stop_src == TRIG_COUNT && devpriv->timer_mode == 0 &&
devpriv->dma_transfer_size > devpriv->adc_byte_count)
devpriv->dma_transfer_size = devpriv->adc_byte_count;
- // re-enable dma
+ /* re-enable dma */
if ((async->events & COMEDI_CB_EOA) == 0) {
set_dma_addr(devpriv->dma_chan,
devpriv->dma_buffer_addr[devpriv->current_buffer]);
printk("comedi%d: das16:", dev->minor);
- // check that clock setting is valid
+ /* check that clock setting is valid */
if (it->options[3]) {
if (it->options[3] != 0 &&
it->options[3] != 1 && it->options[3] != 10) {
dev->iobase = iobase;
- // probe id bits to make sure they are consistent
+ /* probe id bits to make sure they are consistent */
if (das16_probe(dev, it)) {
printk(" id bits do not match selected board, aborting\n");
return -EINVAL;
}
dev->board_name = thisboard->name;
- // get master clock speed
+ /* get master clock speed */
if (thisboard->size < 0x400) {
if (it->options[3])
devpriv->clockbase = 1000 / it->options[3];
else
- devpriv->clockbase = 1000; // 1 MHz default
+ devpriv->clockbase = 1000; /* 1 MHz default */
} else {
das1600_mode_detect(dev);
}
return -EINVAL;
}
- // initialize dma
+ /* initialize dma */
dma_chan = it->options[2];
if (dma_chan == 1 || dma_chan == 3) {
- // allocate dma buffers
+ /* allocate dma buffers */
int i;
for (i = 0; i < 2; i++) {
devpriv->dma_buffer[i] = pci_alloc_consistent(NULL,
return -EINVAL;
}
- // get any user-defined input range
+ /* get any user-defined input range */
if (thisboard->ai_pg == das16_pg_none &&
(it->options[4] || it->options[5])) {
- // allocate single-range range table
+ /* allocate single-range range table */
devpriv->user_ai_range_table =
kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange),
GFP_KERNEL);
- // initialize ai range
+ /* initialize ai range */
devpriv->user_ai_range_table->length = 1;
user_ai_range = devpriv->user_ai_range_table->range;
user_ai_range->min = it->options[4];
user_ai_range->max = it->options[5];
user_ai_range->flags = UNIT_volt;
}
- // get any user-defined output range
+ /* get any user-defined output range */
if (it->options[6] || it->options[7]) {
- // allocate single-range range table
+ /* allocate single-range range table */
devpriv->user_ao_range_table =
kmalloc(sizeof(struct comedi_lrange) + sizeof(struct comedi_krange),
GFP_KERNEL);
- // initialize ao range
+ /* initialize ao range */
devpriv->user_ao_range_table->length = 1;
user_ao_range = devpriv->user_ao_range_table->range;
user_ao_range->min = it->options[6];
s->subdev_flags |= SDF_DIFF;
}
s->maxdata = (1 << thisboard->ai_nbits) - 1;
- if (devpriv->user_ai_range_table) { // user defined ai range
+ if (devpriv->user_ai_range_table) { /* user defined ai range */
s->range_table = devpriv->user_ai_range_table;
} else if (devpriv->ai_unipolar) {
s->range_table = das16_ai_uni_lranges[thisboard->ai_pg];
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 2;
s->maxdata = (1 << thisboard->ao_nbits) - 1;
- if (devpriv->user_ao_range_table) { // user defined ao range
+ if (devpriv->user_ao_range_table) { /* user defined ao range */
s->range_table = devpriv->user_ao_range_table;
} else {
s->range_table = &range_unknown;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = thisboard->do_;
- // initialize digital output lines
+ /* initialize digital output lines */
outb(s->state, dev->iobase + DAS16_DIO);
} else {
s->type = COMEDI_SUBD_UNUSED;
devpriv->control_state = DAS16_IRQ(dev->irq);
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
- // turn on das1600 mode if available
+ /* turn on das1600 mode if available */
if (thisboard->size > 0x400) {
outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE);
outb(0, dev->iobase + DAS1600_CONV);
COMEDI_INITCLEANUP(driver_das16);
-// utility function that suggests a dma transfer size in bytes
+/* utility function that suggests a dma transfer size in bytes */
static unsigned int das16_suggest_transfer_size(struct comedi_device * dev,
struct comedi_cmd cmd)
{
freq = 1000000000 / cmd.convert_arg;
else if (cmd.scan_begin_src == TRIG_TIMER)
freq = (1000000000 / cmd.scan_begin_arg) * cmd.chanlist_len;
- // return some default value
+ /* return some default value */
else
freq = 0xffffffff;
if (cmd.flags & TRIG_WAKE_EOS) {
size = sample_size * cmd.chanlist_len;
} else {
- // make buffer fill in no more than 1/3 second
+ /* make buffer fill in no more than 1/3 second */
size = (freq / 3) * sample_size;
}
- // set a minimum and maximum size allowed
+ /* set a minimum and maximum size allowed */
if (size > DAS16_DMA_SIZE)
size = DAS16_DMA_SIZE - DAS16_DMA_SIZE % sample_size;
else if (size < sample_size)