History

media: v4l2-subdev: add VIDIOC_SUBDEV_QUERYCAP ioctl

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.

Hans Verkuil committed 6 years ago

Commit 6446ec61 parent fb15db82 files · +27 −0Browse files

Unified · Split

2 files
  1. drivers/media/v4l2-core/v4l2-subdev.c +11 −0
  2. include/uapi/linux/v4l2-subdev.h +16 −0
drivers/media/v4l2-core/v4l2-subdev.c+11−0
@@ -15,6 +15,7 @@ · 14 unmodified lines
15#include <linux/types.h>15#include <linux/types.h>
16#include <linux/videodev2.h>16#include <linux/videodev2.h>
17#include <linux/export.h>17#include <linux/export.h>
18#include <linux/version.h>
18 19
19#include <media/v4l2-ctrls.h>20#include <media/v4l2-ctrls.h>
20#include <media/v4l2-device.h>21#include <media/v4l2-device.h>
@@ -344,6 +345,16 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) · 323 unmodified lines
344 int rval;345 int rval;
345 346
346 switch (cmd) {347 switch (cmd) {
348 case VIDIOC_SUBDEV_QUERYCAP: {
349 struct v4l2_subdev_capability *cap = arg;
350
351 memset(cap->reserved, 0, sizeof(cap->reserved));
352 cap->version = LINUX_VERSION_CODE;
353 cap->capabilities = ro_subdev ? V4L2_SUBDEV_CAP_RO_SUBDEV : 0;
354
355 return 0;
356 }
357
347 case VIDIOC_QUERYCTRL:358 case VIDIOC_QUERYCTRL:
348 /*359 /*
349 * TODO: this really should be folded into v4l2_queryctrl (this360 * TODO: this really should be folded into v4l2_queryctrl (this
include/uapi/linux/v4l2-subdev.h+16−0
@@ -155,9 +155,25 @@ struct v4l2_subdev_selection { · 154 unmodified lines
155 __u32 reserved[8];155 __u32 reserved[8];
156};156};
157 157
158/**
159 * struct v4l2_subdev_capability - subdev capabilities
160 * @version: the driver versioning number
161 * @capabilities: the subdev capabilities, see V4L2_SUBDEV_CAP_*
162 * @reserved: for future use, set to zero for now
163 */
164struct v4l2_subdev_capability {
165 __u32 version;
166 __u32 capabilities;
167 __u32 reserved[14];
168};
169
170/* The v4l2 sub-device video device node is registered in read-only mode. */
171#define V4L2_SUBDEV_CAP_RO_SUBDEV BIT(0)
172
158/* Backwards compatibility define --- to be removed */173/* Backwards compatibility define --- to be removed */
159#define v4l2_subdev_edid v4l2_edid174#define v4l2_subdev_edid v4l2_edid
160 175
176#define VIDIOC_SUBDEV_QUERYCAP _IOR('V', 0, struct v4l2_subdev_capability)
161#define VIDIOC_SUBDEV_G_FMT _IOWR('V', 4, struct v4l2_subdev_format)177#define VIDIOC_SUBDEV_G_FMT _IOWR('V', 4, struct v4l2_subdev_format)
162#define VIDIOC_SUBDEV_S_FMT _IOWR('V', 5, struct v4l2_subdev_format)178#define VIDIOC_SUBDEV_S_FMT _IOWR('V', 5, struct v4l2_subdev_format)
163#define VIDIOC_SUBDEV_G_FRAME_INTERVAL _IOWR('V', 21, struct v4l2_subdev_frame_interval)179#define VIDIOC_SUBDEV_G_FRAME_INTERVAL _IOWR('V', 21, struct v4l2_subdev_frame_interval)