[libcamera-devel] [PATCH v3 10/22] v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUMINPUT, VIDIOC_G/S_INPUT
Paul Elder
paul.elder at ideasonboard.com
Tue Jun 23 21:08:24 CEST 2020
Implement VIDIOC_ENUMINPUT, VIDIOC_G_INPUT, and VIDIOC_S_INPUT. Only the
zeroth input device is supported, and the info returned by enuminput is
hardcoded and basic. This is sufficient to pass v4l2-compliance.
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
Changes in v3:
- cosmetic changes
Changes in v2:
- use V4L2CameraFile instead of fd
- remove arg == nullptr check as it has been moved away to the main
ioctl handler
---
src/v4l2/v4l2_camera_proxy.cpp | 48 ++++++++++++++++++++++++++++++++++
src/v4l2/v4l2_camera_proxy.h | 3 +++
2 files changed, 51 insertions(+)
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 361abe4..7925ed1 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -382,6 +382,42 @@ int V4L2CameraProxy::vidioc_s_priority(V4L2CameraFile *file, enum v4l2_priority
return 0;
}
+int V4L2CameraProxy::vidioc_enuminput(V4L2CameraFile *file, struct v4l2_input *arg)
+{
+ LOG(V4L2Compat, Debug) << "Servicing vidioc_enuminput fd = " << file->efd();
+
+ if (arg->index != 0)
+ return -EINVAL;
+
+ memset(arg, 0, sizeof(*arg));
+
+ utils::strlcpy(reinterpret_cast<char *>(arg->name),
+ reinterpret_cast<char *>(capabilities_.card),
+ sizeof(arg->name));
+ arg->type = V4L2_INPUT_TYPE_CAMERA;
+
+ return 0;
+}
+
+int V4L2CameraProxy::vidioc_g_input(V4L2CameraFile *file, int *arg)
+{
+ LOG(V4L2Compat, Debug) << "Servicing vidioc_g_input fd = " << file->efd();
+
+ *arg = 0;
+
+ return 0;
+}
+
+int V4L2CameraProxy::vidioc_s_input(V4L2CameraFile *file, int *arg)
+{
+ LOG(V4L2Compat, Debug) << "Servicing vidioc_s_input fd = " << file->efd();
+
+ if (*arg != 0)
+ return -EINVAL;
+
+ return 0;
+}
+
int V4L2CameraProxy::freeBuffers()
{
LOG(V4L2Compat, Debug) << "Freeing libcamera bufs";
@@ -601,6 +637,9 @@ const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {
VIDIOC_TRY_FMT,
VIDIOC_G_PRIORITY,
VIDIOC_S_PRIORITY,
+ VIDIOC_ENUMINPUT,
+ VIDIOC_G_INPUT,
+ VIDIOC_S_INPUT,
VIDIOC_REQBUFS,
VIDIOC_QUERYBUF,
VIDIOC_QBUF,
@@ -649,6 +688,15 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar
case VIDIOC_S_PRIORITY:
ret = vidioc_s_priority(file, static_cast<enum v4l2_priority *>(arg));
break;
+ case VIDIOC_ENUMINPUT:
+ ret = vidioc_enuminput(file, static_cast<struct v4l2_input *>(arg));
+ break;
+ case VIDIOC_G_INPUT:
+ ret = vidioc_g_input(file, static_cast<int *>(arg));
+ break;
+ case VIDIOC_S_INPUT:
+ ret = vidioc_s_input(file, static_cast<int *>(arg));
+ break;
case VIDIOC_REQBUFS:
ret = vidioc_reqbufs(file, static_cast<struct v4l2_requestbuffers *>(arg));
break;
diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
index a7293bf..bc427d4 100644
--- a/src/v4l2/v4l2_camera_proxy.h
+++ b/src/v4l2/v4l2_camera_proxy.h
@@ -54,6 +54,9 @@ private:
int vidioc_try_fmt(V4L2CameraFile *file, struct v4l2_format *arg);
int vidioc_g_priority(V4L2CameraFile *file, enum v4l2_priority *arg);
int vidioc_s_priority(V4L2CameraFile *file, enum v4l2_priority *arg);
+ int vidioc_enuminput(V4L2CameraFile *file, struct v4l2_input *arg);
+ int vidioc_g_input(V4L2CameraFile *file, int *arg);
+ int vidioc_s_input(V4L2CameraFile *file, int *arg);
int vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg);
int vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg);
int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);
--
2.27.0
More information about the libcamera-devel
mailing list