Loading Documentation/ABI/testing/configfs-usb-gadget-uvc +24 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Control descriptors All attributes read only: bInterfaceNumber - USB interface number for this streaming interface What: /config/usb-gadget/gadget/functions/uvc.name/control/class Date: Dec 2014 KernelVersion: 4.0 Loading Loading @@ -109,6 +113,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Streaming descriptors All attributes read only: bInterfaceNumber - USB interface number for this streaming interface What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class Date: Dec 2014 KernelVersion: 4.0 Loading Loading @@ -160,6 +168,10 @@ Description: Specific MJPEG format descriptors All attributes read only, except bmaControls and bDefaultFrameIndex: bFormatIndex - unique id for this format descriptor; only defined after parent header is linked into the streaming class; read-only bmaControls - this format's data for bmaControls in the streaming header bmInterfaceFlags - specifies interlace information, Loading @@ -177,6 +189,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Specific MJPEG frame descriptors bFrameIndex - unique id for this framedescriptor; only defined after parent format is linked into the streaming header; read-only dwFrameInterval - indicates how frame interval can be programmed; a number of values separated by newline can be specified Loading Loading @@ -204,6 +220,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Specific uncompressed format descriptors bFormatIndex - unique id for this format descriptor; only defined after parent header is linked into the streaming class; read-only bmaControls - this format's data for bmaControls in the streaming header bmInterfaceFlags - specifies interlace information, Loading @@ -224,6 +244,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Specific uncompressed frame descriptors bFrameIndex - unique id for this framedescriptor; only defined after parent format is linked into the streaming header; read-only dwFrameInterval - indicates how frame interval can be programmed; a number of values separated by newline can be specified Loading drivers/usb/gadget/function/f_uvc.c +26 −31 Original line number Diff line number Diff line Loading @@ -197,12 +197,6 @@ static const struct usb_descriptor_header * const uvc_ss_streaming[] = { NULL, }; void uvc_set_trace_param(unsigned int trace) { uvc_gadget_trace_param = trace; } EXPORT_SYMBOL(uvc_set_trace_param); /* -------------------------------------------------------------------------- * Control requests */ Loading Loading @@ -232,13 +226,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) struct v4l2_event v4l2_event; struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; /* printk(KERN_INFO "setup request %02x %02x value %04x index %04x %04x\n", * ctrl->bRequestType, ctrl->bRequest, le16_to_cpu(ctrl->wValue), * le16_to_cpu(ctrl->wIndex), le16_to_cpu(ctrl->wLength)); */ if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) { INFO(f->config->cdev, "invalid request type\n"); uvcg_info(f, "invalid request type\n"); return -EINVAL; } Loading Loading @@ -272,7 +261,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface) { struct uvc_device *uvc = to_uvc(f); INFO(f->config->cdev, "uvc_function_get_alt(%u)\n", interface); uvcg_info(f, "%s(%u)\n", __func__, interface); if (interface == uvc->control_intf) return 0; Loading @@ -291,13 +280,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; int ret; INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt); uvcg_info(f, "%s(%u, %u)\n", __func__, interface, alt); if (interface == uvc->control_intf) { if (alt) return -EINVAL; INFO(cdev, "reset UVC Control\n"); uvcg_info(f, "reset UVC Control\n"); usb_ep_disable(uvc->control_ep); if (!uvc->control_ep->desc) Loading Loading @@ -348,7 +337,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) if (!uvc->video.ep) return -EINVAL; INFO(cdev, "reset UVC\n"); uvcg_info(f, "reset UVC\n"); usb_ep_disable(uvc->video.ep); ret = config_ep_by_speed(f->config->cdev->gadget, Loading @@ -373,7 +362,7 @@ uvc_function_disable(struct usb_function *f) struct uvc_device *uvc = to_uvc(f); struct v4l2_event v4l2_event; INFO(f->config->cdev, "uvc_function_disable\n"); uvcg_info(f, "%s()\n", __func__); memset(&v4l2_event, 0, sizeof(v4l2_event)); v4l2_event.type = UVC_EVENT_DISCONNECT; Loading @@ -392,21 +381,19 @@ uvc_function_disable(struct usb_function *f) void uvc_function_connect(struct uvc_device *uvc) { struct usb_composite_dev *cdev = uvc->func.config->cdev; int ret; if ((ret = usb_function_activate(&uvc->func)) < 0) INFO(cdev, "UVC connect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret); } void uvc_function_disconnect(struct uvc_device *uvc) { struct usb_composite_dev *cdev = uvc->func.config->cdev; int ret; if ((ret = usb_function_deactivate(&uvc->func)) < 0) INFO(cdev, "UVC disconnect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret); } /* -------------------------------------------------------------------------- Loading Loading @@ -605,7 +592,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) struct f_uvc_opts *opts; int ret = -EINVAL; INFO(cdev, "uvc_function_bind\n"); uvcg_info(f, "%s()\n", __func__); opts = fi_to_f_uvc_opts(f->fi); /* Sanity check the streaming endpoint module parameters. Loading @@ -618,7 +605,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) if (opts->streaming_maxburst && (opts->streaming_maxpacket % 1024) != 0) { opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024); INFO(cdev, "overriding streaming_maxpacket to %d\n", uvcg_info(f, "overriding streaming_maxpacket to %d\n", opts->streaming_maxpacket); } Loading Loading @@ -658,7 +645,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) /* Allocate endpoints. */ ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep); if (!ep) { INFO(cdev, "Unable to allocate control EP\n"); uvcg_info(f, "Unable to allocate control EP\n"); goto error; } uvc->control_ep = ep; Loading @@ -672,7 +659,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); if (!ep) { INFO(cdev, "Unable to allocate streaming EP\n"); uvcg_info(f, "Unable to allocate streaming EP\n"); goto error; } uvc->video.ep = ep; Loading @@ -699,12 +686,14 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) uvc_iad.bFirstInterface = ret; uvc_control_intf.bInterfaceNumber = ret; uvc->control_intf = ret; opts->control_interface = ret; if ((ret = usb_interface_id(c, f)) < 0) goto error; uvc_streaming_intf_alt0.bInterfaceNumber = ret; uvc_streaming_intf_alt1.bInterfaceNumber = ret; uvc->streaming_intf = ret; opts->streaming_interface = ret; /* Copy descriptors */ f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); Loading Loading @@ -743,19 +732,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) uvc->control_req->context = uvc; if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { printk(KERN_INFO "v4l2_device_register failed\n"); uvcg_err(f, "failed to register V4L2 device\n"); goto error; } /* Initialise video. */ ret = uvcg_video_init(&uvc->video); ret = uvcg_video_init(&uvc->video, uvc); if (ret < 0) goto error; /* Register a V4L2 device. */ ret = uvc_register_video(uvc); if (ret < 0) { printk(KERN_INFO "Unable to register video device\n"); uvcg_err(f, "failed to register video device\n"); goto error; } Loading Loading @@ -792,6 +781,7 @@ static struct usb_function_instance *uvc_alloc_inst(void) struct uvc_output_terminal_descriptor *od; struct uvc_color_matching_descriptor *md; struct uvc_descriptor_header **ctl_cls; int ret; opts = kzalloc(sizeof(*opts), GFP_KERNEL); if (!opts) Loading Loading @@ -868,7 +858,12 @@ static struct usb_function_instance *uvc_alloc_inst(void) opts->streaming_interval = 1; opts->streaming_maxpacket = 1024; uvcg_attach_configfs(opts); ret = uvcg_attach_configfs(opts); if (ret < 0) { kfree(opts); return ERR_PTR(ret); } return &opts->func_inst; } Loading @@ -886,7 +881,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f) struct usb_composite_dev *cdev = c->cdev; struct uvc_device *uvc = to_uvc(f); INFO(cdev, "%s\n", __func__); uvcg_info(f, "%s\n", __func__); device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); video_unregister_device(&uvc->vdev); Loading drivers/usb/gadget/function/u_uvc.h +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ struct f_uvc_opts { unsigned int streaming_maxpacket; unsigned int streaming_maxburst; unsigned int control_interface; unsigned int streaming_interface; /* * Control descriptors array pointers for full-/high-speed and * super-speed. They point by default to the uvc_fs_control_cls and Loading drivers/usb/gadget/function/uvc.h +8 −8 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ struct usb_ep; struct usb_request; struct uvc_descriptor_header; struct uvc_device; /* ------------------------------------------------------------------------ * Debugging, printing and logging Loading Loading @@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param; printk(KERN_DEBUG "uvcvideo: " msg); \ } while (0) #define uvc_warn_once(dev, warn, msg...) \ do { \ if (!test_and_set_bit(warn, &dev->warnings)) \ printk(KERN_INFO "uvcvideo: " msg); \ } while (0) #define uvc_printk(level, msg...) \ printk(level "uvcvideo: " msg) #define uvcg_dbg(f, fmt, args...) \ dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) #define uvcg_info(f, fmt, args...) \ dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) #define uvcg_err(f, fmt, args...) \ dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) /* ------------------------------------------------------------------------ * Driver specific constants Loading @@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param; */ struct uvc_video { struct uvc_device *uvc; struct usb_ep *ep; /* Frame parameters */ Loading drivers/usb/gadget/function/uvc_configfs.c +668 −500 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
Documentation/ABI/testing/configfs-usb-gadget-uvc +24 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Control descriptors All attributes read only: bInterfaceNumber - USB interface number for this streaming interface What: /config/usb-gadget/gadget/functions/uvc.name/control/class Date: Dec 2014 KernelVersion: 4.0 Loading Loading @@ -109,6 +113,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Streaming descriptors All attributes read only: bInterfaceNumber - USB interface number for this streaming interface What: /config/usb-gadget/gadget/functions/uvc.name/streaming/class Date: Dec 2014 KernelVersion: 4.0 Loading Loading @@ -160,6 +168,10 @@ Description: Specific MJPEG format descriptors All attributes read only, except bmaControls and bDefaultFrameIndex: bFormatIndex - unique id for this format descriptor; only defined after parent header is linked into the streaming class; read-only bmaControls - this format's data for bmaControls in the streaming header bmInterfaceFlags - specifies interlace information, Loading @@ -177,6 +189,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Specific MJPEG frame descriptors bFrameIndex - unique id for this framedescriptor; only defined after parent format is linked into the streaming header; read-only dwFrameInterval - indicates how frame interval can be programmed; a number of values separated by newline can be specified Loading Loading @@ -204,6 +220,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Specific uncompressed format descriptors bFormatIndex - unique id for this format descriptor; only defined after parent header is linked into the streaming class; read-only bmaControls - this format's data for bmaControls in the streaming header bmInterfaceFlags - specifies interlace information, Loading @@ -224,6 +244,10 @@ Date: Dec 2014 KernelVersion: 4.0 Description: Specific uncompressed frame descriptors bFrameIndex - unique id for this framedescriptor; only defined after parent format is linked into the streaming header; read-only dwFrameInterval - indicates how frame interval can be programmed; a number of values separated by newline can be specified Loading
drivers/usb/gadget/function/f_uvc.c +26 −31 Original line number Diff line number Diff line Loading @@ -197,12 +197,6 @@ static const struct usb_descriptor_header * const uvc_ss_streaming[] = { NULL, }; void uvc_set_trace_param(unsigned int trace) { uvc_gadget_trace_param = trace; } EXPORT_SYMBOL(uvc_set_trace_param); /* -------------------------------------------------------------------------- * Control requests */ Loading Loading @@ -232,13 +226,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) struct v4l2_event v4l2_event; struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; /* printk(KERN_INFO "setup request %02x %02x value %04x index %04x %04x\n", * ctrl->bRequestType, ctrl->bRequest, le16_to_cpu(ctrl->wValue), * le16_to_cpu(ctrl->wIndex), le16_to_cpu(ctrl->wLength)); */ if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) { INFO(f->config->cdev, "invalid request type\n"); uvcg_info(f, "invalid request type\n"); return -EINVAL; } Loading Loading @@ -272,7 +261,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface) { struct uvc_device *uvc = to_uvc(f); INFO(f->config->cdev, "uvc_function_get_alt(%u)\n", interface); uvcg_info(f, "%s(%u)\n", __func__, interface); if (interface == uvc->control_intf) return 0; Loading @@ -291,13 +280,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; int ret; INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt); uvcg_info(f, "%s(%u, %u)\n", __func__, interface, alt); if (interface == uvc->control_intf) { if (alt) return -EINVAL; INFO(cdev, "reset UVC Control\n"); uvcg_info(f, "reset UVC Control\n"); usb_ep_disable(uvc->control_ep); if (!uvc->control_ep->desc) Loading Loading @@ -348,7 +337,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) if (!uvc->video.ep) return -EINVAL; INFO(cdev, "reset UVC\n"); uvcg_info(f, "reset UVC\n"); usb_ep_disable(uvc->video.ep); ret = config_ep_by_speed(f->config->cdev->gadget, Loading @@ -373,7 +362,7 @@ uvc_function_disable(struct usb_function *f) struct uvc_device *uvc = to_uvc(f); struct v4l2_event v4l2_event; INFO(f->config->cdev, "uvc_function_disable\n"); uvcg_info(f, "%s()\n", __func__); memset(&v4l2_event, 0, sizeof(v4l2_event)); v4l2_event.type = UVC_EVENT_DISCONNECT; Loading @@ -392,21 +381,19 @@ uvc_function_disable(struct usb_function *f) void uvc_function_connect(struct uvc_device *uvc) { struct usb_composite_dev *cdev = uvc->func.config->cdev; int ret; if ((ret = usb_function_activate(&uvc->func)) < 0) INFO(cdev, "UVC connect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret); } void uvc_function_disconnect(struct uvc_device *uvc) { struct usb_composite_dev *cdev = uvc->func.config->cdev; int ret; if ((ret = usb_function_deactivate(&uvc->func)) < 0) INFO(cdev, "UVC disconnect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret); } /* -------------------------------------------------------------------------- Loading Loading @@ -605,7 +592,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) struct f_uvc_opts *opts; int ret = -EINVAL; INFO(cdev, "uvc_function_bind\n"); uvcg_info(f, "%s()\n", __func__); opts = fi_to_f_uvc_opts(f->fi); /* Sanity check the streaming endpoint module parameters. Loading @@ -618,7 +605,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) if (opts->streaming_maxburst && (opts->streaming_maxpacket % 1024) != 0) { opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024); INFO(cdev, "overriding streaming_maxpacket to %d\n", uvcg_info(f, "overriding streaming_maxpacket to %d\n", opts->streaming_maxpacket); } Loading Loading @@ -658,7 +645,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) /* Allocate endpoints. */ ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep); if (!ep) { INFO(cdev, "Unable to allocate control EP\n"); uvcg_info(f, "Unable to allocate control EP\n"); goto error; } uvc->control_ep = ep; Loading @@ -672,7 +659,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); if (!ep) { INFO(cdev, "Unable to allocate streaming EP\n"); uvcg_info(f, "Unable to allocate streaming EP\n"); goto error; } uvc->video.ep = ep; Loading @@ -699,12 +686,14 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) uvc_iad.bFirstInterface = ret; uvc_control_intf.bInterfaceNumber = ret; uvc->control_intf = ret; opts->control_interface = ret; if ((ret = usb_interface_id(c, f)) < 0) goto error; uvc_streaming_intf_alt0.bInterfaceNumber = ret; uvc_streaming_intf_alt1.bInterfaceNumber = ret; uvc->streaming_intf = ret; opts->streaming_interface = ret; /* Copy descriptors */ f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); Loading Loading @@ -743,19 +732,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) uvc->control_req->context = uvc; if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { printk(KERN_INFO "v4l2_device_register failed\n"); uvcg_err(f, "failed to register V4L2 device\n"); goto error; } /* Initialise video. */ ret = uvcg_video_init(&uvc->video); ret = uvcg_video_init(&uvc->video, uvc); if (ret < 0) goto error; /* Register a V4L2 device. */ ret = uvc_register_video(uvc); if (ret < 0) { printk(KERN_INFO "Unable to register video device\n"); uvcg_err(f, "failed to register video device\n"); goto error; } Loading Loading @@ -792,6 +781,7 @@ static struct usb_function_instance *uvc_alloc_inst(void) struct uvc_output_terminal_descriptor *od; struct uvc_color_matching_descriptor *md; struct uvc_descriptor_header **ctl_cls; int ret; opts = kzalloc(sizeof(*opts), GFP_KERNEL); if (!opts) Loading Loading @@ -868,7 +858,12 @@ static struct usb_function_instance *uvc_alloc_inst(void) opts->streaming_interval = 1; opts->streaming_maxpacket = 1024; uvcg_attach_configfs(opts); ret = uvcg_attach_configfs(opts); if (ret < 0) { kfree(opts); return ERR_PTR(ret); } return &opts->func_inst; } Loading @@ -886,7 +881,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f) struct usb_composite_dev *cdev = c->cdev; struct uvc_device *uvc = to_uvc(f); INFO(cdev, "%s\n", __func__); uvcg_info(f, "%s\n", __func__); device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); video_unregister_device(&uvc->vdev); Loading
drivers/usb/gadget/function/u_uvc.h +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ struct f_uvc_opts { unsigned int streaming_maxpacket; unsigned int streaming_maxburst; unsigned int control_interface; unsigned int streaming_interface; /* * Control descriptors array pointers for full-/high-speed and * super-speed. They point by default to the uvc_fs_control_cls and Loading
drivers/usb/gadget/function/uvc.h +8 −8 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ struct usb_ep; struct usb_request; struct uvc_descriptor_header; struct uvc_device; /* ------------------------------------------------------------------------ * Debugging, printing and logging Loading Loading @@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param; printk(KERN_DEBUG "uvcvideo: " msg); \ } while (0) #define uvc_warn_once(dev, warn, msg...) \ do { \ if (!test_and_set_bit(warn, &dev->warnings)) \ printk(KERN_INFO "uvcvideo: " msg); \ } while (0) #define uvc_printk(level, msg...) \ printk(level "uvcvideo: " msg) #define uvcg_dbg(f, fmt, args...) \ dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) #define uvcg_info(f, fmt, args...) \ dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) #define uvcg_err(f, fmt, args...) \ dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args) /* ------------------------------------------------------------------------ * Driver specific constants Loading @@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param; */ struct uvc_video { struct uvc_device *uvc; struct usb_ep *ep; /* Frame parameters */ Loading
drivers/usb/gadget/function/uvc_configfs.c +668 −500 File changed.Preview size limit exceeded, changes collapsed. Show changes