From 1ebb6eae3f9dc67b3bb68184bb1e4dd911263688 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 27 Jun 2008 18:16:22 +0200 Subject: v4l2-ctl: fix bug in --set-standard From: Hans Verkuil --set-standard allows you to set a standard index corresponding to what ENUMSTD returns. But this clashes when you specify a standard whose ID is very small, like PAL-BG. Then the utility thinks you specified a standard index and will select the wrong standard. Fixed by using a flag to mark that the standard actually is a standard and not a standard index. Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-ctl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'v4l2-apps/util/v4l2-ctl.cpp') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index d637e34d7..8a9287418 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -1365,7 +1365,7 @@ int main(int argc, char **argv) std = V4L2_STD_SECAM; } else { - std = strtol(optarg, 0L, 0); + std = strtol(optarg, 0L, 0) | (1ULL << 63); } break; case OptGetCtrl: @@ -1562,8 +1562,8 @@ int main(int argc, char **argv) } if (options[OptSetStandard]) { - if (std < 16) { - vs.index = std; + if (std & (1ULL << 63)) { + vs.index = std & 0xffff; if (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) { std = vs.id; } -- cgit v1.2.3 From 7c2a34949f56cc9bd1cf1a1295ee58041499730b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 29 Jun 2008 11:27:34 +0200 Subject: v4l2-ctl: improve handling of control names with non-alnum chars From: Hans Verkuil Signed-off-by: Hans Verkuil --- v4l2-apps/util/v4l2-ctl.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'v4l2-apps/util/v4l2-ctl.cpp') diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp index 8a9287418..57d98fc13 100644 --- a/v4l2-apps/util/v4l2-ctl.cpp +++ b/v4l2-apps/util/v4l2-ctl.cpp @@ -485,10 +485,16 @@ static void print_sliced_vbi_cap(struct v4l2_sliced_vbi_cap &cap) static std::string name2var(unsigned char *name) { std::string s; + int add_underscore = 0; while (*name) { - if (*name == ' ') s += "_"; - else s += std::string(1, tolower(*name)); + if (isalnum(*name)) { + if (add_underscore) + s += '_'; + add_underscore = 0; + s += std::string(1, tolower(*name)); + } + else if (s.length()) add_underscore = 1; name++; } return s; -- cgit v1.2.3