diff options
author | Alexey Fisher <bug-track@fisher-privat.net> | 2011-11-03 08:39:37 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-11 08:22:07 -0500 |
commit | edbaa39842793fc4ac6603b277f2ad76f2057a45 (patch) | |
tree | 6a7a2213fb36540587a8dc77953efa3dcc6ba812 /drivers/media/video/uvc | |
parent | c4d99f89e20c87c8e2a992ce4cf9aa4325dc7fa7 (diff) |
[media] uvcvideo: Add debugfs support
Create a debugfs entry per UVC stream. This will be used to export
stream statistics.
Signed-off-by: Alexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[mchehab@redhat.com: add incude <linux/module.h> to avoid compilation breakage]
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/uvc')
-rw-r--r-- | drivers/media/video/uvc/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/video/uvc/uvc_debugfs.c | 77 | ||||
-rw-r--r-- | drivers/media/video/uvc/uvc_driver.c | 21 | ||||
-rw-r--r-- | drivers/media/video/uvc/uvcvideo.h | 9 |
4 files changed, 103 insertions, 6 deletions
diff --git a/drivers/media/video/uvc/Makefile b/drivers/media/video/uvc/Makefile index 2071ca8a2f03..c26d12fdb8f4 100644 --- a/drivers/media/video/uvc/Makefile +++ b/drivers/media/video/uvc/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \ | 1 | uvcvideo-objs := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \ |
2 | uvc_status.o uvc_isight.o | 2 | uvc_status.o uvc_isight.o uvc_debugfs.o |
3 | ifeq ($(CONFIG_MEDIA_CONTROLLER),y) | 3 | ifeq ($(CONFIG_MEDIA_CONTROLLER),y) |
4 | uvcvideo-objs += uvc_entity.o | 4 | uvcvideo-objs += uvc_entity.o |
5 | endif | 5 | endif |
diff --git a/drivers/media/video/uvc/uvc_debugfs.c b/drivers/media/video/uvc/uvc_debugfs.c new file mode 100644 index 000000000000..39fd43b3e1d2 --- /dev/null +++ b/drivers/media/video/uvc/uvc_debugfs.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * uvc_debugfs.c -- USB Video Class driver - Debugging support | ||
3 | * | ||
4 | * Copyright (C) 2011 | ||
5 | * Laurent Pinchart (laurent.pinchart@ideasonboard.com) | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/debugfs.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/usb.h> | ||
18 | |||
19 | #include "uvcvideo.h" | ||
20 | |||
21 | /* ----------------------------------------------------------------------------- | ||
22 | * Global and stream initialization/cleanup | ||
23 | */ | ||
24 | |||
25 | static struct dentry *uvc_debugfs_root_dir; | ||
26 | |||
27 | int uvc_debugfs_init_stream(struct uvc_streaming *stream) | ||
28 | { | ||
29 | struct usb_device *udev = stream->dev->udev; | ||
30 | struct dentry *dent; | ||
31 | char dir_name[32]; | ||
32 | |||
33 | if (uvc_debugfs_root_dir == NULL) | ||
34 | return -ENODEV; | ||
35 | |||
36 | sprintf(dir_name, "%u-%u", udev->bus->busnum, udev->devnum); | ||
37 | |||
38 | dent = debugfs_create_dir(dir_name, uvc_debugfs_root_dir); | ||
39 | if (IS_ERR_OR_NULL(dent)) { | ||
40 | uvc_printk(KERN_INFO, "Unable to create debugfs %s directory.\n", | ||
41 | dir_name); | ||
42 | return -ENODEV; | ||
43 | } | ||
44 | |||
45 | stream->debugfs_dir = dent; | ||
46 | |||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream) | ||
51 | { | ||
52 | if (stream->debugfs_dir == NULL) | ||
53 | return; | ||
54 | |||
55 | debugfs_remove_recursive(stream->debugfs_dir); | ||
56 | stream->debugfs_dir = NULL; | ||
57 | } | ||
58 | |||
59 | int uvc_debugfs_init(void) | ||
60 | { | ||
61 | struct dentry *dir; | ||
62 | |||
63 | dir = debugfs_create_dir("uvcvideo", usb_debug_root); | ||
64 | if (IS_ERR_OR_NULL(dir)) { | ||
65 | uvc_printk(KERN_INFO, "Unable to create debugfs directory\n"); | ||
66 | return -ENODATA; | ||
67 | } | ||
68 | |||
69 | uvc_debugfs_root_dir = dir; | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | void uvc_debugfs_cleanup(void) | ||
74 | { | ||
75 | if (uvc_debugfs_root_dir != NULL) | ||
76 | debugfs_remove_recursive(uvc_debugfs_root_dir); | ||
77 | } | ||
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c index 750ab689b99a..a240d43d15d1 100644 --- a/drivers/media/video/uvc/uvc_driver.c +++ b/drivers/media/video/uvc/uvc_driver.c | |||
@@ -1675,6 +1675,8 @@ static void uvc_unregister_video(struct uvc_device *dev) | |||
1675 | 1675 | ||
1676 | video_unregister_device(stream->vdev); | 1676 | video_unregister_device(stream->vdev); |
1677 | stream->vdev = NULL; | 1677 | stream->vdev = NULL; |
1678 | |||
1679 | uvc_debugfs_cleanup_stream(stream); | ||
1678 | } | 1680 | } |
1679 | 1681 | ||
1680 | /* Decrement the stream count and call uvc_delete explicitly if there | 1682 | /* Decrement the stream count and call uvc_delete explicitly if there |
@@ -1700,6 +1702,8 @@ static int uvc_register_video(struct uvc_device *dev, | |||
1700 | return ret; | 1702 | return ret; |
1701 | } | 1703 | } |
1702 | 1704 | ||
1705 | uvc_debugfs_init_stream(stream); | ||
1706 | |||
1703 | /* Register the device with V4L. */ | 1707 | /* Register the device with V4L. */ |
1704 | vdev = video_device_alloc(); | 1708 | vdev = video_device_alloc(); |
1705 | if (vdev == NULL) { | 1709 | if (vdev == NULL) { |
@@ -2405,17 +2409,24 @@ struct uvc_driver uvc_driver = { | |||
2405 | 2409 | ||
2406 | static int __init uvc_init(void) | 2410 | static int __init uvc_init(void) |
2407 | { | 2411 | { |
2408 | int result; | 2412 | int ret; |
2409 | 2413 | ||
2410 | result = usb_register(&uvc_driver.driver); | 2414 | uvc_debugfs_init(); |
2411 | if (result == 0) | 2415 | |
2412 | printk(KERN_INFO DRIVER_DESC " (" DRIVER_VERSION ")\n"); | 2416 | ret = usb_register(&uvc_driver.driver); |
2413 | return result; | 2417 | if (ret < 0) { |
2418 | uvc_debugfs_cleanup(); | ||
2419 | return ret; | ||
2420 | } | ||
2421 | |||
2422 | printk(KERN_INFO DRIVER_DESC " (" DRIVER_VERSION ")\n"); | ||
2423 | return 0; | ||
2414 | } | 2424 | } |
2415 | 2425 | ||
2416 | static void __exit uvc_cleanup(void) | 2426 | static void __exit uvc_cleanup(void) |
2417 | { | 2427 | { |
2418 | usb_deregister(&uvc_driver.driver); | 2428 | usb_deregister(&uvc_driver.driver); |
2429 | uvc_debugfs_cleanup(); | ||
2419 | } | 2430 | } |
2420 | 2431 | ||
2421 | module_init(uvc_init); | 2432 | module_init(uvc_init); |
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h index 2b84cbb49665..d975636cbb10 100644 --- a/drivers/media/video/uvc/uvcvideo.h +++ b/drivers/media/video/uvc/uvcvideo.h | |||
@@ -403,6 +403,9 @@ struct uvc_streaming { | |||
403 | 403 | ||
404 | __u32 sequence; | 404 | __u32 sequence; |
405 | __u8 last_fid; | 405 | __u8 last_fid; |
406 | |||
407 | /* debugfs */ | ||
408 | struct dentry *debugfs_dir; | ||
406 | }; | 409 | }; |
407 | 410 | ||
408 | enum uvc_device_state { | 411 | enum uvc_device_state { |
@@ -606,4 +609,10 @@ extern struct usb_host_endpoint *uvc_find_endpoint( | |||
606 | void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream, | 609 | void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream, |
607 | struct uvc_buffer *buf); | 610 | struct uvc_buffer *buf); |
608 | 611 | ||
612 | /* debugfs */ | ||
613 | int uvc_debugfs_init(void); | ||
614 | void uvc_debugfs_cleanup(void); | ||
615 | int uvc_debugfs_init_stream(struct uvc_streaming *stream); | ||
616 | void uvc_debugfs_cleanup_stream(struct uvc_streaming *stream); | ||
617 | |||
609 | #endif | 618 | #endif |