From patchwork Tue Feb 9 18:26:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 78090 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 o19IRNMU017923 for ; Tue, 9 Feb 2010 18:27:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751556Ab0BIS1T (ORCPT ); Tue, 9 Feb 2010 13:27:19 -0500 Received: from smtp.nokia.com ([192.100.105.134]:55754 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751089Ab0BIS1H (ORCPT ); Tue, 9 Feb 2010 13:27:07 -0500 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o19IQDkP027353; Tue, 9 Feb 2010 12:27:04 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 9 Feb 2010 20:26:53 +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); Tue, 9 Feb 2010 20:26:52 +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 o19IQoYT028865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Feb 2010 20:26:51 +0200 Received: from lanttu (lanttu.localdomain [192.168.239.4]) by maxwell.research.nokia.com (Postfix) with ESMTPS id C48CF7010D; Tue, 9 Feb 2010 20:26:50 +0200 (EET) Received: from sakke by lanttu with local (Exim 4.69) (envelope-from ) id 1NeunS-0006IK-Im; Tue, 09 Feb 2010 20:26:50 +0200 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, iivanov@mm-sol.com, gururaj.nagendra@intel.com, david.cohen@nokia.com Subject: [PATCH v3 6/7] V4L: Events: Sequence numbers Date: Tue, 9 Feb 2010 20:26:49 +0200 Message-Id: <1265740010-24144-6-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1265740010-24144-5-git-send-email-sakari.ailus@maxwell.research.nokia.com> References: <4B71A8DF.8070907@maxwell.research.nokia.com> <1265740010-24144-1-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-2-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-3-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-4-git-send-email-sakari.ailus@maxwell.research.nokia.com> <1265740010-24144-5-git-send-email-sakari.ailus@maxwell.research.nokia.com> X-OriginalArrivalTime: 09 Feb 2010 18:26:52.0614 (UTC) FILETIME=[738AEE60:01CAA9B5] 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]); Tue, 09 Feb 2010 18:27:23 +0000 (UTC) diff --git a/drivers/media/video/v4l2-event.c b/drivers/media/video/v4l2-event.c index eeaba4c..3a4065a 100644 --- a/drivers/media/video/v4l2-event.c +++ b/drivers/media/video/v4l2-event.c @@ -93,6 +93,7 @@ int v4l2_event_init(struct v4l2_fh *fh, unsigned int n, unsigned int max_events) atomic_set(&fh->events->navailable, 0); atomic_set(&fh->events->max_events, max_events); + atomic_set(&fh->events->sequence, -1); ret = v4l2_event_alloc(fh, n); if (ret < 0) @@ -170,15 +171,23 @@ void v4l2_event_queue(struct video_device *vdev, struct v4l2_event *ev) list_for_each_entry(fh, &vdev->fh_list, list) { struct v4l2_events *events = fh->events; struct v4l2_kevent *kev; + u32 sequence; - /* Do we have any free events and are we subscribed? */ - if (list_empty(&events->free) || - !__v4l2_event_subscribed(fh, ev->type)) + /* Are we subscribed? */ + if (!__v4l2_event_subscribed(fh, ev->type)) + continue; + + /* Increase event sequence number on fh. */ + sequence = atomic_inc_return(&events->sequence); + + /* Do we have any free events? */ + if (list_empty(&events->free)) continue; /* Take one and fill it. */ kev = list_first_entry(&events->free, struct v4l2_kevent, list); kev->event = *ev; + kev->event.sequence = sequence; list_move_tail(&kev->list, &events->available); atomic_inc(&events->navailable); diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h index a9d0333..3b69582 100644 --- a/include/media/v4l2-event.h +++ b/include/media/v4l2-event.h @@ -50,6 +50,7 @@ struct v4l2_events { atomic_t navailable; atomic_t max_events; /* Never allocate more. */ struct list_head free; /* Events ready for use */ + atomic_t sequence; }; int v4l2_event_alloc(struct v4l2_fh *fh, unsigned int n);