aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/pcl818.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/comedi/drivers/pcl818.c')
-rw-r--r--drivers/staging/comedi/drivers/pcl818.c578
1 files changed, 297 insertions, 281 deletions
diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c
index 43a9d56c6a4..039a77a6645 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -107,9 +107,9 @@ A word or two about DMA. Driver support DMA operations at two ways:
#include "8253.h"
-// #define PCL818_MODE13_AO 1
+/* #define PCL818_MODE13_AO 1 */
-// boards constants
+/* boards constants */
#define boardPCL818L 0
#define boardPCL818H 1
@@ -118,60 +118,60 @@ A word or two about DMA. Driver support DMA operations at two ways:
#define boardPCL818 4
#define boardPCL718 5
-// IO space len
+/* IO space len */
#define PCLx1x_RANGE 16
-// IO space len if we use FIFO
+/* IO space len if we use FIFO */
#define PCLx1xFIFO_RANGE 32
-// W: clear INT request
+/* W: clear INT request */
#define PCL818_CLRINT 8
-// R: return status byte
+/* R: return status byte */
#define PCL818_STATUS 8
-// R: A/D high byte W: A/D range control
+/* R: A/D high byte W: A/D range control */
#define PCL818_RANGE 1
-// R: next mux scan channel W: mux scan channel & range control pointer
+/* R: next mux scan channel W: mux scan channel & range control pointer */
#define PCL818_MUX 2
-// R/W: operation control register
+/* R/W: operation control register */
#define PCL818_CONTROL 9
-// W: counter enable
+/* W: counter enable */
#define PCL818_CNTENABLE 10
-// R: low byte of A/D W: soft A/D trigger
+/* R: low byte of A/D W: soft A/D trigger */
#define PCL818_AD_LO 0
-// R: high byte of A/D W: A/D range control
+/* R: high byte of A/D W: A/D range control */
#define PCL818_AD_HI 1
-// W: D/A low&high byte
+/* W: D/A low&high byte */
#define PCL818_DA_LO 4
#define PCL818_DA_HI 5
-// R: low&high byte of DI
+/* R: low&high byte of DI */
#define PCL818_DI_LO 3
#define PCL818_DI_HI 11
-// W: low&high byte of DO
+/* W: low&high byte of DO */
#define PCL818_DO_LO 3
#define PCL818_DO_HI 11
-// W: PCL718 second D/A
+/* W: PCL718 second D/A */
#define PCL718_DA2_LO 6
#define PCL718_DA2_HI 7
-// counters
+/* counters */
#define PCL818_CTR0 12
#define PCL818_CTR1 13
#define PCL818_CTR2 14
-// W: counter control
+/* W: counter control */
#define PCL818_CTRCTL 15
-// W: fifo enable/disable
+/* W: fifo enable/disable */
#define PCL818_FI_ENABLE 6
-// W: fifo interrupt clear
+/* W: fifo interrupt clear */
#define PCL818_FI_INTCLR 20
-// W: fifo interrupt clear
+/* W: fifo interrupt clear */
#define PCL818_FI_FLUSH 25
-// R: fifo status
+/* R: fifo status */
#define PCL818_FI_STATUS 25
-// R: one record from FIFO
+/* R: one record from FIFO */
#define PCL818_FI_DATALO 23
#define PCL818_FI_DATAHI 23
-// type of interrupt handler
+/* type of interrupt handler */
#define INT_TYPE_AI1_INT 1
#define INT_TYPE_AI1_DMA 2
#define INT_TYPE_AI1_FIFO 3
@@ -184,7 +184,7 @@ A word or two about DMA. Driver support DMA operations at two ways:
#endif
#ifdef unused
-// RTC stuff...
+/* RTC stuff... */
#define INT_TYPE_AI1_DMA_RTC 9
#define INT_TYPE_AI3_DMA_RTC 10
@@ -244,8 +244,8 @@ static const struct comedi_lrange range718_bipolar0_5 = { 1, {BIP_RANGE(0.5),} }
static const struct comedi_lrange range718_unipolar2 = { 1, {UNI_RANGE(2),} };
static const struct comedi_lrange range718_unipolar1 = { 1, {BIP_RANGE(1),} };
-static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * it);
-static int pcl818_detach(struct comedi_device * dev);
+static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcl818_detach(struct comedi_device *dev);
#ifdef unused
static int RTC_lock = 0; /* RTC lock */
@@ -254,22 +254,22 @@ static int RTC_timer_lock = 0; /* RTC int lock */
struct pcl818_board {
- const char *name; // driver name
- int n_ranges; // len of range list
- int n_aichan_se; // num of A/D chans in single ended mode
- int n_aichan_diff; // num of A/D chans in diferencial mode
- unsigned int ns_min; // minimal alllowed delay between samples (in ns)
- int n_aochan; // num of D/A chans
- int n_dichan; // num of DI chans
- int n_dochan; // num of DO chans
- const struct comedi_lrange *ai_range_type; // default A/D rangelist
- const struct comedi_lrange *ao_range_type; // default D/A rangelist
- unsigned int io_range; // len of IO space
- unsigned int IRQbits; // allowed interrupts
- unsigned int DMAbits; // allowed DMA chans
- int ai_maxdata; // maxdata for A/D
- int ao_maxdata; // maxdata for D/A
- unsigned char fifo; // 1=board has FIFO
+ const char *name; /* driver name */
+ int n_ranges; /* len of range list */
+ int n_aichan_se; /* num of A/D chans in single ended mode */
+ int n_aichan_diff; /* num of A/D chans in diferencial mode */
+ unsigned int ns_min; /* minimal alllowed delay between samples (in ns) */
+ int n_aochan; /* num of D/A chans */
+ int n_dichan; /* num of DI chans */
+ int n_dochan; /* num of DO chans */
+ const struct comedi_lrange *ai_range_type; /* default A/D rangelist */
+ const struct comedi_lrange *ao_range_type; /* default D/A rangelist */
+ unsigned int io_range; /* len of IO space */
+ unsigned int IRQbits; /* allowed interrupts */
+ unsigned int DMAbits; /* allowed DMA chans */
+ int ai_maxdata; /* maxdata for A/D */
+ int ao_maxdata; /* maxdata for D/A */
+ unsigned char fifo; /* 1=board has FIFO */
int is_818;
};
@@ -302,67 +302,67 @@ static const struct pcl818_board boardtypes[] = {
#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl818_board))
static struct comedi_driver driver_pcl818 = {
- driver_name:"pcl818",
- module:THIS_MODULE,
- attach:pcl818_attach,
- detach:pcl818_detach,
- board_name:&boardtypes[0].name,
- num_names:n_boardtypes,
- offset:sizeof(struct pcl818_board),
+ .driver_name = "pcl818",
+ .module = THIS_MODULE,
+ .attach = pcl818_attach,
+ .detach = pcl818_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = n_boardtypes,
+ .offset = sizeof(struct pcl818_board),
};
COMEDI_INITCLEANUP(driver_pcl818);
struct pcl818_private {
- unsigned int dma; // used DMA, 0=don't use DMA
- int dma_rtc; // 1=RTC used with DMA, 0=no RTC alloc
+ unsigned int dma; /* used DMA, 0=don't use DMA */
+ int dma_rtc; /* 1=RTC used with DMA, 0=no RTC alloc */
unsigned int io_range;
#ifdef unused
- unsigned long rtc_iobase; // RTC port region
+ unsigned long rtc_iobase; /* RTC port region */
unsigned int rtc_iosize;
unsigned int rtc_irq;
- struct timer_list rtc_irq_timer; // timer for RTC sanity check
- unsigned long rtc_freq; // RTC int freq
- int rtc_irq_blocked; // 1=we now do AI with DMA&RTC
+ struct timer_list rtc_irq_timer; /* timer for RTC sanity check */
+ unsigned long rtc_freq; /* RTC int freq */
+ int rtc_irq_blocked; /* 1=we now do AI with DMA&RTC */
#endif
- unsigned long dmabuf[2]; // pointers to begin of DMA buffers
- unsigned int dmapages[2]; // len of DMA buffers in PAGE_SIZEs
- unsigned int hwdmaptr[2]; // hardware address of DMA buffers
- unsigned int hwdmasize[2]; // len of DMA buffers in Bytes
- unsigned int dmasamplsize; // size in samples hwdmasize[0]/2
- unsigned int last_top_dma; // DMA pointer in last RTC int
- int next_dma_buf; // which DMA buffer will be used next round
- long dma_runs_to_end; // how many we must permorm DMA transfer to end of record
- unsigned long last_dma_run; // how many bytes we must transfer on last DMA page
- unsigned char neverending_ai; // if=1, then we do neverending record (you must use cancel())
- unsigned int ns_min; // manimal alllowed delay between samples (in us) for actual card
- int i8253_osc_base; // 1/frequency of on board oscilator in ns
- int irq_free; // 1=have allocated IRQ
- int irq_blocked; // 1=IRQ now uses any subdev
- int irq_was_now_closed; // when IRQ finish, there's stored int818_mode for last interrupt
- int ai_mode; // who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma
- struct comedi_subdevice *last_int_sub; // ptr to subdevice which now finish
- int ai_act_scan; // how many scans we finished
- int ai_act_chan; // actual position in actual scan
- unsigned int act_chanlist[16]; // MUX setting for actual AI operations
- unsigned int act_chanlist_len; // how long is actual MUX list
- unsigned int act_chanlist_pos; // actual position in MUX list
- unsigned int ai_scans; // len of scanlist
- unsigned int ai_n_chan; // how many channels is measured
- unsigned int *ai_chanlist; // actaul chanlist
- unsigned int ai_flags; // flaglist
- unsigned int ai_data_len; // len of data buffer
- short *ai_data; // data buffer
- unsigned int ai_timer1; // timers
+ unsigned long dmabuf[2]; /* pointers to begin of DMA buffers */
+ unsigned int dmapages[2]; /* len of DMA buffers in PAGE_SIZEs */
+ unsigned int hwdmaptr[2]; /* hardware address of DMA buffers */
+ unsigned int hwdmasize[2]; /* len of DMA buffers in Bytes */
+ unsigned int dmasamplsize; /* size in samples hwdmasize[0]/2 */
+ unsigned int last_top_dma; /* DMA pointer in last RTC int */
+ int next_dma_buf; /* which DMA buffer will be used next round */
+ long dma_runs_to_end; /* how many we must permorm DMA transfer to end of record */
+ unsigned long last_dma_run; /* how many bytes we must transfer on last DMA page */
+ unsigned char neverending_ai; /* if=1, then we do neverending record (you must use cancel()) */
+ unsigned int ns_min; /* manimal alllowed delay between samples (in us) for actual card */
+ int i8253_osc_base; /* 1/frequency of on board oscilator in ns */
+ int irq_free; /* 1=have allocated IRQ */
+ int irq_blocked; /* 1=IRQ now uses any subdev */
+ int irq_was_now_closed; /* when IRQ finish, there's stored int818_mode for last interrupt */
+ int ai_mode; /* who now uses IRQ - 1=AI1 int, 2=AI1 dma, 3=AI3 int, 4AI3 dma */
+ struct comedi_subdevice *last_int_sub; /* ptr to subdevice which now finish */
+ int ai_act_scan; /* how many scans we finished */
+ int ai_act_chan; /* actual position in actual scan */
+ unsigned int act_chanlist[16]; /* MUX setting for actual AI operations */
+ unsigned int act_chanlist_len; /* how long is actual MUX list */
+ unsigned int act_chanlist_pos; /* actual position in MUX list */
+ unsigned int ai_scans; /* len of scanlist */
+ unsigned int ai_n_chan; /* how many channels is measured */
+ unsigned int *ai_chanlist; /* actaul chanlist */
+ unsigned int ai_flags; /* flaglist */
+ unsigned int ai_data_len; /* len of data buffer */
+ short *ai_data; /* data buffer */
+ unsigned int ai_timer1; /* timers */
unsigned int ai_timer2;
- struct comedi_subdevice *sub_ai; // ptr to AI subdevice
- unsigned char usefifo; // 1=use fifo
+ struct comedi_subdevice *sub_ai; /* ptr to AI subdevice */
+ unsigned char usefifo; /* 1=use fifo */
unsigned int ao_readback[2];
};
-static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // used for gain list programming
+static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, /* used for gain list programming */
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
};
@@ -372,13 +372,13 @@ static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0
/*
==============================================================================
*/
-static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan, unsigned int seglen);
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan);
-static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s);
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2);
#ifdef unused
@@ -391,8 +391,8 @@ static int rtc_setfreq_irq(int freq);
==============================================================================
ANALOG INPUT MODE0, 818 cards, slow version
*/
-static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int timeout;
@@ -418,7 +418,7 @@ static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
while (timeout--) {
if (inb(dev->iobase + PCL818_STATUS) & 0x10)
goto conv_finish;
- comedi_udelay(1);
+ udelay(1);
}
comedi_error(dev, "A/D insn timeout");
/* clear INT (conversion end) flag */
@@ -438,8 +438,8 @@ static int pcl818_ai_insn_read(struct comedi_device * dev, struct comedi_subdevi
ANALOG OUTPUT MODE0, 818 cards
only one sample per call is supported
*/
-static int pcl818_ao_insn_read(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -451,8 +451,8 @@ static int pcl818_ao_insn_read(struct comedi_device * dev, struct comedi_subdevi
return n;
}
-static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int chan = CR_CHAN(insn->chanspec);
@@ -460,9 +460,9 @@ static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
for (n = 0; n < insn->n; n++) {
devpriv->ao_readback[chan] = data[n];
outb((data[n] & 0x000f) << 4, dev->iobase +
- (chan) ? PCL718_DA2_LO : PCL818_DA_LO);
+ (chan ? PCL718_DA2_LO : PCL818_DA_LO));
outb((data[n] & 0x0ff0) >> 4, dev->iobase +
- (chan) ? PCL718_DA2_HI : PCL818_DA_HI);
+ (chan ? PCL718_DA2_HI : PCL818_DA_HI));
}
return n;
@@ -474,8 +474,8 @@ static int pcl818_ao_insn_write(struct comedi_device * dev, struct comedi_subdev
only one sample per call is supported
*/
-static int pcl818_di_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -492,8 +492,8 @@ static int pcl818_di_insn_bits(struct comedi_device * dev, struct comedi_subdevi
only one sample per call is supported
*/
-static int pcl818_do_insn_bits(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_insn * insn, unsigned int * data)
+static int pcl818_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
if (insn->n != 2)
return -EINVAL;
@@ -524,7 +524,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
while (timeout--) {
if (inb(dev->iobase + PCL818_STATUS) & 0x10)
goto conv_finish;
- comedi_udelay(1);
+ udelay(1);
}
outb(0, dev->iobase + PCL818_STATUS); /* clear INT request */
comedi_error(dev, "A/D mode1/3 IRQ without DRDY!");
@@ -535,11 +535,11 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
conv_finish:
low = inb(dev->iobase + PCL818_AD_LO);
- comedi_buf_put(s->async, ((inb(dev->iobase + PCL818_AD_HI) << 4) | (low >> 4))); // get one sample
+ comedi_buf_put(s->async, ((inb(dev->iobase + PCL818_AD_HI) << 4) | (low >> 4))); /* get one sample */
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
- if ((low & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((low & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 IRQ - channel dropout %x!=%x !\n",
(low & 0xf),
devpriv->act_chanlist[devpriv->act_chanlist_pos]);
@@ -549,7 +549,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_int(int irq, void *d)
return IRQ_HANDLED;
}
if (s->async->cur_chan == 0) {
- // rt_printk("E");
+ /* printk("E"); */
devpriv->ai_act_scan--;
}
@@ -577,7 +577,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
disable_dma(devpriv->dma);
devpriv->next_dma_buf = 1 - devpriv->next_dma_buf;
- if ((devpriv->dma_runs_to_end) > -1 || devpriv->neverending_ai) { // switch dma bufs
+ if ((devpriv->dma_runs_to_end) > -1 || devpriv->neverending_ai) { /* switch dma bufs */
set_dma_mode(devpriv->dma, DMA_MODE_READ);
flags = claim_dma_lock();
set_dma_addr(devpriv->dma,
@@ -591,7 +591,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
release_dma_lock(flags);
enable_dma(devpriv->dma);
}
- rt_printk("comedi: A/D mode1/3 IRQ \n");
+ printk("comedi: A/D mode1/3 IRQ \n");
devpriv->dma_runs_to_end--;
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
@@ -601,8 +601,8 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
bufptr = 0;
for (i = 0; i < len; i++) {
- if ((ptr[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((ptr[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 DMA - channel dropout %d(card)!=%d(chanlist) at %d !\n",
(ptr[bufptr] & 0xf),
devpriv->act_chanlist[devpriv->
@@ -614,7 +614,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
return IRQ_HANDLED;
}
- comedi_buf_put(s->async, ptr[bufptr++] >> 4); // get one sample
+ comedi_buf_put(s->async, ptr[bufptr++] >> 4); /* get one sample */
devpriv->act_chanlist_pos++;
if (devpriv->act_chanlist_pos >= devpriv->act_chanlist_len) {
@@ -627,7 +627,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma(int irq, void *d)
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
- // printk("done int ai13 dma\n");
+ /* printk("done int ai13 dma\n"); */
return IRQ_HANDLED;
}
}
@@ -651,7 +651,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
long ofs_dats;
short *dmabuf = (short *) devpriv->dmabuf[0];
- //outb(2,0x378);
+ /* outb(2,0x378); */
switch (devpriv->ai_mode) {
case INT_TYPE_AI1_DMA_RTC:
case INT_TYPE_AI3_DMA_RTC:
@@ -668,32 +668,32 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
if (top1 != top2)
return IRQ_HANDLED;
- top1 = devpriv->hwdmasize[0] - top1; // where is now DMA in buffer
+ top1 = devpriv->hwdmasize[0] - top1; /* where is now DMA in buffer */
top1 >>= 1;
- ofs_dats = top1 - devpriv->last_top_dma; // new samples from last call
+ ofs_dats = top1 - devpriv->last_top_dma; /* new samples from last call */
if (ofs_dats < 0)
ofs_dats = (devpriv->dmasamplsize) + ofs_dats;
if (!ofs_dats)
- return IRQ_HANDLED; // exit=no new samples from last call
- // obsluz data
+ return IRQ_HANDLED; /* exit=no new samples from last call */
+ /* obsluz data */
i = devpriv->last_top_dma - 1;
i &= (devpriv->dmasamplsize - 1);
- if (dmabuf[i] != MAGIC_DMA_WORD) { // DMA overflow!
+ if (dmabuf[i] != MAGIC_DMA_WORD) { /* DMA overflow! */
comedi_error(dev, "A/D mode1/3 DMA buffer overflow!");
- //rt_printk("I %d dmabuf[i] %d %d\n",i,dmabuf[i],devpriv->dmasamplsize);
+ /* printk("I %d dmabuf[i] %d %d\n",i,dmabuf[i],devpriv->dmasamplsize); */
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
comedi_event(dev, s);
return IRQ_HANDLED;
}
- //rt_printk("r %ld ",ofs_dats);
+ /* printk("r %ld ",ofs_dats); */
bufptr = devpriv->last_top_dma;
for (i = 0; i < ofs_dats; i++) {
- if ((dmabuf[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((dmabuf[bufptr] & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 DMA - channel dropout %d!=%d !\n",
(dmabuf[bufptr] & 0xf),
devpriv->act_chanlist[devpriv->
@@ -705,7 +705,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
return IRQ_HANDLED;
}
- comedi_buf_put(s->async, dmabuf[bufptr++] >> 4); // get one sample
+ comedi_buf_put(s->async, dmabuf[bufptr++] >> 4); /* get one sample */
bufptr &= (devpriv->dmasamplsize - 1);
if (s->async->cur_chan == 0) {
@@ -717,7 +717,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
pcl818_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
- //printk("done int ai13 dma\n");
+ /* printk("done int ai13 dma\n"); */
return IRQ_HANDLED;
}
}
@@ -727,11 +727,11 @@ static irqreturn_t interrupt_pcl818_ai_mode13_dma_rtc(int irq, void *d)
bufptr &= (devpriv->dmasamplsize - 1);
dmabuf[bufptr] = MAGIC_DMA_WORD;
comedi_event(dev, s);
- //outb(0,0x378);
+ /* outb(0,0x378); */
return IRQ_HANDLED;
}
- //outb(0,0x378);
+ /* outb(0,0x378); */
return IRQ_HANDLED;
}
#endif
@@ -746,7 +746,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
struct comedi_subdevice *s = dev->subdevices + 0;
int i, len, lo;
- outb(0, dev->iobase + PCL818_FI_INTCLR); // clear fifo int request
+ outb(0, dev->iobase + PCL818_FI_INTCLR); /* clear fifo int request */
lo = inb(dev->iobase + PCL818_FI_STATUS);
@@ -774,8 +774,8 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
for (i = 0; i < len; i++) {
lo = inb(dev->iobase + PCL818_FI_DATALO);
- if ((lo & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { // dropout!
- rt_printk
+ if ((lo & 0xf) != devpriv->act_chanlist[devpriv->act_chanlist_pos]) { /* dropout! */
+ printk
("comedi: A/D mode1/3 FIFO - channel dropout %d!=%d !\n",
(lo & 0xf),
devpriv->act_chanlist[devpriv->
@@ -786,7 +786,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
return IRQ_HANDLED;
}
- comedi_buf_put(s->async, (lo >> 4) | (inb(dev->iobase + PCL818_FI_DATAHI) << 4)); // get one sample
+ comedi_buf_put(s->async, (lo >> 4) | (inb(dev->iobase + PCL818_FI_DATAHI) << 4)); /* get one sample */
if (s->async->cur_chan == 0) {
devpriv->ai_act_scan--;
@@ -810,7 +810,7 @@ static irqreturn_t interrupt_pcl818_ai_mode13_fifo(int irq, void *d)
==============================================================================
INT procedure
*/
-static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
+static irqreturn_t interrupt_pcl818(int irq, void *d)
{
struct comedi_device *dev = d;
@@ -818,7 +818,28 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
comedi_error(dev, "premature interrupt");
return IRQ_HANDLED;
}
- //rt_printk("I\n");
+ /* printk("I\n"); */
+
+ if (devpriv->irq_blocked && devpriv->irq_was_now_closed) {
+ if ((devpriv->neverending_ai || (!devpriv->neverending_ai &&
+ devpriv->ai_act_scan > 0)) &&
+ (devpriv->ai_mode == INT_TYPE_AI1_DMA ||
+ devpriv->ai_mode == INT_TYPE_AI3_DMA)) {
+ /* The cleanup from ai_cancel() has been delayed
+ until now because the card doesn't seem to like
+ being reprogrammed while a DMA transfer is in
+ progress.
+ */
+ struct comedi_subdevice *s = dev->subdevices + 0;
+ devpriv->ai_act_scan = 0;
+ devpriv->neverending_ai = 0;
+ pcl818_ai_cancel(dev, s);
+ }
+
+ outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
+
+ return IRQ_HANDLED;
+ }
switch (devpriv->ai_mode) {
case INT_TYPE_AI1_DMA:
@@ -843,25 +864,6 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
if ((!dev->irq) || (!devpriv->irq_free) || (!devpriv->irq_blocked)
|| (!devpriv->ai_mode)) {
- if (devpriv->irq_was_now_closed) {
- if (devpriv->neverending_ai &&
- (devpriv->ai_mode == INT_TYPE_AI1_DMA
- || devpriv->ai_mode ==
- INT_TYPE_AI3_DMA)) {
- /* we had neverending ai but ai_cancel() has been called
- the cleanup from ai_cancel() has been delayed until know
- because the card doesn't seem to like being reprogrammed
- while a DMA transfer is in progress
- */
- struct comedi_subdevice *s = dev->subdevices + 0;
- devpriv->ai_mode = devpriv->irq_was_now_closed;
- devpriv->irq_was_now_closed = 0;
- devpriv->neverending_ai = 0;
- pcl818_ai_cancel(dev, s);
- }
- devpriv->irq_was_now_closed = 0;
- return IRQ_HANDLED;
- }
comedi_error(dev, "bad IRQ!");
return IRQ_NONE;
}
@@ -874,19 +876,19 @@ static irqreturn_t interrupt_pcl818(int irq, void *d PT_REGS_ARG)
==============================================================================
ANALOG INPUT MODE 1 or 3 DMA , 818 cards
*/
-static void pcl818_ai_mode13dma_int(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void pcl818_ai_mode13dma_int(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned int flags;
unsigned int bytes;
- rt_printk("mode13dma_int, mode: %d\n", mode);
- disable_dma(devpriv->dma); // disable dma
+ printk("mode13dma_int, mode: %d\n", mode);
+ disable_dma(devpriv->dma); /* disable dma */
bytes = devpriv->hwdmasize[0];
if (!devpriv->neverending_ai) {
- bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); // how many
- devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; // how many DMA pages we must fiil
- devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; //on last dma transfer must be moved
+ bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); /* how many */
+ devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fiil */
+ devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */
devpriv->dma_runs_to_end--;
if (devpriv->dma_runs_to_end >= 0)
bytes = devpriv->hwdmasize[0];
@@ -915,8 +917,8 @@ static void pcl818_ai_mode13dma_int(int mode, struct comedi_device * dev,
==============================================================================
ANALOG INPUT MODE 1 or 3 DMA rtc, 818 cards
*/
-static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned int flags;
short *pole;
@@ -928,7 +930,7 @@ static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev,
set_dma_count(devpriv->dma, devpriv->hwdmasize[0]);
release_dma_lock(flags);
enable_dma(devpriv->dma);
- devpriv->last_top_dma = 0; //devpriv->hwdmasize[0];
+ devpriv->last_top_dma = 0; /* devpriv->hwdmasize[0]; */
pole = (short *) devpriv->dmabuf[0];
devpriv->dmasamplsize = devpriv->hwdmasize[0] / 2;
pole[devpriv->dmasamplsize - 1] = MAGIC_DMA_WORD;
@@ -956,14 +958,14 @@ static void pcl818_ai_mode13dma_rtc(int mode, struct comedi_device * dev,
==============================================================================
ANALOG INPUT MODE 1 or 3, 818 cards
*/
-static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
- struct comedi_subdevice * s)
+static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int divisor1, divisor2;
unsigned int seglen;
- rt_printk("pcl818_ai_cmd_mode()\n");
+ printk("pcl818_ai_cmd_mode()\n");
if ((!dev->irq) && (!devpriv->dma_rtc)) {
comedi_error(dev, "IRQ not defined!");
return -EINVAL;
@@ -972,7 +974,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
if (devpriv->irq_blocked)
return -EBUSY;
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
devpriv->ai_n_chan);
@@ -981,7 +983,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
setup_channel_list(dev, s, devpriv->ai_chanlist,
devpriv->ai_n_chan, seglen);
- comedi_udelay(1);
+ udelay(1);
devpriv->ai_act_scan = devpriv->ai_scans;
devpriv->ai_act_chan = 0;
@@ -992,7 +994,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
devpriv->dma_runs_to_end = 0;
if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1))
- devpriv->neverending_ai = 1; //well, user want neverending
+ devpriv->neverending_ai = 1; /* well, user want neverending */
if (mode == 1) {
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
@@ -1010,7 +1012,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
outb(0, dev->iobase + PCL818_CNTENABLE); /* enable pacer */
switch (devpriv->dma) {
- case 1: // DMA
+ case 1: /* DMA */
case 3:
if (devpriv->dma_rtc == 0) {
pcl818_ai_mode13dma_int(mode, dev, s);
@@ -1025,26 +1027,32 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
}
#endif
break;
- case 0: // IRQ
- // rt_printk("IRQ\n");
- if (mode == 1) {
- devpriv->ai_mode = INT_TYPE_AI1_INT;
- outb(0x83 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); /* Pacer+IRQ */
- } else {
- devpriv->ai_mode = INT_TYPE_AI3_INT;
- outb(0x82 | (dev->irq << 4), dev->iobase + PCL818_CONTROL); /* Ext trig+IRQ */
- };
- break;
- case -1: // FIFO
- outb(1, dev->iobase + PCL818_FI_ENABLE); // enable FIFO
- if (mode == 1) {
- devpriv->ai_mode = INT_TYPE_AI1_FIFO;
- outb(0x03, dev->iobase + PCL818_CONTROL); /* Pacer */
+ case 0:
+ if (!devpriv->usefifo) {
+ /* IRQ */
+ /* printk("IRQ\n"); */
+ if (mode == 1) {
+ devpriv->ai_mode = INT_TYPE_AI1_INT;
+ /* Pacer+IRQ */
+ outb(0x83 | (dev->irq << 4), dev->iobase + PCL818_CONTROL);
+ } else {
+ devpriv->ai_mode = INT_TYPE_AI3_INT;
+ /* Ext trig+IRQ */
+ outb(0x82 | (dev->irq << 4), dev->iobase + PCL818_CONTROL);
+ }
} else {
- devpriv->ai_mode = INT_TYPE_AI3_FIFO;
- outb(0x02, dev->iobase + PCL818_CONTROL);
- }; /* Ext trig */
- break;
+ /* FIFO */
+ /* enable FIFO */
+ outb(1, dev->iobase + PCL818_FI_ENABLE);
+ if (mode == 1) {
+ devpriv->ai_mode = INT_TYPE_AI1_FIFO;
+ /* Pacer */
+ outb(0x03, dev->iobase + PCL818_CONTROL);
+ } else {
+ devpriv->ai_mode = INT_TYPE_AI3_FIFO;
+ outb(0x02, dev->iobase + PCL818_CONTROL);
+ }
+ }
}
start_pacer(dev, mode, divisor1, divisor2);
@@ -1057,7 +1065,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
break;
}
#endif
- rt_printk("pcl818_ai_cmd_mode() end\n");
+ printk("pcl818_ai_cmd_mode() end\n");
return 0;
}
@@ -1067,8 +1075,8 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device * dev,
ANALOG OUTPUT MODE 1 or 3, 818 cards
*/
#ifdef PCL818_MODE13_AO
-static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_subdevice * s,
- comedi_trig * it)
+static int pcl818_ao_mode13(int mode, struct comedi_device *dev, struct comedi_subdevice *s,
+ comedi_trig *it)
{
int divisor1, divisor2;
@@ -1080,7 +1088,7 @@ static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_
if (devpriv->irq_blocked)
return -EBUSY;
- start_pacer(dev, -1, 0, 0); // stop pacer
+ start_pacer(dev, -1, 0, 0); /* stop pacer */
devpriv->int13_act_scan = it->n;
devpriv->int13_act_chan = 0;
@@ -1120,8 +1128,8 @@ static int pcl818_ao_mode13(int mode, struct comedi_device * dev, struct comedi_
==============================================================================
ANALOG OUTPUT MODE 1, 818 cards
*/
-static int pcl818_ao_mode1(struct comedi_device * dev, struct comedi_subdevice * s,
- comedi_trig * it)
+static int pcl818_ao_mode1(struct comedi_device *dev, struct comedi_subdevice *s,
+ comedi_trig *it)
{
return pcl818_ao_mode13(1, dev, s, it);
}
@@ -1130,8 +1138,8 @@ static int pcl818_ao_mode1(struct comedi_device * dev, struct comedi_subdevice *
==============================================================================
ANALOG OUTPUT MODE 3, 818 cards
*/
-static int pcl818_ao_mode3(struct comedi_device * dev, struct comedi_subdevice * s,
- comedi_trig * it)
+static int pcl818_ao_mode3(struct comedi_device *dev, struct comedi_subdevice *s,
+ comedi_trig *it)
{
return pcl818_ao_mode13(3, dev, s, it);
}
@@ -1142,12 +1150,12 @@ static int pcl818_ao_mode3(struct comedi_device * dev, struct comedi_subdevice *
==============================================================================
Start/stop pacer onboard pacer
*/
-static void start_pacer(struct comedi_device * dev, int mode, unsigned int divisor1,
+static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
unsigned int divisor2)
{
outb(0xb4, dev->iobase + PCL818_CTRCTL);
outb(0x74, dev->iobase + PCL818_CTRCTL);
- comedi_udelay(1);
+ udelay(1);
if (mode == 1) {
outb(divisor2 & 0xff, dev->iobase + PCL818_CTR2);
@@ -1162,7 +1170,7 @@ static void start_pacer(struct comedi_device * dev, int mode, unsigned int divis
Check if channel list from user is builded correctly
If it's ok, then program scan/gain logic
*/
-static int check_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan)
{
unsigned int chansegment[16];
@@ -1175,32 +1183,36 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
}
if (n_chan > 1) {
- // first channel is everytime ok
+ /* first channel is everytime ok */
chansegment[0] = chanlist[0];
- // build part of chanlist
+ /* build part of chanlist */
for (i = 1, seglen = 1; i < n_chan; i++, seglen++) {
- // rt_printk("%d. %d %d\n",i,CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i]));
- // we detect loop, this must by finish
+
+ /* printk("%d. %d * %d\n",i,
+ * CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i]));*/
+
+ /* we detect loop, this must by finish */
+
if (chanlist[0] == chanlist[i])
break;
nowmustbechan =
(CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
- if (nowmustbechan != CR_CHAN(chanlist[i])) { // channel list isn't continous :-(
- rt_printk
+ if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continous :-( */
+ printk
("comedi%d: pcl818: channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n",
dev->minor, i, CR_CHAN(chanlist[i]),
nowmustbechan, CR_CHAN(chanlist[0]));
return 0;
}
- // well, this is next correct channel in list
+ /* well, this is next correct channel in list */
chansegment[i] = chanlist[i];
}
- // check whole chanlist
+ /* check whole chanlist */
for (i = 0, segpos = 0; i < n_chan; i++) {
- //rt_printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i]));
+ /* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(it->chanlist[i]),CR_RANGE(it->chanlist[i])); */
if (chanlist[i] != chansegment[i % seglen]) {
- rt_printk
+ printk
("comedi%d: pcl818: bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
dev->minor, i, CR_CHAN(chansegment[i]),
CR_RANGE(chansegment[i]),
@@ -1208,17 +1220,17 @@ static int check_channel_list(struct comedi_device * dev, struct comedi_subdevic
CR_CHAN(chanlist[i % seglen]),
CR_RANGE(chanlist[i % seglen]),
CR_AREF(chansegment[i % seglen]));
- return 0; // chan/gain list is strange
+ return 0; /* chan/gain list is strange */
}
}
} else {
seglen = 1;
}
- rt_printk("check_channel_list: seglen %d\n", seglen);
+ printk("check_channel_list: seglen %d\n", seglen);
return seglen;
}
-static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevice * s,
+static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned int *chanlist, unsigned int n_chan, unsigned int seglen)
{
int i;
@@ -1226,13 +1238,13 @@ static void setup_channel_list(struct comedi_device * dev, struct comedi_subdevi
devpriv->act_chanlist_len = seglen;
devpriv->act_chanlist_pos = 0;
- for (i = 0; i < seglen; i++) { // store range list to card
+ for (i = 0; i < seglen; i++) { /* store range list to card */
devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]);
outb(muxonechan[CR_CHAN(chanlist[i])], dev->iobase + PCL818_MUX); /* select channel */
outb(CR_RANGE(chanlist[i]), dev->iobase + PCL818_RANGE); /* select gain */
}
- comedi_udelay(1);
+ udelay(1);
/* select channel interval to scan */
outb(devpriv->act_chanlist[0] | (devpriv->act_chanlist[seglen -
@@ -1255,8 +1267,8 @@ static int check_single_ended(unsigned int port)
/*
==============================================================================
*/
-static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
- struct comedi_cmd * cmd)
+static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_cmd *cmd)
{
int err = 0;
int tmp, divisor1, divisor2;
@@ -1391,7 +1403,7 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
if (cmd->chanlist) {
if (!check_channel_list(dev, s, cmd->chanlist,
cmd->chanlist_len))
- return 5; // incorrect channels list
+ return 5; /* incorrect channels list */
}
return 0;
@@ -1400,12 +1412,12 @@ static int ai_cmdtest(struct comedi_device * dev, struct comedi_subdevice * s,
/*
==============================================================================
*/
-static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
+static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct comedi_cmd *cmd = &s->async->cmd;
int retval;
- rt_printk("pcl818_ai_cmd()\n");
+ printk("pcl818_ai_cmd()\n");
devpriv->ai_n_chan = cmd->chanlist_len;
devpriv->ai_chanlist = cmd->chanlist;
devpriv->ai_flags = cmd->flags;
@@ -1420,14 +1432,14 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
devpriv->ai_scans = 0;
}
- if (cmd->scan_begin_src == TRIG_FOLLOW) { // mode 1, 3
- if (cmd->convert_src == TRIG_TIMER) { // mode 1
+ if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 3 */
+ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 */
devpriv->ai_timer1 = cmd->convert_arg;
retval = pcl818_ai_cmd_mode(1, dev, s);
- rt_printk("pcl818_ai_cmd() end\n");
+ printk("pcl818_ai_cmd() end\n");
return retval;
}
- if (cmd->convert_src == TRIG_EXT) { // mode 3
+ if (cmd->convert_src == TRIG_EXT) { /* mode 3 */
return pcl818_ai_cmd_mode(3, dev, s);
}
}
@@ -1439,23 +1451,24 @@ static int ai_cmd(struct comedi_device * dev, struct comedi_subdevice * s)
==============================================================================
cancel any mode 1-4 AI
*/
-static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice * s)
+static int pcl818_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
if (devpriv->irq_blocked > 0) {
- rt_printk("pcl818_ai_cancel()\n");
- devpriv->irq_was_now_closed = devpriv->ai_mode;
- devpriv->ai_mode = 0;
+ printk("pcl818_ai_cancel()\n");
+ devpriv->irq_was_now_closed = 1;
- switch (devpriv->irq_was_now_closed) {
+ switch (devpriv->ai_mode) {
#ifdef unused
case INT_TYPE_AI1_DMA_RTC:
case INT_TYPE_AI3_DMA_RTC:
- set_rtc_irq_bit(0); // stop RTC
+ set_rtc_irq_bit(0); /* stop RTC */
del_timer(&devpriv->rtc_irq_timer);
#endif
case INT_TYPE_AI1_DMA:
case INT_TYPE_AI3_DMA:
- if (devpriv->neverending_ai) {
+ if (devpriv->neverending_ai ||
+ (!devpriv->neverending_ai &&
+ devpriv->ai_act_scan > 0)) {
/* wait for running dma transfer to end, do cleanup in interrupt */
goto end;
}
@@ -1469,14 +1482,14 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
case INT_TYPE_AO3_INT:
#endif
outb(inb(dev->iobase + PCL818_CONTROL) & 0x73, dev->iobase + PCL818_CONTROL); /* Stop A/D */
- comedi_udelay(1);
+ udelay(1);
start_pacer(dev, -1, 0, 0);
outb(0, dev->iobase + PCL818_AD_LO);
inb(dev->iobase + PCL818_AD_LO);
inb(dev->iobase + PCL818_AD_HI);
outb(0, dev->iobase + PCL818_CLRINT); /* clear INT request */
outb(0, dev->iobase + PCL818_CONTROL); /* Stop A/D */
- if (devpriv->usefifo) { // FIFO shutdown
+ if (devpriv->usefifo) { /* FIFO shutdown */
outb(0, dev->iobase + PCL818_FI_INTCLR);
outb(0, dev->iobase + PCL818_FI_FLUSH);
outb(0, dev->iobase + PCL818_FI_ENABLE);
@@ -1484,12 +1497,14 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
devpriv->irq_blocked = 0;
devpriv->last_int_sub = s;
devpriv->neverending_ai = 0;
+ devpriv->ai_mode = 0;
+ devpriv->irq_was_now_closed = 0;
break;
}
}
end:
- rt_printk("pcl818_ai_cancel() end\n");
+ printk("pcl818_ai_cancel() end\n");
return 0;
}
@@ -1500,39 +1515,39 @@ static int pcl818_ai_cancel(struct comedi_device * dev, struct comedi_subdevice
static int pcl818_check(unsigned long iobase)
{
outb(0x00, iobase + PCL818_MUX);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL818_MUX) != 0x00)
- return 1; //there isn't card
+ return 1; /* there isn't card */
outb(0x55, iobase + PCL818_MUX);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL818_MUX) != 0x55)
- return 1; //there isn't card
+ return 1; /* there isn't card */
outb(0x00, iobase + PCL818_MUX);
- comedi_udelay(1);
+ udelay(1);
outb(0x18, iobase + PCL818_CONTROL);
- comedi_udelay(1);
+ udelay(1);
if (inb(iobase + PCL818_CONTROL) != 0x18)
- return 1; //there isn't card
- return 0; // ok, card exist
+ return 1; /* there isn't card */
+ return 0; /* ok, card exist */
}
/*
==============================================================================
reset whole PCL-818 cards
*/
-static void pcl818_reset(struct comedi_device * dev)
+static void pcl818_reset(struct comedi_device *dev)
{
- if (devpriv->usefifo) { // FIFO shutdown
+ if (devpriv->usefifo) { /* FIFO shutdown */
outb(0, dev->iobase + PCL818_FI_INTCLR);
outb(0, dev->iobase + PCL818_FI_FLUSH);
outb(0, dev->iobase + PCL818_FI_ENABLE);
}
- outb(0, dev->iobase + PCL818_DA_LO); // DAC=0V
+ outb(0, dev->iobase + PCL818_DA_LO); /* DAC=0V */
outb(0, dev->iobase + PCL818_DA_HI);
- comedi_udelay(1);
- outb(0, dev->iobase + PCL818_DO_HI); // DO=$0000
+ udelay(1);
+ outb(0, dev->iobase + PCL818_DO_HI); /* DO=$0000 */
outb(0, dev->iobase + PCL818_DO_LO);
- comedi_udelay(1);
+ udelay(1);
outb(0, dev->iobase + PCL818_CONTROL);
outb(0, dev->iobase + PCL818_CNTENABLE);
outb(0, dev->iobase + PCL818_MUX);
@@ -1641,9 +1656,9 @@ static int rtc_setfreq_irq(int freq)
==============================================================================
Free any resources that we have claimed
*/
-static void free_resources(struct comedi_device * dev)
+static void free_resources(struct comedi_device *dev)
{
- //rt_printk("free_resource()\n");
+ /* printk("free_resource()\n"); */
if (dev->private) {
pcl818_ai_cancel(dev, devpriv->sub_ai);
pcl818_reset(dev);
@@ -1655,7 +1670,7 @@ static void free_resources(struct comedi_device * dev)
free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
#ifdef unused
if (devpriv->rtc_irq)
- comedi_free_irq(devpriv->rtc_irq, dev);
+ free_irq(devpriv->rtc_irq, dev);
if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
if (devpriv->rtc_iobase)
release_region(devpriv->rtc_iobase,
@@ -1670,7 +1685,7 @@ static void free_resources(struct comedi_device * dev)
free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, devpriv->io_range);
- //rt_printk("free_resource() end\n");
+ /* printk("free_resource() end\n"); */
}
/*
@@ -1679,15 +1694,17 @@ static void free_resources(struct comedi_device * dev)
Initialization
*/
-static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * it)
+static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
unsigned long iobase;
- unsigned int irq, dma;
+ unsigned int irq;
+ int dma;
unsigned long pages;
struct comedi_subdevice *s;
- if ((ret = alloc_private(dev, sizeof(struct pcl818_private))) < 0)
+ ret = alloc_private(dev, sizeof(struct pcl818_private));
+ if (ret < 0)
return ret; /* Can't alloc mem */
/* claim our I/O space */
@@ -1695,19 +1712,19 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
printk("comedi%d: pcl818: board=%s, ioport=0x%03lx",
dev->minor, this_board->name, iobase);
devpriv->io_range = this_board->io_range;
- if ((this_board->fifo) && (it->options[2] == -1)) { // we've board with FIFO and we want to use FIFO
+ if ((this_board->fifo) && (it->options[2] == -1)) { /* we've board with FIFO and we want to use FIFO */
devpriv->io_range = PCLx1xFIFO_RANGE;
devpriv->usefifo = 1;
}
if (!request_region(iobase, devpriv->io_range, "pcl818")) {
- rt_printk("I/O port conflict\n");
+ printk("I/O port conflict\n");
return -EIO;
}
dev->iobase = iobase;
if (pcl818_check(iobase)) {
- rt_printk(", I can't detect board. FAIL!\n");
+ printk(", I can't detect board. FAIL!\n");
return -EIO;
}
@@ -1719,19 +1736,18 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
irq = it->options[1];
if (irq) { /* we want to use IRQ */
if (((1 << irq) & this_board->IRQbits) == 0) {
- rt_printk
+ printk
(", IRQ %u is out of allowed range, DISABLING IT",
irq);
irq = 0; /* Bad IRQ */
} else {
- if (comedi_request_irq(irq, interrupt_pcl818, 0,
- "pcl818", dev)) {
- rt_printk
+ if (request_irq(irq, interrupt_pcl818, 0, "pcl818", dev)) {
+ printk
(", unable to allocate IRQ %u, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- rt_printk(", irq=%u", irq);
+ printk(", irq=%u", irq);
}
}
}
@@ -1750,7 +1766,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
#ifdef unused
/* grab RTC for DMA operations */
devpriv->dma_rtc = 0;
- if (it->options[2] > 0) { // we want to use DMA
+ if (it->options[2] > 0) { /* we want to use DMA */
if (RTC_lock == 0) {
if (!request_region(RTC_PORT(0), RTC_IO_EXTENT,
"pcl818 (RTC)"))
@@ -1759,12 +1775,11 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
devpriv->rtc_iobase = RTC_PORT(0);
devpriv->rtc_iosize = RTC_IO_EXTENT;
RTC_lock++;
- if (!comedi_request_irq(RTC_IRQ,
- interrupt_pcl818_ai_mode13_dma_rtc, 0,
+ if (!request_irq(RTC_IRQ, interrupt_pcl818_ai_mode13_dma_rtc, 0,
"pcl818 DMA (RTC)", dev)) {
devpriv->dma_rtc = 1;
devpriv->rtc_irq = RTC_IRQ;
- rt_printk(", dma_irq=%u", devpriv->rtc_irq);
+ printk(", dma_irq=%u", devpriv->rtc_irq);
} else {
RTC_lock--;
if (RTC_lock == 0) {
@@ -1789,31 +1804,31 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
if (dma < 1)
goto no_dma; /* DMA disabled */
if (((1 << dma) & this_board->DMAbits) == 0) {
- rt_printk(", DMA is out of allowed range, FAIL!\n");
+ printk(", DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
ret = request_dma(dma, "pcl818");
if (ret) {
- rt_printk(", unable to allocate DMA %u, FAIL!\n", dma);
+ printk(", unable to allocate DMA %u, FAIL!\n", dma);
return -EBUSY; /* DMA isn't free */
}
devpriv->dma = dma;
- rt_printk(", dma=%u", dma);
+ printk(", dma=%u", dma);
pages = 2; /* we need 16KB */
devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[0]) {
- rt_printk(", unable to allocate DMA buffer, FAIL!\n");
+ printk(", unable to allocate DMA buffer, FAIL!\n");
/* maybe experiment with try_to_free_pages() will help .... */
return -EBUSY; /* no buffer :-( */
}
devpriv->dmapages[0] = pages;
devpriv->hwdmaptr[0] = virt_to_bus((void *)devpriv->dmabuf[0]);
devpriv->hwdmasize[0] = (1 << pages) * PAGE_SIZE;
- //rt_printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE);
- if (devpriv->dma_rtc == 0) { // we must do duble buff :-(
+ /* printk("%d %d %ld, ",devpriv->dmapages[0],devpriv->hwdmasize[0],PAGE_SIZE); */
+ if (devpriv->dma_rtc == 0) { /* we must do duble buff :-( */
devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages);
if (!devpriv->dmabuf[1]) {
- rt_printk
+ printk
(", unable to allocate DMA buffer, FAIL!\n");
return -EBUSY;
}
@@ -1826,7 +1841,8 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
no_dma:
- if ((ret = alloc_subdevices(dev, 4)) < 0)
+ ret = alloc_subdevices(dev, 4);
+ if (ret < 0)
return ret;
s = dev->subdevices + 0;
@@ -1858,7 +1874,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
}
if (this_board->is_818) {
if ((it->options[4] == 1) || (it->options[4] == 10))
- s->range_table = &range_pcl818l_h_ai; // secondary range list jumper selectable
+ s->range_table = &range_pcl818l_h_ai; /* secondary range list jumper selectable */
} else {
switch (it->options[4]) {
case 0:
@@ -1971,7 +1987,7 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
pcl818_reset(dev);
- rt_printk("\n");
+ printk("\n");
return 0;
}
@@ -1980,9 +1996,9 @@ static int pcl818_attach(struct comedi_device * dev, struct comedi_devconfig * i
==============================================================================
Removes device
*/
-static int pcl818_detach(struct comedi_device * dev)
+static int pcl818_detach(struct comedi_device *dev)
{
- // rt_printk("comedi%d: pcl818: remove\n", dev->minor);
+ /* printk("comedi%d: pcl818: remove\n", dev->minor); */
free_resources(dev);
return 0;
}