Commit 4e06839f authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (10873): w9968cf: add v4l2_device.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 78175bf2
...@@ -3495,12 +3495,14 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) ...@@ -3495,12 +3495,14 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
if (!cam) if (!cam)
return -ENOMEM; return -ENOMEM;
err = v4l2_device_register(&udev->dev, &cam->v4l2_dev);
if (err)
goto fail0;
mutex_init(&cam->dev_mutex); mutex_init(&cam->dev_mutex);
mutex_lock(&cam->dev_mutex); mutex_lock(&cam->dev_mutex);
cam->usbdev = udev; cam->usbdev = udev;
/* NOTE: a local copy is used to avoid possible race conditions */
memcpy(&cam->dev, &udev->dev, sizeof(struct device));
DBG(2, "%s detected", symbolic(camlist, mod_id)) DBG(2, "%s detected", symbolic(camlist, mod_id))
...@@ -3549,7 +3551,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) ...@@ -3549,7 +3551,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
cam->v4ldev->minor = video_nr[dev_nr]; cam->v4ldev->minor = video_nr[dev_nr];
cam->v4ldev->release = video_device_release; cam->v4ldev->release = video_device_release;
video_set_drvdata(cam->v4ldev, cam); video_set_drvdata(cam->v4ldev, cam);
cam->v4ldev->parent = &cam->dev; cam->v4ldev->v4l2_dev = &cam->v4l2_dev;
err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
video_nr[dev_nr]); video_nr[dev_nr]);
...@@ -3579,6 +3581,9 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) ...@@ -3579,6 +3581,9 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
usb_set_intfdata(intf, cam); usb_set_intfdata(intf, cam);
mutex_unlock(&cam->dev_mutex); mutex_unlock(&cam->dev_mutex);
if (ovmod_load)
request_module("ovcamchip");
return 0; return 0;
fail: /* Free unused memory */ fail: /* Free unused memory */
...@@ -3587,6 +3592,8 @@ fail: /* Free unused memory */ ...@@ -3587,6 +3592,8 @@ fail: /* Free unused memory */
if (cam->v4ldev) if (cam->v4ldev)
video_device_release(cam->v4ldev); video_device_release(cam->v4ldev);
mutex_unlock(&cam->dev_mutex); mutex_unlock(&cam->dev_mutex);
v4l2_device_unregister(&cam->v4l2_dev);
fail0:
kfree(cam); kfree(cam);
return err; return err;
} }
...@@ -3622,9 +3629,11 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf) ...@@ -3622,9 +3629,11 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf)
mutex_unlock(&cam->dev_mutex); mutex_unlock(&cam->dev_mutex);
if (!cam->users) if (!cam->users) {
v4l2_device_unregister(&cam->v4l2_dev);
kfree(cam); kfree(cam);
} }
}
up_write(&w9968cf_disconnect); up_write(&w9968cf_disconnect);
} }
...@@ -3650,9 +3659,6 @@ static int __init w9968cf_module_init(void) ...@@ -3650,9 +3659,6 @@ static int __init w9968cf_module_init(void)
KDBG(2, W9968CF_MODULE_NAME" "W9968CF_MODULE_VERSION) KDBG(2, W9968CF_MODULE_NAME" "W9968CF_MODULE_VERSION)
KDBG(3, W9968CF_MODULE_AUTHOR) KDBG(3, W9968CF_MODULE_AUTHOR)
if (ovmod_load)
request_module("ovcamchip");
if ((err = usb_register(&w9968cf_usb_driver))) if ((err = usb_register(&w9968cf_usb_driver)))
return err; return err;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <media/v4l2-device.h>
#include <media/ovcamchip.h> #include <media/ovcamchip.h>
#include "w9968cf_vpp.h" #include "w9968cf_vpp.h"
...@@ -195,10 +196,9 @@ enum w9968cf_vpp_flag { ...@@ -195,10 +196,9 @@ enum w9968cf_vpp_flag {
/* Main device driver structure */ /* Main device driver structure */
struct w9968cf_device { struct w9968cf_device {
struct device dev; /* device structure */
enum w9968cf_model_id id; /* private device identifier */ enum w9968cf_model_id id; /* private device identifier */
struct v4l2_device v4l2_dev;
struct video_device* v4ldev; /* -> V4L structure */ struct video_device* v4ldev; /* -> V4L structure */
struct list_head v4llist; /* entry of the list of V4L cameras */ struct list_head v4llist; /* entry of the list of V4L cameras */
...@@ -291,13 +291,13 @@ struct w9968cf_device { ...@@ -291,13 +291,13 @@ struct w9968cf_device {
if ( ((specific_debug) && (debug == (level))) || \ if ( ((specific_debug) && (debug == (level))) || \
((!specific_debug) && (debug >= (level))) ) { \ ((!specific_debug) && (debug >= (level))) ) { \
if ((level) == 1) \ if ((level) == 1) \
dev_err(&cam->dev, fmt "\n", ## args); \ v4l2_err(&cam->v4l2_dev, fmt "\n", ## args); \
else if ((level) == 2 || (level) == 3) \ else if ((level) == 2 || (level) == 3) \
dev_info(&cam->dev, fmt "\n", ## args); \ v4l2_info(&cam->v4l2_dev, fmt "\n", ## args); \
else if ((level) == 4) \ else if ((level) == 4) \
dev_warn(&cam->dev, fmt "\n", ## args); \ v4l2_warn(&cam->v4l2_dev, fmt "\n", ## args); \
else if ((level) >= 5) \ else if ((level) >= 5) \
dev_info(&cam->dev, "[%s:%d] " fmt "\n", \ v4l2_info(&cam->v4l2_dev, "[%s:%d] " fmt "\n", \
__func__, __LINE__ , ## args); \ __func__, __LINE__ , ## args); \
} \ } \
} }
...@@ -321,7 +321,7 @@ struct w9968cf_device { ...@@ -321,7 +321,7 @@ struct w9968cf_device {
#undef PDBG #undef PDBG
#define PDBG(fmt, args...) \ #define PDBG(fmt, args...) \
dev_info(&cam->dev, "[%s:%d] " fmt "\n", __func__, __LINE__ , ## args); v4l2_info(&cam->v4l2_dev, "[%s:%d] " fmt "\n", __func__, __LINE__ , ## args);
#undef PDBGG #undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0); /* nothing: it's a placeholder */ #define PDBGG(fmt, args...) do {;} while(0); /* nothing: it's a placeholder */
......
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