libiio 1.0
Library for interfacing with IIO devices
Loading...
Searching...
No Matches
Block
Collaboration diagram for Block:

Functions

__api __check_ret struct iio_block * iio_buffer_stream_create_block (struct iio_buffer_stream *buf_stream, size_t size)
 Create a data block for the given buffer stream.
 
__api void iio_block_destroy (struct iio_block *block)
 Destroy the given block.
 
__api __check_ret int iio_block_get_dmabuf_fd (const struct iio_block *block)
 Get the file descriptor of the underlying DMABUF object.
 
__api int iio_block_disable_cpu_access (struct iio_block *block, bool disable)
 Disable CPU access of a given block.
 
__api void * iio_block_start (const struct iio_block *block)
 Get the start address of the block.
 
__api void * iio_block_first (const struct iio_block *block, const struct iio_channel *chn)
 Find the first sample of a channel in a block.
 
__api void * iio_block_end (const struct iio_block *block)
 Get the address after the last sample in a block.
 
__api __check_ret ssize_t iio_block_foreach_sample (const struct iio_block *block, const struct iio_channels_mask *mask, ssize_t(*callback)(const struct iio_channel *chn, void *src, size_t bytes, void *d), void *data)
 Call the supplied callback for each sample found in a block.
 
__api int iio_block_enqueue (struct iio_block *block, size_t bytes_used, bool cyclic)
 Enqueue the given iio_block to the buffer's queue.
 
__api int iio_block_dequeue (struct iio_block *block, bool nonblock)
 Dequeue the given iio_block from the buffer's queue.
 
__api struct iio_buffer_streamiio_block_get_buffer_stream (const struct iio_block *block)
 Retrieve a pointer to the iio_buffer_stream structure.
 

Detailed Description

Function Documentation

◆ iio_block_dequeue()

__api int iio_block_dequeue ( struct iio_block *  block,
bool  nonblock 
)

Dequeue the given iio_block from the buffer's queue.

Parameters
blockA pointer to an iio_block structure
nonblockif True, the operation won't block and return -EBUSY if the block is not ready for dequeue.
Returns
On success, 0 is returned
On error, a negative error code is returned
Here is the caller graph for this function:

◆ iio_block_destroy()

__api void iio_block_destroy ( struct iio_block *  block)

Destroy the given block.

Parameters
blockA pointer to an iio_block structure
Here is the caller graph for this function:

◆ iio_block_disable_cpu_access()

__api int iio_block_disable_cpu_access ( struct iio_block *  block,
bool  disable 
)

Disable CPU access of a given block.

Parameters
blockA pointer to an iio_block structure
disableWhether or not to disable CPU access

NOTE:Disabling CPU access is useful when manipulating DMABUF objects. If CPU access is disabled, the block's internal buffer of samples should not be accessed. Therefore, the following functions should not be called: iio_block_start, iio_block_first, iio_block_end, iio_block_foreach_sample.

◆ iio_block_end()

__api void * iio_block_end ( const struct iio_block *  block)

Get the address after the last sample in a block.

Parameters
blockA pointer to an iio_block structure
Returns
A pointer corresponding to the address that follows the last sample present in the buffer
Here is the caller graph for this function:

◆ iio_block_enqueue()

__api int iio_block_enqueue ( struct iio_block *  block,
size_t  bytes_used,
bool  cyclic 
)

Enqueue the given iio_block to the buffer's queue.

Parameters
blockA pointer to an iio_block structure
bytes_usedThe amount of data in bytes to be transferred (either transmitted or received). If zero, the size of the block is used.
cyclicIf True, enable cyclic mode. The block's content will be repeated on the hardware's output until the buffer is cancelled or destroyed.
Returns
On success, 0 is returned
On error, a negative error code is returned

NOTE: After iio_block_enqueue is called, the block's data must not be accessed until iio_block_dequeue successfully returns.

Here is the caller graph for this function:

◆ iio_block_first()

__api void * iio_block_first ( const struct iio_block *  block,
const struct iio_channel chn 
)

Find the first sample of a channel in a block.

Parameters
blockA pointer to an iio_block structure
chnA pointer to an iio_channel structure
Returns
A pointer to the first sample found, or to the end of the block if no sample for the given channel is present in the block

NOTE: This function, coupled with iio_block_end, can be used to iterate on all the samples of a given channel present in the block, doing the following:

for (void *ptr = iio_block_first(block, chn);
     ptr < iio_block_end(block);
     ptr += iio_device_get_sample_size(dev, mask)) {
   ....
}

The iio_channel passed as argument must be from the iio_device that was used to create the iio_buffer and then the iio_block, otherwise the result is undefined.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iio_block_foreach_sample()

__api __check_ret ssize_t iio_block_foreach_sample ( const struct iio_block *  block,
const struct iio_channels_mask *  mask,
ssize_t(*)(const struct iio_channel *chn, void *src, size_t bytes, void *d)  callback,
void *  data 
)

Call the supplied callback for each sample found in a block.

Parameters
blockA pointer to an iio_block structure
maskA pointer to the iio_channels_mask structure that represents the list of channels for which we want samples
callbackA pointer to a function to call for each sample found
dataA user-specified pointer that will be passed to the callback
Returns
number of bytes processed.

NOTE: The callback receives four arguments:

  • A pointer to the iio_channel structure corresponding to the sample,
  • A pointer to the sample itself,
  • The length of the sample in bytes,
  • The user-specified pointer passed to iio_block_foreach_sample.
Examples
dummy-iiostream.c.

◆ iio_block_get_buffer_stream()

__api struct iio_buffer_stream * iio_block_get_buffer_stream ( const struct iio_block *  block)

Retrieve a pointer to the iio_buffer_stream structure.

Parameters
blockA pointer to an iio_block structure
Returns
A pointer to an iio_buffer_stream structure
Here is the caller graph for this function:

◆ iio_block_get_dmabuf_fd()

__api __check_ret int iio_block_get_dmabuf_fd ( const struct iio_block *  block)

Get the file descriptor of the underlying DMABUF object.

Parameters
blockA pointer to an iio_block structure
Returns
The file descriptor of the underlying DMABUF object. If the iio_block is not backed by a DMABUF object, -EINVAL is returned. Otherwise, the file descriptor will be valid until the block is destroyed.

◆ iio_block_start()

__api void * iio_block_start ( const struct iio_block *  block)

Get the start address of the block.

Parameters
blockA pointer to an iio_block structure
Returns
A pointer corresponding to the start address of the block
Here is the caller graph for this function:

◆ iio_buffer_stream_create_block()

__api __check_ret struct iio_block * iio_buffer_stream_create_block ( struct iio_buffer_stream buf_stream,
size_t  size 
)

Create a data block for the given buffer stream.

Parameters
buf_streamA pointer to an iio_buffer_stream structure
sizeThe size of the block to create, in bytes
Returns
On success, a pointer to an iio_block structure
On failure, a pointer-encoded error is returned
Here is the caller graph for this function: