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>
This commit is contained in:
Laurent Pinchart
2020-03-14 16:14:27 +02:00
parent 46011623bc
commit 92830a1d00
2 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -226,7 +226,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);
+8 -7
View File
@@ -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_);
}
/**