Lines Matching refs:uvc

213 	struct uvc_device *uvc = req->context;  in uvc_function_ep0_complete()  local
217 if (uvc->event_setup_out) { in uvc_function_ep0_complete()
218 uvc->event_setup_out = 0; in uvc_function_ep0_complete()
224 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_ep0_complete()
231 struct uvc_device *uvc = to_uvc(f); in uvc_function_setup() local
252 uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN); in uvc_function_setup()
253 uvc->event_length = le16_to_cpu(ctrl->wLength); in uvc_function_setup()
258 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_setup()
263 void uvc_function_setup_continue(struct uvc_device *uvc) in uvc_function_setup_continue() argument
265 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_setup_continue()
273 struct uvc_device *uvc = to_uvc(f); in uvc_function_get_alt() local
277 if (interface == uvc->control_intf) in uvc_function_get_alt()
279 else if (interface != uvc->streaming_intf) in uvc_function_get_alt()
282 return uvc->video.ep->enabled ? 1 : 0; in uvc_function_get_alt()
288 struct uvc_device *uvc = to_uvc(f); in uvc_function_set_alt() local
296 if (interface == uvc->control_intf) { in uvc_function_set_alt()
301 usb_ep_disable(uvc->control_ep); in uvc_function_set_alt()
303 if (!uvc->control_ep->desc) in uvc_function_set_alt()
304 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep)) in uvc_function_set_alt()
307 usb_ep_enable(uvc->control_ep); in uvc_function_set_alt()
309 if (uvc->state == UVC_STATE_DISCONNECTED) { in uvc_function_set_alt()
313 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
315 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
321 if (interface != uvc->streaming_intf) in uvc_function_set_alt()
331 if (uvc->state != UVC_STATE_STREAMING) in uvc_function_set_alt()
334 if (uvc->video.ep) in uvc_function_set_alt()
335 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
339 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
341 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
345 if (uvc->state != UVC_STATE_CONNECTED) in uvc_function_set_alt()
348 if (!uvc->video.ep) in uvc_function_set_alt()
352 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
355 &(uvc->func), uvc->video.ep); in uvc_function_set_alt()
358 usb_ep_enable(uvc->video.ep); in uvc_function_set_alt()
362 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
373 struct uvc_device *uvc = to_uvc(f); in uvc_function_disable() local
380 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_disable()
382 uvc->state = UVC_STATE_DISCONNECTED; in uvc_function_disable()
384 usb_ep_disable(uvc->video.ep); in uvc_function_disable()
385 usb_ep_disable(uvc->control_ep); in uvc_function_disable()
393 uvc_function_connect(struct uvc_device *uvc) in uvc_function_connect() argument
395 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_connect()
398 if ((ret = usb_function_activate(&uvc->func)) < 0) in uvc_function_connect()
403 uvc_function_disconnect(struct uvc_device *uvc) in uvc_function_disconnect() argument
405 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_disconnect()
408 if ((ret = usb_function_deactivate(&uvc->func)) < 0) in uvc_function_disconnect()
419 struct uvc_device *uvc = dev_get_drvdata(dev); in function_name_show() local
421 return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name); in function_name_show()
427 uvc_register_video(struct uvc_device *uvc) in uvc_register_video() argument
429 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_register_video()
433 uvc->vdev.v4l2_dev = &uvc->v4l2_dev; in uvc_register_video()
434 uvc->vdev.fops = &uvc_v4l2_fops; in uvc_register_video()
435 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops; in uvc_register_video()
436 uvc->vdev.release = video_device_release_empty; in uvc_register_video()
437 uvc->vdev.vfl_dir = VFL_DIR_TX; in uvc_register_video()
438 uvc->vdev.lock = &uvc->video.mutex; in uvc_register_video()
439 strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name)); in uvc_register_video()
441 video_set_drvdata(&uvc->vdev, uvc); in uvc_register_video()
443 ret = video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1); in uvc_register_video()
447 ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_register_video()
449 video_unregister_device(&uvc->vdev); in uvc_register_video()
474 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed) in uvc_copy_descriptors() argument
492 uvc_control_desc = uvc->desc.ss_control; in uvc_copy_descriptors()
493 uvc_streaming_cls = uvc->desc.ss_streaming; in uvc_copy_descriptors()
498 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
499 uvc_streaming_cls = uvc->desc.hs_streaming; in uvc_copy_descriptors()
505 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
506 uvc_streaming_cls = uvc->desc.fs_streaming; in uvc_copy_descriptors()
575 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf; in uvc_copy_descriptors()
588 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address; in uvc_copy_descriptors()
600 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()
701 uvc->control_intf = ret; in uvc_function_bind()
707 uvc->streaming_intf = ret; in uvc_function_bind()
710 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); in uvc_function_bind()
717 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); in uvc_function_bind()
725 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); in uvc_function_bind()
734 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); in uvc_function_bind()
735 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL); in uvc_function_bind()
736 if (uvc->control_req == NULL || uvc->control_buf == NULL) { in uvc_function_bind()
741 uvc->control_req->buf = uvc->control_buf; in uvc_function_bind()
742 uvc->control_req->complete = uvc_function_ep0_complete; in uvc_function_bind()
743 uvc->control_req->context = uvc; in uvc_function_bind()
745 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { in uvc_function_bind()
751 ret = uvcg_video_init(&uvc->video); in uvc_function_bind()
756 ret = uvc_register_video(uvc); in uvc_function_bind()
765 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_bind()
767 if (uvc->control_req) in uvc_function_bind()
768 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_bind()
769 kfree(uvc->control_buf); in uvc_function_bind()
877 struct uvc_device *uvc = to_uvc(f); in uvc_free() local
881 kfree(uvc); in uvc_free()
887 struct uvc_device *uvc = to_uvc(f); in uvc_unbind() local
891 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_unbind()
892 video_unregister_device(&uvc->vdev); in uvc_unbind()
893 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_unbind()
895 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_unbind()
896 kfree(uvc->control_buf); in uvc_unbind()
903 struct uvc_device *uvc; in uvc_alloc() local
907 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL); in uvc_alloc()
908 if (uvc == NULL) in uvc_alloc()
911 mutex_init(&uvc->video.mutex); in uvc_alloc()
912 uvc->state = UVC_STATE_DISCONNECTED; in uvc_alloc()
932 uvc->desc.fs_control = opts->fs_control; in uvc_alloc()
933 uvc->desc.ss_control = opts->ss_control; in uvc_alloc()
934 uvc->desc.fs_streaming = opts->fs_streaming; in uvc_alloc()
935 uvc->desc.hs_streaming = opts->hs_streaming; in uvc_alloc()
936 uvc->desc.ss_streaming = opts->ss_streaming; in uvc_alloc()
941 uvc->func.name = "uvc"; in uvc_alloc()
942 uvc->func.bind = uvc_function_bind; in uvc_alloc()
943 uvc->func.unbind = uvc_unbind; in uvc_alloc()
944 uvc->func.get_alt = uvc_function_get_alt; in uvc_alloc()
945 uvc->func.set_alt = uvc_function_set_alt; in uvc_alloc()
946 uvc->func.disable = uvc_function_disable; in uvc_alloc()
947 uvc->func.setup = uvc_function_setup; in uvc_alloc()
948 uvc->func.free_func = uvc_free; in uvc_alloc()
949 uvc->func.bind_deactivated = true; in uvc_alloc()
951 return &uvc->func; in uvc_alloc()
954 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);