diff options
author | Hans de Goede <hdegoede@redhat.com> | 2012-04-08 11:59:46 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-07 15:28:35 -0400 |
commit | c53c2549333b340e2662dc64ec81323476b69a97 (patch) | |
tree | 4bd55780eba1302caaf7359631b996043dc1082f /include | |
parent | a22d85fea89744fad2cb215da1fe0c1ce226a613 (diff) |
[media] v4l2-event: Add v4l2_subscribed_event_ops
Just like with ctrl events, drivers may want to get called back on
listener add / remove for other event types too. Rather then special
casing all of this in subscribe / unsubscribe event it is better to
use ops for this.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/media/v4l2-event.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h index 5f14e8895ce2..88fa9a1e0df3 100644 --- a/include/media/v4l2-event.h +++ b/include/media/v4l2-event.h | |||
@@ -78,6 +78,19 @@ struct v4l2_kevent { | |||
78 | struct v4l2_event event; | 78 | struct v4l2_event event; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** struct v4l2_subscribed_event_ops - Subscribed event operations. | ||
82 | * @add: Optional callback, called when a new listener is added | ||
83 | * @del: Optional callback, called when a listener stops listening | ||
84 | * @replace: Optional callback that can replace event 'old' with event 'new'. | ||
85 | * @merge: Optional callback that can merge event 'old' into event 'new'. | ||
86 | */ | ||
87 | struct v4l2_subscribed_event_ops { | ||
88 | int (*add)(struct v4l2_subscribed_event *sev); | ||
89 | void (*del)(struct v4l2_subscribed_event *sev); | ||
90 | void (*replace)(struct v4l2_event *old, const struct v4l2_event *new); | ||
91 | void (*merge)(const struct v4l2_event *old, struct v4l2_event *new); | ||
92 | }; | ||
93 | |||
81 | /** struct v4l2_subscribed_event - Internal struct representing a subscribed event. | 94 | /** struct v4l2_subscribed_event - Internal struct representing a subscribed event. |
82 | * @list: List node for the v4l2_fh->subscribed list. | 95 | * @list: List node for the v4l2_fh->subscribed list. |
83 | * @type: Event type. | 96 | * @type: Event type. |
@@ -85,8 +98,7 @@ struct v4l2_kevent { | |||
85 | * @flags: Copy of v4l2_event_subscription->flags. | 98 | * @flags: Copy of v4l2_event_subscription->flags. |
86 | * @fh: Filehandle that subscribed to this event. | 99 | * @fh: Filehandle that subscribed to this event. |
87 | * @node: List node that hooks into the object's event list (if there is one). | 100 | * @node: List node that hooks into the object's event list (if there is one). |
88 | * @replace: Optional callback that can replace event 'old' with event 'new'. | 101 | * @ops: v4l2_subscribed_event_ops |
89 | * @merge: Optional callback that can merge event 'old' into event 'new'. | ||
90 | * @elems: The number of elements in the events array. | 102 | * @elems: The number of elements in the events array. |
91 | * @first: The index of the events containing the oldest available event. | 103 | * @first: The index of the events containing the oldest available event. |
92 | * @in_use: The number of queued events. | 104 | * @in_use: The number of queued events. |
@@ -99,10 +111,7 @@ struct v4l2_subscribed_event { | |||
99 | u32 flags; | 111 | u32 flags; |
100 | struct v4l2_fh *fh; | 112 | struct v4l2_fh *fh; |
101 | struct list_head node; | 113 | struct list_head node; |
102 | void (*replace)(struct v4l2_event *old, | 114 | const struct v4l2_subscribed_event_ops *ops; |
103 | const struct v4l2_event *new); | ||
104 | void (*merge)(const struct v4l2_event *old, | ||
105 | struct v4l2_event *new); | ||
106 | unsigned elems; | 115 | unsigned elems; |
107 | unsigned first; | 116 | unsigned first; |
108 | unsigned in_use; | 117 | unsigned in_use; |
@@ -115,7 +124,8 @@ void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev); | |||
115 | void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev); | 124 | void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev); |
116 | int v4l2_event_pending(struct v4l2_fh *fh); | 125 | int v4l2_event_pending(struct v4l2_fh *fh); |
117 | int v4l2_event_subscribe(struct v4l2_fh *fh, | 126 | int v4l2_event_subscribe(struct v4l2_fh *fh, |
118 | struct v4l2_event_subscription *sub, unsigned elems); | 127 | struct v4l2_event_subscription *sub, unsigned elems, |
128 | const struct v4l2_subscribed_event_ops *ops); | ||
119 | int v4l2_event_unsubscribe(struct v4l2_fh *fh, | 129 | int v4l2_event_unsubscribe(struct v4l2_fh *fh, |
120 | struct v4l2_event_subscription *sub); | 130 | struct v4l2_event_subscription *sub); |
121 | void v4l2_event_unsubscribe_all(struct v4l2_fh *fh); | 131 | void v4l2_event_unsubscribe_all(struct v4l2_fh *fh); |