[RFC v2 6/7] V4L: Events: Sequence numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add sequence numbers to events.

Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxxxxxxxxxxxxx>
---
 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. */
 };
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux