aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-15 03:59:00 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 13:35:47 -0500
commit44d06d8273e032119c5ae0d0f90bb57ab8118a5b (patch)
treeb8554d7a59426e04df466913cd0b485d5ed1abe3
parent7041dec7a93039d1386ad0f5070dc2318d66a18d (diff)
[media] s2255: add support for control events and prio handling
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/usb/s2255/s2255drv.c22
1 files 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 @@
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/videodev2.h> 44#include <linux/videodev2.h>
45#include <linux/mm.h> 45#include <linux/mm.h>
46#include <linux/vmalloc.h>
47#include <linux/usb.h>
46#include <media/videobuf-vmalloc.h> 48#include <media/videobuf-vmalloc.h>
47#include <media/v4l2-common.h> 49#include <media/v4l2-common.h>
48#include <media/v4l2-device.h> 50#include <media/v4l2-device.h>
49#include <media/v4l2-ioctl.h> 51#include <media/v4l2-ioctl.h>
50#include <media/v4l2-ctrls.h> 52#include <media/v4l2-ctrls.h>
51#include <linux/vmalloc.h> 53#include <media/v4l2-event.h>
52#include <linux/usb.h>
53 54
54#define S2255_VERSION "1.22.1" 55#define S2255_VERSION "1.22.1"
55#define FIRMWARE_FILE_NAME "f2255usb.bin" 56#define FIRMWARE_FILE_NAME "f2255usb.bin"
@@ -295,6 +296,8 @@ struct s2255_buffer {
295}; 296};
296 297
297struct s2255_fh { 298struct s2255_fh {
299 /* this must be the first field in this struct */
300 struct v4l2_fh fh;
298 struct s2255_dev *dev; 301 struct s2255_dev *dev;
299 struct videobuf_queue vb_vidq; 302 struct videobuf_queue vb_vidq;
300 enum v4l2_buf_type type; 303 enum v4l2_buf_type type;
@@ -1666,7 +1669,9 @@ static int __s2255_open(struct file *file)
1666 fh = kzalloc(sizeof(*fh), GFP_KERNEL); 1669 fh = kzalloc(sizeof(*fh), GFP_KERNEL);
1667 if (NULL == fh) 1670 if (NULL == fh)
1668 return -ENOMEM; 1671 return -ENOMEM;
1669 file->private_data = fh; 1672 v4l2_fh_init(&fh->fh, vdev);
1673 v4l2_fh_add(&fh->fh);
1674 file->private_data = &fh->fh;
1670 fh->dev = dev; 1675 fh->dev = dev;
1671 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1676 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1672 fh->channel = channel; 1677 fh->channel = channel;
@@ -1709,12 +1714,13 @@ static unsigned int s2255_poll(struct file *file,
1709{ 1714{
1710 struct s2255_fh *fh = file->private_data; 1715 struct s2255_fh *fh = file->private_data;
1711 struct s2255_dev *dev = fh->dev; 1716 struct s2255_dev *dev = fh->dev;
1712 int rc; 1717 int rc = v4l2_ctrl_poll(file, wait);
1718
1713 dprintk(100, "%s\n", __func__); 1719 dprintk(100, "%s\n", __func__);
1714 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) 1720 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
1715 return POLLERR; 1721 return POLLERR;
1716 mutex_lock(&dev->lock); 1722 mutex_lock(&dev->lock);
1717 rc = videobuf_poll_stream(file, &fh->vb_vidq, wait); 1723 rc |= videobuf_poll_stream(file, &fh->vb_vidq, wait);
1718 mutex_unlock(&dev->lock); 1724 mutex_unlock(&dev->lock);
1719 return rc; 1725 return rc;
1720} 1726}
@@ -1761,6 +1767,8 @@ static int s2255_release(struct file *file)
1761 videobuf_mmap_free(&fh->vb_vidq); 1767 videobuf_mmap_free(&fh->vb_vidq);
1762 mutex_unlock(&dev->lock); 1768 mutex_unlock(&dev->lock);
1763 dprintk(1, "%s (dev=%s)\n", __func__, video_device_node_name(vdev)); 1769 dprintk(1, "%s (dev=%s)\n", __func__, video_device_node_name(vdev));
1770 v4l2_fh_del(&fh->fh);
1771 v4l2_fh_exit(&fh->fh);
1764 kfree(fh); 1772 kfree(fh);
1765 return 0; 1773 return 0;
1766} 1774}
@@ -1815,6 +1823,9 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
1815 .vidioc_s_parm = vidioc_s_parm, 1823 .vidioc_s_parm = vidioc_s_parm,
1816 .vidioc_g_parm = vidioc_g_parm, 1824 .vidioc_g_parm = vidioc_g_parm,
1817 .vidioc_enum_frameintervals = vidioc_enum_frameintervals, 1825 .vidioc_enum_frameintervals = vidioc_enum_frameintervals,
1826 .vidioc_log_status = v4l2_ctrl_log_status,
1827 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1828 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1818}; 1829};
1819 1830
1820static void s2255_video_device_release(struct video_device *vdev) 1831static void s2255_video_device_release(struct video_device *vdev)
@@ -1898,6 +1909,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1898 channel->vdev.ctrl_handler = &channel->hdl; 1909 channel->vdev.ctrl_handler = &channel->hdl;
1899 channel->vdev.lock = &dev->lock; 1910 channel->vdev.lock = &dev->lock;
1900 channel->vdev.v4l2_dev = &dev->v4l2_dev; 1911 channel->vdev.v4l2_dev = &dev->v4l2_dev;
1912 set_bit(V4L2_FL_USE_FH_PRIO, &channel->vdev.flags);
1901 video_set_drvdata(&channel->vdev, channel); 1913 video_set_drvdata(&channel->vdev, channel);
1902 if (video_nr == -1) 1914 if (video_nr == -1)
1903 ret = video_register_device(&channel->vdev, 1915 ret = video_register_device(&channel->vdev,