Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186839
b: refs/heads/master
c: dd105f0
h: refs/heads/master
i:
  186837: 48715a7
  186835: 1df2693
  186831: d41088a
v: v3
  • Loading branch information
Andrea Gelmini authored and Greg Kroah-Hartman committed Mar 4, 2010
1 parent 9cb46cd commit e763768
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 74 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d539047c7bb3d462b4b505accbb3cc31dce87801
refs/heads/master: dd105f08c0e9d4081629f96b09abadc0bb51e0d8
119 changes: 46 additions & 73 deletions trunk/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You should also find the complete GPL in the COPYING file accompanying this sour
*/

#include "hwdrv_apci3120.h"
static unsigned int ui_Temp = 0;
static unsigned int ui_Temp;

/* FUNCTION DEFINITIONS */

Expand Down Expand Up @@ -98,25 +98,22 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_su

devpriv->b_InterruptMode = APCI3120_EOS_MODE;

if (data[1]) {
if (data[1])
devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
} else
else
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
/* Copy channel list and Range List to devpriv */

devpriv->ui_AiNbrofChannels = data[3];
for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) {
for (i = 0; i < devpriv->ui_AiNbrofChannels; i++)
devpriv->ui_AiChannelList[i] = data[4 + i];
}

} else /* EOC */
{
} else { /* EOC */
devpriv->b_InterruptMode = APCI3120_EOC_MODE;
if (data[1]) {
if (data[1])
devpriv->b_EocEosInterrupt = APCI3120_ENABLE;
} else {
else
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
}
}

return insn->n;
Expand Down Expand Up @@ -166,13 +163,9 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
devpriv->us_OutputRegister = 0;
/* devpriv->b_DigitalOutputRegister=0; */

if (insn->unused[0] == 222) /* second insn read */
{

for (i = 0; i < insn->n; i++) {
if (insn->unused[0] == 222) { /* second insn read */
for (i = 0; i < insn->n; i++)
data[i] = devpriv->ui_AiReadData[i];
}

} else {
devpriv->tsk_Current = current; /* Save the current process task structure */
/*
Expand Down Expand Up @@ -519,9 +512,8 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s

/* step 2: make sure trigger sources are unique and mutually compatible */

if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) {
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
}

if (cmd->scan_begin_src != TRIG_TIMER &&
cmd->scan_begin_src != TRIG_FOLLOW)
Expand All @@ -548,16 +540,14 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
err++;
}

if (cmd->scan_begin_src == TRIG_TIMER) /* Test Delay timing */
{
if (cmd->scan_begin_src == TRIG_TIMER) { /* Test Delay timing */
if (cmd->scan_begin_arg < this_board->ui_MinDelaytimeNs) {
cmd->scan_begin_arg = this_board->ui_MinDelaytimeNs;
err++;
}
}

if (cmd->convert_src == TRIG_TIMER) /* Test Acquisition timing */
{
if (cmd->convert_src == TRIG_TIMER) { /* Test Acquisition timing */
if (cmd->scan_begin_src == TRIG_TIMER) {
if ((cmd->convert_arg)
&& (cmd->convert_arg <
Expand Down Expand Up @@ -653,11 +643,10 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subde
/* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */
devpriv->ui_AiDataLength = s->async->prealloc_bufsz;

if (cmd->stop_src == TRIG_COUNT) {
if (cmd->stop_src == TRIG_COUNT)
devpriv->ui_AiNbrofScans = cmd->stop_arg;
} else {
else
devpriv->ui_AiNbrofScans = 0;
}

devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */
devpriv->ui_AiTimer1 = 0;
Expand Down Expand Up @@ -849,9 +838,8 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
}
/*** EL241003 End ******************************************************************************/

if (devpriv->b_ExttrigEnable == APCI3120_ENABLE) {
if (devpriv->b_ExttrigEnable == APCI3120_ENABLE)
i_APCI3120_ExttrigEnable(dev); /* activate EXT trigger */
}
switch (mode) {
case 1:
/* init timer0 in mode 2 */
Expand Down Expand Up @@ -1049,12 +1037,10 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
dmalen1 = 4;
}
} else { /* isn't output buff smaller that our DMA buff? */
if (dmalen0 > (devpriv->ui_AiDataLength)) {
if (dmalen0 > (devpriv->ui_AiDataLength))
dmalen0 = devpriv->ui_AiDataLength;
}
if (dmalen1 > (devpriv->ui_AiDataLength)) {
if (dmalen1 > (devpriv->ui_AiDataLength))
dmalen1 = devpriv->ui_AiDataLength;
}
}
devpriv->ui_DmaBufferUsesize[0] = dmalen0;
devpriv->ui_DmaBufferUsesize[1] = dmalen1;
Expand Down Expand Up @@ -1356,11 +1342,10 @@ int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevi
/* store range list to card */
us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number; */

if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) {
if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES)
us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */
} else {
else
us_TmpValue |= APCI3120_UNIPOLAR; /* enable unipolar...... */
}

gain = CR_RANGE(chanlist[i]); /* get gain number */
us_TmpValue |= ((gain & 0x03) << 4); /* <<4 for G0 and G1 bit in RAM */
Expand Down Expand Up @@ -1514,8 +1499,7 @@ void v_APCI3120_Interrupt(int irq, void *d)
/* Check If EOS interrupt */
if ((int_daq & 0x2) && (devpriv->b_InterruptMode == APCI3120_EOS_MODE)) {

if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) /* enable this in without DMA ??? */
{
if (devpriv->b_EocEosInterrupt == APCI3120_ENABLE) { /* enable this in without DMA ??? */

if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
ui_Check = 0;
Expand Down Expand Up @@ -1966,8 +1950,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
APCI3120_DISABLE_EOS_INT;
outb(devpriv->b_ModeSelectRegister,
devpriv->iobase + APCI3120_WRITE_MODE_SELECT);
if (data[0] == APCI3120_TIMER) /* initialize timer */
{
if (data[0] == APCI3120_TIMER) { /* initialize timer */
/* devpriv->b_ModeSelectRegister=devpriv->b_ModeSelectRegister |
* APCI3120_ENABLE_TIMER_INT; */

Expand Down Expand Up @@ -2006,8 +1989,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
/* timer2 in Timer mode enabled */
devpriv->b_Timer2Mode = APCI3120_TIMER;

} else /* Initialize Watch dog */
{
} else { /* Initialize Watch dog */

/* Set the Timer 2 in mode 5(Watchdog) */

Expand Down Expand Up @@ -2092,8 +2074,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
return -EINVAL;
}

if (data[0] == 2) /* write new value */
{
if (data[0] == 2) { /* write new value */
if (devpriv->b_Timer2Mode != APCI3120_TIMER) {
comedi_error(dev,
"write :timer2 not configured in TIMER MODE");
Expand All @@ -2113,13 +2094,11 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice

/* Reset FC_TIMER BIT */
inb(devpriv->iobase + APCI3120_TIMER_STATUS_REGISTER);
if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */
{
if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */
/* Enable Timer */
devpriv->b_ModeSelectRegister =
devpriv->b_ModeSelectRegister & 0x0B;
} else /* start watch dog */
{
} else { /* start watch dog */
/* Enable WatchDog */
devpriv->b_ModeSelectRegister =
(devpriv->
Expand All @@ -2146,8 +2125,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
outb(devpriv->b_ModeSelectRegister,
devpriv->iobase + APCI3120_WRITE_MODE_SELECT);

if (devpriv->b_Timer2Mode == APCI3120_TIMER) /* start timer */
{
if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */
/* For Timer mode is Gate2 must be activated **timer started */
devpriv->us_OutputRegister =
devpriv->
Expand Down Expand Up @@ -2299,8 +2277,7 @@ int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice
/* combining both words */
data[0] = (unsigned int) ((us_TmpValue) | ((us_TmpValue_2) << 16));

} else /* Read watch dog status */
{
} else { /* Read watch dog status */

us_StatusValue = inw(devpriv->iobase + APCI3120_RD_STATUS);
us_StatusValue =
Expand Down Expand Up @@ -2441,10 +2418,9 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
devpriv->b_OutputMemoryStatus = APCI3120_DISABLE;
devpriv->b_DigitalOutputRegister = 0;
}
if (!devpriv->b_OutputMemoryStatus) {
if (!devpriv->b_OutputMemoryStatus)
ui_Temp = 0;

} /* if(!devpriv->b_OutputMemoryStatus ) */
/* if(!devpriv->b_OutputMemoryStatus ) */

return insn->n;
}
Expand Down Expand Up @@ -2504,23 +2480,23 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,

/*
+----------------------------------------------------------------------------+
| Function name :int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,|
|struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
| |
| Function name :int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,|
|struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task : Write digiatl output |
| |
| Task : Write digiatl output |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
data[0] Value to be written
data[1] :1 Set digital o/p ON
data[1] 2 Set digital o/p OFF with memory ON
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
data[0] Value to be written
data[1] :1 Set digital o/p ON
data[1] 2 Set digital o/p OFF with memory ON
+----------------------------------------------------------------------------+
| Return Value : |
| |
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/

Expand Down Expand Up @@ -2615,8 +2591,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
ui_Channel = CR_CHAN(insn->chanspec);

/* this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); */
if (ui_Range) /* if 1 then unipolar */
{
if (ui_Range) { /* if 1 then unipolar */

if (data[0] != 0)
data[0] =
Expand All @@ -2627,8 +2602,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
((((ui_Channel & 0x03) << 14) & 0xC000) | (1 <<
13) | 8192);

} else /* if 0 then bipolar */
{
} else { /* if 0 then bipolar */
data[0] =
((((ui_Channel & 0x03) << 14) & 0xC000) | (0 << 13) |
data[0]);
Expand All @@ -2639,8 +2613,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
* out put n values at the given channel. printk("\nwaiting for
* DA_READY BIT");
*/
do /* Waiting of DA_READY BIT */
{
do { /* Waiting of DA_READY BIT */
us_TmpValue =
((unsigned short) inw(devpriv->iobase +
APCI3120_RD_STATUS)) & 0x0001;
Expand Down

0 comments on commit e763768

Please sign in to comment.