Lines Matching full:buffer
19 #include <linux/iio/buffer-dma.h>
27 * has its own memory buffer. The size of the block is the granularity at which
74 * the actual number of bytes in the buffer. Typically this will be equal to the
82 * perform a DMA transfer for the block, e.g. because the buffer was disabled
87 * It will be called when the buffer is disabled and can be used to cancel
113 iio_buffer_put(&queue->buffer); in iio_buffer_block_release()
169 return container_of(buf, struct iio_dma_buffer_queue, buffer); in iio_buffer_to_queue()
195 iio_buffer_get(&queue->buffer); in iio_dma_buffer_alloc_block()
213 if (queue->buffer.direction == IIO_BUFFER_DIRECTION_IN) in iio_dma_buffer_queue_wake()
218 wake_up_interruptible_poll(&queue->buffer.pollq, flags); in iio_dma_buffer_queue_wake()
290 * default case when enabling the buffer, unless the DMA controller does in iio_dma_block_reusable()
313 * iio_dma_buffer_request_update() - DMA buffer request_update callback
314 * @buffer: The buffer which to request an update
319 int iio_dma_buffer_request_update(struct iio_buffer *buffer) in iio_dma_buffer_request_update() argument
321 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_request_update()
328 * Split the buffer into two even parts. This is used as a double in iio_dma_buffer_request_update()
332 size = DIV_ROUND_UP(queue->buffer.bytes_per_datum * in iio_dma_buffer_request_update()
333 queue->buffer.length, 2); in iio_dma_buffer_request_update()
398 * If it's an input buffer, mark the block as queued, and in iio_dma_buffer_request_update()
402 if (queue->buffer.direction == IIO_BUFFER_DIRECTION_IN) { in iio_dma_buffer_request_update()
460 * other then wait for the buffer to be disabled and re-enabled in iio_dma_buffer_submit_block()
465 * notify consumers that something went wrong and the buffer in iio_dma_buffer_submit_block()
473 * iio_dma_buffer_enable() - Enable DMA buffer
474 * @buffer: IIO buffer to enable
475 * @indio_dev: IIO device the buffer is attached to
477 * Needs to be called when the device that the buffer is attached to starts
482 int iio_dma_buffer_enable(struct iio_buffer *buffer, struct iio_dev *indio_dev) in iio_dma_buffer_enable() argument
484 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_enable()
499 * iio_dma_buffer_disable() - Disable DMA buffer
500 * @buffer: IIO DMA buffer to disable
501 * @indio_dev: IIO device the buffer is attached to
503 * Needs to be called when the device that the buffer is attached to stops
506 int iio_dma_buffer_disable(struct iio_buffer *buffer, struct iio_dev *indio_dev) in iio_dma_buffer_disable() argument
508 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_disable()
553 static int iio_dma_buffer_io(struct iio_buffer *buffer, size_t n, in iio_dma_buffer_io() argument
556 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_io()
561 if (n < buffer->bytes_per_datum) in iio_dma_buffer_io()
577 n = rounddown(n, buffer->bytes_per_datum); in iio_dma_buffer_io()
600 * iio_dma_buffer_read() - DMA buffer read callback
601 * @buffer: Buffer to read from
603 * @user_buffer: Userspace buffer to copy the data to
608 int iio_dma_buffer_read(struct iio_buffer *buffer, size_t n, in iio_dma_buffer_read() argument
611 return iio_dma_buffer_io(buffer, n, user_buffer, false); in iio_dma_buffer_read()
616 * iio_dma_buffer_write() - DMA buffer write callback
617 * @buffer: Buffer to write to
619 * @user_buffer: Userspace buffer to copy the data from
624 int iio_dma_buffer_write(struct iio_buffer *buffer, size_t n, in iio_dma_buffer_write() argument
627 return iio_dma_buffer_io(buffer, n, in iio_dma_buffer_write()
633 * iio_dma_buffer_usage() - DMA buffer data_available and
635 * @buf: Buffer to check for data availability
672 iio_dma_buffer_attach_dmabuf(struct iio_buffer *buffer, in iio_dma_buffer_attach_dmabuf() argument
675 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_attach_dmabuf()
681 * If the buffer is enabled and in fileio mode new blocks can't be in iio_dma_buffer_attach_dmabuf()
698 void iio_dma_buffer_detach_dmabuf(struct iio_buffer *buffer, in iio_dma_buffer_detach_dmabuf() argument
727 int iio_dma_buffer_enqueue_dmabuf(struct iio_buffer *buffer, in iio_dma_buffer_enqueue_dmabuf() argument
733 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_enqueue_dmabuf()
759 struct device *iio_dma_buffer_get_dma_dev(struct iio_buffer *buffer) in iio_dma_buffer_get_dma_dev() argument
761 return iio_buffer_to_queue(buffer)->dev; in iio_dma_buffer_get_dma_dev()
765 void iio_dma_buffer_lock_queue(struct iio_buffer *buffer) in iio_dma_buffer_lock_queue() argument
767 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_lock_queue()
773 void iio_dma_buffer_unlock_queue(struct iio_buffer *buffer) in iio_dma_buffer_unlock_queue() argument
775 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer); in iio_dma_buffer_unlock_queue()
782 * iio_dma_buffer_set_bytes_per_datum() - DMA buffer set_bytes_per_datum callback
783 * @buffer: Buffer to set the bytes-per-datum for
789 int iio_dma_buffer_set_bytes_per_datum(struct iio_buffer *buffer, size_t bpd) in iio_dma_buffer_set_bytes_per_datum() argument
791 buffer->bytes_per_datum = bpd; in iio_dma_buffer_set_bytes_per_datum()
798 * iio_dma_buffer_set_length - DMA buffer set_length callback
799 * @buffer: Buffer to set the length for
800 * @length: The new buffer length
805 int iio_dma_buffer_set_length(struct iio_buffer *buffer, unsigned int length) in iio_dma_buffer_set_length() argument
810 buffer->length = length; in iio_dma_buffer_set_length()
811 buffer->watermark = length / 2; in iio_dma_buffer_set_length()
818 * iio_dma_buffer_init() - Initialize DMA buffer queue
819 * @queue: Buffer to initialize
821 * @ops: DMA buffer queue callback operations
830 iio_buffer_init(&queue->buffer); in iio_dma_buffer_init()
831 queue->buffer.length = PAGE_SIZE; in iio_dma_buffer_init()
832 queue->buffer.watermark = queue->buffer.length / 2; in iio_dma_buffer_init()
844 * iio_dma_buffer_exit() - Cleanup DMA buffer queue
845 * @queue: Buffer to cleanup
848 * associated with the buffer and are accessed inside the callback operations.
860 * iio_dma_buffer_release() - Release final buffer resources
861 * @queue: Buffer to release
865 * the memory associated with the buffer.
874 MODULE_DESCRIPTION("DMA buffer for the IIO framework");