From patchwork Wed Jun 29 12:00:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hans Verkuil (hansverk)" X-Patchwork-Id: 928292 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5TC0oME024044 for ; Wed, 29 Jun 2011 12:00:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755111Ab1F2MAs (ORCPT ); Wed, 29 Jun 2011 08:00:48 -0400 Received: from ams-iport-1.cisco.com ([144.254.224.140]:55759 "EHLO ams-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753781Ab1F2MAs (ORCPT ); Wed, 29 Jun 2011 08:00:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=hansverk@cisco.com; l=5032; q=dns/txt; s=iport; t=1309348847; x=1310558447; h=from:to:subject:date:cc:mime-version: content-transfer-encoding:message-id; bh=/Q2eRPaEftOCNe1VnHsRIMnsCK/fZMzeC4HZt/xK6vA=; b=MtMxCDgd3JtwS4cNGW+B5nuGNPSNrS5SU2MJNJoiwsensefzjsMDYZYy Pmw4UPRRUvAXx+bDrxck2iw6SIMIHazu+uE4Xii2mjVouuL0vCWsBrBbo Dy+0ZyernvIjcwU8ab6e7DCAeh3/ckkDkciePJS3GhxxqjXz/Y3aquZKQ w=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAKoSC06Q/khN/2dsb2JhbABSp1l3q0aeHoYwBJIXhH6DEIge X-IronPort-AV: E=Sophos;i="4.65,443,1304294400"; d="scan'208";a="98805665" Received: from ams-core-4.cisco.com ([144.254.72.77]) by ams-iport-1.cisco.com with ESMTP; 29 Jun 2011 12:00:46 +0000 Received: from OSLEXCP11.eu.tandberg.int ([173.38.136.5]) by ams-core-4.cisco.com (8.14.3/8.14.3) with ESMTP id p5TC0jLA003192; Wed, 29 Jun 2011 12:00:45 GMT Received: from ultra.eu.tandberg.int ([10.47.1.15]) by OSLEXCP11.eu.tandberg.int with Microsoft SMTPSVC(6.0.3790.4675); Wed, 29 Jun 2011 14:00:46 +0200 Received: from cobaltpc1.localnet ([10.54.77.72]) by ultra.eu.tandberg.int (8.13.1/8.13.1) with ESMTP id p5TC0j6T001473; Wed, 29 Jun 2011 14:00:46 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [RFCv2 PATCH] Add support for V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK Date: Wed, 29 Jun 2011 14:00:37 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.35-27-generic; KDE/4.6.1; x86_64; ; ) Cc: Laurent Pinchart MIME-Version: 1.0 Message-Id: <201106291400.37234.hansverk@cisco.com> X-OriginalArrivalTime: 29 Jun 2011 12:00:46.0247 (UTC) FILETIME=[2DEB9B70:01CC3654] Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 29 Jun 2011 12:00:51 +0000 (UTC) Hi all, Second attempt: inverted the meaning of the flag as per Laurent's suggestion. Regards, Hans Normally no control events will go to the filehandle that called the VIDIOC_S_CTRL/VIDIOC_S_EXT_CTRLS ioctls. This is to prevent a feedback loop. This can now be overridden by setting the new V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK flag. Based on suggestions from Mauro Carvalho Chehab and Laurent Pinchart . Signed-off-by: Hans Verkuil --- .../DocBook/media/v4l/vidioc-subscribe-event.xml | 36 ++++++++++++++++---- drivers/media/video/v4l2-ctrls.c | 3 +- include/linux/videodev2.h | 3 +- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml index 039a969..25471e8 100644 --- a/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml +++ b/Documentation/DocBook/media/v4l/vidioc-subscribe-event.xml @@ -114,25 +114,28 @@ V4L2_EVENT_CTRL 3 - This event requires that the id + This event requires that the id matches the control ID from which you want to receive events. This event is triggered if the control's value changes, if a button control is pressed or if the control's flags change. This event has a &v4l2-event-ctrl; associated with it. This struct contains much of the same information as &v4l2-queryctrl; and - &v4l2-control;. + &v4l2-control;. - If the event is generated due to a call to &VIDIOC-S-CTRL; or - &VIDIOC-S-EXT-CTRLS;, then the event will not be sent to + If the event is generated due to a call to &VIDIOC-S-CTRL; or + &VIDIOC-S-EXT-CTRLS;, then the event will not be sent to the file handle that called the ioctl function. This prevents - nasty feedback loops. + nasty feedback loops. If you do want to get the + event, then set the V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK + flag. + - This event type will ensure that no information is lost when + This event type will ensure that no information is lost when more events are raised than there is room internally. In that case the &v4l2-event-ctrl; of the second-oldest event is kept, but the changes field of the second-oldest event is ORed with the changes - field of the oldest event. + field of the oldest event. @@ -157,6 +160,25 @@ that are triggered by a status change such as V4L2_EVENT_CTRL. Other events will ignore this flag. + + V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK + 0x0002 + If set, then events directly caused by an ioctl will also be sent to + the filehandle that called that ioctl. For example, changing a control using + &VIDIOC-S-CTRL; will cause a V4L2_EVENT_CTRL to be sent back to that same + filehandle. Normally such events are suppressed to prevent feedback loops + where an application changes a control to a one value and then another, and + then receives an event telling it that that control has changed to the first + value. + + Since it can't tell whether that event was caused by another application + or by the &VIDIOC-S-CTRL; call it is hard to decide whether to set the + control to the value in the event, or ignore it. + + Think carefully when you set this flag so you won't get into situations + like that. + + diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c index bc08f86..bd2456d 100644 --- a/drivers/media/video/v4l2-ctrls.c +++ b/drivers/media/video/v4l2-ctrls.c @@ -590,7 +590,8 @@ static void send_event(struct v4l2_fh *fh, struct v4l2_ctrl *ctrl, u32 changes) fill_event(&ev, ctrl, changes); list_for_each_entry(sev, &ctrl->ev_subs, node) - if (sev->fh && sev->fh != fh) + if (sev->fh && (sev->fh != fh || + (sev->flags & V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK))) v4l2_event_queue_fh(sev->fh, &ev); } diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index baafe2f..2c4e837 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h @@ -1832,7 +1832,8 @@ struct v4l2_event { __u32 reserved[8]; }; -#define V4L2_EVENT_SUB_FL_SEND_INITIAL (1 << 0) +#define V4L2_EVENT_SUB_FL_SEND_INITIAL (1 << 0) +#define V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK (1 << 1) struct v4l2_event_subscription { __u32 type;