Lines Matching defs:uvc

27 #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);
245 uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN);
246 uvc->event_length = le16_to_cpu(ctrl->wLength);
258 if (interface == uvc->streaming_intf)
261 v4l2_event_queue(&uvc->vdev, &v4l2_event);
266 void uvc_function_setup_continue(struct uvc_device *uvc)
268 struct usb_composite_dev *cdev = uvc->func.config->cdev;
276 struct uvc_device *uvc = to_uvc(f);
280 if (interface == uvc->control_intf)
282 else if (interface != uvc->streaming_intf)
285 return uvc->video.ep->enabled ? 1 : 0;
291 struct uvc_device *uvc = to_uvc(f);
299 if (interface == uvc->control_intf) {
303 if (uvc->enable_interrupt_ep) {
305 usb_ep_disable(uvc->interrupt_ep);
307 if (!uvc->interrupt_ep->desc)
309 uvc->interrupt_ep))
312 usb_ep_enable(uvc->interrupt_ep);
315 if (uvc->state == UVC_STATE_DISCONNECTED) {
319 v4l2_event_queue(&uvc->vdev, &v4l2_event);
321 uvc->state = UVC_STATE_CONNECTED;
327 if (interface != uvc->streaming_intf)
331 if (usb_endpoint_xfer_bulk(&uvc->desc.vs_ep))
337 if (uvc->state != UVC_STATE_STREAMING)
340 if (uvc->video.ep)
341 usb_ep_disable(uvc->video.ep);
345 v4l2_event_queue(&uvc->vdev, &v4l2_event);
347 uvc->state = UVC_STATE_CONNECTED;
351 if (uvc->state != UVC_STATE_CONNECTED)
354 if (!uvc->video.ep)
358 usb_ep_disable(uvc->video.ep);
361 &(uvc->func), uvc->video.ep);
364 usb_ep_enable(uvc->video.ep);
368 v4l2_event_queue(&uvc->vdev, &v4l2_event);
379 struct uvc_device *uvc = to_uvc(f);
386 v4l2_event_queue(&uvc->vdev, &v4l2_event);
388 uvc->state = UVC_STATE_DISCONNECTED;
390 usb_ep_disable(uvc->video.ep);
391 if (uvc->enable_interrupt_ep)
392 usb_ep_disable(uvc->interrupt_ep);
400 uvc_function_connect(struct uvc_device *uvc)
404 if ((ret = usb_function_activate(&uvc->func)) < 0)
405 uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret);
409 uvc_function_disconnect(struct uvc_device *uvc)
413 if ((ret = usb_function_deactivate(&uvc->func)) < 0)
414 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret);
424 struct uvc_device *uvc = dev_get_drvdata(dev);
426 return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name);
432 uvc_register_video(struct uvc_device *uvc)
434 struct usb_composite_dev *cdev = uvc->func.config->cdev;
438 memset(&uvc->vdev, 0, sizeof(uvc->vdev));
439 uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
440 uvc->vdev.v4l2_dev->dev = &cdev->gadget->dev;
441 uvc->vdev.fops = &uvc_v4l2_fops;
442 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops;
443 uvc->vdev.release = video_device_release_empty;
444 uvc->vdev.vfl_dir = VFL_DIR_TX;
445 uvc->vdev.lock = &uvc->video.mutex;
446 uvc->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
447 strscpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name));
449 video_set_drvdata(&uvc->vdev, uvc);
451 ret = video_register_device(&uvc->vdev, VFL_TYPE_VIDEO, -1);
455 ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name);
457 video_unregister_device(&uvc->vdev);
501 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed)
520 uvc_control_desc = uvc->desc.ss_control;
521 uvc_streaming_cls = uvc->desc.ss_streaming;
526 uvc_control_desc = uvc->desc.fs_control;
527 uvc_streaming_cls = uvc->desc.hs_streaming;
533 uvc_control_desc = uvc->desc.fs_control;
534 uvc_streaming_cls = uvc->desc.fs_streaming;
563 if (uvc->enable_interrupt_ep) {
580 list_for_each_entry(xu, uvc->desc.extension_units, list) {
613 list_for_each_entry(xu, uvc->desc.extension_units, list)
618 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf;
620 if (uvc->enable_interrupt_ep) {
634 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address;
646 struct uvc_device *uvc = to_uvc(f);
717 uvc->interrupt_ep = ep;
720 uvc->enable_interrupt_ep = opts->enable_interrupt_ep;
727 * memory for this uvc functions. This is the only straightforward method to resolve the UDC
742 uvc->video.ep = ep;
744 uvc_fs_streaming_ep.bEndpointAddress = uvc->video.ep->address;
745 uvc_hs_streaming_ep.bEndpointAddress = uvc->video.ep->address;
746 uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address;
782 uvc->control_intf = ret;
789 uvc->streaming_intf = ret;
793 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL);
800 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH);
807 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER);
815 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
816 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL);
817 if (uvc->control_req == NULL || uvc->control_buf == NULL) {
822 uvc->control_req->buf = uvc->control_buf;
823 uvc->control_req->complete = uvc_function_ep0_complete;
824 uvc->control_req->context = uvc;
826 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) {
832 ret = uvcg_video_init(&uvc->video, uvc);
837 ret = uvc_register_video(uvc);
846 v4l2_device_unregister(&uvc->v4l2_dev);
848 if (uvc->control_req)
849 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
850 kfree(uvc->control_buf);
966 struct uvc_device *uvc = to_uvc(f);
970 config_item_put(&uvc->header->item);
972 kfree(uvc);
979 struct uvc_device *uvc = to_uvc(f);
980 struct uvc_video *video = &uvc->video;
994 if (uvc->func_connected) {
996 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue,
997 uvc->func_connected == false, msecs_to_jiffies(500));
1001 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
1002 video_unregister_device(&uvc->vdev);
1003 v4l2_device_unregister(&uvc->v4l2_dev);
1005 if (uvc->func_connected) {
1012 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue,
1013 uvc->func_connected == false, msecs_to_jiffies(1000));
1017 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
1018 kfree(uvc->control_buf);
1025 struct uvc_device *uvc;
1030 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL);
1031 if (uvc == NULL)
1034 mutex_init(&uvc->video.mutex);
1035 uvc->state = UVC_STATE_DISCONNECTED;
1036 init_waitqueue_head(&uvc->func_connected_queue);
1056 uvc->desc.fs_control = opts->fs_control;
1057 uvc->desc.ss_control = opts->ss_control;
1058 uvc->desc.fs_streaming = opts->fs_streaming;
1059 uvc->desc.hs_streaming = opts->hs_streaming;
1060 uvc->desc.ss_streaming = opts->ss_streaming;
1063 uvc->header = opts->header;
1079 uvc->header = to_uvcg_streaming_header(h);
1080 if (!uvc->header->linked) {
1082 kfree(uvc);
1087 uvc->desc.extension_units = &opts->extension_units;
1093 uvc->func.name = "uvc";
1094 uvc->func.bind = uvc_function_bind;
1095 uvc->func.unbind = uvc_function_unbind;
1096 uvc->func.get_alt = uvc_function_get_alt;
1097 uvc->func.set_alt = uvc_function_set_alt;
1098 uvc->func.disable = uvc_function_disable;
1099 uvc->func.setup = uvc_function_setup;
1100 uvc->func.free_func = uvc_free;
1101 uvc->func.bind_deactivated = true;
1103 return &uvc->func;
1107 kfree(uvc);
1111 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);