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->enabled ? 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()
302 usb_ep_disable(uvc->control_ep); in uvc_function_set_alt()
304 if (!uvc->control_ep->desc) in uvc_function_set_alt()
305 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep)) in uvc_function_set_alt()
308 usb_ep_enable(uvc->control_ep); in uvc_function_set_alt()
310 if (uvc->state == UVC_STATE_DISCONNECTED) { in uvc_function_set_alt()
314 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
316 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
322 if (interface != uvc->streaming_intf) in uvc_function_set_alt()
332 if (uvc->state != UVC_STATE_STREAMING) in uvc_function_set_alt()
335 if (uvc->video.ep) in uvc_function_set_alt()
336 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
340 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
342 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
346 if (uvc->state != UVC_STATE_CONNECTED) in uvc_function_set_alt()
349 if (!uvc->video.ep) in uvc_function_set_alt()
353 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
356 &(uvc->func), uvc->video.ep); in uvc_function_set_alt()
359 usb_ep_enable(uvc->video.ep); in uvc_function_set_alt()
363 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
374 struct uvc_device *uvc = to_uvc(f); in uvc_function_disable() local
381 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_disable()
383 uvc->state = UVC_STATE_DISCONNECTED; in uvc_function_disable()
385 usb_ep_disable(uvc->video.ep); in uvc_function_disable()
386 usb_ep_disable(uvc->control_ep); in uvc_function_disable()
394 uvc_function_connect(struct uvc_device *uvc) in uvc_function_connect() argument
396 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_connect()
399 if ((ret = usb_function_activate(&uvc->func)) < 0) in uvc_function_connect()
404 uvc_function_disconnect(struct uvc_device *uvc) in uvc_function_disconnect() argument
406 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_disconnect()
409 if ((ret = usb_function_deactivate(&uvc->func)) < 0) in uvc_function_disconnect()
418 uvc_register_video(struct uvc_device *uvc) in uvc_register_video() argument
420 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_register_video()
423 uvc->vdev.v4l2_dev = &uvc->v4l2_dev; in uvc_register_video()
424 uvc->vdev.fops = &uvc_v4l2_fops; in uvc_register_video()
425 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops; in uvc_register_video()
426 uvc->vdev.release = video_device_release_empty; in uvc_register_video()
427 uvc->vdev.vfl_dir = VFL_DIR_TX; in uvc_register_video()
428 uvc->vdev.lock = &uvc->video.mutex; in uvc_register_video()
429 strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name)); in uvc_register_video()
431 video_set_drvdata(&uvc->vdev, uvc); in uvc_register_video()
433 return video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1); in uvc_register_video()
454 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed) in uvc_copy_descriptors() argument
472 uvc_control_desc = uvc->desc.ss_control; in uvc_copy_descriptors()
473 uvc_streaming_cls = uvc->desc.ss_streaming; in uvc_copy_descriptors()
478 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
479 uvc_streaming_cls = uvc->desc.hs_streaming; in uvc_copy_descriptors()
485 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
486 uvc_streaming_cls = uvc->desc.fs_streaming; in uvc_copy_descriptors()
555 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf; in uvc_copy_descriptors()
568 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address; in uvc_copy_descriptors()
580 struct uvc_device *uvc = to_uvc(f); in uvc_function_bind() local
636 uvc->control_ep = ep; in uvc_function_bind()
650 uvc->video.ep = ep; in uvc_function_bind()
652 uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
653 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
654 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
673 uvc->control_intf = ret; in uvc_function_bind()
679 uvc->streaming_intf = ret; in uvc_function_bind()
682 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); in uvc_function_bind()
689 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); in uvc_function_bind()
697 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); in uvc_function_bind()
706 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); in uvc_function_bind()
707 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL); in uvc_function_bind()
708 if (uvc->control_req == NULL || uvc->control_buf == NULL) { in uvc_function_bind()
713 uvc->control_req->buf = uvc->control_buf; in uvc_function_bind()
714 uvc->control_req->complete = uvc_function_ep0_complete; in uvc_function_bind()
715 uvc->control_req->context = uvc; in uvc_function_bind()
717 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { in uvc_function_bind()
723 ret = uvcg_video_init(&uvc->video); in uvc_function_bind()
728 ret = uvc_register_video(uvc); in uvc_function_bind()
737 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_bind()
739 if (uvc->control_req) in uvc_function_bind()
740 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_bind()
741 kfree(uvc->control_buf); in uvc_function_bind()
849 struct uvc_device *uvc = to_uvc(f); in uvc_free() local
853 kfree(uvc); in uvc_free()
859 struct uvc_device *uvc = to_uvc(f); in uvc_unbind() local
863 video_unregister_device(&uvc->vdev); in uvc_unbind()
864 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_unbind()
866 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_unbind()
867 kfree(uvc->control_buf); in uvc_unbind()
874 struct uvc_device *uvc; in uvc_alloc() local
878 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL); in uvc_alloc()
879 if (uvc == NULL) in uvc_alloc()
882 mutex_init(&uvc->video.mutex); in uvc_alloc()
883 uvc->state = UVC_STATE_DISCONNECTED; in uvc_alloc()
903 uvc->desc.fs_control = opts->fs_control; in uvc_alloc()
904 uvc->desc.ss_control = opts->ss_control; in uvc_alloc()
905 uvc->desc.fs_streaming = opts->fs_streaming; in uvc_alloc()
906 uvc->desc.hs_streaming = opts->hs_streaming; in uvc_alloc()
907 uvc->desc.ss_streaming = opts->ss_streaming; in uvc_alloc()
912 uvc->func.name = "uvc"; in uvc_alloc()
913 uvc->func.bind = uvc_function_bind; in uvc_alloc()
914 uvc->func.unbind = uvc_unbind; in uvc_alloc()
915 uvc->func.get_alt = uvc_function_get_alt; in uvc_alloc()
916 uvc->func.set_alt = uvc_function_set_alt; in uvc_alloc()
917 uvc->func.disable = uvc_function_disable; in uvc_alloc()
918 uvc->func.setup = uvc_function_setup; in uvc_alloc()
919 uvc->func.free_func = uvc_free; in uvc_alloc()
920 uvc->func.bind_deactivated = true; in uvc_alloc()
922 return &uvc->func; in uvc_alloc()
925 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);