[libcamera-devel] [PATCH 3/9] libcamera: v4l2_videodevice: Pass memory type to reqbufs()
Niklas Söderlund
niklas.soderlund at ragnatech.se
Mon Mar 16 14:40:11 CET 2020
Hi Laurent,
Thanks for your patch.
On 2020-03-15 01:57:22 +0200, Laurent Pinchart wrote:
> To prepare for the rework of buffer export, pass the memory type
> explicitly to the V4L2VideoDevice::reqbufs() function.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> src/libcamera/include/v4l2_videodevice.h | 2 +-
> src/libcamera/v4l2_videodevice.cpp | 15 ++++++++-------
> 2 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h
> index 893d28c7db88..26f5e5917716 100644
> --- a/src/libcamera/include/v4l2_videodevice.h
> +++ b/src/libcamera/include/v4l2_videodevice.h
> @@ -227,7 +227,7 @@ private:
>
> int setSelection(unsigned int target, Rectangle *rect);
>
> - int requestBuffers(unsigned int count);
> + int requestBuffers(unsigned int count, enum v4l2_memory memoryType);
> std::unique_ptr<FrameBuffer> createBuffer(const struct v4l2_buffer &buf);
> FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);
>
> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
> index aea7a4ea3a23..6911ab024fd7 100644
> --- a/src/libcamera/v4l2_videodevice.cpp
> +++ b/src/libcamera/v4l2_videodevice.cpp
> @@ -1013,14 +1013,15 @@ int V4L2VideoDevice::setSelection(unsigned int target, Rectangle *rect)
> return 0;
> }
>
> -int V4L2VideoDevice::requestBuffers(unsigned int count)
> +int V4L2VideoDevice::requestBuffers(unsigned int count,
> + enum v4l2_memory memoryType)
> {
> struct v4l2_requestbuffers rb = {};
> int ret;
>
> rb.count = count;
> rb.type = bufferType_;
> - rb.memory = memoryType_;
> + rb.memory = memoryType;
>
> ret = ioctl(VIDIOC_REQBUFS, &rb);
> if (ret < 0) {
> @@ -1033,7 +1034,7 @@ int V4L2VideoDevice::requestBuffers(unsigned int count)
> if (rb.count < count) {
> LOG(V4L2, Error)
> << "Not enough buffers provided by V4L2VideoDevice";
> - requestBuffers(0);
> + requestBuffers(0, memoryType);
> return -ENOMEM;
> }
>
> @@ -1059,7 +1060,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count,
>
> memoryType_ = V4L2_MEMORY_MMAP;
>
> - int ret = requestBuffers(count);
> + int ret = requestBuffers(count, V4L2_MEMORY_MMAP);
> if (ret < 0)
> return ret;
>
> @@ -1096,7 +1097,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count,
> return count;
>
> err_buf:
> - requestBuffers(0);
> + requestBuffers(0, V4L2_MEMORY_MMAP);
>
> buffers->clear();
>
> @@ -1166,7 +1167,7 @@ int V4L2VideoDevice::importBuffers(unsigned int count)
>
> memoryType_ = V4L2_MEMORY_DMABUF;
>
> - int ret = requestBuffers(count);
> + int ret = requestBuffers(count, V4L2_MEMORY_DMABUF);
> if (ret)
> return ret;
>
> @@ -1187,7 +1188,7 @@ int V4L2VideoDevice::releaseBuffers()
> delete cache_;
> cache_ = nullptr;
>
> - return requestBuffers(0);
> + return requestBuffers(0, memoryType_);
> }
>
> /**
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list