From 88af316150e9ef353d84b4071f912377759ef64e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 27 Jan 2012 16:18:42 -0300 Subject: [PATCH] --- yaml --- r: 294910 b: refs/heads/master c: a26243b0e3726d2b39dc23dd2c8717c52a286af4 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/media/video/v4l2-ctrls.c | 20 ++++++++++++++++++++ trunk/include/media/v4l2-ctrls.h | 9 +++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 25a1bac3876f..5ed9df4b5749 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 42194e728f067cde09a95ce522c108756d44c0be +refs/heads/master: a26243b0e3726d2b39dc23dd2c8717c52a286af4 diff --git a/trunk/drivers/media/video/v4l2-ctrls.c b/trunk/drivers/media/video/v4l2-ctrls.c index 7d58e4d420cd..909117203610 100644 --- a/trunk/drivers/media/video/v4l2-ctrls.c +++ b/trunk/drivers/media/video/v4l2-ctrls.c @@ -2394,3 +2394,23 @@ int v4l2_ctrl_log_status(struct file *file, void *fh) return 0; } EXPORT_SYMBOL(v4l2_ctrl_log_status); + +int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, + struct v4l2_event_subscription *sub) +{ + if (sub->type == V4L2_EVENT_CTRL) + return v4l2_event_subscribe(fh, sub, 0); + return -EINVAL; +} +EXPORT_SYMBOL(v4l2_ctrl_subscribe_event); + +unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait) +{ + struct v4l2_fh *fh = file->private_data; + + if (v4l2_event_pending(fh)) + return POLLPRI; + poll_wait(file, &fh->wait, wait); + return 0; +} +EXPORT_SYMBOL(v4l2_ctrl_poll); diff --git a/trunk/include/media/v4l2-ctrls.h b/trunk/include/media/v4l2-ctrls.h index 5f246c277ff8..3dbd06638506 100644 --- a/trunk/include/media/v4l2-ctrls.h +++ b/trunk/include/media/v4l2-ctrls.h @@ -33,6 +33,7 @@ struct video_device; struct v4l2_subdev; struct v4l2_subscribed_event; struct v4l2_fh; +struct poll_table_struct; /** struct v4l2_ctrl_ops - The control operations that the driver has to provide. * @g_volatile_ctrl: Get a new value for this control. Generally only relevant @@ -496,6 +497,14 @@ void v4l2_ctrl_del_event(struct v4l2_ctrl *ctrl, associated with the filehandle. */ int v4l2_ctrl_log_status(struct file *file, void *fh); +/* Can be used as a vidioc_subscribe_event function that just subscribes + control events. */ +int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, + struct v4l2_event_subscription *sub); + +/* Can be used as a poll function that just polls for control events. */ +unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait); + /* Helpers for ioctl_ops. If hdl == NULL then they will all return -EINVAL. */ int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc); int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm);