summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_videodevice.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-14 16:14:27 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-18 19:15:18 +0200
commit92830a1d00728908bfba373d86e6143439c38b59 (patch)
tree863bb80e45fde869a376194d127abc5002b20142 /src/libcamera/v4l2_videodevice.cpp
parent46011623bca91877400481cb738064eb4e3cee92 (diff)
libcamera: v4l2_videodevice: Pass memory type to reqbufs()
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@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/v4l2_videodevice.cpp')
-rw-r--r--src/libcamera/v4l2_videodevice.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index a8c6d6be..100a92b5 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -997,14 +997,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) {
@@ -1017,7 +1018,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;
}
@@ -1043,7 +1044,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;
@@ -1080,7 +1081,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count,
return count;
err_buf:
- requestBuffers(0);
+ requestBuffers(0, V4L2_MEMORY_MMAP);
buffers->clear();
@@ -1150,7 +1151,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;
@@ -1171,7 +1172,7 @@ int V4L2VideoDevice::releaseBuffers()
delete cache_;
cache_ = nullptr;
- return requestBuffers(0);
+ return requestBuffers(0, memoryType_);
}
/**