aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-01-18 16:16:26 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-01-18 16:16:26 +0100
commitfc89f67d9fe0cd9092d0609ffcc363508d544e50 (patch)
tree4215286523ee5dacdef4252df7536b41d5099159
parent2a368db7af32b1812a68c104810f3fa0213298f2 (diff)
v4l2-ctl: add support for VIDIOC_SUBDEV_QUERYCAP
This ioctl was introduce some time ago, but support for this was never added to v4l2-ctl. Fix this. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index ae3a3010..6da4698a 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -1120,7 +1120,8 @@ int main(int argc, char **argv)
const char *device = "/dev/video0"; /* -d device */
const char *out_device = nullptr;
const char *export_device = nullptr;
- struct v4l2_capability vcap; /* list_cap */
+ struct v4l2_capability vcap = {};
+ struct v4l2_subdev_capability subdevcap = {};
__u32 wait_for_event = 0; /* wait for this event */
const char *wait_event_id = nullptr;
__u32 poll_for_event = 0; /* poll for this event */
@@ -1131,8 +1132,6 @@ int main(int argc, char **argv)
char short_options[26 * 2 * 3 + 1];
int idx = 0;
- memset(&vcap, 0, sizeof(vcap));
-
if (argc == 1) {
common_usage();
return 0;
@@ -1339,10 +1338,16 @@ int main(int argc, char **argv)
if (!is_subdev && doioctl(fd, VIDIOC_QUERYCAP, &vcap)) {
fprintf(stderr, "%s: not a v4l2 node\n", device);
std::exit(EXIT_FAILURE);
+ } else if (is_subdev) {
+ // This ioctl was introduced in kernel 5.10, so don't
+ // exit if this ioctl returns an error.
+ doioctl(fd, VIDIOC_SUBDEV_QUERYCAP, &subdevcap);
+ }
+ if (!is_subdev) {
+ capabilities = vcap.capabilities;
+ if (capabilities & V4L2_CAP_DEVICE_CAPS)
+ capabilities = vcap.device_caps;
}
- capabilities = vcap.capabilities;
- if (capabilities & V4L2_CAP_DEVICE_CAPS)
- capabilities = vcap.device_caps;
media_fd = mi_get_media_fd(fd);
@@ -1446,10 +1451,13 @@ int main(int argc, char **argv)
/* Information Opts */
- if (!is_subdev && options[OptGetDriverInfo]) {
+ if (options[OptGetDriverInfo]) {
printf("Driver Info%s:\n",
options[OptUseWrapper] ? " (using libv4l2)" : "");
- v4l2_info_capability(vcap);
+ if (is_subdev)
+ v4l2_info_subdev_capability(subdevcap);
+ else
+ v4l2_info_capability(vcap);
}
if (options[OptGetDriverInfo] && media_fd >= 0)
mi_media_info_for_fd(media_fd, fd);

Privacy Policy