Input/Output
[EDT DMA Library]


Detailed Description

These functions are used to perform and control DMA transfers.


Functions

int edt_abort_current_dma (EdtDev *edt_p)
 Stops the current transfers, resets the ring buffer pointers to the next buffer.
int edt_abort_dma (EdtDev *edt_p)
 Stops any transfers currently in progress, resets the ring buffer pointers to restart on the current buffer.
unsigned int edt_allocated_size (EdtDev *edt_p, int bufnum)
 Gets the allocated size of the specified buffer.
unsigned char ** edt_buffer_addresses (EdtDev *edt_p)
 Returns an array containing the addresses of the ring buffers.
unsigned char * edt_check_for_buffers (EdtDev *edt_p, uint_t count)
 Checks whether the specified number of buffers have completed without blocking.
int edt_configure_block_buffers (EdtDev *edt_p, int bufsize, int numbufs, int write_flag, int header_size, int header_before)
 Configures the EDT device ring buffers.
int edt_configure_block_buffers_mem (EdtDev *edt_p, int bufsize, int numbufs, int write_flag, int header_size, int header_before, u_char *user_mem)
 Identical to edt_configure_block_buffers, with the additional parameter user_mem, which allows the user to specify a block of pre-allocated memory to use (Note: this does not work on Linux).
int edt_configure_ring_buffers (EdtDev *edt_p, int bufsize, int numbufs, int write_flag, unsigned char **bufarray)
 Configures the EDT device ring buffers.
int edt_disable_ring_buffers (EdtDev *edt_p)
 Disables the EDT device ring buffers.
int edt_do_timeout (EdtDev *edt_p)
 Causes the driver to perform the same actions as it would on a timeout (causing partially filled fifos to be flushed and dma to be aborted).
bufcnt_t edt_done_count (EdtDev *edt_p)
 Returns the cumulative count of completed buffer transfers in ring buffer mode.
void edt_enddma_action (EdtDev *edt_p, uint_t val)
 Specifies when to perform the action at the end of a dma transfer as specified by edt_enddma_reg.
void edt_enddma_reg (EdtDev *edt_p, uint_t desc, uint_t val)
 Sets the register and value to use at the end of dma, as set by edt_enddma_action.
int edt_get_burst_enable (EdtDev *edt_p)
 Returns the value of the burst enable flag, determining whether the DMA master transfers as many words as possible at once, or transfers them one at a time as soon as the data is acquired.
uint_t edt_get_bytecount (EdtDev *edt_p)
 OBSOLETE: Use edt_get_bufbytecount(edt_p, &bufnum) instead.
unsigned char * edt_get_current_dma_buf (EdtDev *edt_p)
 edt_current_dma_buf
unsigned short edt_get_direction (EdtDev *edt_p)
 Gets the value of the PCD_DIRA and PCD_DIRB registers.
int edt_get_goodbits (EdtDev *edt_p)
 Returns the current number of good bits in the last long word of a read buffer (0 through 31).
int edt_get_numbufs (EdtDev *edt_p)
 edt_get_numbufs
int edt_get_reftime (EdtDev *edt_p, u_int *timep)
 Gets the seconds and nanoseconds timestamp in the same format as the buffer_timed functions.
int edt_get_rtimeout (EdtDev *edt_p)
 Gets the current read timeout value: the number of milliseconds to wait for DMA reads to complete before returning.
uint_t edt_get_timeout_count (EdtDev *edt_p)
 Returns the number of bytes transferred at last timeout.
int edt_get_timeout_goodbits (EdtDev *edt_p)
 Returns the number of good bits in the last long word of a read buffer after the last timeout.
int edt_get_timestamp (EdtDev *edt_p, u_int *timep, u_int bufnum)
 Gets the seconds and nanoseconds timestamp of when dma was completed on the buffer specified by bufnum.
uint_t edt_get_todo (EdtDev *edt_p)
 Gets the number of buffers that the driver has been told to acquire.
int edt_get_total_bufsize (EdtDev *edt_p, int bufsize, int header_size)
 edt_get_total_bufsize
int edt_get_wtimeout (EdtDev *edt_p)
 Gets the current write timeout value: the number of milliseconds to wait for DMA writes to complete before returning.
unsigned char * edt_last_buffer (EdtDev *edt_p)
 Waits for the last buffer that has been transferred.
unsigned char * edt_last_buffer_timed (EdtDev *edt_p, u_int *timep)
 Like edt_last_buffer but also returns the time at which the DMA was complete on this buffer.
caddr_t edt_map_dmamem (EdtDev *edt_p)
unsigned char * edt_next_writebuf (EdtDev *edt_p)
 Returns a pointer to the next buffer scheduled for output DMA, in order to fill the buffer with data.
uint_t edt_next_writebuf_index (EdtDev *edt_p)
 Returns the index of the next buffer scheduled for output DMA, in order to fill the buffer with data.
int edt_read (EdtDev *edt_p, void *buf, uint_t size)
 Performs a read on the EDT Product.
void edt_read_end_action (EdtDev *edt_p, u_int enable, u_int reg_desc, u_char set, u_char clear, u_char setclear, u_char clearset, int delay1, int delay2)
 Enables an action where a specified register will be programmed with a specified value at the end of a dma read operation.
void edt_read_start_action (EdtDev *edt_p, u_int enable, u_int reg_desc, u_char set, u_char clear, u_char setclear, u_char clearset, int delay1, int delay2)
 Enables an action where a specified register will be programmed with a specified value at the start of a dma read operation.
int edt_ref_tmstamp (EdtDev *edt_p, u_int val)
 Causes application-defined events to show up in the same timeline as driver events when the event history is listed by running setdebug -g.
int edt_remove_event_func (EdtDev *edt_p, int event_type)
 Removes an event function previously set with edt_set_event_func.
int edt_reset_ring_buffers (EdtDev *edt_p, uint_t bufnum)
 Stops any DMA currently in progress, then resets the ring buffer to start the next DMA at bufnum.
int edt_ring_buffer_overrun (EdtDev *edt_p)
 Returns true (1) when DMA has wrapped around the ring buffer and overwritten the buffer which the application is about to access.
int edt_set_buffer (EdtDev *edt_p, uint_t bufnum)
 Sets which buffer should be started next.
int edt_set_buffer_physaddr (EdtDev *edt_p, uint_t index, uint64_t physaddr)
int edt_set_buffer_size (EdtDev *edt_p, uint_t which_buf, uint_t size, uint_t write_flag)
 Used to change the size or direction of one of the ring buffers.
int edt_set_burst_enable (EdtDev *edt_p, int on)
 Sets the burst enable flag, determining whether the DMA master transfers as many words as possible at once, or transfers them one at a time as soon as the data is acquired.
void edt_set_direction (EdtDev *edt_p, int direction)
 On PCD cards, sets DMA direction to read or write.
int edt_set_event_func (EdtDev *edt_p, int event_type, EdtEventFunc f, void *data, int continuous)
 Defines a function to call when an event occurs.
int edt_set_rtimeout (EdtDev *edt_p, int value)
 Sets the number of milliseconds for data read calls, such as edt_read, to wait for DMA to complete before returning.
int edt_set_timeout_action (EdtDev *edt_p, u_int action)
 Sets the driver behavior on a timeout.
int edt_set_wtimeout (EdtDev *edt_p, int value)
 Sets the number of milliseconds for data write calls, such as edt_write, to wait for DMA to complete before returning.
int edt_start_buffers (EdtDev *edt_p, uint_t count)
 Starts DMA to the specified number of buffers.
void edt_startdma_action (EdtDev *edt_p, uint_t val)
 Specifies when to perform the action at the start of a dma transfer as specified by edt_startdma_reg.
void edt_startdma_reg (EdtDev *edt_p, uint_t desc, uint_t val)
 Sets the register and value to use at the start of dma, as set by edt_startdma_action.
int edt_stop_buffers (EdtDev *edt_p)
 Stops DMA transfer after the current buffer has completed.
int edt_timeouts (EdtDev *edt_p)
 Returns the number of read and write timeouts that have occurred since the last call of edt_open.
unsigned char * edt_wait_buffers_timed (EdtDev *edt_p, int count, u_int *timep)
 Blocks until the specified number of buffers have completed with a pointer to the time the last buffer finished.
unsigned char * edt_wait_for_buffers (EdtDev *edt_p, int count)
 Blocks until the specified number of buffers have completed.
unsigned char * edt_wait_for_next_buffer (EdtDev *edt_p)
 Waits for the next buffer that finishes DMA.
int edt_write (EdtDev *edt_p, void *buf, uint_t size)
 Perform a write on the EDT Product.
void edt_write_end_action (EdtDev *edt_p, u_int enable, u_int reg_desc, u_char set, u_char clear, u_char setclear, u_char clearset, int delay1, int delay2)
 Enables an action where a specified register will be programmed with a specified value at the end of a dma write operation.
void edt_write_start_action (EdtDev *edt_p, u_int enable, u_int reg_desc, u_char set, u_char clear, u_char setclear, u_char clearset, int delay1, int delay2)
 Enables an action where a specified register will be programmed with a specified value at the start of a dma write operation.


Function Documentation

int edt_abort_current_dma ( EdtDev edt_p  ) 

Stops the current transfers, resets the ring buffer pointers to the next buffer.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
0 on sucess, -1 on error. If an error occurs, call edt_perror to get the system error message.
See also:
edt_abort_dma

Definition at line 6111 of file libedt.c.

int edt_abort_dma ( EdtDev edt_p  ) 

Stops any transfers currently in progress, resets the ring buffer pointers to restart on the current buffer.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
0 on sucess, -1 on error. If an error occurs, call edt_perror to get the system error message.
See also:
edt_abort_current_dma

Definition at line 6089 of file libedt.c.

unsigned int edt_allocated_size ( EdtDev edt_p,
int  buffer 
)

Gets the allocated size of the specified buffer.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
buffer the index of the buffer.
Returns:
The buffer size, in bytes, or 0 if the specified index is invalid.

Definition at line 2042 of file libedt.c.

unsigned char** edt_buffer_addresses ( EdtDev edt_p  ) 

Returns an array containing the addresses of the ring buffers.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
An array of pointers to the ring buffers allocated by the driver or the library. The array is indexed from zero to n-1 where n is the number of ring buffers set in edt_configure_ring_buffers.

Definition at line 2295 of file libedt.c.

unsigned char* edt_check_for_buffers ( EdtDev edt_p,
uint_t  count 
)

Checks whether the specified number of buffers have completed without blocking.

Parameters:
edt_p pointer to edt device structure returned by edt_open
count number of buffers. Must be 1 or greater. Four is recommended.
Returns:
Returns the address of the ring buffer corresponding to count if it has completed DMA, or NULL if count buffers are not yet complete.
Note:
If the ring buffer is in free-running mode and the application cannot process data as fast as it is acquired, DMA will wrap around and overwrite the referenced buffer. The application must ensure that the data in the buffer is processed or copied out in time to prevent overrun.

Definition at line 2837 of file libedt.c.

int edt_configure_block_buffers ( EdtDev edt_p,
int  bufsize,
int  numbufs,
int  write_flag,
int  header_size,
int  header_before 
)

Configures the EDT device ring buffers.

Any previous configuration is replaced, and previously allocated buffers are released. Buffers are normally allocated and maintained within the EDT device library (bufarray = NULL).

Note:
bufarray can alternately point to an array of user buffers which will be used instead of the internally allocated ones, however it will fail (possibly with a system crash) if the system has more than 4 GBytes of memory. Since > 4 GBytes is becoming ubiquitous, providing user buffers has effectively been deprecated. The argument remains in order to maintain code constency, nevertheless EDT can not provide support for any applications that provide a non-NULL argument in bufarray.
Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
bufsize size of each buffer, in bytes. For optimal efficiency, allocate a value approximating throughput divided by 20: that is, if transfer occurs at 20 MB per second, allocate 1 MB per buffer. Buffers significantly larger or smaller can overuse memory or lock the system up in processing interrupts at this speed.
numbufs number of buffers. Must be 1 or greater. Four is recommended for most applications.
write_flag Indicates whether this connection is to be used for input or output. Only one direction is possible per device or subdevice at any given time:
  • EDT_READ = 0
  • EDT_WRITE = 1
bufarray If NULL, the library will allocate a set of page-aligned ring buffers. If not null (Deprecated -- see note above) this argument is an array of pointers to application-allocated and page aligned buffers (use edt_alloc to allocate page alligned buffers); these buffers must match the size and number of buffers specified in this call and will be used as the ring buffers.
Returns:
0 on success, -1 on error. If all buffers cannot be allocated, none are allocated and an error is returned. Call edt_perror to get the system error message.

Definition at line 1866 of file libedt.c.

int edt_configure_block_buffers_mem ( EdtDev edt_p,
int  bufsize,
int  numbufs,
int  write_flag,
int  header_size,
int  header_before,
u_char *  user_mem 
)

Identical to edt_configure_block_buffers, with the additional parameter user_mem, which allows the user to specify a block of pre-allocated memory to use (Note: this does not work on Linux).

Users are encourage to use edt_configure_block_buffers rather than this function, as that function handles allocation of memory and works on all systems.

Definition at line 1760 of file libedt.c.

int edt_configure_ring_buffers ( EdtDev edt_p,
int  bufsize,
int  numbufs,
int  write_flag,
unsigned char **  bufarray 
)

Configures the EDT device ring buffers.

Any previous configuration is replaced, and previously allocated buffers are released. Buffers are normally allocated and maintained within the EDT device library (bufarray = NULL).

Note:
bufarray can alternately point to an array of user buffers which will be used instead of the internally allocated ones, however it will fail (possibly with a system crash) if the system has more than 4 GBytes of memory. Since > 4 GBytes is becoming ubiquitous, providing user buffers has effectively been deprecated. The argument remains in order to maintain code constency, nevertheless EDT can not provide support for any applications that provide a non-NULL argument in bufarray.
Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
bufsize size of each buffer, in bytes. For optimal efficiency, allocate a value approximating throughput divided by 20: that is, if transfer occurs at 20 MB per second, allocate 1 MB per buffer. Buffers significantly larger or smaller can overuse memory or lock the system up in processing interrupts at this speed.
numbufs number of buffers. Must be 1 or greater. Four is recommended for most applications.
write_flag Indicates whether this connection is to be used for input or output. Only one direction is possible per device or subdevice at any given time:
  • EDT_READ = 0
  • EDT_WRITE = 1
bufarray If NULL, the library will allocate a set of page-aligned ring buffers. If not null (Deprecated -- see note above) this argument is an array of pointers to application-allocated and page aligned buffers (use edt_alloc to allocate page alligned buffers); these buffers must match the size and number of buffers specified in this call and will be used as the ring buffers.
Returns:
0 on success, -1 on error. If all buffers cannot be allocated, none are allocated and an error is returned. Call edt_perror to get the system error message.

Definition at line 1742 of file libedt.c.

int edt_disable_ring_buffers ( EdtDev edt_p  ) 

Disables the EDT device ring buffers.

Pending DMA is cancelled and all buffers are released.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
0 on success, -1 on error. If an error occurs, call edt_perror to get the system error message.

Definition at line 1955 of file libedt.c.

int edt_do_timeout ( EdtDev edt_p  ) 

Causes the driver to perform the same actions as it would on a timeout (causing partially filled fifos to be flushed and dma to be aborted).

Used when the application has knowledge that no more data will be sent/accepted. Used when a common timeout cannot be known, such as when acquiring data from a telescope ccd array where the amount of data sent depends on unknown future celestial events. Also used by the library when the operating system can not otherwise wait for an interrupt and timeout at the same time.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
0 on success; -1 on failure
See also:
ring buffer discussion

Definition at line 2459 of file libedt.c.

bufcnt_t edt_done_count ( EdtDev edt_p  ) 

Returns the cumulative count of completed buffer transfers in ring buffer mode.

Parameters:
edt_p pointer to edt device structure returned by edt_open
Returns:
The number of completed buffer transfers. Completed buffers are numbered consecutively starting with 0 when edt_configure_ring_buffers is invoked. The index of the ring buffer most recently completed by the driver equals the number returned modulo the number of ring buffers. -1 is returned if ring buffer mode is not configured. If an error occurs, call edt_perror to get the system error message.

Definition at line 2870 of file libedt.c.

void edt_enddma_action ( EdtDev edt_p,
uint_t  val 
)

Specifies when to perform the action at the end of a dma transfer as specified by edt_enddma_reg.

A common use of this is to write to a register which signals an external device that dma is complete, or to change the state of a signal which will be changed at the start of dma, so the external device can look for an edge. The default is no end of dma action. Most applications can set the output signal, if needed, from the application with edt_reg_write. This routine is only needed if the action must happen within microseconds of the end of dma.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
val One of EDT_ACT_NEVER, EDT_ACT_ONCE, or EDT_ACT_ALWAYS
Example
 u_int fnct_value=0x1;
 edt_enddma_action(edt_p, EDT_ACT_ALWAYS);
 edt_enddma_reg(edt_p, PCD_FUNCT, fnct_value);

See also:
edt_startdma_action, edt_startdma_reg, edt_reg_write, edt_reg_read

Definition at line 3246 of file libedt.c.

void edt_enddma_reg ( EdtDev edt_p,
uint_t  desc,
uint_t  val 
)

Sets the register and value to use at the end of dma, as set by edt_enddma_action.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
desc register description of which register to use as in edtreg.h.
val value to write
See also:
edt_enddma_action for example

Definition at line 3296 of file libedt.c.

int edt_get_burst_enable ( EdtDev edt_p  ) 

Returns the value of the burst enable flag, determining whether the DMA master transfers as many words as possible at once, or transfers them one at a time as soon as the data is acquired.

Burst transfers are enabled by default to optimize use of the bus. For more information, see edt_set_burst_enable.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
A value of 1 if burst transfers are enabled; 0 otherwise.

Definition at line 3776 of file libedt.c.

uint_t edt_get_bytecount ( EdtDev edt_p  ) 

OBSOLETE: Use edt_get_bufbytecount(edt_p, &bufnum) instead.

Obsoleted 04/2013 in favor of edt_get_buf_bytecount since it fails to identify offset and buffer atomically.

Returns the number of bytes read so far into the current buffer. Can be used to monitor how much data has been read into the buffer during acquisition.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
The number of bytes transferred, as described above.

Definition at line 4196 of file libedt.c.

unsigned char* edt_get_current_dma_buf ( EdtDev edt_p  ) 

edt_current_dma_buf

Returns the address of the current active DMA buffer, for linescan cameras where the buffer is only partially filled. Note there is a possible error if this is called with normal DMA that doesn't time out, because the "current" buffer may change between a call to this function and the pointer's access.

Parameters:
edt_p,: device handle returned from edt_open

Definition at line 2793 of file libedt.c.

unsigned short edt_get_direction ( EdtDev edt_p  ) 

Gets the value of the PCD_DIRA and PCD_DIRB registers.

The value from PCD_DIRB is shifted up 8 bits.

Definition at line 4230 of file libedt.c.

int edt_get_goodbits ( EdtDev edt_p  ) 

Returns the current number of good bits in the last long word of a read buffer (0 through 31).

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
Number 0-31 representing the number of good bits in the last 32-bit word of the current read buffer.

Definition at line 5106 of file libedt.c.

int edt_get_numbufs ( EdtDev edt_p  ) 

edt_get_numbufs

returns the number of buffers allocated even if by other process (for monitoring from a separate call to edt_open)

Definition at line 1117 of file libedt.c.

int edt_get_reftime ( EdtDev edt_p,
u_int *  timep 
)

Gets the seconds and nanoseconds timestamp in the same format as the buffer_timed functions.

Used for debugging and coordinating dma completion time with other events.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
timep pointer to an unsigned integer array
Example
 int timestamp[2];
 edt_get_reftime(edt_p, timestamp);

Returns:
0 on success, -1 on failure. Fills in timestamp pointed to by timep.
See also:
edt_timestamp, edt_done_count, edt_wait_buffers_timed

Definition at line 6762 of file libedt.c.

int edt_get_rtimeout ( EdtDev edt_p  ) 

Gets the current read timeout value: the number of milliseconds to wait for DMA reads to complete before returning.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
The number of milliseconds in the current read timeout period.

Definition at line 4630 of file libedt.c.

uint_t edt_get_timeout_count ( EdtDev edt_p  ) 

Returns the number of bytes transferred at last timeout.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
The number of bytes transferred at last timeout.

Definition at line 4216 of file libedt.c.

int edt_get_timeout_goodbits ( EdtDev edt_p  ) 

Returns the number of good bits in the last long word of a read buffer after the last timeout.

This routine is called after a timeout, if the timeout action is set to EDT_TIMEOUT_BIT_STROBE. (See edt_set_timeout_action.)

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
Number 0-31 represents the number of good bits in the last 32-bit word of the read buffer associated with the last timeout.

Definition at line 5076 of file libedt.c.

int edt_get_timestamp ( EdtDev edt_p,
u_int *  timep,
u_int  bufnum 
)

Gets the seconds and nanoseconds timestamp of when dma was completed on the buffer specified by bufnum.

bufnum is moduloed by the number of buffers in the ring buffer, so it can either be an index, or the number of buffers completed.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
timep pointer to an unsigned integer array;
bufnum buffer index, or number of buffers completed
Example
 int timestamp[2];
 u_int bufnum=edt_done_count(edt_p);
 edt_get_timestamp(edt_p, timestamp, bufnum);

Returns:
0 on success, -1 on failure. Fills in timestamp pointed to by timep.

Definition at line 2661 of file libedt.c.

uint_t edt_get_todo ( EdtDev edt_p  ) 

Gets the number of buffers that the driver has been told to acquire.

This allows an application to know the state of the ring buffers within an interrupt, timeout, or when cleaning up on close. It also allows the application to know how close it is getting behind the acquisition. It is not normally needed.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
 int curdone;
 int curtodo;
 curdone = edt_done_count(edt_p);
 curtodo = edt_get_todo(edt_p);
 // curtodo - curdone is how close the DMA is to catching up with our
 // processing

Returns:
Number of buffers started via edt_start_buffers.
See also:
edt_done_count, edt_start_buffers, edt_wait_for_buffers

Definition at line 6710 of file libedt.c.

int edt_get_total_bufsize ( EdtDev edt_p,
int  bufsize,
int  header_size 
)

edt_get_total_bufsize

returns the total buffer size for block of buffers, in which the memory allocation size is rounded up so all buffers start on a page boundary. This is used to allocate a single contiguous block of DMA buffers.

Definition at line 1679 of file libedt.c.

int edt_get_wtimeout ( EdtDev edt_p  ) 

Gets the current write timeout value: the number of milliseconds to wait for DMA writes to complete before returning.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
The number of milliseconds in the current write timeout period.

Definition at line 4650 of file libedt.c.

unsigned char* edt_last_buffer ( EdtDev edt_p  ) 

Waits for the last buffer that has been transferred.

This is useful if the application cannot keep up with buffer transfer. If this routine is called for a second time before another buffer has been transferred, it will block waiting for the next transfer to complete.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
Address of the image.
See also:
edt_wait_for_buffers, edt_last_buffer_timed

Definition at line 2354 of file libedt.c.

unsigned char* edt_last_buffer_timed ( EdtDev edt_p,
u_int *  timep 
)

Like edt_last_buffer but also returns the time at which the DMA was complete on this buffer.

timep should point to an array of two unsigned integers which will be filled in with the seconds and nanoseconds of the time the buffer was finished being transferred.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
timep pointer to an unsigned integer array
Example
 u_int timestamp [2];
 u_char *buf;
 buf = edt_last_buffer_timed(edt_p, timestamp);

Returns:
Address of the image.
See also:
edt_wait_for_buffers, edt_last_buffer, edt_wait_buffers_timed

Definition at line 2398 of file libedt.c.

unsigned char* edt_next_writebuf ( EdtDev edt_p  ) 

Returns a pointer to the next buffer scheduled for output DMA, in order to fill the buffer with data.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
A pointer to the buffer, or NULL on failure.
See also:
edt_next_writebuf_index

Definition at line 2249 of file libedt.c.

uint_t edt_next_writebuf_index ( EdtDev edt_p  ) 

Returns the index of the next buffer scheduled for output DMA, in order to fill the buffer with data.

Increments the next buffer index, so subsequent calls to edt_next_writebuf will return subsequent buffers.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
Index of the buffer, as returned by edt_buffer_addresses, or -1 on failure. If an error occurs, call edt_perror to get the system error message.

Index of the buffer, as returned by edt_buffer_addresses.

Definition at line 2274 of file libedt.c.

int edt_read ( EdtDev edt_p,
void *  buf,
uint_t  size 
)

Performs a read on the EDT Product.

For those on UNIX systems, the UNIX 2 GB file offset bug is avoided during large amounts of input or output, that is, reading past 2^31 bytes does not fail. This call is not multibuffering, and no transfer is active when it completes.

Parameters:
edt_p pointer to edt device structure returned by edt_open
buf address of buffer to read into
size size of read in bytes
Returns:
The return value from read, normally the number of bytes read; -1 is returned in case of error. Call edt_perror to get the system error message.
Note:
If using timeouts, call edt_timeouts after edt_read returns to see if the number of timeouts has incremented. If it has incremented, call edt_get_timeout_count to get the number of bytes transferred into the buffer.

Definition at line 2104 of file libedt.c.

void edt_read_end_action ( EdtDev edt_p,
u_int  enable,
u_int  reg_desc,
u_char  set,
u_char  clear,
u_char  setclear,
u_char  clearset,
int  delay1,
int  delay2 
)

Enables an action where a specified register will be programmed with a specified value at the end of a dma read operation.

Enabled with EDT_ACT_ALWAYS and disabled with EDT_ACT_NEVER passed to the enable argument. A common use of this is to write to a register which signals an external device that dma has ended to notify the device to stop sending.

This routine is intended to work with edt_read(). It will not work well ring buffers since sequential dma operations are pipelined in hardware in the EDT dma engine.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
enable EDT_ACT_ALWAYS to enable, EDT_ACT_NEVER to disable.
reg_desc Register access description code.
set Register bits to be set.
clear Register bits to be cleared.
setclear Register value to be toggled up then down.
clearset Register value to be toggled down then up.
Example
 edt_read_end_action(edt_p, EDT_ACT_ALWAYS, PCD_FUNCT, 0x8F, 0, 0x10, 0);
 edt_read_end_action(edt_p, EDT_ACT_NEVER, dummy, dummy, dummy, dummy);

See also:
edt_read_start_action(), edt_write_start_action(), edt_write_end_action()

Definition at line 3393 of file libedt.c.

void edt_read_start_action ( EdtDev edt_p,
u_int  enable,
u_int  reg_desc,
u_char  set,
u_char  clear,
u_char  setclear,
u_char  clearset,
int  delay1,
int  delay2 
)

Enables an action where a specified register will be programmed with a specified value at the start of a dma read operation.

Enabled with EDT_ACT_ALWAYS and disabled with EDT_ACT_NEVER passed to the enable argument. A common use of this is to write to a register which signals an external device that dma has started, to trigger the device to start sending.

This routine is intended to work with edt_read(). It will not work well ring buffers since sequential dma operations are pipelined in hardware in the EDT dma engine.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
enable EDT_ACT_ALWAYS to enable, EDT_ACT_NEVER to disable.
reg_desc Register access description code.
set Register bits to be set.
clear Register bits to be cleared.
setclear Register value to be toggled up then down.
clearset Register value to be toggled down then up.
Example
 edt_read_start_action(edt_p, EDT_ACT_ALWAYS, PCD_FUNCT, 0x8F, 0, 0x10, 0);
 edt_read_start_action(edt_p, EDT_ACT_NEVER, dummy, dummy, dummy, dummy);

See also:
edt_read_end_action(), edt_write_start_action(), edt_write_end_action()

Definition at line 3342 of file libedt.c.

int edt_ref_tmstamp ( EdtDev edt_p,
u_int  val 
)

Causes application-defined events to show up in the same timeline as driver events when the event history is listed by running setdebug -g.

This is useful for debugging.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
val an arbitrary value meaningful to the application
Example
 #define BEFORE_WAIT 0x1212aaaa
 #define AFTER_WAIT 0x3434bbbb
 u_char *buf;
 edt_ref_tmstamp(edt_p, BEFORE_WAIT);
 buf=edt_wait_for_buffer(edt_p);
 edt_ref_tmstamp(edt_p, AFTER_WAIT);

 // now look at output of setdebug -g and you'll see something like:

 // 0: 0001ca0 REFTMSTAMP           : 1212aaaa      324.422071 (0.004189)
 // ... other events from edt_wait_for_buffer() shown, like START_BUF, SETUP_DMA, FLUSH, etc
 // 0: 0001d08 REFTMSTAMP           : 3434bbbb        324.518885 (0.000045)

Returns:
0 on success, -1 on failure
See also:
setdebug --help

Definition at line 6443 of file libedt.c.

int edt_remove_event_func ( EdtDev edt_p,
int  event_type 
)

Removes an event function previously set with edt_set_event_func.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
event_type The event that causes the function to be called. Valid events are as listed in edt_set_event_func.
Returns:
0 on success, -1 on failure. If an error occurs, call edt_perror to get the system error message.

Definition at line 5932 of file libedt.c.

int edt_reset_ring_buffers ( EdtDev edt_p,
uint_t  bufnum 
)

Stops any DMA currently in progress, then resets the ring buffer to start the next DMA at bufnum.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
bufnum The index of the ring buffer at which to start the next DMA. A number larger than the number of buffers set up sets the current done count to the number supplied modulo the number of buffers.
Returns:
0 on success; -1 on error. If an error occurs, call edt_perror to get the system error message.

Definition at line 6057 of file libedt.c.

int edt_ring_buffer_overrun ( EdtDev edt_p  ) 

Returns true (1) when DMA has wrapped around the ring buffer and overwritten the buffer which the application is about to access.

Returns false (0) otherwise.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
1(true) when overrun has occurred, 0(false) otherwise.

Definition at line 6130 of file libedt.c.

int edt_set_buffer ( EdtDev edt_p,
uint_t  bufnum 
)

Sets which buffer should be started next.

Usually done to recover after a timeout, interrupt, or error.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
bufnum the index of the buffer to start next.
Example
 u_int curdone;
 edt_stop_buffers(edt_p);
 curdone = edt_done_count(edt_p);
 edt_set_buffer(edt_p, curdone);

Returns:
0 on success, -1 on failure.
See also:
edt_stop_buffers, edt_done_count, edt_get_todo

Definition at line 2074 of file libedt.c.

int edt_set_buffer_size ( EdtDev edt_p,
uint_t  index,
uint_t  size,
uint_t  write_flag 
)

Used to change the size or direction of one of the ring buffers.

Almost never used. Mixing directions requires detailed knowledge of the interface since pending preloaded DMA transfers need to be coordinated with the interface fifo direction. For example, a dma write will complete when the data is in the output fifo, but the dma read should not be started until the data is out to the external device. Most applications requiring fast mixed reads/writes have worked out more cleanly using seperate, simultaneous, read and write dma transfers using different dma channels.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
index index of ring buffer to change
size size to change it to
write_flag direction
Example
 u_int bufnum=3;
 u_int bsize=1024;
 u_int dirflag=EDT_WRITE;
 int ret;
 ret=edt_set_buffer_size(edt_p, bufnum, bsize, dirflag);

Returns:
0 on success, -1 on failure
See also:
edt_open_channel, rdpcd8.c, rd16.c, rdssdio.c, wrssdio.c

Definition at line 6592 of file libedt.c.

int edt_set_burst_enable ( EdtDev edt_p,
int  onoff 
)

Sets the burst enable flag, determining whether the DMA master transfers as many words as possible at once, or transfers them one at a time as soon as the data is acquired.

Burst transfers are enabled by default to optimize use of the bus; however, you may wish to disable them if data latency is an issue, or for diagnosing DMA problems.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
onoff a value of 1 turns the flag on (the default); 0 turns it off.

Definition at line 3756 of file libedt.c.

void edt_set_direction ( EdtDev edt_p,
int  direction 
)

On PCD cards, sets DMA direction to read or write.

Most users will not need to use this function, but instead can just set the direction when calling edt_configure_ring_buffers.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
direction one of EDT_READ or EDT_WRITE

Definition at line 4271 of file libedt.c.

int edt_set_event_func ( EdtDev edt_p,
int  event_type,
EdtEventFunc  func,
void *  data,
int  continuous 
)

Defines a function to call when an event occurs.

Use this routine to send an application-specific function when required; for example, when DMA completes, allowing the application to continue executing until the event of interest occurs.

If you wish to receive notification of one event only, and then disable further event notification, send a final argument of 0 (see the continue parameter described below). This disables event notification at the time of the callback to your function.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
event_type The event that causes the function to be called. Valid events are:
EventDescriptionBoard
EDT_PDV_EVENT_ACQUIRE Image has been acquired; shutter has closed;
subject can be moved if necessary; DMA will now restart
PCI DV, PCI DVK, PCI FOI
EDT_PDV_EVENT_FVAL Frame Valid line is set PCI DV, PCI DVK
EDT_EVENT_P16D_DINT Device interrupt occurred PCI 16D
EDT_EVENT_P11W_ATTN Attention interrupt occurred PCI 11W
EDT_EVENT_P11W_CNT Count interrupt occurred PCI 11W
EDT_EVENT_PCD_STAT1 Interrupt occurred on Status 1 line PCI CD
EDT_EVENT_PCD_STAT2 Interrupt occurred on Status 2 line PCI CD
EDT_EVENT_PCD_STAT3 Interrupt occurred on Status 3 line PCI CD
EDT_EVENT_PCD_STAT4 Interrupt occurred on Status 4 line PCI CD
EDT_EVENT_ENDDMA DMA has completed ALL
func The function you've defined to call when the event occurs.
data Pointer to data block (if any) to send to the function as an argument; usually edt_p.
continuous Flag to enable or disable continued event notification. A value of 0 causes an implied edt_remove_event_func as the event is triggered.
Returns:
0 on success, -1 on failure. If an error occurs, call edt_perror to get the system error message.

int edt_set_rtimeout ( EdtDev edt_p,
int  value 
)

Sets the number of milliseconds for data read calls, such as edt_read, to wait for DMA to complete before returning.

A value of 0 causes the I/O operation to wait forever--that is, to block on a read. edt_set_rtimeout affects edt_wait_for_buffers and edt_read.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
value The number of milliseconds in the timeout period.
Returns:
0 on success; -1 on error

Definition at line 4590 of file libedt.c.

int edt_set_timeout_action ( EdtDev edt_p,
u_int  action 
)

Sets the driver behavior on a timeout.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
action integer configures the any action taken on a timeout. Definitions:
  • EDT_TIMEOUT_NULL no extra action taken
  • EDT_TIMEOUT_BIT_STROBE flush any valid bits left in input circuits of SSDIO.
Returns:
0 on success, -1 on failure.

Definition at line 5047 of file libedt.c.

int edt_set_wtimeout ( EdtDev edt_p,
int  value 
)

Sets the number of milliseconds for data write calls, such as edt_write, to wait for DMA to complete before returning.

A value of 0 causes the I/O operation to wait forever--that is, to block on a write. edt_set_wtimeout affects edt_wait_for_buffers and edt_write.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
value The number of milliseconds in the timeout period.
Returns:
0 on success; -1 on error. If an error occurs, call edt_perror to get the system error message.

Definition at line 4612 of file libedt.c.

int edt_start_buffers ( EdtDev edt_p,
uint_t  count 
)

Starts DMA to the specified number of buffers.

If you supply a number greater than the number of buffers set up, DMA continues looping through the buffers until the total count has been satisfied.

Parameters:
edt_p pointer to edt device structure returned by edt_open
count Number of buffers to release to the driver for transfer. An argument of 0 puts the driver in free running mode, and transfers run continuously until edt_stop_buffers is called.
Returns:
0 on success, -1 on error. If an error occurs, call edt_perror to get the system error message.

Definition at line 2013 of file libedt.c.

void edt_startdma_action ( EdtDev edt_p,
uint_t  val 
)

Specifies when to perform the action at the start of a dma transfer as specified by edt_startdma_reg.

A common use of this is to write to a register which signals an external device that dma has started, to trigger the device to start sending. The default is no dma action. The PDV library uses this function to send a trigger to a camera at the start of dma. This function allows the register write to occur in a critical section with the start of dma and at the same time.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
val One of EDT_ACT_NEVER, EDT_ACT_ONCE, or EDT_ACT_ALWAYS
Example
 edt_startdma_action(edt_p, EDT_ACT_ALWAYS);
 edt_startdma_reg(edt_p, PDV_CMD, PDV_ENABLE_GRAB);

See also:
edt_startdma_reg, edt_reg_write, edt_reg_read

Definition at line 3210 of file libedt.c.

void edt_startdma_reg ( EdtDev edt_p,
uint_t  desc,
uint_t  val 
)

Sets the register and value to use at the start of dma, as set by edt_startdma_action.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
desc register description of which register to use as in edtreg.h.
val value to write
Example
 edt_startdma_action(edt_p, EDT_ACT_ALWAYS);
 edt_startdma_reg(edt_p, PDV_CMD, PDV_ENABLE_GRAB);

See also:
edt_startdma_action

Definition at line 3271 of file libedt.c.

int edt_stop_buffers ( EdtDev edt_p  ) 

Stops DMA transfer after the current buffer has completed.

Ring buffer mode remains active, and transfers will be continued by calling edt_start_buffers.

Parameters:
edt_p pointer to edt device structure returned by edt_open
Returns:
0 on success, -1 on failure. If an error occurs, call edt_perror to get the system error message.

Definition at line 6030 of file libedt.c.

int edt_timeouts ( EdtDev edt_p  ) 

Returns the number of read and write timeouts that have occurred since the last call of edt_open.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
The number of read and write timeouts that have occurred since the last call of edt_open.

Definition at line 4471 of file libedt.c.

unsigned char* edt_wait_buffers_timed ( EdtDev edt_p,
int  count,
u_int *  timep 
)

Blocks until the specified number of buffers have completed with a pointer to the time the last buffer finished.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
count buffer number for which to block. Completed buffers are numbered cumulatively starting with 0 when the EDT Product is opened.
timep pointer to an array of two unsigned integers. The first integer is seconds, the next integer is nanoseconds representing the system time at which the buffer completed.
Returns:
Address of last completed buffer on success; NULL on error. If an error occurs, call edt_perror to get the system error message.
Note:
If the ring buffer is in free-running mode and the application cannot process data as fast as it is acquired, DMA will wrap around and overwrite the referenced buffer . The application must ensure that the data in the buffer is processed or copied out in time to prevent overrun.

Definition at line 2323 of file libedt.c.

unsigned char* edt_wait_for_buffers ( EdtDev edt_p,
int  count 
)

Blocks until the specified number of buffers have completed.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel count: how many buffers to block for
count How many buffers to block for. Completed buffers are numbered relatively; start each call with 1.
Returns:
Address of last completed buffer on success; NULL on error. If an error occurs, call edt_perror to get the system error message.
Note:
If using timeouts, call edt_timeouts after edt_wait_for_buffers returns to see if the number of timeouts has incremented. If it has incremented, call edt_get_timeout_count to get the number of bytes transferred into the buffer. DMA does not automatically continue on to the next buffer, so you need to call edt_start_buffers to move on to the next buffer in the ring.

If the ring buffer is in free-running mode and the application cannot process data as fast as it is acquired, DMA will wrap around and overwrite the referenced buffer. The application must ensure that the data in the buffer is processed or copied out in time to prevent overrun.

Definition at line 2519 of file libedt.c.

unsigned char* edt_wait_for_next_buffer ( EdtDev edt_p  ) 

Waits for the next buffer that finishes DMA.

Depending on how often this routine is called, buffers that have already completed DMA might be skipped.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
Returns:
Returns a pointer to the buffer, or NULL on failure. If an error occurs, call edt_perror to get the system error message.

Definition at line 2706 of file libedt.c.

int edt_write ( EdtDev edt_p,
void *  buf,
uint_t  size 
)

Perform a write on the EDT Product.

For those on UNIX systems, the UNIX 2 GB file offset bug is avoided during large amounts of input or output; that is, writing past 2^31 bytes does not fail. This call is not multibuffering, and no transfer is active when it completes.

Parameters:
edt_p pointer to edt device structure returned by edt_open
buf address of buffer to write from
size size of write in bytes
Returns:
The return value from write; -1 is returned in case of error. Call edt_perror to get the system error message.
Note:
If using timeouts, call edt_timeouts after edt_write returns to see if the number of timeouts has incremented. If it has incremented, call edt_get_timeout_count to get the number of bytes transferred into the buffer. DMA does not automatically continue on to the next buffer, so you need to call edt_start_buffers to move on to the next buffer in the ring.

Definition at line 2174 of file libedt.c.

void edt_write_end_action ( EdtDev edt_p,
u_int  enable,
u_int  reg_desc,
u_char  set,
u_char  clear,
u_char  setclear,
u_char  clearset,
int  delay1,
int  delay2 
)

Enables an action where a specified register will be programmed with a specified value at the end of a dma write operation.

Enabled with EDT_ACT_ALWAYS and disabled with EDT_ACT_NEVER passed to the enable argument. A common use of this is to write to a register which signals an external device that dma has ended to notify the device to stop sending.

This routine is intended to work with edt_write(). It will not work well ring buffers since sequential dma operations are pipelined in hardware in the EDT dma engine.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
enable EDT_ACT_ALWAYS to enable, EDT_ACT_NEVER to disable.
reg_desc Register access description code.
set Register bits to be set.
clear Register bits to be cleared.
setclear Register value to be toggled up then down.
clearset Register value to be toggled down then up.
Example
 edt_write_end_action(edt_p, EDT_ACT_ALWAYS, PCD_FUNCT, 0x8F, 0, 0x10, 0);
 edt_write_end_action(edt_p, EDT_ACT_NEVER, dummy, dummy, dummy, dummy);

See also:
edt_write_start_action(), edt_read_start_action(), edt_read_end_action()

Definition at line 3495 of file libedt.c.

void edt_write_start_action ( EdtDev edt_p,
u_int  enable,
u_int  reg_desc,
u_char  set,
u_char  clear,
u_char  setclear,
u_char  clearset,
int  delay1,
int  delay2 
)

Enables an action where a specified register will be programmed with a specified value at the start of a dma write operation.

Enabled with EDT_ACT_ALWAYS and disabled with EDT_ACT_NEVER passed to the enable argument. A common use of this is to write to a register which signals an external device that dma has started, to trigger the device to start sending.

This routine is intended to work with edt_write(). It will not work well ring buffers since sequential dma operations are pipelined in hardware in the EDT dma engine.

Parameters:
edt_p pointer to edt device structure returned by edt_open or edt_open_channel
enable EDT_ACT_ALWAYS to enable, EDT_ACT_NEVER to disable.
reg_desc Register access description code.
set Register bits to be set.
clear Register bits to be cleared.
setclear Register value to be toggled up then down.
clearset Register value to be toggled down then up.
Example
 edt_write_start_action(edt_p, EDT_ACT_ALWAYS, PCD_FUNCT, 0x8F, 0, 0x10, 0);
 edt_write_start_action(edt_p, EDT_ACT_NEVER, dummy, dummy, dummy, dummy);

See also:
edt_write_end_action(), edt_read_start_action(), edt_read_end_action()

Definition at line 3444 of file libedt.c.


Generated on 19 Jun 2015 by  doxygen 1.4.7