diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-01-21 03:39:47 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-25 18:50:49 -0400 |
commit | 5a254d751e52e0f817090c29950d16cf18490d5b (patch) | |
tree | 0f0d0076a6dbd478d3c0758bd339a93a6970bfee /drivers/media/video | |
parent | 115d2535f8ced13503b62a1275338e09a51681dc (diff) |
[media] uvcvideo: Register a v4l2_device
As a first step to the media controller integration register a
v4l2_device for each UVC control interface and make the video_device a
child of the v4l2_device.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/uvc/uvc_driver.c | 29 | ||||
-rw-r--r-- | drivers/media/video/uvc/uvcvideo.h | 6 |
2 files changed, 33 insertions, 2 deletions
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c index 823f4b389745..0e8cd1fd870f 100644 --- a/drivers/media/video/uvc/uvc_driver.c +++ b/drivers/media/video/uvc/uvc_driver.c | |||
@@ -1585,6 +1585,13 @@ static void uvc_delete(struct uvc_device *dev) | |||
1585 | uvc_status_cleanup(dev); | 1585 | uvc_status_cleanup(dev); |
1586 | uvc_ctrl_cleanup_device(dev); | 1586 | uvc_ctrl_cleanup_device(dev); |
1587 | 1587 | ||
1588 | if (dev->vdev.dev) | ||
1589 | v4l2_device_unregister(&dev->vdev); | ||
1590 | #ifdef CONFIG_MEDIA_CONTROLLER | ||
1591 | if (media_devnode_is_registered(&dev->mdev.devnode)) | ||
1592 | media_device_unregister(&dev->mdev); | ||
1593 | #endif | ||
1594 | |||
1588 | list_for_each_safe(p, n, &dev->chains) { | 1595 | list_for_each_safe(p, n, &dev->chains) { |
1589 | struct uvc_video_chain *chain; | 1596 | struct uvc_video_chain *chain; |
1590 | chain = list_entry(p, struct uvc_video_chain, list); | 1597 | chain = list_entry(p, struct uvc_video_chain, list); |
@@ -1682,7 +1689,7 @@ static int uvc_register_video(struct uvc_device *dev, | |||
1682 | * unregistered before the reference is released, so we don't need to | 1689 | * unregistered before the reference is released, so we don't need to |
1683 | * get another one. | 1690 | * get another one. |
1684 | */ | 1691 | */ |
1685 | vdev->parent = &dev->intf->dev; | 1692 | vdev->v4l2_dev = &dev->vdev; |
1686 | vdev->fops = &uvc_fops; | 1693 | vdev->fops = &uvc_fops; |
1687 | vdev->release = uvc_release; | 1694 | vdev->release = uvc_release; |
1688 | strlcpy(vdev->name, dev->name, sizeof vdev->name); | 1695 | strlcpy(vdev->name, dev->name, sizeof vdev->name); |
@@ -1814,6 +1821,24 @@ static int uvc_probe(struct usb_interface *intf, | |||
1814 | "linux-uvc-devel mailing list.\n"); | 1821 | "linux-uvc-devel mailing list.\n"); |
1815 | } | 1822 | } |
1816 | 1823 | ||
1824 | /* Register the media and V4L2 devices. */ | ||
1825 | #ifdef CONFIG_MEDIA_CONTROLLER | ||
1826 | dev->mdev.dev = &intf->dev; | ||
1827 | strlcpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model)); | ||
1828 | if (udev->serial) | ||
1829 | strlcpy(dev->mdev.serial, udev->serial, | ||
1830 | sizeof(dev->mdev.serial)); | ||
1831 | strcpy(dev->mdev.bus_info, udev->devpath); | ||
1832 | dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); | ||
1833 | dev->mdev.driver_version = DRIVER_VERSION_NUMBER; | ||
1834 | if (media_device_register(&dev->mdev) < 0) | ||
1835 | goto error; | ||
1836 | |||
1837 | dev->vdev.mdev = &dev->mdev; | ||
1838 | #endif | ||
1839 | if (v4l2_device_register(&intf->dev, &dev->vdev) < 0) | ||
1840 | goto error; | ||
1841 | |||
1817 | /* Initialize controls. */ | 1842 | /* Initialize controls. */ |
1818 | if (uvc_ctrl_init_device(dev) < 0) | 1843 | if (uvc_ctrl_init_device(dev) < 0) |
1819 | goto error; | 1844 | goto error; |
@@ -1822,7 +1847,7 @@ static int uvc_probe(struct usb_interface *intf, | |||
1822 | if (uvc_scan_device(dev) < 0) | 1847 | if (uvc_scan_device(dev) < 0) |
1823 | goto error; | 1848 | goto error; |
1824 | 1849 | ||
1825 | /* Register video devices. */ | 1850 | /* Register video device nodes. */ |
1826 | if (uvc_register_chains(dev) < 0) | 1851 | if (uvc_register_chains(dev) < 0) |
1827 | goto error; | 1852 | goto error; |
1828 | 1853 | ||
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h index 7cf224bae2e5..aab7508f2bd2 100644 --- a/drivers/media/video/uvc/uvcvideo.h +++ b/drivers/media/video/uvc/uvcvideo.h | |||
@@ -100,6 +100,8 @@ struct uvc_xu_control { | |||
100 | #include <linux/poll.h> | 100 | #include <linux/poll.h> |
101 | #include <linux/usb/video.h> | 101 | #include <linux/usb/video.h> |
102 | #include <linux/uvcvideo.h> | 102 | #include <linux/uvcvideo.h> |
103 | #include <media/media-device.h> | ||
104 | #include <media/v4l2-device.h> | ||
103 | 105 | ||
104 | /* -------------------------------------------------------------------------- | 106 | /* -------------------------------------------------------------------------- |
105 | * UVC constants | 107 | * UVC constants |
@@ -504,6 +506,10 @@ struct uvc_device { | |||
504 | atomic_t nmappings; | 506 | atomic_t nmappings; |
505 | 507 | ||
506 | /* Video control interface */ | 508 | /* Video control interface */ |
509 | #ifdef CONFIG_MEDIA_CONTROLLER | ||
510 | struct media_device mdev; | ||
511 | #endif | ||
512 | struct v4l2_device vdev; | ||
507 | __u16 uvc_version; | 513 | __u16 uvc_version; |
508 | __u32 clock_frequency; | 514 | __u32 clock_frequency; |
509 | 515 | ||