[media] stk-webcam: add support for control events and prio handling
Also correct the first_init static: this should be part of the stk_camera struct. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Arvydas Sidorenko <asido4@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
10351adc6a
commit
89ea47069c
|
@ -35,6 +35,7 @@
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <media/v4l2-common.h>
|
#include <media/v4l2-common.h>
|
||||||
#include <media/v4l2-ioctl.h>
|
#include <media/v4l2-ioctl.h>
|
||||||
|
#include <media/v4l2-event.h>
|
||||||
|
|
||||||
#include "stk-webcam.h"
|
#include "stk-webcam.h"
|
||||||
|
|
||||||
|
@ -603,20 +604,21 @@ static void stk_free_buffers(struct stk_camera *dev)
|
||||||
|
|
||||||
static int v4l_stk_open(struct file *fp)
|
static int v4l_stk_open(struct file *fp)
|
||||||
{
|
{
|
||||||
static int first_init = 1; /* webcam LED management */
|
|
||||||
struct stk_camera *dev = video_drvdata(fp);
|
struct stk_camera *dev = video_drvdata(fp);
|
||||||
|
int err;
|
||||||
|
|
||||||
if (dev == NULL || !is_present(dev))
|
if (dev == NULL || !is_present(dev))
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
if (!first_init)
|
if (!dev->first_init)
|
||||||
stk_camera_write_reg(dev, 0x0, 0x24);
|
stk_camera_write_reg(dev, 0x0, 0x24);
|
||||||
else
|
else
|
||||||
first_init = 0;
|
dev->first_init = 0;
|
||||||
|
|
||||||
usb_autopm_get_interface(dev->interface);
|
err = v4l2_fh_open(fp);
|
||||||
|
if (!err)
|
||||||
return 0;
|
usb_autopm_get_interface(dev->interface);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int v4l_stk_release(struct file *fp)
|
static int v4l_stk_release(struct file *fp)
|
||||||
|
@ -633,8 +635,7 @@ static int v4l_stk_release(struct file *fp)
|
||||||
|
|
||||||
if (is_present(dev))
|
if (is_present(dev))
|
||||||
usb_autopm_put_interface(dev->interface);
|
usb_autopm_put_interface(dev->interface);
|
||||||
|
return v4l2_fh_release(fp);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t v4l_stk_read(struct file *fp, char __user *buf,
|
static ssize_t v4l_stk_read(struct file *fp, char __user *buf,
|
||||||
|
@ -701,6 +702,7 @@ static ssize_t v4l_stk_read(struct file *fp, char __user *buf,
|
||||||
static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait)
|
static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait)
|
||||||
{
|
{
|
||||||
struct stk_camera *dev = video_drvdata(fp);
|
struct stk_camera *dev = video_drvdata(fp);
|
||||||
|
unsigned res = v4l2_ctrl_poll(fp, wait);
|
||||||
|
|
||||||
poll_wait(fp, &dev->wait_frame, wait);
|
poll_wait(fp, &dev->wait_frame, wait);
|
||||||
|
|
||||||
|
@ -708,9 +710,9 @@ static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait)
|
||||||
return POLLERR;
|
return POLLERR;
|
||||||
|
|
||||||
if (!list_empty(&dev->sio_full))
|
if (!list_empty(&dev->sio_full))
|
||||||
return POLLIN | POLLRDNORM;
|
return res | POLLIN | POLLRDNORM;
|
||||||
|
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1190,6 +1192,9 @@ static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = {
|
||||||
.vidioc_streamoff = stk_vidioc_streamoff,
|
.vidioc_streamoff = stk_vidioc_streamoff,
|
||||||
.vidioc_g_parm = stk_vidioc_g_parm,
|
.vidioc_g_parm = stk_vidioc_g_parm,
|
||||||
.vidioc_enum_framesizes = stk_vidioc_enum_framesizes,
|
.vidioc_enum_framesizes = stk_vidioc_enum_framesizes,
|
||||||
|
.vidioc_log_status = v4l2_ctrl_log_status,
|
||||||
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
||||||
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void stk_v4l_dev_release(struct video_device *vd)
|
static void stk_v4l_dev_release(struct video_device *vd)
|
||||||
|
@ -1217,6 +1222,7 @@ static int stk_register_video_device(struct stk_camera *dev)
|
||||||
dev->vdev = stk_v4l_data;
|
dev->vdev = stk_v4l_data;
|
||||||
dev->vdev.debug = debug;
|
dev->vdev.debug = debug;
|
||||||
dev->vdev.v4l2_dev = &dev->v4l2_dev;
|
dev->vdev.v4l2_dev = &dev->v4l2_dev;
|
||||||
|
set_bit(V4L2_FL_USE_FH_PRIO, &dev->vdev.flags);
|
||||||
video_set_drvdata(&dev->vdev, dev);
|
video_set_drvdata(&dev->vdev, dev);
|
||||||
err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
|
err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -1270,6 +1276,7 @@ static int stk_camera_probe(struct usb_interface *interface,
|
||||||
|
|
||||||
spin_lock_init(&dev->spinlock);
|
spin_lock_init(&dev->spinlock);
|
||||||
init_waitqueue_head(&dev->wait_frame);
|
init_waitqueue_head(&dev->wait_frame);
|
||||||
|
dev->first_init = 1; /* webcam LED management */
|
||||||
|
|
||||||
dev->udev = udev;
|
dev->udev = udev;
|
||||||
dev->interface = interface;
|
dev->interface = interface;
|
||||||
|
|
|
@ -99,6 +99,7 @@ struct stk_camera {
|
||||||
struct usb_interface *interface;
|
struct usb_interface *interface;
|
||||||
int webcam_model;
|
int webcam_model;
|
||||||
struct file *owner;
|
struct file *owner;
|
||||||
|
int first_init;
|
||||||
|
|
||||||
u8 isoc_ep;
|
u8 isoc_ep;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue