@@ -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);
@@ -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);