diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-09-15 14:04:45 +0200 |
---|---|---|
committer | Hans Verkuil <hans.verkuil@cisco.com> | 2014-09-15 14:04:45 +0200 |
commit | 0ba5ee4ba7854f09ce327d410f88d0c06040ce95 (patch) | |
tree | 9d3441df3b2caf9c3947d0966d20b768eb724fa5 | |
parent | 8a4ac8966b367c90c81e0edf236df7409cee081a (diff) |
v4l2-ctl: fix control support for old kernels.
For old kernels that return -EINVAL if QUERY_EXT_CTRL does not exist
no controls are reported anymore. Add an explicit test whether
QUERY_EXT_CTRL exists.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r-- | utils/v4l2-ctl/v4l2-ctl-common.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index a9f4e059..e00b428e 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -51,6 +51,8 @@ typedef std::map<std::string, std::string> dev_map; static enum v4l2_priority prio = V4L2_PRIORITY_UNSET; +static bool have_query_ext_ctrl; + void common_usage(void) { printf("\nGeneral/Common options:\n" @@ -451,9 +453,11 @@ static int query_ext_ctrl_ioctl(int fd, struct v4l2_query_ext_ctrl &qctrl) struct v4l2_queryctrl qc; int rc; - rc = test_ioctl(fd, VIDIOC_QUERY_EXT_CTRL, &qctrl); - if (errno != ENOTTY) - return rc; + if (have_query_ext_ctrl) { + rc = test_ioctl(fd, VIDIOC_QUERY_EXT_CTRL, &qctrl); + if (errno != ENOTTY) + return rc; + } qc.id = qctrl.id; rc = test_ioctl(fd, VIDIOC_QUERYCTRL, &qc); if (rc == 0) { @@ -553,6 +557,14 @@ int common_find_ctrl_id(const char *name) void common_process_controls(int fd) { + struct v4l2_query_ext_ctrl qc = { + V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND + }; + int rc; + + rc = test_ioctl(fd, VIDIOC_QUERY_EXT_CTRL, &qc); + have_query_ext_ctrl = rc == 0; + find_controls(fd); for (ctrl_get_list::iterator iter = get_ctrls.begin(); iter != get_ctrls.end(); ++iter) { if (ctrl_str2q.find(*iter) == ctrl_str2q.end()) { |