Lines Matching refs:uvc

274 	struct uvc_device *uvc = req->context;  in uvc_function_ep0_complete()  local
280 uvc->event_setup_out, req->actual); in uvc_function_ep0_complete()
282 if (uvc->event_setup_out) { in uvc_function_ep0_complete()
283 uvc->event_setup_out = 0; in uvc_function_ep0_complete()
290 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_ep0_complete()
297 struct uvc_device *uvc = to_uvc(f); in uvc_function_setup() local
318 uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN); in uvc_function_setup()
319 uvc->event_length = le16_to_cpu(ctrl->wLength); in uvc_function_setup()
324 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_setup()
329 void uvc_function_setup_continue(struct uvc_device *uvc) in uvc_function_setup_continue() argument
331 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_function_setup_continue()
339 struct uvc_device *uvc = to_uvc(f); in uvc_function_get_alt() local
346 if (interface == uvc->control_intf) in uvc_function_get_alt()
348 else if (interface != uvc->streaming_intf) in uvc_function_get_alt()
351 return uvc->video.ep->enabled ? 1 : 0; in uvc_function_get_alt()
366 struct uvc_device *uvc = to_uvc(f); in uvc_function_set_alt() local
377 if (interface == uvc->control_intf) { in uvc_function_set_alt()
382 usb_ep_disable(uvc->control_ep); in uvc_function_set_alt()
384 if (!uvc->control_ep->desc) in uvc_function_set_alt()
385 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep)) in uvc_function_set_alt()
388 usb_ep_enable(uvc->control_ep); in uvc_function_set_alt()
390 if (uvc->event_suspend) { in uvc_function_set_alt()
393 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
394 uvc->event_suspend = 0; in uvc_function_set_alt()
398 if (uvc->state == UVC_STATE_DISCONNECTED) { in uvc_function_set_alt()
402 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
404 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
410 if (interface != uvc->streaming_intf) in uvc_function_set_alt()
416 if (uvc->state != UVC_STATE_STREAMING) in uvc_function_set_alt()
419 if (uvc->video.ep) in uvc_function_set_alt()
420 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
424 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
426 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
430 if (uvc->state != UVC_STATE_CONNECTED) in uvc_function_set_alt()
433 if (!uvc->video.ep) in uvc_function_set_alt()
437 usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
440 &uvc->func, uvc->video.ep); in uvc_function_set_alt()
443 usb_ep_enable(uvc->video.ep); in uvc_function_set_alt()
447 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
454 switch (uvc->state) { in uvc_function_set_alt()
456 if (uvc->video.ep && in uvc_function_set_alt()
457 !uvc->video.ep->enabled) { in uvc_function_set_alt()
463 &uvc->func, in uvc_function_set_alt()
464 uvc->video.ep); in uvc_function_set_alt()
467 ret = usb_ep_enable(uvc->video.ep); in uvc_function_set_alt()
473 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
475 uvc->state = UVC_STATE_STREAMING; in uvc_function_set_alt()
485 if (uvc->video.ep && in uvc_function_set_alt()
486 uvc->video.ep->enabled) { in uvc_function_set_alt()
487 ret = usb_ep_disable(uvc->video.ep); in uvc_function_set_alt()
494 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_set_alt()
495 uvc->state = UVC_STATE_CONNECTED; in uvc_function_set_alt()
507 struct uvc_device *uvc = to_uvc(f); in uvc_function_disable() local
514 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_disable()
516 uvc->state = UVC_STATE_DISCONNECTED; in uvc_function_disable()
518 usb_ep_disable(uvc->video.ep); in uvc_function_disable()
519 usb_ep_disable(uvc->control_ep); in uvc_function_disable()
524 struct uvc_device *uvc = to_uvc(f); in uvc_function_suspend() local
529 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_suspend()
530 uvc->event_suspend = 1; in uvc_function_suspend()
536 struct uvc_device *uvc = to_uvc(f); in uvc_function_resume() local
541 v4l2_event_queue(&uvc->vdev, &v4l2_event); in uvc_function_resume()
542 uvc->event_suspend = 0; in uvc_function_resume()
551 uvc_function_connect(struct uvc_device *uvc) in uvc_function_connect() argument
555 if ((ret = usb_function_activate(&uvc->func)) < 0) in uvc_function_connect()
556 uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret); in uvc_function_connect()
560 uvc_function_disconnect(struct uvc_device *uvc) in uvc_function_disconnect() argument
564 if ((ret = usb_function_deactivate(&uvc->func)) < 0) in uvc_function_disconnect()
565 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret); in uvc_function_disconnect()
575 struct uvc_device *uvc = dev_get_drvdata(dev); in function_name_show() local
577 return sprintf(buf, "%s\n", uvc->func.fi->group.cg_item.ci_name); in function_name_show()
583 uvc_register_video(struct uvc_device *uvc) in uvc_register_video() argument
585 struct usb_composite_dev *cdev = uvc->func.config->cdev; in uvc_register_video()
589 uvc->vdev.v4l2_dev = &uvc->v4l2_dev; in uvc_register_video()
590 uvc->vdev.fops = &uvc_v4l2_fops; in uvc_register_video()
591 uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops; in uvc_register_video()
592 uvc->vdev.release = video_device_release_empty; in uvc_register_video()
593 uvc->vdev.vfl_dir = VFL_DIR_TX; in uvc_register_video()
594 uvc->vdev.lock = &uvc->video.mutex; in uvc_register_video()
595 uvc->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING; in uvc_register_video()
596 strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name)); in uvc_register_video()
598 video_set_drvdata(&uvc->vdev, uvc); in uvc_register_video()
600 ret = video_register_device(&uvc->vdev, VFL_TYPE_VIDEO, -1); in uvc_register_video()
604 ret = device_create_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_register_video()
606 video_unregister_device(&uvc->vdev); in uvc_register_video()
631 uvc_copy_descriptors(struct uvc_device *uvc, enum usb_device_speed speed) in uvc_copy_descriptors() argument
649 opts = fi_to_f_uvc_opts(uvc->func.fi); in uvc_copy_descriptors()
653 uvc_control_desc = uvc->desc.ss_control; in uvc_copy_descriptors()
654 uvc_streaming_cls = uvc->desc.ss_streaming; in uvc_copy_descriptors()
662 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
663 uvc_streaming_cls = uvc->desc.hs_streaming; in uvc_copy_descriptors()
672 uvc_control_desc = uvc->desc.fs_control; in uvc_copy_descriptors()
673 uvc_streaming_cls = uvc->desc.fs_streaming; in uvc_copy_descriptors()
750 uvc_control_header->baInterfaceNr[0] = uvc->streaming_intf; in uvc_copy_descriptors()
763 uvc_streaming_header->bEndpointAddress = uvc->video.ep->address; in uvc_copy_descriptors()
775 struct uvc_device *uvc = to_uvc(f); in uvc_function_bind() local
873 uvc->control_ep = ep; in uvc_function_bind()
914 uvc->video.ep = ep; in uvc_function_bind()
915 address = uvc->video.ep->address; in uvc_function_bind()
954 uvc->control_intf = ret; in uvc_function_bind()
967 uvc->streaming_intf = ret; in uvc_function_bind()
971 f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); in uvc_function_bind()
978 f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); in uvc_function_bind()
986 f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); in uvc_function_bind()
995 uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); in uvc_function_bind()
996 uvc->control_buf = kmalloc(UVC_MAX_REQUEST_SIZE, GFP_KERNEL); in uvc_function_bind()
997 if (uvc->control_req == NULL || uvc->control_buf == NULL) { in uvc_function_bind()
1002 uvc->control_req->buf = uvc->control_buf; in uvc_function_bind()
1003 uvc->control_req->complete = uvc_function_ep0_complete; in uvc_function_bind()
1004 uvc->control_req->context = uvc; in uvc_function_bind()
1006 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { in uvc_function_bind()
1012 ret = uvcg_video_init(&uvc->video, uvc); in uvc_function_bind()
1017 uvc->video.max_payload_size = uvc->video.imagesize; in uvc_function_bind()
1019 ret = uvc_register_video(uvc); in uvc_function_bind()
1028 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_bind()
1030 if (uvc->control_req) in uvc_function_bind()
1031 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_bind()
1032 kfree(uvc->control_buf); in uvc_function_bind()
1189 struct uvc_device *uvc = to_uvc(f); in uvc_free() local
1193 kfree(uvc); in uvc_free()
1200 struct uvc_device *uvc = to_uvc(f); in uvc_function_unbind() local
1210 if (uvc->func_connected) { in uvc_function_unbind()
1212 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
1213 uvc->func_connected == false, msecs_to_jiffies(500)); in uvc_function_unbind()
1217 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); in uvc_function_unbind()
1218 video_unregister_device(&uvc->vdev); in uvc_function_unbind()
1219 v4l2_device_unregister(&uvc->v4l2_dev); in uvc_function_unbind()
1221 if (uvc->func_connected) { in uvc_function_unbind()
1227 wait_ret = wait_event_interruptible_timeout(uvc->func_connected_queue, in uvc_function_unbind()
1228 uvc->func_connected == false, msecs_to_jiffies(1000)); in uvc_function_unbind()
1232 usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); in uvc_function_unbind()
1233 kfree(uvc->control_buf); in uvc_function_unbind()
1240 struct uvc_device *uvc; in uvc_alloc() local
1244 uvc = kzalloc(sizeof(*uvc), GFP_KERNEL); in uvc_alloc()
1245 if (uvc == NULL) in uvc_alloc()
1248 mutex_init(&uvc->video.mutex); in uvc_alloc()
1249 uvc->state = UVC_STATE_DISCONNECTED; in uvc_alloc()
1250 init_waitqueue_head(&uvc->func_connected_queue); in uvc_alloc()
1270 uvc->desc.fs_control = opts->fs_control; in uvc_alloc()
1271 uvc->desc.ss_control = opts->ss_control; in uvc_alloc()
1272 uvc->desc.fs_streaming = opts->fs_streaming; in uvc_alloc()
1273 uvc->desc.hs_streaming = opts->hs_streaming; in uvc_alloc()
1274 uvc->desc.ss_streaming = opts->ss_streaming; in uvc_alloc()
1279 uvc->func.name = "uvc"; in uvc_alloc()
1280 uvc->func.bind = uvc_function_bind; in uvc_alloc()
1281 uvc->func.unbind = uvc_function_unbind; in uvc_alloc()
1282 uvc->func.get_alt = uvc_function_get_alt; in uvc_alloc()
1283 uvc->func.set_alt = uvc_function_set_alt; in uvc_alloc()
1284 uvc->func.disable = uvc_function_disable; in uvc_alloc()
1285 uvc->func.setup = uvc_function_setup; in uvc_alloc()
1286 uvc->func.free_func = uvc_free; in uvc_alloc()
1287 uvc->func.suspend = uvc_function_suspend; in uvc_alloc()
1288 uvc->func.resume = uvc_function_resume; in uvc_alloc()
1289 uvc->func.bind_deactivated = true; in uvc_alloc()
1291 return &uvc->func; in uvc_alloc()
1294 DECLARE_USB_FUNCTION_INIT(uvc, uvc_alloc_inst, uvc_alloc);