Re: [PATCH][libv4l] Support V4L2_CTRL_FLAG_NEXT_CTRL for fake controls

2009-05-17 Thread Hans de Goede



On 04/19/2009 12:45 AM, Adam Baker wrote:

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

Signed-off-by: Adam Baker


Thanks, reviewed and tested looks fine, so it has been applied to my tree:
http://linuxtv.org/hg/~hgoede/libv4l

And will be in the next libv4l release.

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][libv4l] Support V4L2_CTRL_FLAG_NEXT_CTRL for fake controls

2009-04-18 Thread 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

Signed-off-by: Adam Baker 
---
This isn't extensively tested but v4l2ucp (and my version does use the flag) now
lists both fake and original control for a camera with both and adds the fake 
controls
for a camera with none.
---
--- libv4l-0.5.97/libv4lconvert/control/libv4lcontrol.c 2009-04-14 
09:17:02.0 +0100
+++ new/libv4lconvert/control/libv4lcontrol.c   2009-04-18 23:36:28.0 
+0100
@@ -280,7 +280,10 @@
 {
   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) {
@@ -288,7 +291,21 @@
   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)

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html