Use the new function interface of f_uvc. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx> --- drivers/usb/gadget/Kconfig | 1 + drivers/usb/gadget/Makefile | 4 +- drivers/usb/gadget/f_uvc.c | 4 --- drivers/usb/gadget/webcam.c | 46 +++++++++++++++++++++++++++++------------- 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 6032e84..c8a72e0 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1144,6 +1144,7 @@ config USB_G_WEBCAM depends on VIDEO_DEV select USB_LIBCOMPOSITE select VIDEOBUF2_VMALLOC + select USB_F_UVC help The Webcam Gadget acts as a composite USB Audio and Video Class device. It provides a userspace API to process UVC control requests diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index d2aeea3..eac0e08 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -63,7 +63,7 @@ usb_f_rndis-y := f_rndis.o obj-$(CONFIG_USB_F_RNDIS) += usb_f_rndis.o usb_f_mass_storage-y := f_mass_storage.o storage_common.o obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o -usb_f_uvc-u := f_uvc.o +usb_f_uvc-y := f_uvc.o uvc_queue.o uvc_v4l2.o uvc_video.o obj-$(CONFIG_USB_F_UVC) += usb_f_uvc.o # @@ -82,7 +82,7 @@ g_multi-y := multi.o g_hid-y := hid.o g_dbgp-y := dbgp.o g_nokia-y := nokia.o -g_webcam-y := webcam.o uvc_queue.o uvc_v4l2.o uvc_video.o +g_webcam-y := webcam.o g_ncm-y := ncm.o g_acm_ms-y := acm_ms.o g_tcm_usb_gadget-y := tcm_usb_gadget.o diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c index 647713f..cadc248 100644 --- a/drivers/usb/gadget/f_uvc.c +++ b/drivers/usb/gadget/f_uvc.c @@ -1067,10 +1067,6 @@ uvc_bind_config(struct usb_configuration *c, uvc->state = UVC_STATE_DISCONNECTED; - streaming_interval = streaming_interval_webcam; - streaming_maxpacket = streaming_maxpacket_webcam; - streaming_maxburst = streaming_maxburst_webcam; - uvc_gadget_trace_param = uvc_gadget_trace_webcam; uvc->desc.fs_control = uvc_fs_control_cls; uvc->desc.ss_control = uvc_ss_control_cls; diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index 994e386..a9fdee5 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c @@ -15,15 +15,7 @@ #include <linux/module.h> #include <linux/usb/video.h> -/* - * Kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a "gcc --combine ... part1.c part2.c part3.c ... " build would. - */ -#define USBF_UVC_INCLUDED -#include "f_uvc.c" +#include "u_uvc.h" USB_GADGET_COMPOSITE_OPTIONS(); @@ -82,6 +74,9 @@ static struct usb_gadget_strings *webcam_device_strings[] = { NULL, }; +static struct usb_function_instance *fi_uvc; +static struct usb_function *f_uvc; + static struct usb_device_descriptor webcam_device_descriptor = { .bLength = USB_DT_DEVICE_SIZE, .bDescriptorType = USB_DT_DEVICE, @@ -106,10 +101,17 @@ static struct usb_device_descriptor webcam_device_descriptor = { static int __init webcam_config_bind(struct usb_configuration *c) { - return uvc_bind_config(c, streaming_interval_webcam, - streaming_maxpacket_webcam, - streaming_maxburst_webcam, - uvc_gadget_trace_param_webcam); + int status = 0; + + f_uvc = usb_get_function(fi_uvc); + if (IS_ERR(f_uvc)) + return PTR_ERR(f_uvc); + + status = usb_add_function(c, f_uvc); + if (status < 0) + usb_put_function(f_uvc); + + return status; } static struct usb_configuration webcam_config_driver = { @@ -123,14 +125,30 @@ static struct usb_configuration webcam_config_driver = { static int /* __init_or_exit */ webcam_unbind(struct usb_composite_dev *cdev) { + if (!IS_ERR_OR_NULL(f_uvc)) + usb_put_function(f_uvc); + if (!IS_ERR_OR_NULL(fi_uvc)) + usb_put_function_instance(fi_uvc); return 0; } static int __init webcam_bind(struct usb_composite_dev *cdev) { + struct f_uvc_opts *uvc_opts; int ret; + fi_uvc = usb_get_function_instance("uvc"); + if (IS_ERR(fi_uvc)) + return PTR_ERR(fi_uvc); + + uvc_opts = container_of(fi_uvc, struct f_uvc_opts, func_inst); + + uvc_opts->streaming_interval = streaming_interval_webcam; + uvc_opts->streaming_maxpacket = streaming_maxpacket_webcam; + uvc_opts->streaming_maxburst = streaming_maxburst_webcam; + uvc_set_trace_param(uvc_gadget_trace_param_webcam); + /* Allocate string descriptor numbers ... note that string contents * can be overridden by the composite_dev glue. */ @@ -154,7 +172,7 @@ webcam_bind(struct usb_composite_dev *cdev) return 0; error: - webcam_unbind(cdev); + usb_put_function_instance(fi_uvc); return ret; } -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html