[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>
This commit is contained in:
parent
7041dec7a9
commit
44d06d8273
1 changed files with 17 additions and 5 deletions
|
@ -43,13 +43,14 @@
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
#include <linux/vmalloc.h>
|
||||||
|
#include <linux/usb.h>
|
||||||
#include <media/videobuf-vmalloc.h>
|
#include <media/videobuf-vmalloc.h>
|
||||||
#include <media/v4l2-common.h>
|
#include <media/v4l2-common.h>
|
||||||
#include <media/v4l2-device.h>
|
#include <media/v4l2-device.h>
|
||||||
#include <media/v4l2-ioctl.h>
|
#include <media/v4l2-ioctl.h>
|
||||||
#include <media/v4l2-ctrls.h>
|
#include <media/v4l2-ctrls.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <media/v4l2-event.h>
|
||||||
#include <linux/usb.h>
|
|
||||||
|
|
||||||
#define S2255_VERSION "1.22.1"
|
#define S2255_VERSION "1.22.1"
|
||||||
#define FIRMWARE_FILE_NAME "f2255usb.bin"
|
#define FIRMWARE_FILE_NAME "f2255usb.bin"
|
||||||
|
@ -295,6 +296,8 @@ struct s2255_buffer {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct s2255_fh {
|
struct s2255_fh {
|
||||||
|
/* this must be the first field in this struct */
|
||||||
|
struct v4l2_fh fh;
|
||||||
struct s2255_dev *dev;
|
struct s2255_dev *dev;
|
||||||
struct videobuf_queue vb_vidq;
|
struct videobuf_queue vb_vidq;
|
||||||
enum v4l2_buf_type type;
|
enum v4l2_buf_type type;
|
||||||
|
@ -1666,7 +1669,9 @@ static int __s2255_open(struct file *file)
|
||||||
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
|
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
|
||||||
if (NULL == fh)
|
if (NULL == fh)
|
||||||
return -ENOMEM;
|
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->dev = dev;
|
||||||
fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
fh->channel = channel;
|
fh->channel = channel;
|
||||||
|
@ -1709,12 +1714,13 @@ static unsigned int s2255_poll(struct file *file,
|
||||||
{
|
{
|
||||||
struct s2255_fh *fh = file->private_data;
|
struct s2255_fh *fh = file->private_data;
|
||||||
struct s2255_dev *dev = fh->dev;
|
struct s2255_dev *dev = fh->dev;
|
||||||
int rc;
|
int rc = v4l2_ctrl_poll(file, wait);
|
||||||
|
|
||||||
dprintk(100, "%s\n", __func__);
|
dprintk(100, "%s\n", __func__);
|
||||||
if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
|
if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
|
||||||
return POLLERR;
|
return POLLERR;
|
||||||
mutex_lock(&dev->lock);
|
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);
|
mutex_unlock(&dev->lock);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -1761,6 +1767,8 @@ static int s2255_release(struct file *file)
|
||||||
videobuf_mmap_free(&fh->vb_vidq);
|
videobuf_mmap_free(&fh->vb_vidq);
|
||||||
mutex_unlock(&dev->lock);
|
mutex_unlock(&dev->lock);
|
||||||
dprintk(1, "%s (dev=%s)\n", __func__, video_device_node_name(vdev));
|
dprintk(1, "%s (dev=%s)\n", __func__, video_device_node_name(vdev));
|
||||||
|
v4l2_fh_del(&fh->fh);
|
||||||
|
v4l2_fh_exit(&fh->fh);
|
||||||
kfree(fh);
|
kfree(fh);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1815,6 +1823,9 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
|
||||||
.vidioc_s_parm = vidioc_s_parm,
|
.vidioc_s_parm = vidioc_s_parm,
|
||||||
.vidioc_g_parm = vidioc_g_parm,
|
.vidioc_g_parm = vidioc_g_parm,
|
||||||
.vidioc_enum_frameintervals = vidioc_enum_frameintervals,
|
.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)
|
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.ctrl_handler = &channel->hdl;
|
||||||
channel->vdev.lock = &dev->lock;
|
channel->vdev.lock = &dev->lock;
|
||||||
channel->vdev.v4l2_dev = &dev->v4l2_dev;
|
channel->vdev.v4l2_dev = &dev->v4l2_dev;
|
||||||
|
set_bit(V4L2_FL_USE_FH_PRIO, &channel->vdev.flags);
|
||||||
video_set_drvdata(&channel->vdev, channel);
|
video_set_drvdata(&channel->vdev, channel);
|
||||||
if (video_nr == -1)
|
if (video_nr == -1)
|
||||||
ret = video_register_device(&channel->vdev,
|
ret = video_register_device(&channel->vdev,
|
||||||
|
|
Loading…
Reference in a new issue