Lines Matching full:buffer
18 #include <linux/iio/buffer-dma.h>
26 * has its own memory buffer. The size of the block is the granularity at which
73 * the actual number of bytes in the buffer. Typically this will be equal to the
81 * perform a DMA transfer for the block, e.g. because the buffer was disabled
86 * It will be called when the buffer is disabled and can be used to cancel
112 iio_buffer_put(&queue->buffer); in iio_buffer_block_release()
171 return container_of(buf, struct iio_dma_buffer_queue, buffer); in iio_buffer_to_queue()
199 iio_buffer_get(&queue->buffer); in iio_dma_buffer_alloc_block()
217 if (queue->buffer.direction == IIO_BUFFER_DIRECTION_IN) in iio_dma_buffer_queue_wake()
222 wake_up_interruptible_poll(&queue->buffer.pollq, flags); in iio_dma_buffer_queue_wake()
296 * default case when enabling the buffer, unless the DMA controller does in iio_dma_block_reusable()
319 * iio_dma_buffer_request_update() - DMA buffer request_update callback
320 * @buffer: The buffer which to request an update
325 int iio_dma_buffer_request_update(struct iio_buffer *buffer) in iio_dma_buffer_request_update() argument
327 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_request_update()
335 * Split the buffer into two even parts. This is used as a double in iio_dma_buffer_request_update()
339 size = DIV_ROUND_UP(queue->buffer.bytes_per_datum * in iio_dma_buffer_request_update()
340 queue->buffer.length, 2); in iio_dma_buffer_request_update()
406 * If it's an input buffer, mark the block as queued, and in iio_dma_buffer_request_update()
410 if (queue->buffer.direction == IIO_BUFFER_DIRECTION_IN) { in iio_dma_buffer_request_update()
471 * other then wait for the buffer to be disabled and re-enabled in iio_dma_buffer_submit_block()
476 * notify consumers that something went wrong and the buffer in iio_dma_buffer_submit_block()
484 * iio_dma_buffer_enable() - Enable DMA buffer
485 * @buffer: IIO buffer to enable
486 * @indio_dev: IIO device the buffer is attached to
488 * Needs to be called when the device that the buffer is attached to starts
493 int iio_dma_buffer_enable(struct iio_buffer *buffer, in iio_dma_buffer_enable() argument
496 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_enable()
512 * iio_dma_buffer_disable() - Disable DMA buffer
513 * @buffer: IIO DMA buffer to disable
514 * @indio_dev: IIO device the buffer is attached to
516 * Needs to be called when the device that the buffer is attached to stops
519 int iio_dma_buffer_disable(struct iio_buffer *buffer, in iio_dma_buffer_disable() argument
522 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_disable()
571 static int iio_dma_buffer_io(struct iio_buffer *buffer, size_t n, in iio_dma_buffer_io() argument
574 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_io()
579 if (n < buffer->bytes_per_datum) in iio_dma_buffer_io()
596 n = rounddown(n, buffer->bytes_per_datum); in iio_dma_buffer_io()
626 * iio_dma_buffer_read() - DMA buffer read callback
627 * @buffer: Buffer to read from
629 * @user_buffer: Userspace buffer to copy the data to
634 int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n, in iio_dma_buffer_read() argument
637 return iio_dma_buffer_io(buffer, n, user_buffer, false); in iio_dma_buffer_read()
642 * iio_dma_buffer_write() - DMA buffer write callback
643 * @buffer: Buffer to write to
645 * @user_buffer: Userspace buffer to copy the data from
650 int iio_dma_buffer_write(struct iio_buffer *buffer, size_t n, in iio_dma_buffer_write() argument
653 return iio_dma_buffer_io(buffer, n, in iio_dma_buffer_write()
659 * iio_dma_buffer_usage() - DMA buffer data_available and
661 * @buf: Buffer to check for data availability
702 iio_dma_buffer_attach_dmabuf(struct iio_buffer *buffer, in iio_dma_buffer_attach_dmabuf() argument
705 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_attach_dmabuf()
711 * If the buffer is enabled and in fileio mode new blocks can't be in iio_dma_buffer_attach_dmabuf()
728 void iio_dma_buffer_detach_dmabuf(struct iio_buffer *buffer, in iio_dma_buffer_detach_dmabuf() argument
757 int iio_dma_buffer_enqueue_dmabuf(struct iio_buffer *buffer, in iio_dma_buffer_enqueue_dmabuf() argument
763 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_enqueue_dmabuf()
789 struct device *iio_dma_buffer_get_dma_dev(struct iio_buffer *buffer) in iio_dma_buffer_get_dma_dev() argument
791 return iio_buffer_to_queue(buffer)->dev; in iio_dma_buffer_get_dma_dev()
795 void iio_dma_buffer_lock_queue(struct iio_buffer *buffer) in iio_dma_buffer_lock_queue() argument
797 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_lock_queue()
803 void iio_dma_buffer_unlock_queue(struct iio_buffer *buffer) in iio_dma_buffer_unlock_queue() argument
805 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_unlock_queue()
812 * iio_dma_buffer_set_bytes_per_datum() - DMA buffer set_bytes_per_datum callback
813 * @buffer: Buffer to set the bytes-per-datum for
819 int iio_dma_buffer_set_bytes_per_datum(struct iio_buffer *buffer, size_t bpd) in iio_dma_buffer_set_bytes_per_datum() argument
821 buffer->bytes_per_datum = bpd; in iio_dma_buffer_set_bytes_per_datum()
828 * iio_dma_buffer_set_length - DMA buffer set_length callback
829 * @buffer: Buffer to set the length for
830 * @length: The new buffer length
835 int iio_dma_buffer_set_length(struct iio_buffer *buffer, unsigned int length) in iio_dma_buffer_set_length() argument
840 buffer->length = length; in iio_dma_buffer_set_length()
841 buffer->watermark = length / 2; in iio_dma_buffer_set_length()
848 * iio_dma_buffer_init() - Initialize DMA buffer queue
849 * @queue: Buffer to initialize
851 * @ops: DMA buffer queue callback operations
860 iio_buffer_init(&queue->buffer); in iio_dma_buffer_init()
861 queue->buffer.length = PAGE_SIZE; in iio_dma_buffer_init()
862 queue->buffer.watermark = queue->buffer.length / 2; in iio_dma_buffer_init()
876 * iio_dma_buffer_exit() - Cleanup DMA buffer queue
877 * @queue: Buffer to cleanup
880 * associated with the buffer and are accessed inside the callback operations.
894 * iio_dma_buffer_release() - Release final buffer resources
895 * @queue: Buffer to release
899 * the memory associated with the buffer.
908 MODULE_DESCRIPTION("DMA buffer for the IIO framework");