aboutsummaryrefslogtreecommitdiffstats
path: root/include
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
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')
-rw-r--r--include/linux/videodev2.h29
-rw-r--r--include/media/v4l2-ctrls.h23
-rw-r--r--include/media/v4l2-event.h2
3 files changed, 47 insertions, 7 deletions
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 8a4c309d2344..baafe2f2e02a 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -1791,6 +1791,7 @@ struct v4l2_streamparm {
1791#define V4L2_EVENT_ALL 0 1791#define V4L2_EVENT_ALL 0
1792#define V4L2_EVENT_VSYNC 1 1792#define V4L2_EVENT_VSYNC 1
1793#define V4L2_EVENT_EOS 2 1793#define V4L2_EVENT_EOS 2
1794#define V4L2_EVENT_CTRL 3
1794#define V4L2_EVENT_PRIVATE_START 0x08000000 1795#define V4L2_EVENT_PRIVATE_START 0x08000000
1795 1796
1796/* Payload for V4L2_EVENT_VSYNC */ 1797/* Payload for V4L2_EVENT_VSYNC */
@@ -1799,21 +1800,45 @@ struct v4l2_event_vsync {
1799 __u8 field; 1800 __u8 field;
1800} __attribute__ ((packed)); 1801} __attribute__ ((packed));
1801 1802
1803/* Payload for V4L2_EVENT_CTRL */
1804#define V4L2_EVENT_CTRL_CH_VALUE (1 << 0)
1805#define V4L2_EVENT_CTRL_CH_FLAGS (1 << 1)
1806
1807struct v4l2_event_ctrl {
1808 __u32 changes;
1809 __u32 type;
1810 union {
1811 __s32 value;
1812 __s64 value64;
1813 };
1814 __u32 flags;
1815 __s32 minimum;
1816 __s32 maximum;
1817 __s32 step;
1818 __s32 default_value;
1819};
1820
1802struct v4l2_event { 1821struct v4l2_event {
1803 __u32 type; 1822 __u32 type;
1804 union { 1823 union {
1805 struct v4l2_event_vsync vsync; 1824 struct v4l2_event_vsync vsync;
1825 struct v4l2_event_ctrl ctrl;
1806 __u8 data[64]; 1826 __u8 data[64];
1807 } u; 1827 } u;
1808 __u32 pending; 1828 __u32 pending;
1809 __u32 sequence; 1829 __u32 sequence;
1810 struct timespec timestamp; 1830 struct timespec timestamp;
1811 __u32 reserved[9]; 1831 __u32 id;
1832 __u32 reserved[8];
1812}; 1833};
1813 1834
1835#define V4L2_EVENT_SUB_FL_SEND_INITIAL (1 << 0)
1836
1814struct v4l2_event_subscription { 1837struct v4l2_event_subscription {
1815 __u32 type; 1838 __u32 type;
1816 __u32 reserved[7]; 1839 __u32 id;
1840 __u32 flags;
1841 __u32 reserved[5];
1817}; 1842};
1818 1843
1819/* 1844/*
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);