From 44d06d8273e032119c5ae0d0f90bb57ab8118a5b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 15 Feb 2013 05:59:00 -0300 Subject: [PATCH] [media] s2255: add support for control events and prio handling Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/s2255/s2255drv.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 42c3afe215b2..55c972a0dbed 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c @@ -43,13 +43,14 @@ #include #include #include +#include +#include #include #include #include #include #include -#include -#include +#include #define S2255_VERSION "1.22.1" #define FIRMWARE_FILE_NAME "f2255usb.bin" @@ -295,6 +296,8 @@ struct s2255_buffer { }; struct s2255_fh { + /* this must be the first field in this struct */ + struct v4l2_fh fh; struct s2255_dev *dev; struct videobuf_queue vb_vidq; enum v4l2_buf_type type; @@ -1666,7 +1669,9 @@ static int __s2255_open(struct file *file) fh = kzalloc(sizeof(*fh), GFP_KERNEL); if (NULL == fh) return -ENOMEM; - file->private_data = fh; + v4l2_fh_init(&fh->fh, vdev); + v4l2_fh_add(&fh->fh); + file->private_data = &fh->fh; fh->dev = dev; fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fh->channel = channel; @@ -1709,12 +1714,13 @@ static unsigned int s2255_poll(struct file *file, { struct s2255_fh *fh = file->private_data; struct s2255_dev *dev = fh->dev; - int rc; + int rc = v4l2_ctrl_poll(file, wait); + dprintk(100, "%s\n", __func__); if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) return POLLERR; mutex_lock(&dev->lock); - rc = videobuf_poll_stream(file, &fh->vb_vidq, wait); + rc |= videobuf_poll_stream(file, &fh->vb_vidq, wait); mutex_unlock(&dev->lock); return rc; } @@ -1761,6 +1767,8 @@ static int s2255_release(struct file *file) videobuf_mmap_free(&fh->vb_vidq); mutex_unlock(&dev->lock); dprintk(1, "%s (dev=%s)\n", __func__, video_device_node_name(vdev)); + v4l2_fh_del(&fh->fh); + v4l2_fh_exit(&fh->fh); kfree(fh); return 0; } @@ -1815,6 +1823,9 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = { .vidioc_s_parm = vidioc_s_parm, .vidioc_g_parm = vidioc_g_parm, .vidioc_enum_frameintervals = vidioc_enum_frameintervals, + .vidioc_log_status = v4l2_ctrl_log_status, + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; static void s2255_video_device_release(struct video_device *vdev) @@ -1898,6 +1909,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev) channel->vdev.ctrl_handler = &channel->hdl; channel->vdev.lock = &dev->lock; channel->vdev.v4l2_dev = &dev->v4l2_dev; + set_bit(V4L2_FL_USE_FH_PRIO, &channel->vdev.flags); video_set_drvdata(&channel->vdev, channel); if (video_nr == -1) ret = video_register_device(&channel->vdev, -- 2.34.1