Message ID | 20211115142243.60605-2-paul@crapouillou.net (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | iio: buffer-dma: write() and new DMABUF based API | expand |
On Mon, Nov 15, 2021 at 4:22 PM Paul Cercueil <paul@crapouillou.net> wrote: > > Introduce a new flag IIO_BUFFER_DMABUF_CYCLIC in the "flags" field of > the iio_dmabuf uapi structure. > > When set, the DMABUF enqueued with the enqueue ioctl will be endlessly > repeated on the TX output, until the buffer is disabled. > Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> > Signed-off-by: Paul Cercueil <paul@crapouillou.net> > --- > drivers/iio/industrialio-buffer.c | 5 +++++ > include/uapi/linux/iio/buffer.h | 3 ++- > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c > index 30910e6c2346..41bc51c88002 100644 > --- a/drivers/iio/industrialio-buffer.c > +++ b/drivers/iio/industrialio-buffer.c > @@ -1600,6 +1600,11 @@ static int iio_buffer_enqueue_dmabuf(struct iio_buffer *buffer, > if (dmabuf.flags & ~IIO_BUFFER_DMABUF_SUPPORTED_FLAGS) > return -EINVAL; > > + /* Cyclic flag is only supported on output buffers */ > + if ((dmabuf.flags & IIO_BUFFER_DMABUF_CYCLIC) && > + buffer->direction != IIO_BUFFER_DIRECTION_OUT) > + return -EINVAL; > + > return buffer->access->enqueue_dmabuf(buffer, &dmabuf); > } > > diff --git a/include/uapi/linux/iio/buffer.h b/include/uapi/linux/iio/buffer.h > index e4621b926262..2d541d038c02 100644 > --- a/include/uapi/linux/iio/buffer.h > +++ b/include/uapi/linux/iio/buffer.h > @@ -7,7 +7,8 @@ > > #include <linux/types.h> > > -#define IIO_BUFFER_DMABUF_SUPPORTED_FLAGS 0x00000000 > +#define IIO_BUFFER_DMABUF_CYCLIC (1 << 0) > +#define IIO_BUFFER_DMABUF_SUPPORTED_FLAGS 0x00000001 > > /** > * struct iio_dmabuf_alloc_req - Descriptor for allocating IIO DMABUFs > -- > 2.33.0 >
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 30910e6c2346..41bc51c88002 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -1600,6 +1600,11 @@ static int iio_buffer_enqueue_dmabuf(struct iio_buffer *buffer, if (dmabuf.flags & ~IIO_BUFFER_DMABUF_SUPPORTED_FLAGS) return -EINVAL; + /* Cyclic flag is only supported on output buffers */ + if ((dmabuf.flags & IIO_BUFFER_DMABUF_CYCLIC) && + buffer->direction != IIO_BUFFER_DIRECTION_OUT) + return -EINVAL; + return buffer->access->enqueue_dmabuf(buffer, &dmabuf); } diff --git a/include/uapi/linux/iio/buffer.h b/include/uapi/linux/iio/buffer.h index e4621b926262..2d541d038c02 100644 --- a/include/uapi/linux/iio/buffer.h +++ b/include/uapi/linux/iio/buffer.h @@ -7,7 +7,8 @@ #include <linux/types.h> -#define IIO_BUFFER_DMABUF_SUPPORTED_FLAGS 0x00000000 +#define IIO_BUFFER_DMABUF_CYCLIC (1 << 0) +#define IIO_BUFFER_DMABUF_SUPPORTED_FLAGS 0x00000001 /** * struct iio_dmabuf_alloc_req - Descriptor for allocating IIO DMABUFs
Introduce a new flag IIO_BUFFER_DMABUF_CYCLIC in the "flags" field of the iio_dmabuf uapi structure. When set, the DMABUF enqueued with the enqueue ioctl will be endlessly repeated on the TX output, until the buffer is disabled. Signed-off-by: Paul Cercueil <paul@crapouillou.net> --- drivers/iio/industrialio-buffer.c | 5 +++++ include/uapi/linux/iio/buffer.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)