From patchwork Sat Feb 6 18:02:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 77543 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o16I2Po2032609 for ; Sat, 6 Feb 2010 18:02:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755922Ab0BFSCX (ORCPT ); Sat, 6 Feb 2010 13:02:23 -0500 Received: from smtp.nokia.com ([192.100.122.230]:19297 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755746Ab0BFSCV (ORCPT ); Sat, 6 Feb 2010 13:02:21 -0500 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o16I2Hwa025217; Sat, 6 Feb 2010 20:02:18 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 6 Feb 2010 20:02:17 +0200 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Sat, 6 Feb 2010 20:02:17 +0200 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.50.162]) by mgw-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o16I2F4w032417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 6 Feb 2010 20:02:15 +0200 Received: from lanttu (unknown [192.168.239.74]) by maxwell.research.nokia.com (Postfix) with ESMTPS id 3315C7012A; Sat, 6 Feb 2010 20:02:15 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1Ndoyz-0005My-Sa; Sat, 06 Feb 2010 20:02:13 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hans.verkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, gururaj.nagendra@intel.com, david.cohen@nokia.com, iivanov@mm-sol.com, Sakari Ailus Subject: [PATCH 7/8] V4L: Events: Sequence numbers Date: Sat, 6 Feb 2010 20:02:10 +0200 Message-Id: <1265479331-20595-7-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <4B6DAE5A.5090508@maxwell.research.nokia.com> References: <4B6DAE5A.5090508@maxwell.research.nokia.com> X-OriginalArrivalTime: 06 Feb 2010 18:02:17.0269 (UTC) FILETIME=[84EDE650:01CAA756] X-Nokia-AV: Clean 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.3 (demeter.kernel.org [140.211.167.41]); Sat, 06 Feb 2010 18:02:25 +0000 (UTC) diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c index b921229..7446b3d 100644 --- a/drivers/media/video/v4l2-event.c +++ b/drivers/media/video/v4l2-event.c @@ -108,6 +108,7 @@ int v4l2_event_init(struct v4l2_fh *fh, unsigned int n) INIT_LIST_HEAD(&fh->events->subscribed); atomic_set(&fh->events->navailable, 0); + atomic_set(&fh->events->sequence, -1); ret = v4l2_event_alloc(fh, n); if (ret < 0) @@ -190,6 +191,7 @@ void v4l2_event_queue(struct video_device *vdev, struct v4l2_event *ev) list_for_each_entry(fh, &vdev->fhs.list, list) { struct v4l2_events *events = fh->events; struct v4l2_kevent *kev; + u32 sequence; /* Is it subscribed? */ if (!v4l2_event_subscribed(fh, ev->type)) @@ -209,6 +211,9 @@ void v4l2_event_queue(struct video_device *vdev, struct v4l2_event *ev) } put_me = fh; + /* Increase event sequence number on fh. */ + sequence = atomic_inc_return(&events->sequence); + /* Do we have any free events? */ spin_lock_irqsave(&fh->lock, flags); if (list_empty(&events->free)) { @@ -223,6 +228,7 @@ void v4l2_event_queue(struct video_device *vdev, struct v4l2_event *ev) spin_unlock_irqrestore(&fh->lock, flags); kev->event = *ev; + kev->event.sequence = sequence; /* And add to the available list. */ spin_lock_irqsave(&fh->lock, flags); diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h index 282d215..3db0c3b 100644 --- a/include/media/v4l2-event.h +++ b/include/media/v4l2-event.h @@ -49,6 +49,7 @@ struct v4l2_events { struct list_head available; /* Dequeueable event */ atomic_t navailable; struct list_head free; /* Events ready for use */ + atomic_t sequence; }; int v4l2_event_alloc(struct v4l2_fh *fh, unsigned int n);