Lines Matching refs:uvc
207 struct uvc_device *uvc = req->context; in uvc_function_ep0_complete() local
211 if (uvc->event_setup_out) { in uvc_function_ep0_complete()
212 uvc->event_setup_out = 0; in uvc_function_ep0_complete()
219 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_ep0_complete()
226 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()
258 if (interface == uvc->streaming_intf) in uvc_function_setup()
261 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_setup()
266 void uvc_function_setup_continue(struct uvc_device *uvc, int disable_ep) in uvc_function_setup_continue() argument
268 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_setup_continue()
270 if (disable_ep && uvc->video.ep) in uvc_function_setup_continue()
271 usb_ep_disable(uvc->video.ep); in uvc_function_setup_continue()
279 struct uvc_device *uvc = to_uvc(f); in uvc_function_get_alt() local
283 if (interface == uvc->control_intf) in uvc_function_get_alt()
285 else if (interface != uvc->streaming_intf) in uvc_function_get_alt()
288 return uvc->video.ep->enabled ? 1 : 0; in uvc_function_get_alt()
294 struct uvc_device *uvc = to_uvc(f); in uvc_function_set_alt() local
302 if (interface == uvc->control_intf) { in uvc_function_set_alt()
306 if (uvc->enable_interrupt_ep) { in uvc_function_set_alt()
308 usb_ep_disable(uvc->interrupt_ep); in uvc_function_set_alt()
310 if (!uvc->interrupt_ep->desc) in uvc_function_set_alt()
312 uvc->interrupt_ep)) in uvc_function_set_alt()
315 usb_ep_enable(uvc->interrupt_ep); in uvc_function_set_alt()
318 if (uvc->state == UVC_STATE_DISCONNECTED) { in uvc_function_set_alt()
322 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
324 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
330 if (interface != uvc->streaming_intf) in uvc_function_set_alt()
340 if (uvc->state != UVC_STATE_STREAMING) in uvc_function_set_alt()
345 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
350 if (uvc->state != UVC_STATE_CONNECTED) in uvc_function_set_alt()
353 if (!uvc->video.ep) in uvc_function_set_alt()
357 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
360 &(uvc->func), uvc->video.ep); in uvc_function_set_alt()
363 usb_ep_enable(uvc->video.ep); in uvc_function_set_alt()
365 uvc->video.max_req_size = uvc->video.ep->maxpacket in uvc_function_set_alt()
366 * max_t(unsigned int, uvc->video.ep->maxburst, 1) in uvc_function_set_alt()
367 * (uvc->video.ep->mult); in uvc_function_set_alt()
371 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
382 struct uvc_device *uvc = to_uvc(f); in uvc_function_disable() local
389 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_disable()
391 uvc->state = UVC_STATE_DISCONNECTED; in uvc_function_disable()
393 usb_ep_disable(uvc->video.ep); in uvc_function_disable()
394 if (uvc->enable_interrupt_ep) in uvc_function_disable()
395 usb_ep_disable(uvc->interrupt_ep); in uvc_function_disable()
403 uvc_function_connect(struct uvc_device *uvc) in uvc_function_connect() argument
407 if ((ret = usb_function_activate(&uvc->func)) < 0) in uvc_function_connect()
408 uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret); in uvc_function_connect()
412 uvc_function_disconnect(struct uvc_device *uvc) in uvc_function_disconnect() argument
416 guard(mutex)(&uvc->lock); in uvc_function_disconnect()
417 if (uvc->func_unbound) { in uvc_function_disconnect()
418 dev_dbg(&uvc->vdev.dev, "skipping function deactivate (unbound)\n"); in uvc_function_disconnect()
422 if ((ret = usb_function_deactivate(&uvc->func)) < 0) in uvc_function_disconnect()
423 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret); in uvc_function_disconnect()
433 struct uvc_device *uvc = dev_get_drvdata(dev); in function_name_show() local
435 return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name); in function_name_show()
442 struct uvc_device *uvc = video_get_drvdata(vdev); in uvc_vdev_release() local
445 if (uvc->vdev_release_done) in uvc_vdev_release()
446 complete(uvc->vdev_release_done); in uvc_vdev_release()
450 uvc_register_video(struct uvc_device *uvc) in uvc_register_video() argument
452 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_register_video()
456 memset(&uvc->vdev, 0, sizeof(uvc->vdev)); in uvc_register_video()
457 uvc->vdev.v4l2_dev = &uvc->v4l2_dev; in uvc_register_video()
458 uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev; in uvc_register_video()
459 uvc->vdev.fops = &uvc_v4l2_fops; in uvc_register_video()
460 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops; in uvc_register_video()
461 uvc->vdev.release = uvc_vdev_release; in uvc_register_video()
462 uvc->vdev.vfl_dir = VFL_DIR_TX; in uvc_register_video()
463 uvc->vdev.lock = &uvc->video.mutex; in uvc_register_video()
464 uvc->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; in uvc_register_video()
465 strscpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name)); in uvc_register_video()
467 video_set_drvdata(&uvc->vdev, uvc); in uvc_register_video()
469 ret = video_register_device(&uvc->vdev, VFL_TYPE_VIDEO, -1); in uvc_register_video()
473 ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_register_video()
475 video_unregister_device(&uvc->vdev); in uvc_register_video()
519 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed) in uvc_copy_descriptors() argument
539 uvc_control_desc = uvc->desc.ss_control; in uvc_copy_descriptors()
540 uvc_streaming_cls = uvc->desc.ss_streaming; in uvc_copy_descriptors()
545 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
546 uvc_streaming_cls = uvc->desc.hs_streaming; in uvc_copy_descriptors()
552 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
553 uvc_streaming_cls = uvc->desc.fs_streaming; in uvc_copy_descriptors()
582 if (uvc->enable_interrupt_ep) { in uvc_copy_descriptors()
600 list_for_each_entry(xu, uvc->desc.extension_units, list) { in uvc_copy_descriptors()
633 list_for_each_entry(xu, uvc->desc.extension_units, list) in uvc_copy_descriptors()
638 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf; in uvc_copy_descriptors()
640 if (uvc->enable_interrupt_ep) { in uvc_copy_descriptors()
655 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address; in uvc_copy_descriptors()
667 struct uvc_device *uvc = to_uvc(f); in uvc_function_bind() local
677 scoped_guard(mutex, &uvc->lock) in uvc_function_bind()
678 uvc->func_unbound = false; in uvc_function_bind()
740 uvc->interrupt_ep = ep; in uvc_function_bind()
743 uvc->enable_interrupt_ep = opts->enable_interrupt_ep; in uvc_function_bind()
765 uvc->video.ep = ep; in uvc_function_bind()
767 uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
768 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
769 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
805 uvc->control_intf = ret; in uvc_function_bind()
812 uvc->streaming_intf = ret; in uvc_function_bind()
816 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); in uvc_function_bind()
823 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); in uvc_function_bind()
830 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); in uvc_function_bind()
837 f->ssp_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER_PLUS); in uvc_function_bind()
845 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); in uvc_function_bind()
846 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL); in uvc_function_bind()
847 if (uvc->control_req == NULL || uvc->control_buf == NULL) { in uvc_function_bind()
852 uvc->control_req->buf = uvc->control_buf; in uvc_function_bind()
853 uvc->control_req->complete = uvc_function_ep0_complete; in uvc_function_bind()
854 uvc->control_req->context = uvc; in uvc_function_bind()
856 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { in uvc_function_bind()
862 ret = uvcg_video_init(&uvc->video, uvc); in uvc_function_bind()
867 ret = uvc_register_video(uvc); in uvc_function_bind()
876 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_bind()
878 if (uvc->control_req) in uvc_function_bind()
879 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_bind()
880 kfree(uvc->control_buf); in uvc_function_bind()
996 struct uvc_device *uvc = to_uvc(f); in uvc_free() local
1000 config_item_put(&uvc->header->item); in uvc_free()
1002 kfree(uvc); in uvc_free()
1010 struct uvc_device *uvc = to_uvc(f); in uvc_function_unbind() local
1011 struct uvc_video *video = &uvc->video; in uvc_function_unbind()
1016 scoped_guard(mutex, &uvc->lock) { in uvc_function_unbind()
1017 uvc->func_unbound = true; in uvc_function_unbind()
1018 uvc->vdev_release_done = &vdev_release_done; in uvc_function_unbind()
1019 connected = uvc->func_connected; in uvc_function_unbind()
1035 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
1036 uvc->func_connected == false, msecs_to_jiffies(500)); in uvc_function_unbind()
1040 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_function_unbind()
1041 video_unregister_device(&uvc->vdev); in uvc_function_unbind()
1042 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_unbind()
1044 scoped_guard(mutex, &uvc->lock) in uvc_function_unbind()
1045 connected = uvc->func_connected; in uvc_function_unbind()
1054 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
1055 uvc->func_connected == false, msecs_to_jiffies(1000)); in uvc_function_unbind()
1061 uvc->vdev_release_done = NULL; in uvc_function_unbind()
1063 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_unbind()
1064 kfree(uvc->control_buf); in uvc_function_unbind()
1071 struct uvc_device *uvc; in uvc_alloc() local
1076 uvc = kzalloc_obj(*uvc); in uvc_alloc()
1077 if (uvc == NULL) in uvc_alloc()
1080 mutex_init(&uvc->video.mutex); in uvc_alloc()
1081 mutex_init(&uvc->lock); in uvc_alloc()
1082 uvc->func_unbound = true; in uvc_alloc()
1083 uvc->state = UVC_STATE_DISCONNECTED; in uvc_alloc()
1084 init_waitqueue_head(&uvc->func_connected_queue); in uvc_alloc()
1104 uvc->desc.fs_control = opts->fs_control; in uvc_alloc()
1105 uvc->desc.ss_control = opts->ss_control; in uvc_alloc()
1106 uvc->desc.fs_streaming = opts->fs_streaming; in uvc_alloc()
1107 uvc->desc.hs_streaming = opts->hs_streaming; in uvc_alloc()
1108 uvc->desc.ss_streaming = opts->ss_streaming; in uvc_alloc()
1111 uvc->header = opts->header; in uvc_alloc()
1127 uvc->header = to_uvcg_streaming_header(h); in uvc_alloc()
1128 if (!uvc->header->linked) { in uvc_alloc()
1130 kfree(uvc); in uvc_alloc()
1135 uvc->desc.extension_units = &opts->extension_units; in uvc_alloc()
1141 uvc->func.name = "uvc"; in uvc_alloc()
1142 uvc->func.bind = uvc_function_bind; in uvc_alloc()
1143 uvc->func.unbind = uvc_function_unbind; in uvc_alloc()
1144 uvc->func.get_alt = uvc_function_get_alt; in uvc_alloc()
1145 uvc->func.set_alt = uvc_function_set_alt; in uvc_alloc()
1146 uvc->func.disable = uvc_function_disable; in uvc_alloc()
1147 uvc->func.setup = uvc_function_setup; in uvc_alloc()
1148 uvc->func.free_func = uvc_free; in uvc_alloc()
1149 uvc->func.bind_deactivated = true; in uvc_alloc()
1151 return &uvc->func; in uvc_alloc()
1155 kfree(uvc); in uvc_alloc()
1159 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);