aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/vivi.c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2011-06-07 09:20:23 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:53:20 -0400
commitc7a52f8dced9ee325b8e3a16a5ac07d191fc3d9b (patch)
treec4c275c829da006e0f901293c87b74abea8e12a0 /drivers/media/video/vivi.c
parent85724983c4d212c24116d45f6585a1c4ff845dd3 (diff)
[media] vivi: support control events
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/vivi.c')
-rw-r--r--drivers/media/video/vivi.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 2f0a1b40dd29..e81c10607bb2 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -31,6 +31,7 @@
31#include <media/v4l2-ioctl.h> 31#include <media/v4l2-ioctl.h>
32#include <media/v4l2-ctrls.h> 32#include <media/v4l2-ctrls.h>
33#include <media/v4l2-fh.h> 33#include <media/v4l2-fh.h>
34#include <media/v4l2-event.h>
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
35 36
36#define VIVI_MODULE_NAME "vivi" 37#define VIVI_MODULE_NAME "vivi"
@@ -978,12 +979,26 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
978 if (i >= NUM_INPUTS) 979 if (i >= NUM_INPUTS)
979 return -EINVAL; 980 return -EINVAL;
980 981
982 if (i == dev->input)
983 return 0;
984
981 dev->input = i; 985 dev->input = i;
982 precalculate_bars(dev); 986 precalculate_bars(dev);
983 precalculate_line(dev); 987 precalculate_line(dev);
984 return 0; 988 return 0;
985} 989}
986 990
991static int vidioc_subscribe_event(struct v4l2_fh *fh,
992 struct v4l2_event_subscription *sub)
993{
994 switch (sub->type) {
995 case V4L2_EVENT_CTRL:
996 return v4l2_ctrl_subscribe_fh(fh, sub, 0);
997 default:
998 return -EINVAL;
999 }
1000}
1001
987/* --- controls ---------------------------------------------- */ 1002/* --- controls ---------------------------------------------- */
988 1003
989static int vivi_g_volatile_ctrl(struct v4l2_ctrl *ctrl) 1004static int vivi_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
@@ -1022,10 +1037,17 @@ static unsigned int
1022vivi_poll(struct file *file, struct poll_table_struct *wait) 1037vivi_poll(struct file *file, struct poll_table_struct *wait)
1023{ 1038{
1024 struct vivi_dev *dev = video_drvdata(file); 1039 struct vivi_dev *dev = video_drvdata(file);
1040 struct v4l2_fh *fh = file->private_data;
1025 struct vb2_queue *q = &dev->vb_vidq; 1041 struct vb2_queue *q = &dev->vb_vidq;
1042 unsigned int res;
1026 1043
1027 dprintk(dev, 1, "%s\n", __func__); 1044 dprintk(dev, 1, "%s\n", __func__);
1028 return vb2_poll(q, file, wait); 1045 res = vb2_poll(q, file, wait);
1046 if (v4l2_event_pending(fh))
1047 res |= POLLPRI;
1048 else
1049 poll_wait(file, &fh->events->wait, wait);
1050 return res;
1029} 1051}
1030 1052
1031static int vivi_close(struct file *file) 1053static int vivi_close(struct file *file)
@@ -1132,7 +1154,7 @@ static const struct v4l2_ctrl_config vivi_ctrl_string = {
1132 1154
1133static const struct v4l2_file_operations vivi_fops = { 1155static const struct v4l2_file_operations vivi_fops = {
1134 .owner = THIS_MODULE, 1156 .owner = THIS_MODULE,
1135 .open = v4l2_fh_open, 1157 .open = v4l2_fh_open,
1136 .release = vivi_close, 1158 .release = vivi_close,
1137 .read = vivi_read, 1159 .read = vivi_read,
1138 .poll = vivi_poll, 1160 .poll = vivi_poll,
@@ -1156,6 +1178,8 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = {
1156 .vidioc_s_input = vidioc_s_input, 1178 .vidioc_s_input = vidioc_s_input,
1157 .vidioc_streamon = vidioc_streamon, 1179 .vidioc_streamon = vidioc_streamon,
1158 .vidioc_streamoff = vidioc_streamoff, 1180 .vidioc_streamoff = vidioc_streamoff,
1181 .vidioc_subscribe_event = vidioc_subscribe_event,
1182 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1159}; 1183};
1160 1184
1161static struct video_device vivi_template = { 1185static struct video_device vivi_template = {