From patchwork Tue Dec 22 16:43:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 2355 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Tue, 22 Dec 2009 16:45:10 +0000 Received: from bombadil.infradead.org [18.85.46.34] by gaivota.chehab.org with IMAP (fetchmail-6.3.11) for (single-drop); Tue, 22 Dec 2009 14:48:11 -0200 (BRST) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NN7rC-0004Qc-1X; Tue, 22 Dec 2009 16:45:10 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754108AbZLVQoH (ORCPT + 1 other); Tue, 22 Dec 2009 11:44:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754112AbZLVQoG (ORCPT ); Tue, 22 Dec 2009 11:44:06 -0500 Received: from smtp.nokia.com ([192.100.122.233]:49206 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753889AbZLVQnl (ORCPT ); Tue, 22 Dec 2009 11:43:41 -0500 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBMGhJfW006135; Tue, 22 Dec 2009 18:43:39 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 18:43:17 +0200 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 18:43:17 +0200 Received: from maxwell.research.nokia.com (maxwell.research.nokia.com [172.21.50.162]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nBMGhER9002141; Tue, 22 Dec 2009 18:43:14 +0200 Received: from lanttu (lanttu.localdomain [192.168.239.4]) by maxwell.research.nokia.com (Postfix) with ESMTPS id 80E667012A; Tue, 22 Dec 2009 18:43:12 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NN7pI-0002T0-3g; Tue, 22 Dec 2009 18:43:12 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, iivanov@mm-sol.com, hverkuil@xs4all.nl, gururaj.nagendra@intel.com Subject: [RFC v2 6/7] V4L: Events: Sequence numbers Date: Tue, 22 Dec 2009 18:43:10 +0200 Message-Id: <1261500191-9441-6-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1261500191-9441-5-git-send-email-sakari.ailus@maxwell.research.nokia.com> References: <4B30F713.8070004@maxwell.research.nokia.com> <1261500191-9441-1-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-3-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-4-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1261500191-9441-5-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-OriginalArrivalTime: 22 Dec 2009 16:43:17.0581 (UTC) FILETIME=[DCDA67D0:01CA8325] X-Nokia-AV: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add sequence numbers to events. Signed-off-by: Sakari Ailus --- drivers/media/video/v4l2-event.c | 8 ++++++++ include/media/v4l2-event.h | 1 + 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c index 72fdf7f..cc2bf57 100644 --- a/drivers/media/video/v4l2-event.c +++ b/drivers/media/video/v4l2-event.c @@ -58,6 +58,7 @@ void v4l2_event_init_fh(struct v4l2_fh *fh) INIT_LIST_HEAD(&events->subscribed); atomic_set(&events->navailable, 0); + events->sequence = 0; } EXPORT_SYMBOL_GPL(v4l2_event_init_fh); @@ -158,10 +159,16 @@ void v4l2_event_queue(struct video_device *vdev, struct v4l2_event *ev) list_for_each_entry(fh, &vdev->fh, list) { struct _v4l2_event *_ev; + u32 sequence; if (!v4l2_event_subscribed(fh, ev->type)) continue; + spin_lock(&fh->events.lock); + sequence = fh->events.sequence; + fh->events.sequence++; + spin_unlock(&fh->events.lock); + if (atomic_read(&fh->events.navailable) >= V4L2_MAX_EVENTS) continue; @@ -172,6 +179,7 @@ void v4l2_event_queue(struct video_device *vdev, struct v4l2_event *ev) _ev->event = *ev; spin_lock(&fh->events.lock); + _ev->event.sequence = sequence; list_add_tail(&_ev->list, &fh->events.available); spin_unlock(&fh->events.lock); diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h index 69305c6..5a778d4 100644 --- a/include/media/v4l2-event.h +++ b/include/media/v4l2-event.h @@ -44,6 +44,7 @@ struct v4l2_events { spinlock_t lock; /* Protect everything here. */ struct list_head available; atomic_t navailable; + u32 sequence; wait_queue_head_t wait; struct list_head subscribed; /* Subscribed events. */ };