@@ -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);
@@ -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. */
};