Commit 2333565d authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] gscpa: Use v4l2_fh and add G/S_PRIORITY support

In order to support control event gspca has to use struct v4l2_fh.
As a bonus feature this also gives priority handling for free.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f4c1605a
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/ktime.h> #include <linux/ktime.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h> #include <media/v4l2-ctrls.h>
#include <media/v4l2-fh.h>
#include "gspca.h" #include "gspca.h"
...@@ -1327,6 +1328,7 @@ static void gspca_release(struct video_device *vfd) ...@@ -1327,6 +1328,7 @@ static void gspca_release(struct video_device *vfd)
video_device_node_name(&gspca_dev->vdev)); video_device_node_name(&gspca_dev->vdev));
v4l2_ctrl_handler_free(gspca_dev->vdev.ctrl_handler); v4l2_ctrl_handler_free(gspca_dev->vdev.ctrl_handler);
v4l2_device_unregister(&gspca_dev->v4l2_dev);
kfree(gspca_dev->usb_buf); kfree(gspca_dev->usb_buf);
kfree(gspca_dev); kfree(gspca_dev);
} }
...@@ -1352,7 +1354,7 @@ static int dev_open(struct file *file) ...@@ -1352,7 +1354,7 @@ static int dev_open(struct file *file)
gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL
| V4L2_DEBUG_IOCTL_ARG); | V4L2_DEBUG_IOCTL_ARG);
#endif #endif
return 0; return v4l2_fh_open(file);
} }
static int dev_close(struct file *file) static int dev_close(struct file *file)
...@@ -1378,7 +1380,7 @@ static int dev_close(struct file *file) ...@@ -1378,7 +1380,7 @@ static int dev_close(struct file *file)
PDEBUG(D_STREAM, "close done"); PDEBUG(D_STREAM, "close done");
return 0; return v4l2_fh_release(file);
} }
static int vidioc_querycap(struct file *file, void *priv, static int vidioc_querycap(struct file *file, void *priv,
...@@ -2345,12 +2347,16 @@ int gspca_dev_probe2(struct usb_interface *intf, ...@@ -2345,12 +2347,16 @@ int gspca_dev_probe2(struct usb_interface *intf,
} }
} }
ret = v4l2_device_register(&intf->dev, &gspca_dev->v4l2_dev);
if (ret)
goto out;
gspca_dev->sd_desc = sd_desc; gspca_dev->sd_desc = sd_desc;
gspca_dev->nbufread = 2; gspca_dev->nbufread = 2;
gspca_dev->empty_packet = -1; /* don't check the empty packets */ gspca_dev->empty_packet = -1; /* don't check the empty packets */
gspca_dev->vdev = gspca_template; gspca_dev->vdev = gspca_template;
gspca_dev->vdev.parent = &intf->dev; gspca_dev->vdev.v4l2_dev = &gspca_dev->v4l2_dev;
video_set_drvdata(&gspca_dev->vdev, gspca_dev); video_set_drvdata(&gspca_dev->vdev, gspca_dev);
set_bit(V4L2_FL_USE_FH_PRIO, &gspca_dev->vdev.flags);
gspca_dev->module = module; gspca_dev->module = module;
gspca_dev->present = 1; gspca_dev->present = 1;
...@@ -2462,6 +2468,7 @@ void gspca_disconnect(struct usb_interface *intf) ...@@ -2462,6 +2468,7 @@ void gspca_disconnect(struct usb_interface *intf)
/* the device is freed at exit of this function */ /* the device is freed at exit of this function */
gspca_dev->dev = NULL; gspca_dev->dev = NULL;
v4l2_device_disconnect(&gspca_dev->v4l2_dev);
mutex_unlock(&gspca_dev->usb_lock); mutex_unlock(&gspca_dev->usb_lock);
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-device.h>
#include <linux/mutex.h> #include <linux/mutex.h>
/* compilation option */ /* compilation option */
...@@ -159,6 +160,7 @@ struct gspca_frame { ...@@ -159,6 +160,7 @@ struct gspca_frame {
struct gspca_dev { struct gspca_dev {
struct video_device vdev; /* !! must be the first item */ struct video_device vdev; /* !! must be the first item */
struct module *module; /* subdriver handling the device */ struct module *module; /* subdriver handling the device */
struct v4l2_device v4l2_dev;
struct usb_device *dev; struct usb_device *dev;
struct file *capt_file; /* file doing video capture */ struct file *capt_file; /* file doing video capture */
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment