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. |
int edt_abort_current_dma | ( | EdtDev * | edt_p | ) |
Stops the current transfers, resets the ring buffer pointers to the next buffer.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
int edt_abort_dma | ( | EdtDev * | edt_p | ) |
Stops any transfers currently in progress, resets the ring buffer pointers to restart on the current buffer.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
unsigned int edt_allocated_size | ( | EdtDev * | edt_p, | |
int | buffer | |||
) |
Gets the allocated size of the specified buffer.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
buffer | the index of the buffer. |
unsigned char** edt_buffer_addresses | ( | EdtDev * | edt_p | ) |
Returns an array containing the addresses of the ring buffers.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
unsigned char* edt_check_for_buffers | ( | EdtDev * | edt_p, | |
uint_t | count | |||
) |
Checks whether the specified number of buffers have completed without blocking.
edt_p | pointer to edt device structure returned by edt_open | |
count | number of buffers. Must be 1 or greater. Four is recommended. |
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).
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:
| |
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. |
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.
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).
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:
| |
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. |
int edt_disable_ring_buffers | ( | EdtDev * | edt_p | ) |
Disables the EDT device ring buffers.
Pending DMA is cancelled and all buffers are released.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
Returns the cumulative count of completed buffer transfers in ring buffer mode.
edt_p | pointer to edt device structure returned by edt_open |
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.
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 |
u_int fnct_value=0x1; edt_enddma_action(edt_p, EDT_ACT_ALWAYS); edt_enddma_reg(edt_p, PCD_FUNCT, fnct_value);
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.
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 |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p,: | device handle returned from edt_open |
unsigned short edt_get_direction | ( | EdtDev * | edt_p | ) |
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).
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
int edt_get_numbufs | ( | EdtDev * | edt_p | ) |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
timep | pointer to an unsigned integer array |
int timestamp[2]; edt_get_reftime(edt_p, timestamp);
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
uint_t edt_get_timeout_count | ( | EdtDev * | edt_p | ) |
Returns the number of bytes transferred at last timeout.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.)
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
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 |
int timestamp[2]; u_int bufnum=edt_done_count(edt_p); edt_get_timestamp(edt_p, timestamp, bufnum);
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.
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
int edt_get_total_bufsize | ( | EdtDev * | edt_p, | |
int | bufsize, | |||
int | header_size | |||
) |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
timep | pointer to an unsigned integer array |
u_int timestamp [2]; u_char *buf; buf = edt_last_buffer_timed(edt_p, timestamp);
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
Index of the buffer, as returned by edt_buffer_addresses.
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.
edt_p | pointer to edt device structure returned by edt_open | |
buf | address of buffer to read into | |
size | size of read in bytes |
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.
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. |
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);
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.
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. |
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);
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
val | an arbitrary value meaningful to the application |
#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)
int edt_remove_event_func | ( | EdtDev * | edt_p, | |
int | event_type | |||
) |
Removes an event function previously set with edt_set_event_func.
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. |
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.
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. |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
bufnum | the index of the buffer to start next. |
u_int curdone; edt_stop_buffers(edt_p); curdone = edt_done_count(edt_p); edt_set_buffer(edt_p, curdone);
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.
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 |
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);
rdpcd8.c
, rd16.c
, rdssdio.c
, wrssdio.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.
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. |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
direction | one of EDT_READ or EDT_WRITE |
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.
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:
| ||||||||||||||||||||||||||||||||||
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. |
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
value | The number of milliseconds in the timeout period. |
int edt_set_timeout_action | ( | EdtDev * | edt_p, | |
u_int | action | |||
) |
Sets the driver behavior on a timeout.
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:
|
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel | |
value | The number of milliseconds in the timeout period. |
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.
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. |
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.
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 |
edt_startdma_action(edt_p, EDT_ACT_ALWAYS); edt_startdma_reg(edt_p, PDV_CMD, PDV_ENABLE_GRAB);
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.
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 |
edt_startdma_action(edt_p, EDT_ACT_ALWAYS); edt_startdma_reg(edt_p, PDV_CMD, PDV_ENABLE_GRAB);
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.
edt_p | pointer to edt device structure returned by edt_open |
int edt_timeouts | ( | EdtDev * | edt_p | ) |
Returns the number of read and write timeouts that have occurred since the last call of edt_open.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
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. |
unsigned char* edt_wait_for_buffers | ( | EdtDev * | edt_p, | |
int | count | |||
) |
Blocks until the specified number of buffers have completed.
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. |
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.
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.
edt_p | pointer to edt device structure returned by edt_open or edt_open_channel |
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.
edt_p | pointer to edt device structure returned by edt_open | |
buf | address of buffer to write from | |
size | size of write in bytes |
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.
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. |
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);
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.
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. |
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);