aboutsummaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2011-06-07 10:13:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:53:20 -0400
commit6e239399e5807132f86f64af6c659411c6a3d1a5 (patch)
treeeeb564a25341111f1c7d6e92137e910c4e4d37f3 /include/media
parentab892bac8438c5c2ff09a60d765d9b0c14941ba9 (diff)
[media] v4l2-ctrls: add control events
Whenever a control changes value or state an event is sent to anyone that subscribed to it. This functionality is useful for control panels but also for applications that need to wait for (usually status) controls to change value. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/v4l2-ctrls.h23
-rw-r--r--include/media/v4l2-event.h2
2 files changed, 20 insertions, 5 deletions
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index e720f11a56fd..c45bf40e080d 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -28,9 +28,10 @@
28/* forward references */ 28/* forward references */
29struct v4l2_ctrl_handler; 29struct v4l2_ctrl_handler;
30struct v4l2_ctrl; 30struct v4l2_ctrl;
31struct v4l2_fh;
32struct video_device; 31struct video_device;
33struct v4l2_subdev; 32struct v4l2_subdev;
33struct v4l2_event_subscription;
34struct v4l2_fh;
34 35
35/** struct v4l2_ctrl_ops - The control operations that the driver has to provide. 36/** struct v4l2_ctrl_ops - The control operations that the driver has to provide.
36 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant 37 * @g_volatile_ctrl: Get a new value for this control. Generally only relevant
@@ -107,6 +108,7 @@ struct v4l2_ctrl_ops {
107struct v4l2_ctrl { 108struct v4l2_ctrl {
108 /* Administrative fields */ 109 /* Administrative fields */
109 struct list_head node; 110 struct list_head node;
111 struct list_head fhs;
110 struct v4l2_ctrl_handler *handler; 112 struct v4l2_ctrl_handler *handler;
111 struct v4l2_ctrl **cluster; 113 struct v4l2_ctrl **cluster;
112 unsigned ncontrols; 114 unsigned ncontrols;
@@ -180,6 +182,11 @@ struct v4l2_ctrl_handler {
180 int error; 182 int error;
181}; 183};
182 184
185struct v4l2_ctrl_fh {
186 struct list_head node;
187 struct v4l2_fh *fh;
188};
189
183/** struct v4l2_ctrl_config - Control configuration structure. 190/** struct v4l2_ctrl_config - Control configuration structure.
184 * @ops: The control ops. 191 * @ops: The control ops.
185 * @id: The control ID. 192 * @id: The control ID.
@@ -425,9 +432,9 @@ struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id);
425 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically. 432 * This sets or clears the V4L2_CTRL_FLAG_INACTIVE flag atomically.
426 * Does nothing if @ctrl == NULL. 433 * Does nothing if @ctrl == NULL.
427 * This will usually be called from within the s_ctrl op. 434 * This will usually be called from within the s_ctrl op.
435 * The V4L2_EVENT_CTRL event will be generated afterwards.
428 * 436 *
429 * This function can be called regardless of whether the control handler 437 * This function assumes that the control handler is locked.
430 * is locked or not.
431 */ 438 */
432void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); 439void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
433 440
@@ -437,11 +444,12 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active);
437 * 444 *
438 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically. 445 * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically.
439 * Does nothing if @ctrl == NULL. 446 * Does nothing if @ctrl == NULL.
447 * The V4L2_EVENT_CTRL event will be generated afterwards.
440 * This will usually be called when starting or stopping streaming in the 448 * This will usually be called when starting or stopping streaming in the
441 * driver. 449 * driver.
442 * 450 *
443 * This function can be called regardless of whether the control handler 451 * This function assumes that the control handler is not locked and will
444 * is locked or not. 452 * take the lock itself.
445 */ 453 */
446void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); 454void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed);
447 455
@@ -486,6 +494,11 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl);
486 */ 494 */
487int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); 495int v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val);
488 496
497void v4l2_ctrl_add_fh(struct v4l2_ctrl_handler *hdl,
498 struct v4l2_ctrl_fh *ctrl_fh,
499 struct v4l2_event_subscription *sub);
500void v4l2_ctrl_del_fh(struct v4l2_ctrl *ctrl, struct v4l2_fh *fh);
501
489/* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ 502/* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */
490int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); 503int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc);
491int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm); 504int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);
diff --git a/include/media/v4l2-event.h b/include/media/v4l2-event.h
index 3b86177c8cd2..45e9c1e05513 100644
--- a/include/media/v4l2-event.h
+++ b/include/media/v4l2-event.h
@@ -40,6 +40,7 @@ struct v4l2_kevent {
40struct v4l2_subscribed_event { 40struct v4l2_subscribed_event {
41 struct list_head list; 41 struct list_head list;
42 u32 type; 42 u32 type;
43 u32 id;
43}; 44};
44 45
45struct v4l2_events { 46struct v4l2_events {
@@ -58,6 +59,7 @@ void v4l2_event_free(struct v4l2_fh *fh);
58int v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event, 59int v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event,
59 int nonblocking); 60 int nonblocking);
60void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev); 61void v4l2_event_queue(struct video_device *vdev, const struct v4l2_event *ev);
62void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev);
61int v4l2_event_pending(struct v4l2_fh *fh); 63int v4l2_event_pending(struct v4l2_fh *fh);
62int v4l2_event_subscribe(struct v4l2_fh *fh, 64int v4l2_event_subscribe(struct v4l2_fh *fh,
63 struct v4l2_event_subscription *sub); 65 struct v4l2_event_subscription *sub);