Lines Matching defs:uvc
28 #include "uvc.h"
207 struct uvc_device *uvc = req->context;
211 if (uvc->event_setup_out) {
212 uvc->event_setup_out = 0;
219 v4l2_event_queue(&uvc->vdev, &v4l2_event);
226 struct uvc_device *uvc = to_uvc(f);
242 uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN);
243 uvc->event_length = le16_to_cpu(ctrl->wLength);
248 v4l2_event_queue(&uvc->vdev, &v4l2_event);
253 void uvc_function_setup_continue(struct uvc_device *uvc)
255 struct usb_composite_dev *cdev = uvc->func.config->cdev;
263 struct uvc_device *uvc = to_uvc(f);
267 if (interface == uvc->control_intf)
269 else if (interface != uvc->streaming_intf)
272 return uvc->video.ep->enabled ? 1 : 0;
278 struct uvc_device *uvc = to_uvc(f);
286 if (interface == uvc->control_intf) {
291 usb_ep_disable(uvc->control_ep);
293 if (!uvc->control_ep->desc)
294 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep))
297 usb_ep_enable(uvc->control_ep);
299 if (uvc->state == UVC_STATE_DISCONNECTED) {
303 v4l2_event_queue(&uvc->vdev, &v4l2_event);
305 uvc->state = UVC_STATE_CONNECTED;
311 if (interface != uvc->streaming_intf)
315 if (usb_endpoint_xfer_bulk(&uvc->desc.vs_ep))
321 if (uvc->state != UVC_STATE_STREAMING)
324 if (uvc->video.ep)
325 usb_ep_disable(uvc->video.ep);
329 v4l2_event_queue(&uvc->vdev, &v4l2_event);
331 uvc->state = UVC_STATE_CONNECTED;
335 if (uvc->state != UVC_STATE_CONNECTED)
338 if (!uvc->video.ep)
342 usb_ep_disable(uvc->video.ep);
345 &(uvc->func), uvc->video.ep);
348 usb_ep_enable(uvc->video.ep);
352 v4l2_event_queue(&uvc->vdev, &v4l2_event);
363 struct uvc_device *uvc = to_uvc(f);
370 v4l2_event_queue(&uvc->vdev, &v4l2_event);
372 uvc->state = UVC_STATE_DISCONNECTED;
374 usb_ep_disable(uvc->video.ep);
375 usb_ep_disable(uvc->control_ep);
383 uvc_function_connect(struct uvc_device *uvc)
387 if ((ret = usb_function_activate(&uvc->func)) < 0)
388 uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret);
392 uvc_function_disconnect(struct uvc_device *uvc)
396 if ((ret = usb_function_deactivate(&uvc->func)) < 0)
397 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret);
407 struct uvc_device *uvc = dev_get_drvdata(dev);
409 return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name);
415 uvc_register_video(struct uvc_device *uvc)
417 struct usb_composite_dev *cdev = uvc->func.config->cdev;
421 uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
422 uvc->vdev.fops = &uvc_v4l2_fops;
423 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops;
424 uvc->vdev.release = video_device_release_empty;
425 uvc->vdev.vfl_dir = VFL_DIR_TX;
426 uvc->vdev.lock = &uvc->video.mutex;
427 uvc->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
428 strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name));
430 video_set_drvdata(&uvc->vdev, uvc);
432 ret = video_register_device(&uvc->vdev, VFL_TYPE_VIDEO, -1);
436 ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name);
438 video_unregister_device(&uvc->vdev);
463 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
481 uvc_control_desc = uvc->desc.ss_control;
482 uvc_streaming_cls = uvc->desc.ss_streaming;
487 uvc_control_desc = uvc->desc.fs_control;
488 uvc_streaming_cls = uvc->desc.hs_streaming;
494 uvc_control_desc = uvc->desc.fs_control;
495 uvc_streaming_cls = uvc->desc.fs_streaming;
564 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf;
577 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address;
589 struct uvc_device *uvc = to_uvc(f);
658 uvc->control_ep = ep;
672 uvc->video.ep = ep;
674 uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address;
675 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address;
676 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address;
695 uvc->control_intf = ret;
702 uvc->streaming_intf = ret;
706 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL);
713 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH);
721 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER);
730 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
731 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL);
732 if (uvc->control_req == NULL || uvc->control_buf == NULL) {
737 uvc->control_req->buf = uvc->control_buf;
738 uvc->control_req->complete = uvc_function_ep0_complete;
739 uvc->control_req->context = uvc;
741 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) {
747 ret = uvcg_video_init(&uvc->video, uvc);
752 ret = uvc_register_video(uvc);
761 v4l2_device_unregister(&uvc->v4l2_dev);
763 if (uvc->control_req)
764 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
765 kfree(uvc->control_buf);
880 struct uvc_device *uvc = to_uvc(f);
884 kfree(uvc);
891 struct uvc_device *uvc = to_uvc(f);
901 if (uvc->func_connected) {
903 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue,
904 uvc->func_connected == false, msecs_to_jiffies(500));
908 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
909 video_unregister_device(&uvc->vdev);
910 v4l2_device_unregister(&uvc->v4l2_dev);
912 if (uvc->func_connected) {
918 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue,
919 uvc->func_connected == false, msecs_to_jiffies(1000));
923 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
924 kfree(uvc->control_buf);
931 struct uvc_device *uvc;
935 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL);
936 if (uvc == NULL)
939 mutex_init(&uvc->video.mutex);
940 uvc->state = UVC_STATE_DISCONNECTED;
941 init_waitqueue_head(&uvc->func_connected_queue);
961 uvc->desc.fs_control = opts->fs_control;
962 uvc->desc.ss_control = opts->ss_control;
963 uvc->desc.fs_streaming = opts->fs_streaming;
964 uvc->desc.hs_streaming = opts->hs_streaming;
965 uvc->desc.ss_streaming = opts->ss_streaming;
970 uvc->func.name = "uvc";
971 uvc->func.bind = uvc_function_bind;
972 uvc->func.unbind = uvc_function_unbind;
973 uvc->func.get_alt = uvc_function_get_alt;
974 uvc->func.set_alt = uvc_function_set_alt;
975 uvc->func.disable = uvc_function_disable;
976 uvc->func.setup = uvc_function_setup;
977 uvc->func.free_func = uvc_free;
978 uvc->func.bind_deactivated = true;
980 return &uvc->func;
983 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);