From 89b93efcabe5cc48d405d26843b53d288286752b Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Sat, 16 May 2009 12:57:18 +0200 Subject: libv4l: Support V4L2_CTRL_FLAG_NEXT_CTRL for fake controls From: Adam Baker The "fake" controls added by libv4l to provide whitebalance on some cameras do not respect the V4L2_CTRL_FLAG_NEXT_CTRL and hence don't appear on control programs that try to use that flag if there are any driver controls that do support the flag. Add support for V4L2_CTRL_FLAG_NEXT_CTRL Priority: normal Signed-off-by: Adam Baker Signed-off-by: Hans de Goede --- .../libv4l/libv4lconvert/control/libv4lcontrol.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'v4l2-apps/libv4l/libv4lconvert') diff --git a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c index 93c08c0c2..63de07bf1 100644 --- a/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c +++ b/v4l2-apps/libv4l/libv4lconvert/control/libv4lcontrol.c @@ -292,7 +292,10 @@ int v4lcontrol_vidioc_queryctrl(struct v4lcontrol_data *data, void *arg) { int i; struct v4l2_queryctrl *ctrl = arg; + int retval; + __u32 orig_id=ctrl->id; + /* if we have an exact match return it */ for (i = 0; i < V4LCONTROL_COUNT; i++) if ((data->controls & (1 << i)) && ctrl->id == fake_controls[i].id) { @@ -300,7 +303,21 @@ int v4lcontrol_vidioc_queryctrl(struct v4lcontrol_data *data, void *arg) return 0; } - return syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, arg); + /* find out what the kernel driver would respond. */ + retval = syscall(SYS_ioctl, data->fd, VIDIOC_QUERYCTRL, arg); + + /* if any of our controls have an id > orig_id but less than + ctrl->id then return that control instead. */ + if (orig_id & V4L2_CTRL_FLAG_NEXT_CTRL) + for (i = 0; i < V4LCONTROL_COUNT; i++) + if ((data->controls & (1 << i)) && + (fake_controls[i].id > (orig_id & ~V4L2_CTRL_FLAG_NEXT_CTRL)) && + (fake_controls[i].id <= ctrl->id)) { + memcpy(ctrl, &fake_controls[i], sizeof(struct v4l2_queryctrl)); + retval = 0; + } + + return retval; } int v4lcontrol_vidioc_g_ctrl(struct v4lcontrol_data *data, void *arg) -- cgit v1.2.3