v4l2: v4l2_camera_proxy: Add EXPBUF as one of the supported ioctl
To support DMABUF as one of the memory buffer, we need to implement EXPBUF in the v4l2 compat layer. This patch implements vidioc_expbuf as one of the supported ioctls. Bug: https://bugs.libcamera.org/show_bug.cgi?id=89 Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
44d59841e1
commit
d769a59566
2 changed files with 31 additions and 0 deletions
|
@ -624,6 +624,32 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg)
|
||||
{
|
||||
LOG(V4L2Compat, Debug) << "Servicing vidioc_expbuf fd = " << file->efd();
|
||||
|
||||
if (!hasOwnership(file))
|
||||
return -EBUSY;
|
||||
|
||||
/* \todo Verify that the memory type is MMAP when adding DMABUF support */
|
||||
if (!validateBufferType(arg->type))
|
||||
return -EINVAL;
|
||||
|
||||
if (arg->index >= bufferCount_)
|
||||
return -EINVAL;
|
||||
|
||||
if (arg->flags & ~(O_CLOEXEC | O_ACCMODE))
|
||||
return -EINVAL;
|
||||
|
||||
memset(arg->reserved, 0, sizeof(arg->reserved));
|
||||
|
||||
/* \todo honor the O_ACCMODE flags passed to this function */
|
||||
arg->fd = fcntl(vcam_->getBufferFd(arg->index),
|
||||
arg->flags & O_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg)
|
||||
{
|
||||
LOG(V4L2Compat, Debug) << "Servicing vidioc_streamon fd = " << file->efd();
|
||||
|
@ -685,6 +711,7 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {
|
|||
VIDIOC_QUERYBUF,
|
||||
VIDIOC_QBUF,
|
||||
VIDIOC_DQBUF,
|
||||
VIDIOC_EXPBUF,
|
||||
VIDIOC_STREAMON,
|
||||
VIDIOC_STREAMOFF,
|
||||
};
|
||||
|
@ -755,6 +782,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar
|
|||
case VIDIOC_DQBUF:
|
||||
ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &proxyMutex_);
|
||||
break;
|
||||
case VIDIOC_EXPBUF:
|
||||
ret = vidioc_expbuf(file, static_cast<struct v4l2_exportbuffer *>(arg));
|
||||
break;
|
||||
case VIDIOC_STREAMON:
|
||||
ret = vidioc_streamon(file, static_cast<int *>(arg));
|
||||
break;
|
||||
|
|
|
@ -60,6 +60,7 @@ private:
|
|||
int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);
|
||||
int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,
|
||||
libcamera::Mutex *lock) LIBCAMERA_TSA_REQUIRES(*lock);
|
||||
int vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffer *arg);
|
||||
int vidioc_streamon(V4L2CameraFile *file, int *arg);
|
||||
int vidioc_streamoff(V4L2CameraFile *file, int *arg);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue