Lines Matching refs:uvc
210 struct uvc_device *uvc = req->context; in uvc_function_ep0_complete() local
214 if (uvc->event_setup_out) { in uvc_function_ep0_complete()
215 uvc->event_setup_out = 0; in uvc_function_ep0_complete()
221 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_ep0_complete()
228 struct uvc_device *uvc = to_uvc(f); in uvc_function_setup() local
245 uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN); in uvc_function_setup()
246 uvc->event_length = le16_to_cpu(ctrl->wLength); in uvc_function_setup()
251 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_setup()
256 void uvc_function_setup_continue(struct uvc_device *uvc) in uvc_function_setup_continue() argument
258 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_setup_continue()
266 struct uvc_device *uvc = to_uvc(f); in uvc_function_get_alt() local
270 if (interface == uvc->control_intf) in uvc_function_get_alt()
272 else if (interface != uvc->streaming_intf) in uvc_function_get_alt()
275 return uvc->video.ep->enabled ? 1 : 0; in uvc_function_get_alt()
281 struct uvc_device *uvc = to_uvc(f); in uvc_function_set_alt() local
289 if (interface == uvc->control_intf) { in uvc_function_set_alt()
294 usb_ep_disable(uvc->control_ep); in uvc_function_set_alt()
296 if (!uvc->control_ep->desc) in uvc_function_set_alt()
297 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep)) in uvc_function_set_alt()
300 usb_ep_enable(uvc->control_ep); in uvc_function_set_alt()
302 if (uvc->state == UVC_STATE_DISCONNECTED) { in uvc_function_set_alt()
306 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
308 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
314 if (interface != uvc->streaming_intf) in uvc_function_set_alt()
324 if (uvc->state != UVC_STATE_STREAMING) in uvc_function_set_alt()
327 if (uvc->video.ep) in uvc_function_set_alt()
328 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
332 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
334 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
338 if (uvc->state != UVC_STATE_CONNECTED) in uvc_function_set_alt()
341 if (!uvc->video.ep) in uvc_function_set_alt()
345 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
348 &(uvc->func), uvc->video.ep); in uvc_function_set_alt()
351 usb_ep_enable(uvc->video.ep); in uvc_function_set_alt()
355 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
366 struct uvc_device *uvc = to_uvc(f); in uvc_function_disable() local
373 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_disable()
375 uvc->state = UVC_STATE_DISCONNECTED; in uvc_function_disable()
377 usb_ep_disable(uvc->video.ep); in uvc_function_disable()
378 usb_ep_disable(uvc->control_ep); in uvc_function_disable()
386 uvc_function_connect(struct uvc_device *uvc) in uvc_function_connect() argument
390 if ((ret = usb_function_activate(&uvc->func)) < 0) in uvc_function_connect()
391 uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret); in uvc_function_connect()
395 uvc_function_disconnect(struct uvc_device *uvc) in uvc_function_disconnect() argument
399 if ((ret = usb_function_deactivate(&uvc->func)) < 0) in uvc_function_disconnect()
400 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret); in uvc_function_disconnect()
410 struct uvc_device *uvc = dev_get_drvdata(dev); in function_name_show() local
412 return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name); in function_name_show()
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()
424 memset(&uvc->vdev, 0, sizeof(uvc->vdev)); in uvc_register_video()
425 uvc->vdev.v4l2_dev = &uvc->v4l2_dev; in uvc_register_video()
426 uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev; in uvc_register_video()
427 uvc->vdev.fops = &uvc_v4l2_fops; in uvc_register_video()
428 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops; in uvc_register_video()
429 uvc->vdev.release = video_device_release_empty; in uvc_register_video()
430 uvc->vdev.vfl_dir = VFL_DIR_TX; in uvc_register_video()
431 uvc->vdev.lock = &uvc->video.mutex; in uvc_register_video()
432 uvc->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; in uvc_register_video()
433 strscpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name)); in uvc_register_video()
435 video_set_drvdata(&uvc->vdev, uvc); in uvc_register_video()
437 ret = video_register_device(&uvc->vdev, VFL_TYPE_VIDEO, -1); in uvc_register_video()
441 ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_register_video()
443 video_unregister_device(&uvc->vdev); in uvc_register_video()
468 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed) in uvc_copy_descriptors() argument
486 uvc_control_desc = uvc->desc.ss_control; in uvc_copy_descriptors()
487 uvc_streaming_cls = uvc->desc.ss_streaming; in uvc_copy_descriptors()
492 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
493 uvc_streaming_cls = uvc->desc.hs_streaming; in uvc_copy_descriptors()
499 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
500 uvc_streaming_cls = uvc->desc.fs_streaming; in uvc_copy_descriptors()
570 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf; in uvc_copy_descriptors()
583 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address; in uvc_copy_descriptors()
595 struct uvc_device *uvc = to_uvc(f); in uvc_function_bind() local
664 uvc->control_ep = ep; in uvc_function_bind()
678 uvc->video.ep = ep; in uvc_function_bind()
680 uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
681 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
682 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
702 uvc->control_intf = ret; in uvc_function_bind()
709 uvc->streaming_intf = ret; in uvc_function_bind()
713 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); in uvc_function_bind()
720 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); in uvc_function_bind()
728 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); in uvc_function_bind()
737 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); in uvc_function_bind()
738 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL); in uvc_function_bind()
739 if (uvc->control_req == NULL || uvc->control_buf == NULL) { in uvc_function_bind()
744 uvc->control_req->buf = uvc->control_buf; in uvc_function_bind()
745 uvc->control_req->complete = uvc_function_ep0_complete; in uvc_function_bind()
746 uvc->control_req->context = uvc; in uvc_function_bind()
748 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { in uvc_function_bind()
754 ret = uvcg_video_init(&uvc->video, uvc); in uvc_function_bind()
759 ret = uvc_register_video(uvc); in uvc_function_bind()
768 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_bind()
770 if (uvc->control_req) in uvc_function_bind()
771 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_bind()
772 kfree(uvc->control_buf); in uvc_function_bind()
888 struct uvc_device *uvc = to_uvc(f); in uvc_free() local
891 config_item_put(&uvc->header->item); in uvc_free()
893 kfree(uvc); in uvc_free()
900 struct uvc_device *uvc = to_uvc(f); in uvc_function_unbind() local
901 struct uvc_video *video = &uvc->video; in uvc_function_unbind()
915 if (uvc->func_connected) { in uvc_function_unbind()
917 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
918 uvc->func_connected == false, msecs_to_jiffies(500)); in uvc_function_unbind()
922 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_function_unbind()
923 video_unregister_device(&uvc->vdev); in uvc_function_unbind()
924 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_unbind()
926 if (uvc->func_connected) { in uvc_function_unbind()
933 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
934 uvc->func_connected == false, msecs_to_jiffies(1000)); in uvc_function_unbind()
938 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_unbind()
939 kfree(uvc->control_buf); in uvc_function_unbind()
946 struct uvc_device *uvc; in uvc_alloc() local
951 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL); in uvc_alloc()
952 if (uvc == NULL) in uvc_alloc()
955 mutex_init(&uvc->video.mutex); in uvc_alloc()
956 uvc->state = UVC_STATE_DISCONNECTED; in uvc_alloc()
957 init_waitqueue_head(&uvc->func_connected_queue); in uvc_alloc()
977 uvc->desc.fs_control = opts->fs_control; in uvc_alloc()
978 uvc->desc.ss_control = opts->ss_control; in uvc_alloc()
979 uvc->desc.fs_streaming = opts->fs_streaming; in uvc_alloc()
980 uvc->desc.hs_streaming = opts->hs_streaming; in uvc_alloc()
981 uvc->desc.ss_streaming = opts->ss_streaming; in uvc_alloc()
997 uvc->header = to_uvcg_streaming_header(h); in uvc_alloc()
998 if (!uvc->header->linked) { in uvc_alloc()
1000 kfree(uvc); in uvc_alloc()
1008 uvc->func.name = "uvc"; in uvc_alloc()
1009 uvc->func.bind = uvc_function_bind; in uvc_alloc()
1010 uvc->func.unbind = uvc_function_unbind; in uvc_alloc()
1011 uvc->func.get_alt = uvc_function_get_alt; in uvc_alloc()
1012 uvc->func.set_alt = uvc_function_set_alt; in uvc_alloc()
1013 uvc->func.disable = uvc_function_disable; in uvc_alloc()
1014 uvc->func.setup = uvc_function_setup; in uvc_alloc()
1015 uvc->func.free_func = uvc_free; in uvc_alloc()
1016 uvc->func.bind_deactivated = true; in uvc_alloc()
1018 return &uvc->func; in uvc_alloc()
1022 kfree(uvc); in uvc_alloc()
1026 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);