diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2014-09-08 19:02:11 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-09-09 10:49:31 -0400 |
commit | c913881ec6f5d17defd16dfd96fea576b17c04b9 (patch) | |
tree | b24bf2e30011b4592ab11870378e290394061037 | |
parent | 6d11ed76c45dd7c8322c2d03575f2164cc725c18 (diff) |
usb: gadget: webcam: convert webcam to new interface of f_uvc
Use the new function interface of f_uvc.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/legacy/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/legacy/Makefile | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/legacy/webcam.c | 53 |
3 files changed, 40 insertions, 16 deletions
diff --git a/drivers/usb/gadget/legacy/Kconfig b/drivers/usb/gadget/legacy/Kconfig index bbd4b8545b9d..24392d269709 100644 --- a/drivers/usb/gadget/legacy/Kconfig +++ b/drivers/usb/gadget/legacy/Kconfig | |||
@@ -468,6 +468,7 @@ config USB_G_WEBCAM | |||
468 | depends on VIDEO_DEV | 468 | depends on VIDEO_DEV |
469 | select USB_LIBCOMPOSITE | 469 | select USB_LIBCOMPOSITE |
470 | select VIDEOBUF2_VMALLOC | 470 | select VIDEOBUF2_VMALLOC |
471 | select USB_F_UVC | ||
471 | help | 472 | help |
472 | The Webcam Gadget acts as a composite USB Audio and Video Class | 473 | The Webcam Gadget acts as a composite USB Audio and Video Class |
473 | device. It provides a userspace API to process UVC control requests | 474 | device. It provides a userspace API to process UVC control requests |
diff --git a/drivers/usb/gadget/legacy/Makefile b/drivers/usb/gadget/legacy/Makefile index ed7367e95eec..7f485f25705e 100644 --- a/drivers/usb/gadget/legacy/Makefile +++ b/drivers/usb/gadget/legacy/Makefile | |||
@@ -19,7 +19,7 @@ g_multi-y := multi.o | |||
19 | g_hid-y := hid.o | 19 | g_hid-y := hid.o |
20 | g_dbgp-y := dbgp.o | 20 | g_dbgp-y := dbgp.o |
21 | g_nokia-y := nokia.o | 21 | g_nokia-y := nokia.o |
22 | g_webcam-y := webcam.o ../function/uvc_queue.o ../function/uvc_v4l2.o ../function/uvc_video.o | 22 | g_webcam-y := webcam.o |
23 | g_ncm-y := ncm.o | 23 | g_ncm-y := ncm.o |
24 | g_acm_ms-y := acm_ms.o | 24 | g_acm_ms-y := acm_ms.o |
25 | g_tcm_usb_gadget-y := tcm_usb_gadget.o | 25 | g_tcm_usb_gadget-y := tcm_usb_gadget.o |
diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c index 50d27dbdbfa9..04a3da20f742 100644 --- a/drivers/usb/gadget/legacy/webcam.c +++ b/drivers/usb/gadget/legacy/webcam.c | |||
@@ -15,15 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/usb/video.h> | 16 | #include <linux/usb/video.h> |
17 | 17 | ||
18 | /* | 18 | #include "u_uvc.h" |
19 | * Kbuild is not very cooperative with respect to linking separately | ||
20 | * compiled library objects into one module. So for now we won't use | ||
21 | * separate compilation ... ensuring init/exit sections work to shrink | ||
22 | * the runtime footprint, and giving us at least some parts of what | ||
23 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
24 | */ | ||
25 | #define USBF_UVC_INCLUDED | ||
26 | #include "f_uvc.c" | ||
27 | 19 | ||
28 | USB_GADGET_COMPOSITE_OPTIONS(); | 20 | USB_GADGET_COMPOSITE_OPTIONS(); |
29 | 21 | ||
@@ -79,6 +71,9 @@ static struct usb_gadget_strings *webcam_device_strings[] = { | |||
79 | NULL, | 71 | NULL, |
80 | }; | 72 | }; |
81 | 73 | ||
74 | static struct usb_function_instance *fi_uvc; | ||
75 | static struct usb_function *f_uvc; | ||
76 | |||
82 | static struct usb_device_descriptor webcam_device_descriptor = { | 77 | static struct usb_device_descriptor webcam_device_descriptor = { |
83 | .bLength = USB_DT_DEVICE_SIZE, | 78 | .bLength = USB_DT_DEVICE_SIZE, |
84 | .bDescriptorType = USB_DT_DEVICE, | 79 | .bDescriptorType = USB_DT_DEVICE, |
@@ -342,11 +337,17 @@ static const struct uvc_descriptor_header * const uvc_ss_streaming_cls[] = { | |||
342 | static int __init | 337 | static int __init |
343 | webcam_config_bind(struct usb_configuration *c) | 338 | webcam_config_bind(struct usb_configuration *c) |
344 | { | 339 | { |
345 | return uvc_bind_config(c, uvc_fs_control_cls, | 340 | int status = 0; |
346 | uvc_ss_control_cls, uvc_fs_streaming_cls, | 341 | |
347 | uvc_hs_streaming_cls, uvc_ss_streaming_cls, | 342 | f_uvc = usb_get_function(fi_uvc); |
348 | streaming_interval, streaming_maxpacket, | 343 | if (IS_ERR(f_uvc)) |
349 | streaming_maxburst, trace); | 344 | return PTR_ERR(f_uvc); |
345 | |||
346 | status = usb_add_function(c, f_uvc); | ||
347 | if (status < 0) | ||
348 | usb_put_function(f_uvc); | ||
349 | |||
350 | return status; | ||
350 | } | 351 | } |
351 | 352 | ||
352 | static struct usb_configuration webcam_config_driver = { | 353 | static struct usb_configuration webcam_config_driver = { |
@@ -360,14 +361,36 @@ static struct usb_configuration webcam_config_driver = { | |||
360 | static int /* __init_or_exit */ | 361 | static int /* __init_or_exit */ |
361 | webcam_unbind(struct usb_composite_dev *cdev) | 362 | webcam_unbind(struct usb_composite_dev *cdev) |
362 | { | 363 | { |
364 | if (!IS_ERR_OR_NULL(f_uvc)) | ||
365 | usb_put_function(f_uvc); | ||
366 | if (!IS_ERR_OR_NULL(fi_uvc)) | ||
367 | usb_put_function_instance(fi_uvc); | ||
363 | return 0; | 368 | return 0; |
364 | } | 369 | } |
365 | 370 | ||
366 | static int __init | 371 | static int __init |
367 | webcam_bind(struct usb_composite_dev *cdev) | 372 | webcam_bind(struct usb_composite_dev *cdev) |
368 | { | 373 | { |
374 | struct f_uvc_opts *uvc_opts; | ||
369 | int ret; | 375 | int ret; |
370 | 376 | ||
377 | fi_uvc = usb_get_function_instance("uvc"); | ||
378 | if (IS_ERR(fi_uvc)) | ||
379 | return PTR_ERR(fi_uvc); | ||
380 | |||
381 | uvc_opts = container_of(fi_uvc, struct f_uvc_opts, func_inst); | ||
382 | |||
383 | uvc_opts->streaming_interval = streaming_interval; | ||
384 | uvc_opts->streaming_maxpacket = streaming_maxpacket; | ||
385 | uvc_opts->streaming_maxburst = streaming_maxburst; | ||
386 | uvc_set_trace_param(trace); | ||
387 | |||
388 | uvc_opts->fs_control = uvc_fs_control_cls; | ||
389 | uvc_opts->ss_control = uvc_ss_control_cls; | ||
390 | uvc_opts->fs_streaming = uvc_fs_streaming_cls; | ||
391 | uvc_opts->hs_streaming = uvc_hs_streaming_cls; | ||
392 | uvc_opts->ss_streaming = uvc_ss_streaming_cls; | ||
393 | |||
371 | /* Allocate string descriptor numbers ... note that string contents | 394 | /* Allocate string descriptor numbers ... note that string contents |
372 | * can be overridden by the composite_dev glue. | 395 | * can be overridden by the composite_dev glue. |
373 | */ | 396 | */ |
@@ -391,7 +414,7 @@ webcam_bind(struct usb_composite_dev *cdev) | |||
391 | return 0; | 414 | return 0; |
392 | 415 | ||
393 | error: | 416 | error: |
394 | webcam_unbind(cdev); | 417 | usb_put_function_instance(fi_uvc); |
395 | return ret; | 418 | return ret; |
396 | } | 419 | } |
397 | 420 | ||