aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-04 07:08:41 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 12:41:10 -0500
commit89ea47069cc536f6ae6f428c89bcb960fea3eaff (patch)
treee542497423b096e283605fe6a31aca83b765222e
parent10351adc6ac9251863ec6d90436e3ad277d178e0 (diff)
[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>
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.c27
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.h1
2 files changed, 18 insertions, 10 deletions
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index 49a4dfd22bf2..c07366619227 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -35,6 +35,7 @@
35#include <linux/videodev2.h> 35#include <linux/videodev2.h>
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
38#include <media/v4l2-event.h>
38 39
39#include "stk-webcam.h" 40#include "stk-webcam.h"
40 41
@@ -603,20 +604,21 @@ static void stk_free_buffers(struct stk_camera *dev)
603 604
604static int v4l_stk_open(struct file *fp) 605static int v4l_stk_open(struct file *fp)
605{ 606{
606 static int first_init = 1; /* webcam LED management */
607 struct stk_camera *dev = video_drvdata(fp); 607 struct stk_camera *dev = video_drvdata(fp);
608 int err;
608 609
609 if (dev == NULL || !is_present(dev)) 610 if (dev == NULL || !is_present(dev))
610 return -ENXIO; 611 return -ENXIO;
611 612
612 if (!first_init) 613 if (!dev->first_init)
613 stk_camera_write_reg(dev, 0x0, 0x24); 614 stk_camera_write_reg(dev, 0x0, 0x24);
614 else 615 else
615 first_init = 0; 616 dev->first_init = 0;
616
617 usb_autopm_get_interface(dev->interface);
618 617
619 return 0; 618 err = v4l2_fh_open(fp);
619 if (!err)
620 usb_autopm_get_interface(dev->interface);
621 return err;
620} 622}
621 623
622static int v4l_stk_release(struct file *fp) 624static int v4l_stk_release(struct file *fp)
@@ -633,8 +635,7 @@ static int v4l_stk_release(struct file *fp)
633 635
634 if (is_present(dev)) 636 if (is_present(dev))
635 usb_autopm_put_interface(dev->interface); 637 usb_autopm_put_interface(dev->interface);
636 638 return v4l2_fh_release(fp);
637 return 0;
638} 639}
639 640
640static ssize_t v4l_stk_read(struct file *fp, char __user *buf, 641static 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,
701static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait) 702static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait)
702{ 703{
703 struct stk_camera *dev = video_drvdata(fp); 704 struct stk_camera *dev = video_drvdata(fp);
705 unsigned res = v4l2_ctrl_poll(fp, wait);
704 706
705 poll_wait(fp, &dev->wait_frame, wait); 707 poll_wait(fp, &dev->wait_frame, wait);
706 708
@@ -708,9 +710,9 @@ static unsigned int v4l_stk_poll(struct file *fp, poll_table *wait)
708 return POLLERR; 710 return POLLERR;
709 711
710 if (!list_empty(&dev->sio_full)) 712 if (!list_empty(&dev->sio_full))
711 return POLLIN | POLLRDNORM; 713 return res | POLLIN | POLLRDNORM;
712 714
713 return 0; 715 return res;
714} 716}
715 717
716 718
@@ -1190,6 +1192,9 @@ static const struct v4l2_ioctl_ops v4l_stk_ioctl_ops = {
1190 .vidioc_streamoff = stk_vidioc_streamoff, 1192 .vidioc_streamoff = stk_vidioc_streamoff,
1191 .vidioc_g_parm = stk_vidioc_g_parm, 1193 .vidioc_g_parm = stk_vidioc_g_parm,
1192 .vidioc_enum_framesizes = stk_vidioc_enum_framesizes, 1194 .vidioc_enum_framesizes = stk_vidioc_enum_framesizes,
1195 .vidioc_log_status = v4l2_ctrl_log_status,
1196 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1197 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1193}; 1198};
1194 1199
1195static void stk_v4l_dev_release(struct video_device *vd) 1200static void stk_v4l_dev_release(struct video_device *vd)
@@ -1217,6 +1222,7 @@ static int stk_register_video_device(struct stk_camera *dev)
1217 dev->vdev = stk_v4l_data; 1222 dev->vdev = stk_v4l_data;
1218 dev->vdev.debug = debug; 1223 dev->vdev.debug = debug;
1219 dev->vdev.v4l2_dev = &dev->v4l2_dev; 1224 dev->vdev.v4l2_dev = &dev->v4l2_dev;
1225 set_bit(V4L2_FL_USE_FH_PRIO, &dev->vdev.flags);
1220 video_set_drvdata(&dev->vdev, dev); 1226 video_set_drvdata(&dev->vdev, dev);
1221 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); 1227 err = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
1222 if (err) 1228 if (err)
@@ -1270,6 +1276,7 @@ static int stk_camera_probe(struct usb_interface *interface,
1270 1276
1271 spin_lock_init(&dev->spinlock); 1277 spin_lock_init(&dev->spinlock);
1272 init_waitqueue_head(&dev->wait_frame); 1278 init_waitqueue_head(&dev->wait_frame);
1279 dev->first_init = 1; /* webcam LED management */
1273 1280
1274 dev->udev = udev; 1281 dev->udev = udev;
1275 dev->interface = interface; 1282 dev->interface = interface;
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.h b/drivers/media/usb/stkwebcam/stk-webcam.h
index 901f0df21bc7..2156320487d8 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.h
+++ b/drivers/media/usb/stkwebcam/stk-webcam.h
@@ -99,6 +99,7 @@ struct stk_camera {
99 struct usb_interface *interface; 99 struct usb_interface *interface;
100 int webcam_model; 100 int webcam_model;
101 struct file *owner; 101 struct file *owner;
102 int first_init;
102 103
103 u8 isoc_ep; 104 u8 isoc_ep;
104 105