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()
367 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
378 struct uvc_device *uvc = to_uvc(f); in uvc_function_disable() local
385 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_disable()
387 uvc->state = UVC_STATE_DISCONNECTED; in uvc_function_disable()
389 usb_ep_disable(uvc->video.ep); in uvc_function_disable()
390 if (uvc->enable_interrupt_ep) in uvc_function_disable()
391 usb_ep_disable(uvc->interrupt_ep); in uvc_function_disable()
399 uvc_function_connect(struct uvc_device *uvc) in uvc_function_connect() argument
403 if ((ret = usb_function_activate(&uvc->func)) < 0) in uvc_function_connect()
404 uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret); in uvc_function_connect()
408 uvc_function_disconnect(struct uvc_device *uvc) in uvc_function_disconnect() argument
412 if ((ret = usb_function_deactivate(&uvc->func)) < 0) in uvc_function_disconnect()
413 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret); in uvc_function_disconnect()
423 struct uvc_device *uvc = dev_get_drvdata(dev); in function_name_show() local
425 return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name); in function_name_show()
431 uvc_register_video(struct uvc_device *uvc) in uvc_register_video() argument
433 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_register_video()
437 memset(&uvc->vdev, 0, sizeof(uvc->vdev)); in uvc_register_video()
438 uvc->vdev.v4l2_dev = &uvc->v4l2_dev; in uvc_register_video()
439 uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev; in uvc_register_video()
440 uvc->vdev.fops = &uvc_v4l2_fops; in uvc_register_video()
441 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops; in uvc_register_video()
442 uvc->vdev.release = video_device_release_empty; in uvc_register_video()
443 uvc->vdev.vfl_dir = VFL_DIR_TX; in uvc_register_video()
444 uvc->vdev.lock = &uvc->video.mutex; in uvc_register_video()
445 uvc->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; in uvc_register_video()
446 strscpy(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 ret = video_register_device(&uvc->vdev, VFL_TYPE_VIDEO, -1); in uvc_register_video()
454 ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_register_video()
456 video_unregister_device(&uvc->vdev); in uvc_register_video()
500 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed) in uvc_copy_descriptors() argument
520 uvc_control_desc = uvc->desc.ss_control; in uvc_copy_descriptors()
521 uvc_streaming_cls = uvc->desc.ss_streaming; in uvc_copy_descriptors()
526 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
527 uvc_streaming_cls = uvc->desc.hs_streaming; in uvc_copy_descriptors()
533 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
534 uvc_streaming_cls = uvc->desc.fs_streaming; in uvc_copy_descriptors()
563 if (uvc->enable_interrupt_ep) { in uvc_copy_descriptors()
581 list_for_each_entry(xu, uvc->desc.extension_units, list) { in uvc_copy_descriptors()
614 list_for_each_entry(xu, uvc->desc.extension_units, list) in uvc_copy_descriptors()
619 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf; in uvc_copy_descriptors()
621 if (uvc->enable_interrupt_ep) { in uvc_copy_descriptors()
636 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address; in uvc_copy_descriptors()
648 struct uvc_device *uvc = to_uvc(f); in uvc_function_bind() local
719 uvc->interrupt_ep = ep; in uvc_function_bind()
722 uvc->enable_interrupt_ep = opts->enable_interrupt_ep; in uvc_function_bind()
744 uvc->video.ep = ep; in uvc_function_bind()
746 uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
747 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
748 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address; in uvc_function_bind()
784 uvc->control_intf = ret; in uvc_function_bind()
791 uvc->streaming_intf = ret; in uvc_function_bind()
795 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); in uvc_function_bind()
802 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); in uvc_function_bind()
809 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); in uvc_function_bind()
816 f->ssp_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER_PLUS); in uvc_function_bind()
824 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); in uvc_function_bind()
825 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL); in uvc_function_bind()
826 if (uvc->control_req == NULL || uvc->control_buf == NULL) { in uvc_function_bind()
831 uvc->control_req->buf = uvc->control_buf; in uvc_function_bind()
832 uvc->control_req->complete = uvc_function_ep0_complete; in uvc_function_bind()
833 uvc->control_req->context = uvc; in uvc_function_bind()
835 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { in uvc_function_bind()
841 ret = uvcg_video_init(&uvc->video, uvc); in uvc_function_bind()
846 ret = uvc_register_video(uvc); in uvc_function_bind()
855 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_bind()
857 if (uvc->control_req) in uvc_function_bind()
858 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_bind()
859 kfree(uvc->control_buf); in uvc_function_bind()
975 struct uvc_device *uvc = to_uvc(f); in uvc_free() local
979 config_item_put(&uvc->header->item); in uvc_free()
981 kfree(uvc); in uvc_free()
988 struct uvc_device *uvc = to_uvc(f); in uvc_function_unbind() local
989 struct uvc_video *video = &uvc->video; in uvc_function_unbind()
1003 if (uvc->func_connected) { in uvc_function_unbind()
1005 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
1006 uvc->func_connected == false, msecs_to_jiffies(500)); in uvc_function_unbind()
1010 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_function_unbind()
1011 video_unregister_device(&uvc->vdev); in uvc_function_unbind()
1012 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_unbind()
1014 if (uvc->func_connected) { in uvc_function_unbind()
1021 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
1022 uvc->func_connected == false, msecs_to_jiffies(1000)); in uvc_function_unbind()
1026 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_unbind()
1027 kfree(uvc->control_buf); in uvc_function_unbind()
1034 struct uvc_device *uvc; in uvc_alloc() local
1039 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL); in uvc_alloc()
1040 if (uvc == NULL) in uvc_alloc()
1043 mutex_init(&uvc->video.mutex); in uvc_alloc()
1044 uvc->state = UVC_STATE_DISCONNECTED; in uvc_alloc()
1045 init_waitqueue_head(&uvc->func_connected_queue); in uvc_alloc()
1065 uvc->desc.fs_control = opts->fs_control; in uvc_alloc()
1066 uvc->desc.ss_control = opts->ss_control; in uvc_alloc()
1067 uvc->desc.fs_streaming = opts->fs_streaming; in uvc_alloc()
1068 uvc->desc.hs_streaming = opts->hs_streaming; in uvc_alloc()
1069 uvc->desc.ss_streaming = opts->ss_streaming; in uvc_alloc()
1072 uvc->header = opts->header; in uvc_alloc()
1088 uvc->header = to_uvcg_streaming_header(h); in uvc_alloc()
1089 if (!uvc->header->linked) { in uvc_alloc()
1091 kfree(uvc); in uvc_alloc()
1096 uvc->desc.extension_units = &opts->extension_units; in uvc_alloc()
1102 uvc->func.name = "uvc"; in uvc_alloc()
1103 uvc->func.bind = uvc_function_bind; in uvc_alloc()
1104 uvc->func.unbind = uvc_function_unbind; in uvc_alloc()
1105 uvc->func.get_alt = uvc_function_get_alt; in uvc_alloc()
1106 uvc->func.set_alt = uvc_function_set_alt; in uvc_alloc()
1107 uvc->func.disable = uvc_function_disable; in uvc_alloc()
1108 uvc->func.setup = uvc_function_setup; in uvc_alloc()
1109 uvc->func.free_func = uvc_free; in uvc_alloc()
1110 uvc->func.bind_deactivated = true; in uvc_alloc()
1112 return &uvc->func; in uvc_alloc()
1116 kfree(uvc); in uvc_alloc()
1120 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);