From patchwork Sat Apr 18 22:45:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Baker X-Patchwork-Id: 18875 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3IMkQLF003004 for ; Sat, 18 Apr 2009 22:46:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753830AbZDRWpy (ORCPT ); Sat, 18 Apr 2009 18:45:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755245AbZDRWpy (ORCPT ); Sat, 18 Apr 2009 18:45:54 -0400 Received: from mk-outboundfilter-6.mail.uk.tiscali.com ([212.74.114.14]:7742 "EHLO mk-outboundfilter-6.mail.uk.tiscali.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753830AbZDRWpx (ORCPT ); Sat, 18 Apr 2009 18:45:53 -0400 X-Trace: 94799086/mk-outboundfilter-6.mail.uk.tiscali.com/PIPEX/$PIPEX-ACCEPTED/pipex-customers/62.190.239.28/None/linux@baker-net.org.uk X-SBRS: None X-RemoteIP: 62.190.239.28 X-IP-MAIL-FROM: linux@baker-net.org.uk X-SMTP-AUTH: X-MUA: KMail/1.11.2 (Linux/2.6.28-11-generic; KDE/4.2.2; i686; ; ) X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai8FAEP16Uk+vu8c/2dsb2JhbACBTsseg30G X-IronPort-AV: E=Sophos;i="4.40,210,1238972400"; d="scan'208";a="94799086" X-IP-Direction: IN Received: from userch028.dsl.pipex.com (HELO gromit.localnet) ([62.190.239.28]) by smtp.pipex.tiscali.co.uk with ESMTP; 18 Apr 2009 23:45:50 +0100 From: Adam Baker To: video4linux-list@redhat.com Subject: [PATCH][libv4l] Support V4L2_CTRL_FLAG_NEXT_CTRL for fake controls Date: Sat, 18 Apr 2009 23:45:48 +0100 User-Agent: KMail/1.11.2 (Linux/2.6.28-11-generic; KDE/4.2.2; i686; ; ) Cc: Hans de Goede , SPCA50x Linux Device Driver Development , Linux Media Mailing List References: <49E5D4DE.6090108@hhs.nl> <49E9B989.70602@redhat.com> <200904182044.06879.linux@baker-net.org.uk> In-Reply-To: <200904182044.06879.linux@baker-net.org.uk> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200904182345.48441.linux@baker-net.org.uk> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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. --- -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- libv4l-0.5.97/libv4lconvert/control/libv4lcontrol.c 2009-04-14 09:17:02.000000000 +0100 +++ new/libv4lconvert/control/libv4lcontrol.c 2009-04-18 23:36:28.000000000 +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)