• Home
  • Raw
  • Download

Lines Matching refs:video

64 static void uvc_fixup_buffer_size(struct uvc_video_device *video,  in uvc_fixup_buffer_size()  argument
71 ctrl->bFormatIndex > video->streaming->nformats) in uvc_fixup_buffer_size()
74 format = &video->streaming->format[ctrl->bFormatIndex - 1]; in uvc_fixup_buffer_size()
84 video->dev->uvc_version < 0x0110)) in uvc_fixup_buffer_size()
89 static int uvc_get_video_ctrl(struct uvc_video_device *video, in uvc_get_video_ctrl() argument
96 size = video->dev->uvc_version >= 0x0110 ? 34 : 26; in uvc_get_video_ctrl()
101 ret = __uvc_query_ctrl(video->dev, query, 0, video->streaming->intfnum, in uvc_get_video_ctrl()
110 uvc_warn_once(video->dev, UVC_WARN_MINMAX, "UVC non " in uvc_get_video_ctrl()
122 uvc_warn_once(video->dev, UVC_WARN_PROBE_DEF, "UVC non " in uvc_get_video_ctrl()
154 ctrl->dwClockFrequency = video->dev->clock_frequency; in uvc_get_video_ctrl()
164 uvc_fixup_buffer_size(video, ctrl); in uvc_get_video_ctrl()
172 static int uvc_set_video_ctrl(struct uvc_video_device *video, in uvc_set_video_ctrl() argument
179 size = video->dev->uvc_version >= 0x0110 ? 34 : 26; in uvc_set_video_ctrl()
204 ret = __uvc_query_ctrl(video->dev, SET_CUR, 0, in uvc_set_video_ctrl()
205 video->streaming->intfnum, in uvc_set_video_ctrl()
219 int uvc_probe_video(struct uvc_video_device *video, in uvc_probe_video() argument
227 mutex_lock(&video->streaming->mutex); in uvc_probe_video()
236 if ((ret = uvc_set_video_ctrl(video, probe, 1)) < 0) in uvc_probe_video()
240 if (!(video->dev->quirks & UVC_QUIRK_PROBE_MINMAX)) { in uvc_probe_video()
241 ret = uvc_get_video_ctrl(video, &probe_min, 1, GET_MIN); in uvc_probe_video()
244 ret = uvc_get_video_ctrl(video, &probe_max, 1, GET_MAX); in uvc_probe_video()
252 if ((ret = uvc_set_video_ctrl(video, probe, 1)) < 0 || in uvc_probe_video()
253 (ret = uvc_get_video_ctrl(video, probe, 1, GET_CUR)) < 0) in uvc_probe_video()
256 if (video->streaming->intf->num_altsetting == 1) in uvc_probe_video()
260 if (bandwidth <= video->streaming->maxpsize) in uvc_probe_video()
263 if (video->dev->quirks & UVC_QUIRK_PROBE_MINMAX) { in uvc_probe_video()
276 mutex_unlock(&video->streaming->mutex); in uvc_probe_video()
280 int uvc_commit_video(struct uvc_video_device *video, in uvc_commit_video() argument
283 return uvc_set_video_ctrl(video, probe, 0); in uvc_commit_video()
335 static int uvc_video_decode_start(struct uvc_video_device *video, in uvc_video_decode_start() argument
361 video->last_fid = fid; in uvc_video_decode_start()
374 if (fid == video->last_fid) { in uvc_video_decode_start()
377 if ((video->dev->quirks & UVC_QUIRK_STREAM_NO_FID) && in uvc_video_decode_start()
379 video->last_fid ^= UVC_STREAM_FID; in uvc_video_decode_start()
402 if (fid != video->last_fid && buf->buf.bytesused != 0) { in uvc_video_decode_start()
409 video->last_fid = fid; in uvc_video_decode_start()
414 static void uvc_video_decode_data(struct uvc_video_device *video, in uvc_video_decode_data() argument
417 struct uvc_video_queue *queue = &video->queue; in uvc_video_decode_data()
438 static void uvc_video_decode_end(struct uvc_video_device *video, in uvc_video_decode_end() argument
447 if (video->dev->quirks & UVC_QUIRK_STREAM_NO_FID) in uvc_video_decode_end()
448 video->last_fid ^= UVC_STREAM_FID; in uvc_video_decode_end()
463 static int uvc_video_encode_header(struct uvc_video_device *video, in uvc_video_encode_header() argument
468 | (video->last_fid & UVC_STREAM_FID); in uvc_video_encode_header()
472 static int uvc_video_encode_data(struct uvc_video_device *video, in uvc_video_encode_data() argument
475 struct uvc_video_queue *queue = &video->queue; in uvc_video_encode_data()
482 nbytes = min(video->bulk.max_payload_size - video->bulk.payload_size, in uvc_video_encode_data()
499 struct uvc_video_device *video, struct uvc_buffer *buf) in uvc_video_decode_isoc() argument
514 ret = uvc_video_decode_start(video, buf, mem, in uvc_video_decode_isoc()
517 buf = uvc_queue_next_buffer(&video->queue, buf); in uvc_video_decode_isoc()
524 uvc_video_decode_data(video, buf, mem + ret, in uvc_video_decode_isoc()
528 uvc_video_decode_end(video, buf, mem, in uvc_video_decode_isoc()
533 buf = uvc_queue_next_buffer(&video->queue, buf); in uvc_video_decode_isoc()
538 struct uvc_video_device *video, struct uvc_buffer *buf) in uvc_video_decode_bulk() argument
545 video->bulk.payload_size += len; in uvc_video_decode_bulk()
550 if (video->bulk.header_size == 0 && !video->bulk.skip_payload) { in uvc_video_decode_bulk()
552 ret = uvc_video_decode_start(video, buf, mem, len); in uvc_video_decode_bulk()
554 buf = uvc_queue_next_buffer(&video->queue, buf); in uvc_video_decode_bulk()
559 video->bulk.skip_payload = 1; in uvc_video_decode_bulk()
561 memcpy(video->bulk.header, mem, ret); in uvc_video_decode_bulk()
562 video->bulk.header_size = ret; in uvc_video_decode_bulk()
575 if (!video->bulk.skip_payload && buf != NULL) in uvc_video_decode_bulk()
576 uvc_video_decode_data(video, buf, mem, len); in uvc_video_decode_bulk()
582 video->bulk.payload_size >= video->bulk.max_payload_size) { in uvc_video_decode_bulk()
583 if (!video->bulk.skip_payload && buf != NULL) { in uvc_video_decode_bulk()
584 uvc_video_decode_end(video, buf, video->bulk.header, in uvc_video_decode_bulk()
585 video->bulk.payload_size); in uvc_video_decode_bulk()
588 buf = uvc_queue_next_buffer(&video->queue, buf); in uvc_video_decode_bulk()
591 video->bulk.header_size = 0; in uvc_video_decode_bulk()
592 video->bulk.skip_payload = 0; in uvc_video_decode_bulk()
593 video->bulk.payload_size = 0; in uvc_video_decode_bulk()
598 struct uvc_video_device *video, struct uvc_buffer *buf) in uvc_video_encode_bulk() argument
601 int len = video->urb_size, ret; in uvc_video_encode_bulk()
609 if (video->bulk.header_size == 0) { in uvc_video_encode_bulk()
610 ret = uvc_video_encode_header(video, buf, mem, len); in uvc_video_encode_bulk()
611 video->bulk.header_size = ret; in uvc_video_encode_bulk()
612 video->bulk.payload_size += ret; in uvc_video_encode_bulk()
618 ret = uvc_video_encode_data(video, buf, mem, len); in uvc_video_encode_bulk()
620 video->bulk.payload_size += ret; in uvc_video_encode_bulk()
623 if (buf->buf.bytesused == video->queue.buf_used || in uvc_video_encode_bulk()
624 video->bulk.payload_size == video->bulk.max_payload_size) { in uvc_video_encode_bulk()
625 if (buf->buf.bytesused == video->queue.buf_used) { in uvc_video_encode_bulk()
626 video->queue.buf_used = 0; in uvc_video_encode_bulk()
628 uvc_queue_next_buffer(&video->queue, buf); in uvc_video_encode_bulk()
629 video->last_fid ^= UVC_STREAM_FID; in uvc_video_encode_bulk()
632 video->bulk.header_size = 0; in uvc_video_encode_bulk()
633 video->bulk.payload_size = 0; in uvc_video_encode_bulk()
636 urb->transfer_buffer_length = video->urb_size - len; in uvc_video_encode_bulk()
641 struct uvc_video_device *video = urb->context; in uvc_video_complete() local
642 struct uvc_video_queue *queue = &video->queue; in uvc_video_complete()
656 if (video->frozen) in uvc_video_complete()
671 video->decode(urb, video, buf); in uvc_video_complete()
682 static void uvc_free_urb_buffers(struct uvc_video_device *video) in uvc_free_urb_buffers() argument
687 if (video->urb_buffer[i]) { in uvc_free_urb_buffers()
688 usb_buffer_free(video->dev->udev, video->urb_size, in uvc_free_urb_buffers()
689 video->urb_buffer[i], video->urb_dma[i]); in uvc_free_urb_buffers()
690 video->urb_buffer[i] = NULL; in uvc_free_urb_buffers()
694 video->urb_size = 0; in uvc_free_urb_buffers()
704 static int uvc_alloc_urb_buffers(struct uvc_video_device *video, in uvc_alloc_urb_buffers() argument
710 if (video->urb_size) in uvc_alloc_urb_buffers()
714 video->urb_buffer[i] = usb_buffer_alloc(video->dev->udev, in uvc_alloc_urb_buffers()
715 size, GFP_KERNEL, &video->urb_dma[i]); in uvc_alloc_urb_buffers()
716 if (video->urb_buffer[i] == NULL) { in uvc_alloc_urb_buffers()
717 uvc_free_urb_buffers(video); in uvc_alloc_urb_buffers()
722 video->urb_size = size; in uvc_alloc_urb_buffers()
729 static void uvc_uninit_video(struct uvc_video_device *video, int free_buffers) in uvc_uninit_video() argument
735 if ((urb = video->urb[i]) == NULL) in uvc_uninit_video()
740 video->urb[i] = NULL; in uvc_uninit_video()
744 uvc_free_urb_buffers(video); in uvc_uninit_video()
751 static int uvc_init_video_isoc(struct uvc_video_device *video, in uvc_init_video_isoc() argument
766 size = video->streaming->ctrl.dwMaxVideoFrameSize; in uvc_init_video_isoc()
776 if (uvc_alloc_urb_buffers(video, size) < 0) in uvc_init_video_isoc()
782 uvc_uninit_video(video, 1); in uvc_init_video_isoc()
786 urb->dev = video->dev->udev; in uvc_init_video_isoc()
787 urb->context = video; in uvc_init_video_isoc()
788 urb->pipe = usb_rcvisocpipe(video->dev->udev, in uvc_init_video_isoc()
792 urb->transfer_buffer = video->urb_buffer[i]; in uvc_init_video_isoc()
793 urb->transfer_dma = video->urb_dma[i]; in uvc_init_video_isoc()
803 video->urb[i] = urb; in uvc_init_video_isoc()
813 static int uvc_init_video_bulk(struct uvc_video_device *video, in uvc_init_video_bulk() argument
828 size = video->streaming->ctrl.dwMaxPayloadTransferSize; in uvc_init_video_bulk()
829 video->bulk.max_payload_size = size; in uvc_init_video_bulk()
833 if (uvc_alloc_urb_buffers(video, size) < 0) in uvc_init_video_bulk()
837 pipe = usb_rcvbulkpipe(video->dev->udev, in uvc_init_video_bulk()
840 pipe = usb_sndbulkpipe(video->dev->udev, in uvc_init_video_bulk()
843 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in uvc_init_video_bulk()
849 uvc_uninit_video(video, 1); in uvc_init_video_bulk()
853 usb_fill_bulk_urb(urb, video->dev->udev, pipe, in uvc_init_video_bulk()
854 video->urb_buffer[i], size, uvc_video_complete, in uvc_init_video_bulk()
855 video); in uvc_init_video_bulk()
857 urb->transfer_dma = video->urb_dma[i]; in uvc_init_video_bulk()
859 video->urb[i] = urb; in uvc_init_video_bulk()
868 static int uvc_init_video(struct uvc_video_device *video, gfp_t gfp_flags) in uvc_init_video() argument
870 struct usb_interface *intf = video->streaming->intf; in uvc_init_video()
873 int intfnum = video->streaming->intfnum; in uvc_init_video()
877 video->last_fid = -1; in uvc_init_video()
878 video->bulk.header_size = 0; in uvc_init_video()
879 video->bulk.skip_payload = 0; in uvc_init_video()
880 video->bulk.payload_size = 0; in uvc_init_video()
884 bandwidth = video->streaming->ctrl.dwMaxPayloadTransferSize; in uvc_init_video()
889 video->vdev->name); in uvc_init_video()
896 video->streaming->header.bEndpointAddress); in uvc_init_video()
910 if ((ret = usb_set_interface(video->dev->udev, intfnum, i)) < 0) in uvc_init_video()
913 ret = uvc_init_video_isoc(video, ep, gfp_flags); in uvc_init_video()
917 video->streaming->header.bEndpointAddress); in uvc_init_video()
921 ret = uvc_init_video_bulk(video, ep, gfp_flags); in uvc_init_video()
929 if ((ret = usb_submit_urb(video->urb[i], gfp_flags)) < 0) { in uvc_init_video()
932 uvc_uninit_video(video, 1); in uvc_init_video()
951 int uvc_video_suspend(struct uvc_video_device *video) in uvc_video_suspend() argument
953 if (!uvc_queue_streaming(&video->queue)) in uvc_video_suspend()
956 video->frozen = 1; in uvc_video_suspend()
957 uvc_uninit_video(video, 0); in uvc_video_suspend()
958 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); in uvc_video_suspend()
970 int uvc_video_resume(struct uvc_video_device *video) in uvc_video_resume() argument
974 video->frozen = 0; in uvc_video_resume()
976 if ((ret = uvc_commit_video(video, &video->streaming->ctrl)) < 0) { in uvc_video_resume()
977 uvc_queue_enable(&video->queue, 0); in uvc_video_resume()
981 if (!uvc_queue_streaming(&video->queue)) in uvc_video_resume()
984 if ((ret = uvc_init_video(video, GFP_NOIO)) < 0) in uvc_video_resume()
985 uvc_queue_enable(&video->queue, 0); in uvc_video_resume()
1004 int uvc_video_init(struct uvc_video_device *video) in uvc_video_init() argument
1006 struct uvc_streaming_control *probe = &video->streaming->ctrl; in uvc_video_init()
1012 if (video->streaming->nformats == 0) { in uvc_video_init()
1022 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); in uvc_video_init()
1027 if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_DEF)) < 0 && in uvc_video_init()
1028 (ret = uvc_get_video_ctrl(video, probe, 1, GET_CUR)) < 0) in uvc_video_init()
1034 for (i = video->streaming->nformats; i > 0; --i) { in uvc_video_init()
1035 format = &video->streaming->format[i-1]; in uvc_video_init()
1060 video->streaming->cur_format = format; in uvc_video_init()
1061 video->streaming->cur_frame = frame; in uvc_video_init()
1062 atomic_set(&video->active, 0); in uvc_video_init()
1065 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in uvc_video_init()
1066 if (video->dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT) in uvc_video_init()
1067 video->decode = uvc_video_decode_isight; in uvc_video_init()
1068 else if (video->streaming->intf->num_altsetting > 1) in uvc_video_init()
1069 video->decode = uvc_video_decode_isoc; in uvc_video_init()
1071 video->decode = uvc_video_decode_bulk; in uvc_video_init()
1073 if (video->streaming->intf->num_altsetting == 1) in uvc_video_init()
1074 video->decode = uvc_video_encode_bulk; in uvc_video_init()
1088 int uvc_video_enable(struct uvc_video_device *video, int enable) in uvc_video_enable() argument
1093 uvc_uninit_video(video, 1); in uvc_video_enable()
1094 usb_set_interface(video->dev->udev, in uvc_video_enable()
1095 video->streaming->intfnum, 0); in uvc_video_enable()
1096 uvc_queue_enable(&video->queue, 0); in uvc_video_enable()
1100 if ((video->streaming->cur_format->flags & UVC_FMT_FLAG_COMPRESSED) || in uvc_video_enable()
1102 video->queue.flags &= ~UVC_QUEUE_DROP_INCOMPLETE; in uvc_video_enable()
1104 video->queue.flags |= UVC_QUEUE_DROP_INCOMPLETE; in uvc_video_enable()
1106 if ((ret = uvc_queue_enable(&video->queue, 1)) < 0) in uvc_video_enable()
1110 if ((ret = uvc_commit_video(video, &video->streaming->ctrl)) < 0) in uvc_video_enable()
1113 return uvc_init_video(video, GFP_KERNEL); in uvc_video_enable()