[media] vivi: support control events
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
committed by
Mauro Carvalho Chehab
parent
85724983c4
commit
c7a52f8dce
@@ -31,6 +31,7 @@
|
|||||||
#include <media/v4l2-ioctl.h>
|
#include <media/v4l2-ioctl.h>
|
||||||
#include <media/v4l2-ctrls.h>
|
#include <media/v4l2-ctrls.h>
|
||||||
#include <media/v4l2-fh.h>
|
#include <media/v4l2-fh.h>
|
||||||
|
#include <media/v4l2-event.h>
|
||||||
#include <media/v4l2-common.h>
|
#include <media/v4l2-common.h>
|
||||||
|
|
||||||
#define VIVI_MODULE_NAME "vivi"
|
#define VIVI_MODULE_NAME "vivi"
|
||||||
@@ -978,12 +979,26 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
|
|||||||
if (i >= NUM_INPUTS)
|
if (i >= NUM_INPUTS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (i == dev->input)
|
||||||
|
return 0;
|
||||||
|
|
||||||
dev->input = i;
|
dev->input = i;
|
||||||
precalculate_bars(dev);
|
precalculate_bars(dev);
|
||||||
precalculate_line(dev);
|
precalculate_line(dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vidioc_subscribe_event(struct v4l2_fh *fh,
|
||||||
|
struct v4l2_event_subscription *sub)
|
||||||
|
{
|
||||||
|
switch (sub->type) {
|
||||||
|
case V4L2_EVENT_CTRL:
|
||||||
|
return v4l2_ctrl_subscribe_fh(fh, sub, 0);
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* --- controls ---------------------------------------------- */
|
/* --- controls ---------------------------------------------- */
|
||||||
|
|
||||||
static int vivi_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
|
static int vivi_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
@@ -1022,10 +1037,17 @@ static unsigned int
|
|||||||
vivi_poll(struct file *file, struct poll_table_struct *wait)
|
vivi_poll(struct file *file, struct poll_table_struct *wait)
|
||||||
{
|
{
|
||||||
struct vivi_dev *dev = video_drvdata(file);
|
struct vivi_dev *dev = video_drvdata(file);
|
||||||
|
struct v4l2_fh *fh = file->private_data;
|
||||||
struct vb2_queue *q = &dev->vb_vidq;
|
struct vb2_queue *q = &dev->vb_vidq;
|
||||||
|
unsigned int res;
|
||||||
|
|
||||||
dprintk(dev, 1, "%s\n", __func__);
|
dprintk(dev, 1, "%s\n", __func__);
|
||||||
return vb2_poll(q, file, wait);
|
res = vb2_poll(q, file, wait);
|
||||||
|
if (v4l2_event_pending(fh))
|
||||||
|
res |= POLLPRI;
|
||||||
|
else
|
||||||
|
poll_wait(file, &fh->events->wait, wait);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vivi_close(struct file *file)
|
static int vivi_close(struct file *file)
|
||||||
@@ -1132,7 +1154,7 @@ static const struct v4l2_ctrl_config vivi_ctrl_string = {
|
|||||||
|
|
||||||
static const struct v4l2_file_operations vivi_fops = {
|
static const struct v4l2_file_operations vivi_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = v4l2_fh_open,
|
.open = v4l2_fh_open,
|
||||||
.release = vivi_close,
|
.release = vivi_close,
|
||||||
.read = vivi_read,
|
.read = vivi_read,
|
||||||
.poll = vivi_poll,
|
.poll = vivi_poll,
|
||||||
@@ -1156,6 +1178,8 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = {
|
|||||||
.vidioc_s_input = vidioc_s_input,
|
.vidioc_s_input = vidioc_s_input,
|
||||||
.vidioc_streamon = vidioc_streamon,
|
.vidioc_streamon = vidioc_streamon,
|
||||||
.vidioc_streamoff = vidioc_streamoff,
|
.vidioc_streamoff = vidioc_streamoff,
|
||||||
|
.vidioc_subscribe_event = vidioc_subscribe_event,
|
||||||
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct video_device vivi_template = {
|
static struct video_device vivi_template = {
|
||||||
|
Reference in New Issue
Block a user