Lines Matching refs:uvc
214 struct uvc_device *uvc = req->context; in uvc_function_ep0_complete() local
218 if (uvc->event_setup_out) { in uvc_function_ep0_complete()
219 uvc->event_setup_out = 0; in uvc_function_ep0_complete()
225 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_ep0_complete()
232 struct uvc_device *uvc = to_uvc(f); in uvc_function_setup() local
253 uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN); in uvc_function_setup()
254 uvc->event_length = le16_to_cpu(ctrl->wLength); in uvc_function_setup()
259 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_setup()
264 void uvc_function_setup_continue(struct uvc_device *uvc) in uvc_function_setup_continue() argument
266 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_setup_continue()
274 struct uvc_device *uvc = to_uvc(f); in uvc_function_get_alt() local
278 if (interface == uvc->control_intf) in uvc_function_get_alt()
280 else if (interface != uvc->streaming_intf) in uvc_function_get_alt()
283 return uvc->video.ep->driver_data ? 1 : 0; in uvc_function_get_alt()
289 struct uvc_device *uvc = to_uvc(f); in uvc_function_set_alt() local
297 if (interface == uvc->control_intf) { in uvc_function_set_alt()
301 if (uvc->control_ep->driver_data) { in uvc_function_set_alt()
303 usb_ep_disable(uvc->control_ep); in uvc_function_set_alt()
304 uvc->control_ep->driver_data = NULL; in uvc_function_set_alt()
307 if (!uvc->control_ep->desc) in uvc_function_set_alt()
308 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep)) in uvc_function_set_alt()
311 usb_ep_enable(uvc->control_ep); in uvc_function_set_alt()
312 uvc->control_ep->driver_data = uvc; in uvc_function_set_alt()
314 if (uvc->state == UVC_STATE_DISCONNECTED) { in uvc_function_set_alt()
318 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
320 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
326 if (interface != uvc->streaming_intf) in uvc_function_set_alt()
336 if (uvc->state != UVC_STATE_STREAMING) in uvc_function_set_alt()
339 if (uvc->video.ep) { in uvc_function_set_alt()
340 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
341 uvc->video.ep->driver_data = NULL; in uvc_function_set_alt()
346 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
348 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
352 if (uvc->state != UVC_STATE_CONNECTED) in uvc_function_set_alt()
355 if (!uvc->video.ep) in uvc_function_set_alt()
358 if (uvc->video.ep->driver_data) { in uvc_function_set_alt()
360 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
361 uvc->video.ep->driver_data = NULL; in uvc_function_set_alt()
365 &(uvc->func), uvc->video.ep); in uvc_function_set_alt()
368 usb_ep_enable(uvc->video.ep); in uvc_function_set_alt()
369 uvc->video.ep->driver_data = uvc; in uvc_function_set_alt()
373 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
384 struct uvc_device *uvc = to_uvc(f); in uvc_function_disable() local
391 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_disable()
393 uvc->state = UVC_STATE_DISCONNECTED; in uvc_function_disable()
395 if (uvc->video.ep->driver_data) { in uvc_function_disable()
396 usb_ep_disable(uvc->video.ep); in uvc_function_disable()
397 uvc->video.ep->driver_data = NULL; in uvc_function_disable()
400 if (uvc->control_ep->driver_data) { in uvc_function_disable()
401 usb_ep_disable(uvc->control_ep); in uvc_function_disable()
402 uvc->control_ep->driver_data = NULL; in uvc_function_disable()
411 uvc_function_connect(struct uvc_device *uvc) in uvc_function_connect() argument
413 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_connect()
416 if ((ret = usb_function_activate(&uvc->func)) < 0) in uvc_function_connect()
421 uvc_function_disconnect(struct uvc_device *uvc) in uvc_function_disconnect() argument
423 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_disconnect()
426 if ((ret = usb_function_deactivate(&uvc->func)) < 0) in uvc_function_disconnect()
435 uvc_register_video(struct uvc_device *uvc) in uvc_register_video() argument
437 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_register_video()
440 uvc->vdev.v4l2_dev = &uvc->v4l2_dev; in uvc_register_video()
441 uvc->vdev.fops = &uvc_v4l2_fops; in uvc_register_video()
442 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops; in uvc_register_video()
443 uvc->vdev.release = video_device_release_empty; in uvc_register_video()
444 uvc->vdev.vfl_dir = VFL_DIR_TX; in uvc_register_video()
445 uvc->vdev.lock = &uvc->video.mutex; in uvc_register_video()
446 strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name)); in uvc_register_video()
448 video_set_drvdata(&uvc->vdev, uvc); in uvc_register_video()
450 return video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1); in uvc_register_video()
471 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed) in uvc_copy_descriptors() argument
489 uvc_control_desc = uvc->desc.ss_control; in uvc_copy_descriptors()
490 uvc_streaming_cls = uvc->desc.ss_streaming; in uvc_copy_descriptors()
495 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
496 uvc_streaming_cls = uvc->desc.hs_streaming; in uvc_copy_descriptors()
502 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
503 uvc_streaming_cls = uvc->desc.fs_streaming; in uvc_copy_descriptors()
572 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf; in uvc_copy_descriptors()
585 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address; in uvc_copy_descriptors()
597 struct uvc_device *uvc = to_uvc(f); in uvc_function_bind() local
653 uvc->control_ep = ep; in uvc_function_bind()
654 ep->driver_data = uvc; in uvc_function_bind()
668 uvc->video.ep = ep; in uvc_function_bind()
669 ep->driver_data = uvc; in uvc_function_bind()
671 uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
672 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
673 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
692 uvc->control_intf = ret; in uvc_function_bind()
698 uvc->streaming_intf = ret; in uvc_function_bind()
701 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); in uvc_function_bind()
708 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); in uvc_function_bind()
716 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); in uvc_function_bind()
725 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); in uvc_function_bind()
726 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL); in uvc_function_bind()
727 if (uvc->control_req == NULL || uvc->control_buf == NULL) { in uvc_function_bind()
732 uvc->control_req->buf = uvc->control_buf; in uvc_function_bind()
733 uvc->control_req->complete = uvc_function_ep0_complete; in uvc_function_bind()
734 uvc->control_req->context = uvc; in uvc_function_bind()
742 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { in uvc_function_bind()
748 ret = uvcg_video_init(&uvc->video); in uvc_function_bind()
753 ret = uvc_register_video(uvc); in uvc_function_bind()
762 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_bind()
764 if (uvc->control_ep) in uvc_function_bind()
765 uvc->control_ep->driver_data = NULL; in uvc_function_bind()
766 if (uvc->video.ep) in uvc_function_bind()
767 uvc->video.ep->driver_data = NULL; in uvc_function_bind()
769 if (uvc->control_req) in uvc_function_bind()
770 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_bind()
771 kfree(uvc->control_buf); in uvc_function_bind()
879 struct uvc_device *uvc = to_uvc(f); in uvc_free() local
883 kfree(uvc); in uvc_free()
889 struct uvc_device *uvc = to_uvc(f); in uvc_unbind() local
893 video_unregister_device(&uvc->vdev); in uvc_unbind()
894 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_unbind()
895 uvc->control_ep->driver_data = NULL; in uvc_unbind()
896 uvc->video.ep->driver_data = NULL; in uvc_unbind()
898 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_unbind()
899 kfree(uvc->control_buf); in uvc_unbind()
906 struct uvc_device *uvc; in uvc_alloc() local
910 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL); in uvc_alloc()
911 if (uvc == NULL) in uvc_alloc()
914 mutex_init(&uvc->video.mutex); in uvc_alloc()
915 uvc->state = UVC_STATE_DISCONNECTED; in uvc_alloc()
935 uvc->desc.fs_control = opts->fs_control; in uvc_alloc()
936 uvc->desc.ss_control = opts->ss_control; in uvc_alloc()
937 uvc->desc.fs_streaming = opts->fs_streaming; in uvc_alloc()
938 uvc->desc.hs_streaming = opts->hs_streaming; in uvc_alloc()
939 uvc->desc.ss_streaming = opts->ss_streaming; in uvc_alloc()
944 uvc->func.name = "uvc"; in uvc_alloc()
945 uvc->func.bind = uvc_function_bind; in uvc_alloc()
946 uvc->func.unbind = uvc_unbind; in uvc_alloc()
947 uvc->func.get_alt = uvc_function_get_alt; in uvc_alloc()
948 uvc->func.set_alt = uvc_function_set_alt; in uvc_alloc()
949 uvc->func.disable = uvc_function_disable; in uvc_alloc()
950 uvc->func.setup = uvc_function_setup; in uvc_alloc()
951 uvc->func.free_func = uvc_free; in uvc_alloc()
953 return &uvc->func; in uvc_alloc()
956 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);