]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
media: v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl
authorHans Verkuil <hans.verkuil@cisco.com>
Thu, 7 May 2020 15:12:52 +0000 (17:12 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 12 May 2020 15:05:31 +0000 (17:05 +0200)
While normal video/radio/vbi/swradio nodes have a proper QUERYCAP ioctl
that apps can call to determine that it is indeed a V4L2 device, there
is currently no equivalent for v4l-subdev nodes. Adding this ioctl will
solve that, and it will allow utilities like v4l2-compliance to be used
with these devices as well.

SUBDEV_QUERYCAP currently returns the version and capabilities of the
subdevice. Define a capability flag to report if the subdevice is
registered in read-only mode.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/v4l2-core/v4l2-subdev.c
include/uapi/linux/v4l2-subdev.h

index 174778f9c0bc44cd19b2143c397b46172a827a95..665b0c0f74cf8f937b7929d5d4b698fca9f5325a 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 #include <linux/videodev2.h>
 #include <linux/export.h>
+#include <linux/version.h>
 
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
@@ -344,6 +345,16 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
        int rval;
 
        switch (cmd) {
+       case VIDIOC_SUBDEV_QUERYCAP: {
+               struct v4l2_subdev_capability *cap = arg;
+
+               memset(cap->reserved, 0, sizeof(cap->reserved));
+               cap->version = LINUX_VERSION_CODE;
+               cap->capabilities = ro_subdev ? V4L2_SUBDEV_CAP_RO_SUBDEV : 0;
+
+               return 0;
+       }
+
        case VIDIOC_QUERYCTRL:
                /*
                 * TODO: this really should be folded into v4l2_queryctrl (this
index 03970ce3074193e657705b8486397ce70bdda9d8..5d2a1dab79112be438c52e9c87cde86d9c2a7bfb 100644 (file)
@@ -155,9 +155,25 @@ struct v4l2_subdev_selection {
        __u32 reserved[8];
 };
 
+/**
+ * struct v4l2_subdev_capability - subdev capabilities
+ * @version: the driver versioning number
+ * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
+ * @reserved: for future use, set to zero for now
+ */
+struct v4l2_subdev_capability {
+       __u32 version;
+       __u32 capabilities;
+       __u32 reserved[14];
+};
+
+/* The v4l2 sub-device video device node is registered in read-only mode. */
+#define V4L2_SUBDEV_CAP_RO_SUBDEV              BIT(0)
+
 /* Backwards compatibility define --- to be removed */
 #define v4l2_subdev_edid v4l2_edid
 
+#define VIDIOC_SUBDEV_QUERYCAP                 _IOR('V',  0, struct v4l2_subdev_capability)
 #define VIDIOC_SUBDEV_G_FMT                    _IOWR('V',  4, struct v4l2_subdev_format)
 #define VIDIOC_SUBDEV_S_FMT                    _IOWR('V',  5, struct v4l2_subdev_format)
 #define VIDIOC_SUBDEV_G_FRAME_INTERVAL         _IOWR('V', 21, struct v4l2_subdev_frame_interval)