summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-07-20 16:20:36 +0200
committerHans Verkuil <hverkuil@xs4all.nl>2009-07-20 16:20:36 +0200
commit952c49f54e270f24e84923c228b98348e052317c (patch)
treef84cdfc438a994b1cddb76cd2942a6a37f6c0cc7
parent0b52ea5cb80b6745b684d77d006cfa78053dd6b0 (diff)
downloadmediapointer-dvb-s2-952c49f54e270f24e84923c228b98348e052317c.tar.gz
mediapointer-dvb-s2-952c49f54e270f24e84923c228b98348e052317c.tar.bz2
v4l2-ctl: fix broken camera control support.
From: Hans Verkuil <hverkuil@xs4all.nl> v4l2-ctl didn't properly support the camera controls. Priority: normal Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r--v4l2-apps/util/v4l2-ctl.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/v4l2-apps/util/v4l2-ctl.cpp b/v4l2-apps/util/v4l2-ctl.cpp
index 6f6b5e2f8..5410e5d03 100644
--- a/v4l2-apps/util/v4l2-ctl.cpp
+++ b/v4l2-apps/util/v4l2-ctl.cpp
@@ -147,6 +147,7 @@ static unsigned capabilities;
typedef std::vector<struct v4l2_ext_control> ctrl_list;
static ctrl_list user_ctrls;
static ctrl_list mpeg_ctrls;
+static ctrl_list camera_ctrls;
typedef std::map<std::string, unsigned> ctrl_strmap;
static ctrl_strmap ctrl_str2id;
@@ -2187,6 +2188,8 @@ set_vid_fmt_error:
ctrl.value = strtol(iter->second.c_str(), NULL, 0);
if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_MPEG)
mpeg_ctrls.push_back(ctrl);
+ else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_CAMERA)
+ camera_ctrls.push_back(ctrl);
else
user_ctrls.push_back(ctrl);
}
@@ -2217,6 +2220,22 @@ set_vid_fmt_error:
}
}
}
+ if (camera_ctrls.size()) {
+ ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA;
+ ctrls.count = camera_ctrls.size();
+ ctrls.controls = &camera_ctrls[0];
+ if (doioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls, "VIDIOC_S_EXT_CTRLS")) {
+ if (ctrls.error_idx >= ctrls.count) {
+ fprintf(stderr, "Error setting CAMERA controls: %s\n",
+ strerror(errno));
+ }
+ else {
+ fprintf(stderr, "%s: %s\n",
+ ctrl_id2str[camera_ctrls[ctrls.error_idx].id].c_str(),
+ strerror(errno));
+ }
+ }
+ }
}
/* Get options */
@@ -2432,6 +2451,7 @@ set_vid_fmt_error:
struct v4l2_ext_controls ctrls = { 0 };
mpeg_ctrls.clear();
+ camera_ctrls.clear();
user_ctrls.clear();
for (ctrl_get_list::iterator iter = get_ctrls.begin();
iter != get_ctrls.end(); ++iter) {
@@ -2440,6 +2460,8 @@ set_vid_fmt_error:
ctrl.id = ctrl_str2id[*iter];
if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_MPEG)
mpeg_ctrls.push_back(ctrl);
+ else if (V4L2_CTRL_ID2CLASS(ctrl.id) == V4L2_CTRL_CLASS_CAMERA)
+ camera_ctrls.push_back(ctrl);
else
user_ctrls.push_back(ctrl);
}
@@ -2461,6 +2483,17 @@ set_vid_fmt_error:
printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value);
}
}
+ if (camera_ctrls.size()) {
+ ctrls.ctrl_class = V4L2_CTRL_CLASS_CAMERA;
+ ctrls.count = camera_ctrls.size();
+ ctrls.controls = &camera_ctrls[0];
+ doioctl(fd, VIDIOC_G_EXT_CTRLS, &ctrls, "VIDIOC_G_EXT_CTRLS");
+ for (unsigned i = 0; i < camera_ctrls.size(); i++) {
+ struct v4l2_ext_control ctrl = camera_ctrls[i];
+
+ printf("%s: %d\n", ctrl_id2str[ctrl.id].c_str(), ctrl.value);
+ }
+ }
}
if (options[OptGetTuner]) {