summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-06-16 11:45:13 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2020-06-25 23:47:13 +0900
commitc857ae3c89403e102b32b39bc12f228808100fa7 (patch)
tree3bcb102e04710e3f152f13b0d195829deae932b4 /src
parente0e10d2b53592b316ca7678709a77b1855455965 (diff)
v4l2: v4l2_camera_proxy: Implement VIDIOC_ENUM_FRAMESIZES
Implement VIDIOC_ENUM_FRAMESIZES in the V4L2 compatibility layer. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/v4l2/v4l2_camera_proxy.cpp26
-rw-r--r--src/v4l2/v4l2_camera_proxy.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 198d4af8..0099266e 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -241,6 +241,28 @@ int V4L2CameraProxy::vidioc_querycap(struct v4l2_capability *arg)
return 0;
}
+int V4L2CameraProxy::vidioc_enum_framesizes(V4L2CameraFile *file, struct v4l2_frmsizeenum *arg)
+{
+ LOG(V4L2Compat, Debug) << "Servicing vidioc_enum_framesizes fd = " << file->efd();
+
+ PixelFormat argFormat = v4l2ToDrm(arg->pixel_format);
+ /*
+ * \todo This might need to be expanded as few pipeline handlers
+ * report StreamFormats.
+ */
+ const std::vector<Size> &frameSizes = streamConfig_.formats().sizes(argFormat);
+
+ if (arg->index >= frameSizes.size())
+ return -EINVAL;
+
+ arg->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+ arg->discrete.width = frameSizes[arg->index].width;
+ arg->discrete.height = frameSizes[arg->index].height;
+ memset(arg->reserved, 0, sizeof(arg->reserved));
+
+ return 0;
+}
+
int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *arg)
{
LOG(V4L2Compat, Debug) << "Servicing vidioc_enum_fmt fd = " << file->efd();
@@ -626,6 +648,7 @@ int V4L2CameraProxy::vidioc_streamoff(V4L2CameraFile *file, int *arg)
const std::set<unsigned long> V4L2CameraProxy::supportedIoctls_ = {
VIDIOC_QUERYCAP,
+ VIDIOC_ENUM_FRAMESIZES,
VIDIOC_ENUM_FMT,
VIDIOC_G_FMT,
VIDIOC_S_FMT,
@@ -665,6 +688,9 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar
case VIDIOC_QUERYCAP:
ret = vidioc_querycap(static_cast<struct v4l2_capability *>(arg));
break;
+ case VIDIOC_ENUM_FRAMESIZES:
+ ret = vidioc_enum_framesizes(file, static_cast<struct v4l2_frmsizeenum *>(arg));
+ break;
case VIDIOC_ENUM_FMT:
ret = vidioc_enum_fmt(file, static_cast<struct v4l2_fmtdesc *>(arg));
break;
diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
index 707a0de6..5de2c5ae 100644
--- a/src/v4l2/v4l2_camera_proxy.h
+++ b/src/v4l2/v4l2_camera_proxy.h
@@ -48,6 +48,7 @@ private:
void freeBuffers();
int vidioc_querycap(struct v4l2_capability *arg);
+ int vidioc_enum_framesizes(V4L2CameraFile *file, struct v4l2_frmsizeenum *arg);
int vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *arg);
int vidioc_g_fmt(V4L2CameraFile *file, struct v4l2_format *arg);
int vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg);