Commit 8f8a3534 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: hwdrv_apci3120: remove forward declarations

This source file is #include'd when building the addi_apci_3001 and
addi_apci_3120 drivers. All the functions in this file are actually
static and should not be exported to the kernel.

Move some of the functions to remove the need for the forward declarations
and make all of the functions in this file static. Note, this patch does
not try to fix any of the coding style issues in the functions.

Also, remove most of the big comment blocks preceding each function.
Leave the 'task' information for some of them to assist in later cleanup.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4ebd3047
...@@ -55,27 +55,10 @@ static unsigned int ui_Temp; ...@@ -55,27 +55,10 @@ static unsigned int ui_Temp;
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
/* static int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev,
+----------------------------------------------------------------------------+ struct comedi_subdevice *s,
| Function name :int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev,| struct comedi_insn *insn,
| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | unsigned int *data)
| |
+----------------------------------------------------------------------------+
| Task : Calls card specific function |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{ {
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
unsigned int i; unsigned int i;
...@@ -122,30 +105,69 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_su ...@@ -122,30 +105,69 @@ int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_su
} }
/* /*
+----------------------------------------------------------------------------+ * This function will first check channel list is ok or not and then
| Function name :int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, | * initialize the sequence RAM with the polarity, Gain,Channel number.
| struct comedi_subdevice *s,struct comedi_insn *insn, unsigned int *data) | * If the last argument of function "check"is 1 then it only checks
| | * the channel list is ok or not.
+----------------------------------------------------------------------------+ */
| Task : card specific function | static int i_APCI3120_SetupChannelList(struct comedi_device *dev,
| Reads analog input in synchronous mode | struct comedi_subdevice *s,
| EOC and EOS is selected as per configured | int n_chan,
| if no conversion time is set uses default conversion | unsigned int *chanlist,
| time 10 microsec. | char check)
| | {
+----------------------------------------------------------------------------+ struct addi_private *devpriv = dev->private;
| Input Parameters : struct comedi_device *dev | unsigned int i; /* , differencial=0, bipolar=0; */
| struct comedi_subdevice *s | unsigned int gain;
| struct comedi_insn *insn | unsigned short us_TmpValue;
| unsigned int *data |
+----------------------------------------------------------------------------+ /* correct channel and range number check itself comedi/range.c */
| Return Value : | if (n_chan < 1) {
| | if (!check)
+----------------------------------------------------------------------------+ comedi_error(dev, "range/channel list is empty!");
*/ return 0;
}
/* All is ok, so we can setup channel/range list */
if (check)
return 1;
/* Code to set the PA and PR...Here it set PA to 0.. */
devpriv->us_OutputRegister =
devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR;
devpriv->us_OutputRegister = ((n_chan - 1) & 0xf) << 8;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
for (i = 0; i < n_chan; i++) {
/* store range list to card */
us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number; */
if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES)
us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */
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 */
us_TmpValue |= i << 8; /* To select the RAM LOCATION.... */
outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
printk("\n Gain = %i",
(((unsigned char)CR_RANGE(chanlist[i]) & 0x03) << 2));
printk("\n Channel = %i", CR_CHAN(chanlist[i]));
printk("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR);
}
return 1; /* we can serve this with scan logic */
}
int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s, /*
struct comedi_insn *insn, unsigned int *data) * Reads analog input in synchronous mode EOC and EOS is selected
* as per configured if no conversion time is set uses default
* conversion time 10 microsec.
*/
static int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{ {
const struct addi_board *this_board = comedi_board(dev); const struct addi_board *this_board = comedi_board(dev);
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
...@@ -390,25 +412,83 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd ...@@ -390,25 +412,83 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
} }
static int i_APCI3120_Reset(struct comedi_device *dev)
{
struct addi_private *devpriv = dev->private;
unsigned int i;
unsigned short us_TmpValue;
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
devpriv->b_InterruptMode = APCI3120_EOC_MODE;
devpriv->ui_EocEosConversionTime = 0; /* set eoc eos conv time to 0 */
devpriv->b_OutputMemoryStatus = 0;
/* variables used in timer subdevice */
devpriv->b_Timer2Mode = 0;
devpriv->b_Timer2Interrupt = 0;
devpriv->b_ExttrigEnable = 0; /* Disable ext trigger */
/* Disable all interrupts, watchdog for the anolog output */
devpriv->b_ModeSelectRegister = 0;
outb(devpriv->b_ModeSelectRegister,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
/* Disables all counters, ext trigger and clears PA, PR */
devpriv->us_OutputRegister = 0;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
/* /*
+----------------------------------------------------------------------------+ * Code to set the all anolog o/p channel to 0v 8191 is decimal
| Function name :int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev,| * value for zero(0 v)volt in bipolar mode(default)
| struct comedi_subdevice *s)| */
| | outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 1 */
+----------------------------------------------------------------------------+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 2 */
| Task : Stops Cyclic acquisition | outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 3 */
| | outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 4 */
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev | outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 5 */
| struct comedi_subdevice *s | outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 6 */
| | outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 7 */
+----------------------------------------------------------------------------+ outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 8 */
| Return Value :0 |
| | /* Reset digital output to L0W */
+----------------------------------------------------------------------------+
*/ /* ES05 outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT); */
udelay(10);
inw(dev->iobase + 0); /* make a dummy read */
inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */
inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */
/* code to reset the RAM sequence */
for (i = 0; i < 16; i++) {
us_TmpValue = i << 8; /* select the location */
outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
}
return 0;
}
static int i_APCI3120_ExttrigEnable(struct comedi_device *dev)
{
struct addi_private *devpriv = dev->private;
devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
return 0;
}
static int i_APCI3120_ExttrigDisable(struct comedi_device *dev)
{
struct addi_private *devpriv = dev->private;
devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
return 0;
}
int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s) static int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev,
struct comedi_subdevice *s)
{ {
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
...@@ -461,26 +541,8 @@ int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_su ...@@ -461,26 +541,8 @@ int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_su
return 0; return 0;
} }
/* static int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev,
+----------------------------------------------------------------------------+ struct comedi_subdevice *s,
| Function name :int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev|
| ,struct comedi_subdevice *s,struct comedi_cmd *cmd) |
| |
+----------------------------------------------------------------------------+
| Task : Test validity for a command for cyclic anlog input |
| acquisition |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_cmd *cmd |
+----------------------------------------------------------------------------+
| Return Value :0 |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd) struct comedi_cmd *cmd)
{ {
const struct addi_board *this_board = comedi_board(dev); const struct addi_board *this_board = comedi_board(dev);
...@@ -591,99 +653,13 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s ...@@ -591,99 +653,13 @@ int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
} }
/* /*
+----------------------------------------------------------------------------+ * This is used for analog input cyclic acquisition.
| Function name : int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, | * Performs the command operations.
| struct comedi_subdevice *s) | * If DMA is configured does DMA initialization otherwise does the
| | * acquisition with EOS interrupt.
+----------------------------------------------------------------------------+ */
| Task : Does asynchronous acquisition | static int i_APCI3120_CyclicAnalogInput(int mode,
| Determines the mode 1 or 2. | struct comedi_device *dev,
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct addi_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
/* loading private structure with cmd structure inputs */
devpriv->ui_AiFlags = cmd->flags;
devpriv->ui_AiNbrofChannels = cmd->chanlist_len;
devpriv->ui_AiScanLength = cmd->scan_end_arg;
devpriv->pui_AiChannelList = cmd->chanlist;
/* UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data; */
devpriv->AiData = s->async->prealloc_buf;
/* 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)
devpriv->ui_AiNbrofScans = cmd->stop_arg;
else
devpriv->ui_AiNbrofScans = 0;
devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */
devpriv->ui_AiTimer1 = 0;
if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1))
devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */
/* stopped using cancel */
if (cmd->start_src == TRIG_EXT)
devpriv->b_ExttrigEnable = APCI3120_ENABLE;
else
devpriv->b_ExttrigEnable = APCI3120_DISABLE;
if (cmd->scan_begin_src == TRIG_FOLLOW) {
/* mode 1 or 3 */
if (cmd->convert_src == TRIG_TIMER) {
/* mode 1 */
devpriv->ui_AiTimer0 = cmd->convert_arg; /* timer constant in nano seconds */
/* return this_board->ai_cmd(1,dev,s); */
return i_APCI3120_CyclicAnalogInput(1, dev, s);
}
}
if ((cmd->scan_begin_src == TRIG_TIMER)
&& (cmd->convert_src == TRIG_TIMER)) {
/* mode 2 */
devpriv->ui_AiTimer1 = cmd->scan_begin_arg;
devpriv->ui_AiTimer0 = cmd->convert_arg; /* variable changed timer2 to timer0 */
/* return this_board->ai_cmd(2,dev,s); */
return i_APCI3120_CyclicAnalogInput(2, dev, s);
}
return -1;
}
/*
+----------------------------------------------------------------------------+
| Function name : int i_APCI3120_CyclicAnalogInput(int mode, |
| struct comedi_device * dev,struct comedi_subdevice * s) |
+----------------------------------------------------------------------------+
| Task : This is used for analog input cyclic acquisition |
| Performs the command operations. |
| If DMA is configured does DMA initialization |
| otherwise does the acquisition with EOS interrupt. |
| |
+----------------------------------------------------------------------------+
| Input Parameters : |
| |
| |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
struct comedi_subdevice *s) struct comedi_subdevice *s)
{ {
const struct addi_board *this_board = comedi_board(dev); const struct addi_board *this_board = comedi_board(dev);
...@@ -1196,237 +1172,268 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev, ...@@ -1196,237 +1172,268 @@ int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
} }
/* /*
+----------------------------------------------------------------------------+ * Does asynchronous acquisition.
| intERNAL FUNCTIONS | * Determines the mode 1 or 2.
+----------------------------------------------------------------------------+ */
*/ static int i_APCI3120_CommandAnalogInput(struct comedi_device *dev,
struct comedi_subdevice *s)
/*
+----------------------------------------------------------------------------+
| Function name : int i_APCI3120_Reset(struct comedi_device *dev) |
| |
| |
+----------------------------------------------------------------------------+
| Task : Hardware reset function |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| |
| |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_Reset(struct comedi_device *dev)
{ {
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
unsigned int i; struct comedi_cmd *cmd = &s->async->cmd;
unsigned short us_TmpValue;
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
devpriv->b_EocEosInterrupt = APCI3120_DISABLE;
devpriv->b_InterruptMode = APCI3120_EOC_MODE;
devpriv->ui_EocEosConversionTime = 0; /* set eoc eos conv time to 0 */
devpriv->b_OutputMemoryStatus = 0;
/* variables used in timer subdevice */ /* loading private structure with cmd structure inputs */
devpriv->b_Timer2Mode = 0; devpriv->ui_AiFlags = cmd->flags;
devpriv->b_Timer2Interrupt = 0; devpriv->ui_AiNbrofChannels = cmd->chanlist_len;
devpriv->b_ExttrigEnable = 0; /* Disable ext trigger */ devpriv->ui_AiScanLength = cmd->scan_end_arg;
devpriv->pui_AiChannelList = cmd->chanlist;
/* Disable all interrupts, watchdog for the anolog output */ /* UPDATE-0.7.57->0.7.68devpriv->AiData=s->async->data; */
devpriv->b_ModeSelectRegister = 0; devpriv->AiData = s->async->prealloc_buf;
outb(devpriv->b_ModeSelectRegister, /* UPDATE-0.7.57->0.7.68devpriv->ui_AiDataLength=s->async->data_len; */
dev->iobase + APCI3120_WRITE_MODE_SELECT); devpriv->ui_AiDataLength = s->async->prealloc_bufsz;
/* Disables all counters, ext trigger and clears PA, PR */
devpriv->us_OutputRegister = 0;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
/* if (cmd->stop_src == TRIG_COUNT)
* Code to set the all anolog o/p channel to 0v 8191 is decimal devpriv->ui_AiNbrofScans = cmd->stop_arg;
* value for zero(0 v)volt in bipolar mode(default) else
*/ devpriv->ui_AiNbrofScans = 0;
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_1, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 1 */
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_2, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 2 */
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_3, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 3 */
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_4, dev->iobase + APCI3120_ANALOG_OUTPUT_1); /* channel 4 */
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_5, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 5 */ devpriv->ui_AiTimer0 = 0; /* variables changed to timer0,timer1 */
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_6, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 6 */ devpriv->ui_AiTimer1 = 0;
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_7, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 7 */ if ((devpriv->ui_AiNbrofScans == 0) || (devpriv->ui_AiNbrofScans == -1))
outw(8191 | APCI3120_ANALOG_OP_CHANNEL_8, dev->iobase + APCI3120_ANALOG_OUTPUT_2); /* channel 8 */ devpriv->b_AiContinuous = 1; /* user want neverending analog acquisition */
/* stopped using cancel */
/* Reset digital output to L0W */ if (cmd->start_src == TRIG_EXT)
devpriv->b_ExttrigEnable = APCI3120_ENABLE;
else
devpriv->b_ExttrigEnable = APCI3120_DISABLE;
/* ES05 outb(0x0,dev->iobase+APCI3120_DIGITAL_OUTPUT); */ if (cmd->scan_begin_src == TRIG_FOLLOW) {
udelay(10); /* mode 1 or 3 */
if (cmd->convert_src == TRIG_TIMER) {
/* mode 1 */
inw(dev->iobase + 0); /* make a dummy read */ devpriv->ui_AiTimer0 = cmd->convert_arg; /* timer constant in nano seconds */
inb(dev->iobase + APCI3120_RESET_FIFO); /* flush FIFO */ /* return this_board->ai_cmd(1,dev,s); */
inw(dev->iobase + APCI3120_RD_STATUS); /* flush A/D status register */ return i_APCI3120_CyclicAnalogInput(1, dev, s);
}
/* code to reset the RAM sequence */
for (i = 0; i < 16; i++) {
us_TmpValue = i << 8; /* select the location */
outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
} }
return 0; if ((cmd->scan_begin_src == TRIG_TIMER)
&& (cmd->convert_src == TRIG_TIMER)) {
/* mode 2 */
devpriv->ui_AiTimer1 = cmd->scan_begin_arg;
devpriv->ui_AiTimer0 = cmd->convert_arg; /* variable changed timer2 to timer0 */
/* return this_board->ai_cmd(2,dev,s); */
return i_APCI3120_CyclicAnalogInput(2, dev, s);
}
return -1;
} }
/* /*
+----------------------------------------------------------------------------+ * This function copies the data from DMA buffer to the Comedi buffer.
| Function name : int i_APCI3120_SetupChannelList(struct comedi_device * dev, | */
| struct comedi_subdevice * s, int n_chan,unsigned int *chanlist| static void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
| ,char check) | struct comedi_subdevice *s,
| | short *dma_buffer,
+----------------------------------------------------------------------------+ unsigned int num_samples)
| Task :This function will first check channel list is ok or not| {
|and then initialize the sequence RAM with the polarity, Gain,Channel number | struct addi_private *devpriv = dev->private;
|If the last argument of function "check"is 1 then it only checks the channel|
|list is ok or not. | devpriv->ui_AiActualScan +=
| | (s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength;
+----------------------------------------------------------------------------+ s->async->cur_chan += num_samples;
| Input Parameters : struct comedi_device * dev | s->async->cur_chan %= devpriv->ui_AiScanLength;
| struct comedi_subdevice * s |
| int n_chan |
unsigned int *chanlist
char check
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s, cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short));
int n_chan, unsigned int *chanlist, char check) }
/*
* This is a handler for the DMA interrupt.
* This function copies the data to Comedi Buffer.
* For continuous DMA it reinitializes the DMA operation.
* For single mode DMA it stop the acquisition.
*/
static void v_APCI3120_InterruptDma(int irq, void *d)
{ {
struct comedi_device *dev = d;
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
unsigned int i; /* , differencial=0, bipolar=0; */ struct comedi_subdevice *s = &dev->subdevices[0];
unsigned int gain; unsigned int next_dma_buf, samplesinbuf;
unsigned short us_TmpValue; unsigned long low_word, high_word, var;
unsigned int ui_Tmp;
/* correct channel and range number check itself comedi/range.c */ samplesinbuf =
if (n_chan < 1) { devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer] -
if (!check) inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC);
comedi_error(dev, "range/channel list is empty!");
return 0; if (samplesinbuf <
devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer]) {
comedi_error(dev, "Interrupted DMA transfer!");
} }
/* All is ok, so we can setup channel/range list */ if (samplesinbuf & 1) {
if (check) comedi_error(dev, "Odd count of bytes in DMA ring!");
return 1; i_APCI3120_StopCyclicAcquisition(dev, s);
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
/* Code to set the PA and PR...Here it set PA to 0.. */ return;
devpriv->us_OutputRegister = }
devpriv->us_OutputRegister & APCI3120_CLEAR_PA_PR; samplesinbuf = samplesinbuf >> 1; /* number of received samples */
devpriv->us_OutputRegister = ((n_chan - 1) & 0xf) << 8; if (devpriv->b_DmaDoubleBuffer) {
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); /* switch DMA buffers if is used double buffering */
next_dma_buf = 1 - devpriv->ui_DmaActualBuffer;
for (i = 0; i < n_chan; i++) { ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
/* store range list to card */ outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
us_TmpValue = CR_CHAN(chanlist[i]); /* get channel number; */
if (CR_RANGE(chanlist[i]) < APCI3120_BIPOLAR_RANGES) /* changed since 16 bit interface for add on */
us_TmpValue &= ((~APCI3120_UNIPOLAR) & 0xff); /* set bipolar */ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
else outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
us_TmpValue |= APCI3120_UNIPOLAR; /* enable unipolar...... */ devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* 0x1000 is out putted in windows driver */
gain = CR_RANGE(chanlist[i]); /* get gain number */ var = devpriv->ul_DmaBufferHw[next_dma_buf];
us_TmpValue |= ((gain & 0x03) << 4); /* <<4 for G0 and G1 bit in RAM */ low_word = var & 0xffff;
us_TmpValue |= i << 8; /* To select the RAM LOCATION.... */ var = devpriv->ul_DmaBufferHw[next_dma_buf];
outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS); high_word = var / 65536;
/* DMA Start Address Low */
outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2);
/* DMA Start Address High */
outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
var = devpriv->ui_DmaBufferUsesize[next_dma_buf];
low_word = var & 0xffff;
var = devpriv->ui_DmaBufferUsesize[next_dma_buf];
high_word = var / 65536;
/* Nbr of acquisition LOW */
outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2);
/* Nbr of acquisition HIGH */
outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
/*
* To configure A2P FIFO
* ENABLE A2P FIFO WRITE AND ENABLE AMWEN
* AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
*/
outw(3, devpriv->i_IobaseAddon + 4);
/* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
APCI3120_ENABLE_WRITE_TC_INT),
devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
printk("\n Gain = %i",
(((unsigned char)CR_RANGE(chanlist[i]) & 0x03) << 2));
printk("\n Channel = %i", CR_CHAN(chanlist[i]));
printk("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR);
} }
return 1; /* we can serve this with scan logic */ if (samplesinbuf) {
} v_APCI3120_InterruptDmaMoveBlock16bit(dev, s,
devpriv->ul_DmaBufferVirtual[devpriv->
ui_DmaActualBuffer], samplesinbuf);
if (!(devpriv->ui_AiFlags & TRIG_WAKE_EOS)) {
s->async->events |= COMEDI_CB_EOS;
comedi_event(dev, s);
}
}
if (!devpriv->b_AiContinuous)
if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) {
/* all data sampled */
i_APCI3120_StopCyclicAcquisition(dev, s);
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
return;
}
if (devpriv->b_DmaDoubleBuffer) { /* switch dma buffers */
devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer;
} else {
/* /*
+----------------------------------------------------------------------------+ * restart DMA if is not used double buffering
| Function name : int i_APCI3120_ExttrigEnable(struct comedi_device * dev) | * ADDED REINITIALISE THE DMA
| | */
| | ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
+----------------------------------------------------------------------------+ outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
| Task : Enable the external trigger |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device * dev |
| |
| |
+----------------------------------------------------------------------------+
| Return Value : 0 |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_ExttrigEnable(struct comedi_device *dev) /* changed since 16 bit interface for add on */
{ outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
struct addi_private *devpriv = dev->private; outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* */
/*
* A2P FIFO MANAGEMENT
* A2P fifo reset & transfer control enable
*/
outl(APCI3120_A2P_FIFO_MANAGEMENT,
devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
devpriv->us_OutputRegister |= APCI3120_ENABLE_EXT_TRIGGER; var = devpriv->ul_DmaBufferHw[0];
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS); low_word = var & 0xffff;
return 0; var = devpriv->ul_DmaBufferHw[0];
} high_word = var / 65536;
outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
var = devpriv->ui_DmaBufferUsesize[0];
low_word = var & 0xffff; /* changed */
var = devpriv->ui_DmaBufferUsesize[0];
high_word = var / 65536;
outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
/* /*
+----------------------------------------------------------------------------+ * To configure A2P FIFO
| Function name : int i_APCI3120_ExttrigDisable(struct comedi_device * dev) | * ENABLE A2P FIFO WRITE AND ENABLE AMWEN
| | * AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
+----------------------------------------------------------------------------+ */
| Task : Disables the external trigger | outw(3, devpriv->i_IobaseAddon + 4);
| | /* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
+----------------------------------------------------------------------------+ outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
| Input Parameters : struct comedi_device * dev | APCI3120_ENABLE_WRITE_TC_INT),
| | devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
| | }
+----------------------------------------------------------------------------+ }
| Return Value : 0 |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_ExttrigDisable(struct comedi_device *dev) /*
* This function handles EOS interrupt.
* This function copies the acquired data(from FIFO) to Comedi buffer.
*/
static int i_APCI3120_InterruptHandleEos(struct comedi_device *dev)
{ {
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
int n_chan, i;
struct comedi_subdevice *s = &dev->subdevices[0];
int err = 1;
devpriv->us_OutputRegister &= ~APCI3120_ENABLE_EXT_TRIGGER; n_chan = devpriv->ui_AiNbrofChannels;
outw(devpriv->us_OutputRegister, dev->iobase + APCI3120_WR_ADDRESS);
return 0;
}
/* s->async->events = 0;
+----------------------------------------------------------------------------+
| intERRUPT FUNCTIONS |
+----------------------------------------------------------------------------+
*/
/* for (i = 0; i < n_chan; i++)
+----------------------------------------------------------------------------+ err &= comedi_buf_put(s->async, inw(dev->iobase + 0));
| Function name : void v_APCI3120_Interrupt(int irq, void *d) |
| | s->async->events |= COMEDI_CB_EOS;
| |
+----------------------------------------------------------------------------+ if (err == 0)
| Task :Interrupt handler for APCI3120 | s->async->events |= COMEDI_CB_OVERFLOW;
| When interrupt occurs this gets called. |
| First it finds which interrupt has been generated and | comedi_event(dev, s);
| handles corresponding interrupt |
| |
+----------------------------------------------------------------------------+
| Input Parameters : int irq |
| void *d |
| |
+----------------------------------------------------------------------------+
| Return Value : void |
| |
+----------------------------------------------------------------------------+
*/
void v_APCI3120_Interrupt(int irq, void *d) return 0;
}
static void v_APCI3120_Interrupt(int irq, void *d)
{ {
struct comedi_device *dev = d; struct comedi_device *dev = d;
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
...@@ -1557,346 +1564,77 @@ void v_APCI3120_Interrupt(int irq, void *d) ...@@ -1557,346 +1564,77 @@ void v_APCI3120_Interrupt(int irq, void *d)
break; break;
case APCI3120_TIMER: case APCI3120_TIMER:
/* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
break;
case APCI3120_WATCHDOG:
/* Send a signal to from kernel to user space */
send_sig(SIGIO, devpriv->tsk_Current, 0);
break;
default:
/* disable Timer Interrupt */
devpriv->b_ModeSelectRegister =
devpriv->
b_ModeSelectRegister &
APCI3120_DISABLE_TIMER_INT;
outb(devpriv->b_ModeSelectRegister,
dev->iobase + APCI3120_WRITE_MODE_SELECT);
}
b_DummyRead = inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
}
if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) {
if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
/****************************/
/* Clear Timer Write TC int */
/****************************/
outl(APCI3120_CLEAR_WRITE_TC_INT,
devpriv->i_IobaseAmcc +
APCI3120_AMCC_OP_REG_INTCSR);
/************************************/
/* Clears the timer status register */
/************************************/
inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
v_APCI3120_InterruptDma(irq, d); /* do some data transfer */
} else {
/* Stops the Timer */
outw(devpriv->
us_OutputRegister & APCI3120_DISABLE_TIMER0 &
APCI3120_DISABLE_TIMER1,
dev->iobase + APCI3120_WR_ADDRESS);
}
}
return;
}
/*
+----------------------------------------------------------------------------+
| Function name :int i_APCI3120_InterruptHandleEos(struct comedi_device *dev) |
| |
| |
+----------------------------------------------------------------------------+
| Task : This function handles EOS interrupt. |
| This function copies the acquired data(from FIFO) |
| to Comedi buffer. |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| |
| |
+----------------------------------------------------------------------------+
| Return Value : 0 |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InterruptHandleEos(struct comedi_device *dev)
{
struct addi_private *devpriv = dev->private;
int n_chan, i;
struct comedi_subdevice *s = &dev->subdevices[0];
int err = 1;
n_chan = devpriv->ui_AiNbrofChannels;
s->async->events = 0;
for (i = 0; i < n_chan; i++)
err &= comedi_buf_put(s->async, inw(dev->iobase + 0));
s->async->events |= COMEDI_CB_EOS;
if (err == 0)
s->async->events |= COMEDI_CB_OVERFLOW;
comedi_event(dev, s);
return 0;
}
/*
+----------------------------------------------------------------------------+
| Function name : void v_APCI3120_InterruptDma(int irq, void *d) |
| |
+----------------------------------------------------------------------------+
| Task : This is a handler for the DMA interrupt |
| This function copies the data to Comedi Buffer. |
| For continuous DMA it reinitializes the DMA operation. |
| For single mode DMA it stop the acquisition. |
| |
+----------------------------------------------------------------------------+
| Input Parameters : int irq, void *d |
| |
+----------------------------------------------------------------------------+
| Return Value : void |
| |
+----------------------------------------------------------------------------+
*/
void v_APCI3120_InterruptDma(int irq, void *d)
{
struct comedi_device *dev = d;
struct addi_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
unsigned int next_dma_buf, samplesinbuf;
unsigned long low_word, high_word, var;
unsigned int ui_Tmp;
samplesinbuf =
devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer] -
inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_MWTC);
if (samplesinbuf <
devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer]) {
comedi_error(dev, "Interrupted DMA transfer!");
}
if (samplesinbuf & 1) {
comedi_error(dev, "Odd count of bytes in DMA ring!");
i_APCI3120_StopCyclicAcquisition(dev, s);
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
return;
}
samplesinbuf = samplesinbuf >> 1; /* number of received samples */
if (devpriv->b_DmaDoubleBuffer) {
/* switch DMA buffers if is used double buffering */
next_dma_buf = 1 - devpriv->ui_DmaActualBuffer;
ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
/* changed since 16 bit interface for add on */
outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* 0x1000 is out putted in windows driver */
var = devpriv->ul_DmaBufferHw[next_dma_buf];
low_word = var & 0xffff;
var = devpriv->ul_DmaBufferHw[next_dma_buf];
high_word = var / 65536;
/* DMA Start Address Low */ /* Send a signal to from kernel to user space */
outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0); send_sig(SIGIO, devpriv->tsk_Current, 0);
outw(low_word, devpriv->i_IobaseAddon + 2); break;
/* DMA Start Address High */ case APCI3120_WATCHDOG:
outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
var = devpriv->ui_DmaBufferUsesize[next_dma_buf]; /* Send a signal to from kernel to user space */
low_word = var & 0xffff; send_sig(SIGIO, devpriv->tsk_Current, 0);
var = devpriv->ui_DmaBufferUsesize[next_dma_buf]; break;
high_word = var / 65536;
/* Nbr of acquisition LOW */ default:
outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2);
/* Nbr of acquisition HIGH */ /* disable Timer Interrupt */
outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
/* devpriv->b_ModeSelectRegister =
* To configure A2P FIFO devpriv->
* ENABLE A2P FIFO WRITE AND ENABLE AMWEN b_ModeSelectRegister &
* AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03 APCI3120_DISABLE_TIMER_INT;
*/
outw(3, devpriv->i_IobaseAddon + 4);
/* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
APCI3120_ENABLE_WRITE_TC_INT),
devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
} outb(devpriv->b_ModeSelectRegister,
if (samplesinbuf) { dev->iobase + APCI3120_WRITE_MODE_SELECT);
v_APCI3120_InterruptDmaMoveBlock16bit(dev, s,
devpriv->ul_DmaBufferVirtual[devpriv->
ui_DmaActualBuffer], samplesinbuf);
if (!(devpriv->ui_AiFlags & TRIG_WAKE_EOS)) {
s->async->events |= COMEDI_CB_EOS;
comedi_event(dev, s);
}
}
if (!devpriv->b_AiContinuous)
if (devpriv->ui_AiActualScan >= devpriv->ui_AiNbrofScans) {
/* all data sampled */
i_APCI3120_StopCyclicAcquisition(dev, s);
devpriv->b_AiCyclicAcquisition = APCI3120_DISABLE;
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
return;
} }
if (devpriv->b_DmaDoubleBuffer) { /* switch dma buffers */ b_DummyRead = inb(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
devpriv->ui_DmaActualBuffer = 1 - devpriv->ui_DmaActualBuffer;
} else {
/*
* restart DMA if is not used double buffering
* ADDED REINITIALISE THE DMA
*/
ui_Tmp = AGCSTS_TC_ENABLE | AGCSTS_RESET_A2P_FIFO;
outl(ui_Tmp, devpriv->i_IobaseAddon + AMCC_OP_REG_AGCSTS);
/* changed since 16 bit interface for add on */
outw(APCI3120_ADD_ON_AGCSTS_LOW, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_LOW,
devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_AGCSTS_HIGH, devpriv->i_IobaseAddon + 0);
outw(APCI3120_ENABLE_TRANSFER_ADD_ON_HIGH, devpriv->i_IobaseAddon + 2); /* */
/*
* A2P FIFO MANAGEMENT
* A2P fifo reset & transfer control enable
*/
outl(APCI3120_A2P_FIFO_MANAGEMENT,
devpriv->i_IobaseAmcc + AMCC_OP_REG_MCSR);
var = devpriv->ul_DmaBufferHw[0]; }
low_word = var & 0xffff;
var = devpriv->ul_DmaBufferHw[0];
high_word = var / 65536;
outw(APCI3120_ADD_ON_MWAR_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_MWAR_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
var = devpriv->ui_DmaBufferUsesize[0]; if ((int_daq & 0x4) && (devpriv->b_InterruptMode == APCI3120_DMA_MODE)) {
low_word = var & 0xffff; /* changed */ if (devpriv->b_AiCyclicAcquisition == APCI3120_ENABLE) {
var = devpriv->ui_DmaBufferUsesize[0];
high_word = var / 65536;
outw(APCI3120_ADD_ON_MWTC_LOW, devpriv->i_IobaseAddon + 0);
outw(low_word, devpriv->i_IobaseAddon + 2);
outw(APCI3120_ADD_ON_MWTC_HIGH, devpriv->i_IobaseAddon + 0);
outw(high_word, devpriv->i_IobaseAddon + 2);
/* /****************************/
* To configure A2P FIFO /* Clear Timer Write TC int */
* ENABLE A2P FIFO WRITE AND ENABLE AMWEN /****************************/
* AMWEN_ENABLE | A2P_FIFO_WRITE_ENABLE (0x01|0x02)=0x03
*/
outw(3, devpriv->i_IobaseAddon + 4);
/* initialise end of dma interrupt AINT_WRITE_COMPL = ENABLE_WRITE_TC_INT(ADDI) */
outl((APCI3120_FIFO_ADVANCE_ON_BYTE_2 |
APCI3120_ENABLE_WRITE_TC_INT),
devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);
}
}
/* outl(APCI3120_CLEAR_WRITE_TC_INT,
+----------------------------------------------------------------------------+ devpriv->i_IobaseAmcc +
| Function name :void v_APCI3120_InterruptDmaMoveBlock16bit(comedi_device| APCI3120_AMCC_OP_REG_INTCSR);
|*dev,struct comedi_subdevice *s,short *dma,short *data,int n) |
| |
+----------------------------------------------------------------------------+
| Task : This function copies the data from DMA buffer to the |
| Comedi buffer |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| short *dma |
| short *data,int n |
+----------------------------------------------------------------------------+
| Return Value : void |
| |
+----------------------------------------------------------------------------+
*/
void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev, /************************************/
struct comedi_subdevice *s, short *dma_buffer, unsigned int num_samples) /* Clears the timer status register */
{ /************************************/
struct addi_private *devpriv = dev->private; inw(dev->iobase + APCI3120_TIMER_STATUS_REGISTER);
v_APCI3120_InterruptDma(irq, d); /* do some data transfer */
} else {
/* Stops the Timer */
outw(devpriv->
us_OutputRegister & APCI3120_DISABLE_TIMER0 &
APCI3120_DISABLE_TIMER1,
dev->iobase + APCI3120_WR_ADDRESS);
}
devpriv->ui_AiActualScan += }
(s->async->cur_chan + num_samples) / devpriv->ui_AiScanLength;
s->async->cur_chan += num_samples;
s->async->cur_chan %= devpriv->ui_AiScanLength;
cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short)); return;
} }
/* /*
+----------------------------------------------------------------------------+ * Configure Timer 2
| TIMER SUBDEVICE | *
+----------------------------------------------------------------------------+ * data[0] = TIMER configure as timer
*/ * = WATCHDOG configure as watchdog
* data[1] = Timer constant
/* * data[2] = Timer2 interrupt (1)enable or(0) disable
+----------------------------------------------------------------------------+ */
| Function name :int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, | static int i_APCI3120_InsnConfigTimer(struct comedi_device *dev,
| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | struct comedi_subdevice *s,
| | struct comedi_insn *insn,
+----------------------------------------------------------------------------+ unsigned int *data)
| Task :Configure Timer 2 |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
| |
| data[0]= TIMER configure as timer |
| = WATCHDOG configure as watchdog |
| data[1] = Timer constant |
| data[2] = Timer2 interrupt (1)enable or(0) disable |
| |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{ {
const struct addi_board *this_board = comedi_board(dev); const struct addi_board *this_board = comedi_board(dev);
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
...@@ -2027,35 +1765,21 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic ...@@ -2027,35 +1765,21 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
} }
/* /*
+----------------------------------------------------------------------------+ * To start and stop the timer
| Function name :int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, | *
| struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | * data[0] = 1 (start)
| | * = 0 (stop)
+----------------------------------------------------------------------------+ * = 2 (write new value)
| Task : To start and stop the timer | * data[1] = new value
+----------------------------------------------------------------------------+ *
| Input Parameters : struct comedi_device *dev | * devpriv->b_Timer2Mode = 0 DISABLE
| struct comedi_subdevice *s | * = 1 Timer
| struct comedi_insn *insn | * = 2 Watch dog
| unsigned int *data | */
| | static int i_APCI3120_InsnWriteTimer(struct comedi_device *dev,
| data[0] = 1 (start) | struct comedi_subdevice *s,
| data[0] = 0 (stop ) | struct comedi_insn *insn,
| data[0] = 2 (write new value) | unsigned int *data)
| data[1]= new value |
| |
| devpriv->b_Timer2Mode = 0 DISABLE |
| 1 Timer |
| 2 Watch dog |
| |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{ {
const struct addi_board *this_board = comedi_board(dev); const struct addi_board *this_board = comedi_board(dev);
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
...@@ -2217,30 +1941,17 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice ...@@ -2217,30 +1941,17 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
} }
/* /*
+----------------------------------------------------------------------------+ * Read the Timer value
| Function name : int i_APCI3120_InsnReadTimer(struct comedi_device *dev, | *
| struct comedi_subdevice *s,struct comedi_insn *insn, unsigned int *data) | * for Timer: data[0]= Timer constant
| | *
| | * for watchdog: data[0] = 0 (still running)
+----------------------------------------------------------------------------+ * = 1 (run down)
| Task : read the Timer value | */
+----------------------------------------------------------------------------+ static int i_APCI3120_InsnReadTimer(struct comedi_device *dev,
| Input Parameters : struct comedi_device *dev | struct comedi_subdevice *s,
| struct comedi_subdevice *s | struct comedi_insn *insn,
| struct comedi_insn *insn | unsigned int *data)
| unsigned int *data |
| |
+----------------------------------------------------------------------------+
| Return Value : |
| for Timer: data[0]= Timer constant |
| |
| for watchdog: data[0]=0 (still running) |
| data[0]=1 (run down) |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{ {
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
unsigned char b_Tmp; unsigned char b_Tmp;
...@@ -2288,32 +1999,9 @@ int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice ...@@ -2288,32 +1999,9 @@ int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice
} }
/* /*
+----------------------------------------------------------------------------+ * Reads the value of the specified Digital input channel
| DIGITAL INPUT SUBDEVICE | */
+----------------------------------------------------------------------------+ static int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
*/
/*
+----------------------------------------------------------------------------+
| Function name :int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, |
| struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) |
| |
| |
+----------------------------------------------------------------------------+
| Task : Reads the value of the specified Digital input channel|
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
...@@ -2342,26 +2030,13 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, ...@@ -2342,26 +2030,13 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
} }
/* /*
+----------------------------------------------------------------------------+ * Reads the value of the Digital input Port i.e.4channels
| Function name :int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, | * value is returned in data[0]
|struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) | */
| | static int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev,
+----------------------------------------------------------------------------+ struct comedi_subdevice *s,
| Task : Reads the value of the Digital input Port i.e.4channels| struct comedi_insn *insn,
| value is returned in data[0] | unsigned int *data)
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{ {
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
unsigned int ui_TmpValue; unsigned int ui_TmpValue;
...@@ -2378,31 +2053,12 @@ int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_sub ...@@ -2378,31 +2053,12 @@ int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_sub
} }
/* /*
+----------------------------------------------------------------------------+ * Configure the output memory ON or OFF
| DIGITAL OUTPUT SUBDEVICE | */
+----------------------------------------------------------------------------+ static int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
*/ struct comedi_subdevice *s,
/* struct comedi_insn *insn,
+----------------------------------------------------------------------------+ unsigned int *data)
| Function name :int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device |
| *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task :Configure the output memory ON or OFF |
| |
+----------------------------------------------------------------------------+
| Input Parameters :struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
{ {
struct addi_private *devpriv = dev->private; struct addi_private *devpriv = dev->private;
...@@ -2426,28 +2082,13 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev, ...@@ -2426,28 +2082,13 @@ int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
} }
/* /*
+----------------------------------------------------------------------------+ * Write diatal output port
| Function name :int i_APCI3120_InsnBitsDigitalOutput(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
+----------------------------------------------------------------------------+ * = 2 Set digital o/p OFF with memory ON
| Task : write diatal output port | */
| | static int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
+----------------------------------------------------------------------------+
| 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 : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
...@@ -2481,28 +2122,13 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev, ...@@ -2481,28 +2122,13 @@ int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev,
} }
/* /*
+----------------------------------------------------------------------------+ * Write digital output
| Function name :int i_APCI3120_InsnWriteDigitalOutput(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
+----------------------------------------------------------------------------+ * = 2 Set digital o/p OFF with memory ON
| Task : Write digiatl output | */
| | static int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
+----------------------------------------------------------------------------+
| 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 : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
...@@ -2555,32 +2181,8 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, ...@@ -2555,32 +2181,8 @@ int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev,
} }
/* #ifdef CONFIG_APCI_3120
+----------------------------------------------------------------------------+ static int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
| ANALOG OUTPUT SUBDEVICE |
+----------------------------------------------------------------------------+
*/
/*
+----------------------------------------------------------------------------+
| Function name :int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,|
|struct comedi_subdevice *s, struct comedi_insn *insn,unsigned int *data) |
| |
+----------------------------------------------------------------------------+
| Task : Write analog output |
| |
+----------------------------------------------------------------------------+
| Input Parameters : struct comedi_device *dev |
| struct comedi_subdevice *s |
| struct comedi_insn *insn |
| unsigned int *data |
+----------------------------------------------------------------------------+
| Return Value : |
| |
+----------------------------------------------------------------------------+
*/
int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
...@@ -2638,3 +2240,4 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, ...@@ -2638,3 +2240,4 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
return insn->n; return insn->n;
} }
#endif
...@@ -174,75 +174,3 @@ struct str_AnalogReadInformation { ...@@ -174,75 +174,3 @@ struct str_AnalogReadInformation {
unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; /* Gain of each channel */ unsigned int ui_RangeList[MAX_ANALOGINPUT_CHANNELS]; /* Gain of each channel */
}; };
/* Function Declaration For APCI-3120 */
/* Internal functions */
int i_APCI3120_SetupChannelList(struct comedi_device *dev, struct comedi_subdevice *s,
int n_chan, unsigned int *chanlist, char check);
int i_APCI3120_ExttrigEnable(struct comedi_device *dev);
int i_APCI3120_ExttrigDisable(struct comedi_device *dev);
int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
int i_APCI3120_Reset(struct comedi_device *dev);
int i_APCI3120_CyclicAnalogInput(int mode, struct comedi_device *dev,
struct comedi_subdevice *s);
/* Interrupt functions */
void v_APCI3120_Interrupt(int irq, void *d);
/* UPDATE-0.7.57->0.7.68 void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,struct comedi_subdevice *s,short *dma,short *data,int n); */
void v_APCI3120_InterruptDmaMoveBlock16bit(struct comedi_device *dev,
struct comedi_subdevice *s,
short *dma_buffer,
unsigned int num_samples);
int i_APCI3120_InterruptHandleEos(struct comedi_device *dev);
void v_APCI3120_InterruptDma(int irq, void *d);
/* TIMER */
int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/*
* DI for di read
*/
int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/* DO */
/* int i_APCI3120_WriteDigitalOutput(struct comedi_device *dev,
* unsigned char data);
*/
int i_APCI3120_InsnConfigDigitalOutput(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data);
int i_APCI3120_InsnBitsDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3120_InsnWriteDigitalOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/* AO */
/* int i_APCI3120_Write1AnalogValue(struct comedi_device *dev,UINT ui_Range,
* UINT ui_Channel,UINT data );
*/
int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
/* AI HArdware layer */
int i_APCI3120_InsnConfigAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int i_APCI3120_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd);
int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s);
/* int i_APCI3120_CancelAnalogInput(struct comedi_device *dev, struct comedi_subdevice *s); */
int i_APCI3120_StopCyclicAcquisition(struct comedi_device *dev, struct comedi_subdevice *s);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment