Lines Matching refs:stream

124 static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,  in uvc_fixup_video_ctrl()  argument
131 for (i = 0; i < stream->nformats; ++i) { in uvc_fixup_video_ctrl()
132 if (stream->format[i].index == ctrl->bFormatIndex) { in uvc_fixup_video_ctrl()
133 format = &stream->format[i]; in uvc_fixup_video_ctrl()
153 stream->dev->uvc_version < 0x0110)) in uvc_fixup_video_ctrl()
166 stream->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH && in uvc_fixup_video_ctrl()
167 stream->intf->num_altsetting > 1) { in uvc_fixup_video_ctrl()
184 if (stream->dev->udev->speed == USB_SPEED_HIGH) in uvc_fixup_video_ctrl()
201 static size_t uvc_video_ctrl_size(struct uvc_streaming *stream) in uvc_video_ctrl_size() argument
207 if (stream->dev->uvc_version < 0x0110) in uvc_video_ctrl_size()
209 else if (stream->dev->uvc_version < 0x0150) in uvc_video_ctrl_size()
215 static int uvc_get_video_ctrl(struct uvc_streaming *stream, in uvc_get_video_ctrl() argument
218 u16 size = uvc_video_ctrl_size(stream); in uvc_get_video_ctrl()
222 if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) && in uvc_get_video_ctrl()
230 ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum, in uvc_get_video_ctrl()
239 uvc_warn_once(stream->dev, UVC_WARN_MINMAX, "UVC non " in uvc_get_video_ctrl()
251 uvc_warn_once(stream->dev, UVC_WARN_PROBE_DEF, "UVC non " in uvc_get_video_ctrl()
283 ctrl->dwClockFrequency = stream->dev->clock_frequency; in uvc_get_video_ctrl()
294 uvc_fixup_video_ctrl(stream, ctrl); in uvc_get_video_ctrl()
302 static int uvc_set_video_ctrl(struct uvc_streaming *stream, in uvc_set_video_ctrl() argument
305 u16 size = uvc_video_ctrl_size(stream); in uvc_set_video_ctrl()
333 ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum, in uvc_set_video_ctrl()
347 int uvc_probe_video(struct uvc_streaming *stream, in uvc_probe_video() argument
362 ret = uvc_set_video_ctrl(stream, probe, 1); in uvc_probe_video()
367 if (!(stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX)) { in uvc_probe_video()
368 ret = uvc_get_video_ctrl(stream, &probe_min, 1, UVC_GET_MIN); in uvc_probe_video()
371 ret = uvc_get_video_ctrl(stream, &probe_max, 1, UVC_GET_MAX); in uvc_probe_video()
379 ret = uvc_set_video_ctrl(stream, probe, 1); in uvc_probe_video()
382 ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR); in uvc_probe_video()
386 if (stream->intf->num_altsetting == 1) in uvc_probe_video()
390 if (bandwidth <= stream->maxpsize) in uvc_probe_video()
393 if (stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX) { in uvc_probe_video()
409 static int uvc_commit_video(struct uvc_streaming *stream, in uvc_commit_video() argument
412 return uvc_set_video_ctrl(stream, probe, 0); in uvc_commit_video()
428 uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf, in uvc_video_clock_decode() argument
480 if (dev_sof == stream->clock.last_sof) in uvc_video_clock_decode()
483 stream->clock.last_sof = dev_sof; in uvc_video_clock_decode()
485 host_sof = usb_get_current_frame_number(stream->dev->udev); in uvc_video_clock_decode()
507 if (stream->clock.sof_offset == (u16)-1) { in uvc_video_clock_decode()
510 stream->clock.sof_offset = delta_sof; in uvc_video_clock_decode()
512 stream->clock.sof_offset = 0; in uvc_video_clock_decode()
515 dev_sof = (dev_sof + stream->clock.sof_offset) & 2047; in uvc_video_clock_decode()
517 spin_lock_irqsave(&stream->clock.lock, flags); in uvc_video_clock_decode()
519 sample = &stream->clock.samples[stream->clock.head]; in uvc_video_clock_decode()
526 stream->clock.head = (stream->clock.head + 1) % stream->clock.size; in uvc_video_clock_decode()
528 if (stream->clock.count < stream->clock.size) in uvc_video_clock_decode()
529 stream->clock.count++; in uvc_video_clock_decode()
531 spin_unlock_irqrestore(&stream->clock.lock, flags); in uvc_video_clock_decode()
534 static void uvc_video_clock_reset(struct uvc_streaming *stream) in uvc_video_clock_reset() argument
536 struct uvc_clock *clock = &stream->clock; in uvc_video_clock_reset()
544 static int uvc_video_clock_init(struct uvc_streaming *stream) in uvc_video_clock_init() argument
546 struct uvc_clock *clock = &stream->clock; in uvc_video_clock_init()
556 uvc_video_clock_reset(stream); in uvc_video_clock_init()
561 static void uvc_video_clock_cleanup(struct uvc_streaming *stream) in uvc_video_clock_cleanup() argument
563 kfree(stream->clock.samples); in uvc_video_clock_cleanup()
564 stream->clock.samples = NULL; in uvc_video_clock_cleanup()
655 void uvc_video_clock_update(struct uvc_streaming *stream, in uvc_video_clock_update() argument
659 struct uvc_clock *clock = &stream->clock; in uvc_video_clock_update()
710 stream->dev->name, buf->pts, in uvc_video_clock_update()
745 stream->dev->name, in uvc_video_clock_update()
762 static void uvc_video_stats_decode(struct uvc_streaming *stream, in uvc_video_stats_decode() argument
772 if (stream->stats.stream.nb_frames == 0 && in uvc_video_stats_decode()
773 stream->stats.frame.nb_packets == 0) in uvc_video_stats_decode()
774 stream->stats.stream.start_ts = ktime_get(); in uvc_video_stats_decode()
797 stream->stats.frame.nb_invalid++; in uvc_video_stats_decode()
811 if (has_pts && stream->stats.frame.nb_pts) { in uvc_video_stats_decode()
812 if (stream->stats.frame.pts != pts) { in uvc_video_stats_decode()
813 stream->stats.frame.nb_pts_diffs++; in uvc_video_stats_decode()
814 stream->stats.frame.last_pts_diff = in uvc_video_stats_decode()
815 stream->stats.frame.nb_packets; in uvc_video_stats_decode()
820 stream->stats.frame.nb_pts++; in uvc_video_stats_decode()
821 stream->stats.frame.pts = pts; in uvc_video_stats_decode()
827 if (stream->stats.frame.size == 0) { in uvc_video_stats_decode()
829 stream->stats.frame.has_initial_pts = has_pts; in uvc_video_stats_decode()
831 stream->stats.frame.has_early_pts = true; in uvc_video_stats_decode()
835 if (has_scr && stream->stats.frame.nb_scr) { in uvc_video_stats_decode()
836 if (stream->stats.frame.scr_stc != scr_stc) in uvc_video_stats_decode()
837 stream->stats.frame.nb_scr_diffs++; in uvc_video_stats_decode()
842 if (stream->stats.stream.nb_frames > 0 || in uvc_video_stats_decode()
843 stream->stats.frame.nb_scr > 0) in uvc_video_stats_decode()
844 stream->stats.stream.scr_sof_count += in uvc_video_stats_decode()
845 (scr_sof - stream->stats.stream.scr_sof) % 2048; in uvc_video_stats_decode()
846 stream->stats.stream.scr_sof = scr_sof; in uvc_video_stats_decode()
848 stream->stats.frame.nb_scr++; in uvc_video_stats_decode()
849 stream->stats.frame.scr_stc = scr_stc; in uvc_video_stats_decode()
850 stream->stats.frame.scr_sof = scr_sof; in uvc_video_stats_decode()
852 if (scr_sof < stream->stats.stream.min_sof) in uvc_video_stats_decode()
853 stream->stats.stream.min_sof = scr_sof; in uvc_video_stats_decode()
854 if (scr_sof > stream->stats.stream.max_sof) in uvc_video_stats_decode()
855 stream->stats.stream.max_sof = scr_sof; in uvc_video_stats_decode()
859 if (stream->stats.frame.size == 0 && len > header_size) in uvc_video_stats_decode()
860 stream->stats.frame.first_data = stream->stats.frame.nb_packets; in uvc_video_stats_decode()
863 stream->stats.frame.size += len - header_size; in uvc_video_stats_decode()
866 stream->stats.frame.nb_packets++; in uvc_video_stats_decode()
868 stream->stats.frame.nb_empty++; in uvc_video_stats_decode()
871 stream->stats.frame.nb_errors++; in uvc_video_stats_decode()
874 static void uvc_video_stats_update(struct uvc_streaming *stream) in uvc_video_stats_update() argument
876 struct uvc_stats_frame *frame = &stream->stats.frame; in uvc_video_stats_update()
881 stream->sequence, frame->first_data, in uvc_video_stats_update()
889 stream->stats.stream.nb_frames++; in uvc_video_stats_update()
890 stream->stats.stream.nb_packets += stream->stats.frame.nb_packets; in uvc_video_stats_update()
891 stream->stats.stream.nb_empty += stream->stats.frame.nb_empty; in uvc_video_stats_update()
892 stream->stats.stream.nb_errors += stream->stats.frame.nb_errors; in uvc_video_stats_update()
893 stream->stats.stream.nb_invalid += stream->stats.frame.nb_invalid; in uvc_video_stats_update()
896 stream->stats.stream.nb_pts_early++; in uvc_video_stats_update()
898 stream->stats.stream.nb_pts_initial++; in uvc_video_stats_update()
900 stream->stats.stream.nb_pts_constant++; in uvc_video_stats_update()
902 stream->stats.stream.nb_scr_count_ok++; in uvc_video_stats_update()
904 stream->stats.stream.nb_scr_diffs_ok++; in uvc_video_stats_update()
906 memset(&stream->stats.frame, 0, sizeof(stream->stats.frame)); in uvc_video_stats_update()
909 size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, in uvc_video_stats_dump() argument
919 duration = ktime_ms_delta(stream->stats.stream.stop_ts, in uvc_video_stats_dump()
920 stream->stats.stream.start_ts); in uvc_video_stats_dump()
922 scr_sof_freq = stream->stats.stream.scr_sof_count * 1000 in uvc_video_stats_dump()
930 stream->stats.stream.nb_frames, in uvc_video_stats_dump()
931 stream->stats.stream.nb_packets, in uvc_video_stats_dump()
932 stream->stats.stream.nb_empty, in uvc_video_stats_dump()
933 stream->stats.stream.nb_errors, in uvc_video_stats_dump()
934 stream->stats.stream.nb_invalid); in uvc_video_stats_dump()
937 stream->stats.stream.nb_pts_early, in uvc_video_stats_dump()
938 stream->stats.stream.nb_pts_initial, in uvc_video_stats_dump()
939 stream->stats.stream.nb_pts_constant); in uvc_video_stats_dump()
942 stream->stats.stream.nb_scr_count_ok, in uvc_video_stats_dump()
943 stream->stats.stream.nb_scr_diffs_ok); in uvc_video_stats_dump()
946 stream->stats.stream.min_sof, in uvc_video_stats_dump()
947 stream->stats.stream.max_sof, in uvc_video_stats_dump()
953 static void uvc_video_stats_start(struct uvc_streaming *stream) in uvc_video_stats_start() argument
955 memset(&stream->stats, 0, sizeof(stream->stats)); in uvc_video_stats_start()
956 stream->stats.stream.min_sof = 2048; in uvc_video_stats_start()
959 static void uvc_video_stats_stop(struct uvc_streaming *stream) in uvc_video_stats_stop() argument
961 stream->stats.stream.stop_ts = ktime_get(); in uvc_video_stats_stop()
1003 static int uvc_video_decode_start(struct uvc_streaming *stream, in uvc_video_decode_start() argument
1014 stream->stats.frame.nb_invalid++; in uvc_video_decode_start()
1023 if (stream->last_fid != fid) { in uvc_video_decode_start()
1024 stream->sequence++; in uvc_video_decode_start()
1025 if (stream->sequence) in uvc_video_decode_start()
1026 uvc_video_stats_update(stream); in uvc_video_decode_start()
1029 uvc_video_clock_decode(stream, buf, data, len); in uvc_video_decode_start()
1030 uvc_video_stats_decode(stream, data, len); in uvc_video_decode_start()
1036 stream->last_fid = fid; in uvc_video_decode_start()
1056 if (fid == stream->last_fid) { in uvc_video_decode_start()
1059 if ((stream->dev->quirks & UVC_QUIRK_STREAM_NO_FID) && in uvc_video_decode_start()
1061 stream->last_fid ^= UVC_STREAM_FID; in uvc_video_decode_start()
1066 buf->buf.sequence = stream->sequence; in uvc_video_decode_start()
1088 if (fid != stream->last_fid && buf->bytesused != 0) { in uvc_video_decode_start()
1095 stream->last_fid = fid; in uvc_video_decode_start()
1159 static void uvc_video_decode_end(struct uvc_streaming *stream, in uvc_video_decode_end() argument
1168 if (stream->dev->quirks & UVC_QUIRK_STREAM_NO_FID) in uvc_video_decode_end()
1169 stream->last_fid ^= UVC_STREAM_FID; in uvc_video_decode_end()
1184 static int uvc_video_encode_header(struct uvc_streaming *stream, in uvc_video_encode_header() argument
1189 | (stream->last_fid & UVC_STREAM_FID); in uvc_video_encode_header()
1193 static int uvc_video_encode_data(struct uvc_streaming *stream, in uvc_video_encode_data() argument
1196 struct uvc_video_queue *queue = &stream->queue; in uvc_video_encode_data()
1203 nbytes = min(stream->bulk.max_payload_size - stream->bulk.payload_size, in uvc_video_encode_data()
1227 static void uvc_video_decode_meta(struct uvc_streaming *stream, in uvc_video_decode_meta() argument
1261 if (stream->meta.format == V4L2_META_FMT_UVC) in uvc_video_decode_meta()
1265 !memcmp(scr, stream->clock.last_scr, 6))) in uvc_video_decode_meta()
1271 sof = usb_get_current_frame_number(stream->dev->udev); in uvc_video_decode_meta()
1277 memcpy(stream->clock.last_scr, scr, 6); in uvc_video_decode_meta()
1298 static void uvc_video_validate_buffer(const struct uvc_streaming *stream, in uvc_video_validate_buffer() argument
1301 if (stream->ctrl.dwMaxVideoFrameSize != buf->bytesused && in uvc_video_validate_buffer()
1302 !(stream->cur_format->flags & UVC_FMT_FLAG_COMPRESSED)) in uvc_video_validate_buffer()
1310 static void uvc_video_next_buffers(struct uvc_streaming *stream, in uvc_video_next_buffers() argument
1313 uvc_video_validate_buffer(stream, *video_buf); in uvc_video_next_buffers()
1326 *meta_buf = uvc_queue_next_buffer(&stream->meta.queue, in uvc_video_next_buffers()
1329 *video_buf = uvc_queue_next_buffer(&stream->queue, *video_buf); in uvc_video_next_buffers()
1336 struct uvc_streaming *stream = uvc_urb->stream; in uvc_video_decode_isoc() local
1353 ret = uvc_video_decode_start(stream, buf, mem, in uvc_video_decode_isoc()
1356 uvc_video_next_buffers(stream, &buf, &meta_buf); in uvc_video_decode_isoc()
1362 uvc_video_decode_meta(stream, meta_buf, mem, ret); in uvc_video_decode_isoc()
1369 uvc_video_decode_end(stream, buf, mem, in uvc_video_decode_isoc()
1373 uvc_video_next_buffers(stream, &buf, &meta_buf); in uvc_video_decode_isoc()
1381 struct uvc_streaming *stream = uvc_urb->stream; in uvc_video_decode_bulk() local
1389 if (urb->actual_length == 0 && stream->bulk.header_size == 0) in uvc_video_decode_bulk()
1394 stream->bulk.payload_size += len; in uvc_video_decode_bulk()
1399 if (stream->bulk.header_size == 0 && !stream->bulk.skip_payload) { in uvc_video_decode_bulk()
1401 ret = uvc_video_decode_start(stream, buf, mem, len); in uvc_video_decode_bulk()
1403 uvc_video_next_buffers(stream, &buf, &meta_buf); in uvc_video_decode_bulk()
1408 stream->bulk.skip_payload = 1; in uvc_video_decode_bulk()
1410 memcpy(stream->bulk.header, mem, ret); in uvc_video_decode_bulk()
1411 stream->bulk.header_size = ret; in uvc_video_decode_bulk()
1413 uvc_video_decode_meta(stream, meta_buf, mem, ret); in uvc_video_decode_bulk()
1426 if (!stream->bulk.skip_payload && buf != NULL) in uvc_video_decode_bulk()
1433 stream->bulk.payload_size >= stream->bulk.max_payload_size) { in uvc_video_decode_bulk()
1434 if (!stream->bulk.skip_payload && buf != NULL) { in uvc_video_decode_bulk()
1435 uvc_video_decode_end(stream, buf, stream->bulk.header, in uvc_video_decode_bulk()
1436 stream->bulk.payload_size); in uvc_video_decode_bulk()
1438 uvc_video_next_buffers(stream, &buf, &meta_buf); in uvc_video_decode_bulk()
1441 stream->bulk.header_size = 0; in uvc_video_decode_bulk()
1442 stream->bulk.skip_payload = 0; in uvc_video_decode_bulk()
1443 stream->bulk.payload_size = 0; in uvc_video_decode_bulk()
1451 struct uvc_streaming *stream = uvc_urb->stream; in uvc_video_encode_bulk() local
1454 int len = stream->urb_size, ret; in uvc_video_encode_bulk()
1462 if (stream->bulk.header_size == 0) { in uvc_video_encode_bulk()
1463 ret = uvc_video_encode_header(stream, buf, mem, len); in uvc_video_encode_bulk()
1464 stream->bulk.header_size = ret; in uvc_video_encode_bulk()
1465 stream->bulk.payload_size += ret; in uvc_video_encode_bulk()
1471 ret = uvc_video_encode_data(stream, buf, mem, len); in uvc_video_encode_bulk()
1473 stream->bulk.payload_size += ret; in uvc_video_encode_bulk()
1476 if (buf->bytesused == stream->queue.buf_used || in uvc_video_encode_bulk()
1477 stream->bulk.payload_size == stream->bulk.max_payload_size) { in uvc_video_encode_bulk()
1478 if (buf->bytesused == stream->queue.buf_used) { in uvc_video_encode_bulk()
1479 stream->queue.buf_used = 0; in uvc_video_encode_bulk()
1481 buf->buf.sequence = ++stream->sequence; in uvc_video_encode_bulk()
1482 uvc_queue_next_buffer(&stream->queue, buf); in uvc_video_encode_bulk()
1483 stream->last_fid ^= UVC_STREAM_FID; in uvc_video_encode_bulk()
1486 stream->bulk.header_size = 0; in uvc_video_encode_bulk()
1487 stream->bulk.payload_size = 0; in uvc_video_encode_bulk()
1490 urb->transfer_buffer_length = stream->urb_size - len; in uvc_video_encode_bulk()
1496 struct uvc_streaming *stream = uvc_urb->stream; in uvc_video_complete() local
1497 struct uvc_video_queue *queue = &stream->queue; in uvc_video_complete()
1498 struct uvc_video_queue *qmeta = &stream->meta.queue; in uvc_video_complete()
1499 struct vb2_queue *vb2_qmeta = stream->meta.vdev.queue; in uvc_video_complete()
1514 if (stream->frozen) in uvc_video_complete()
1542 stream->decode(uvc_urb, buf, buf_meta); in uvc_video_complete()
1554 queue_work(stream->async_wq, &uvc_urb->work); in uvc_video_complete()
1560 static void uvc_free_urb_buffers(struct uvc_streaming *stream) in uvc_free_urb_buffers() argument
1564 for_each_uvc_urb(uvc_urb, stream) { in uvc_free_urb_buffers()
1569 usb_free_coherent(stream->dev->udev, stream->urb_size, in uvc_free_urb_buffers()
1577 stream->urb_size = 0; in uvc_free_urb_buffers()
1591 static int uvc_alloc_urb_buffers(struct uvc_streaming *stream, in uvc_alloc_urb_buffers() argument
1598 if (stream->urb_size) in uvc_alloc_urb_buffers()
1599 return stream->urb_size / psize; in uvc_alloc_urb_buffers()
1611 struct uvc_urb *uvc_urb = &stream->uvc_urb[i]; in uvc_alloc_urb_buffers()
1613 stream->urb_size = psize * npackets; in uvc_alloc_urb_buffers()
1616 stream->dev->udev, stream->urb_size, in uvc_alloc_urb_buffers()
1620 kmalloc(stream->urb_size, gfp_flags | __GFP_NOWARN); in uvc_alloc_urb_buffers()
1623 uvc_free_urb_buffers(stream); in uvc_alloc_urb_buffers()
1627 uvc_urb->stream = stream; in uvc_alloc_urb_buffers()
1646 static void uvc_video_stop_transfer(struct uvc_streaming *stream, in uvc_video_stop_transfer() argument
1651 uvc_video_stats_stop(stream); in uvc_video_stop_transfer()
1658 for_each_uvc_urb(uvc_urb, stream) in uvc_video_stop_transfer()
1661 flush_workqueue(stream->async_wq); in uvc_video_stop_transfer()
1663 for_each_uvc_urb(uvc_urb, stream) { in uvc_video_stop_transfer()
1669 uvc_free_urb_buffers(stream); in uvc_video_stop_transfer()
1702 static int uvc_init_video_isoc(struct uvc_streaming *stream, in uvc_init_video_isoc() argument
1711 psize = uvc_endpoint_max_bpi(stream->dev->udev, ep); in uvc_init_video_isoc()
1712 size = stream->ctrl.dwMaxVideoFrameSize; in uvc_init_video_isoc()
1714 npackets = uvc_alloc_urb_buffers(stream, size, psize, gfp_flags); in uvc_init_video_isoc()
1720 for_each_uvc_urb(uvc_urb, stream) { in uvc_init_video_isoc()
1723 uvc_video_stop_transfer(stream, 1); in uvc_init_video_isoc()
1727 urb->dev = stream->dev->udev; in uvc_init_video_isoc()
1729 urb->pipe = usb_rcvisocpipe(stream->dev->udev, in uvc_init_video_isoc()
1758 static int uvc_init_video_bulk(struct uvc_streaming *stream, in uvc_init_video_bulk() argument
1768 size = stream->ctrl.dwMaxPayloadTransferSize; in uvc_init_video_bulk()
1769 stream->bulk.max_payload_size = size; in uvc_init_video_bulk()
1771 npackets = uvc_alloc_urb_buffers(stream, size, psize, gfp_flags); in uvc_init_video_bulk()
1778 pipe = usb_rcvbulkpipe(stream->dev->udev, in uvc_init_video_bulk()
1781 pipe = usb_sndbulkpipe(stream->dev->udev, in uvc_init_video_bulk()
1784 if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in uvc_init_video_bulk()
1787 for_each_uvc_urb(uvc_urb, stream) { in uvc_init_video_bulk()
1790 uvc_video_stop_transfer(stream, 1); in uvc_init_video_bulk()
1794 usb_fill_bulk_urb(urb, stream->dev->udev, pipe, uvc_urb->buffer, in uvc_init_video_bulk()
1810 static int uvc_video_start_transfer(struct uvc_streaming *stream, in uvc_video_start_transfer() argument
1813 struct usb_interface *intf = stream->intf; in uvc_video_start_transfer()
1819 stream->sequence = -1; in uvc_video_start_transfer()
1820 stream->last_fid = -1; in uvc_video_start_transfer()
1821 stream->bulk.header_size = 0; in uvc_video_start_transfer()
1822 stream->bulk.skip_payload = 0; in uvc_video_start_transfer()
1823 stream->bulk.payload_size = 0; in uvc_video_start_transfer()
1825 uvc_video_stats_start(stream); in uvc_video_start_transfer()
1832 int intfnum = stream->intfnum; in uvc_video_start_transfer()
1835 bandwidth = stream->ctrl.dwMaxPayloadTransferSize; in uvc_video_start_transfer()
1852 stream->header.bEndpointAddress); in uvc_video_start_transfer()
1857 psize = uvc_endpoint_max_bpi(stream->dev->udev, ep); in uvc_video_start_transfer()
1874 ret = usb_set_interface(stream->dev->udev, intfnum, altsetting); in uvc_video_start_transfer()
1878 ret = uvc_init_video_isoc(stream, best_ep, gfp_flags); in uvc_video_start_transfer()
1882 stream->header.bEndpointAddress); in uvc_video_start_transfer()
1886 ret = uvc_init_video_bulk(stream, ep, gfp_flags); in uvc_video_start_transfer()
1893 for_each_uvc_urb(uvc_urb, stream) { in uvc_video_start_transfer()
1898 uvc_video_stop_transfer(stream, 1); in uvc_video_start_transfer()
1906 if (stream->dev->quirks & UVC_QUIRK_RESTORE_CTRLS_ON_INIT) in uvc_video_start_transfer()
1907 uvc_ctrl_restore_values(stream->dev); in uvc_video_start_transfer()
1923 int uvc_video_suspend(struct uvc_streaming *stream) in uvc_video_suspend() argument
1925 if (!uvc_queue_streaming(&stream->queue)) in uvc_video_suspend()
1928 stream->frozen = 1; in uvc_video_suspend()
1929 uvc_video_stop_transfer(stream, 0); in uvc_video_suspend()
1930 usb_set_interface(stream->dev->udev, stream->intfnum, 0); in uvc_video_suspend()
1942 int uvc_video_resume(struct uvc_streaming *stream, int reset) in uvc_video_resume() argument
1952 usb_set_interface(stream->dev->udev, stream->intfnum, 0); in uvc_video_resume()
1954 stream->frozen = 0; in uvc_video_resume()
1956 uvc_video_clock_reset(stream); in uvc_video_resume()
1958 if (!uvc_queue_streaming(&stream->queue)) in uvc_video_resume()
1961 ret = uvc_commit_video(stream, &stream->ctrl); in uvc_video_resume()
1965 return uvc_video_start_transfer(stream, GFP_NOIO); in uvc_video_resume()
1982 int uvc_video_init(struct uvc_streaming *stream) in uvc_video_init() argument
1984 struct uvc_streaming_control *probe = &stream->ctrl; in uvc_video_init()
1991 if (stream->nformats == 0) { in uvc_video_init()
1996 atomic_set(&stream->active, 0); in uvc_video_init()
2003 usb_set_interface(stream->dev->udev, stream->intfnum, 0); in uvc_video_init()
2010 if (uvc_get_video_ctrl(stream, probe, 1, UVC_GET_DEF) == 0) in uvc_video_init()
2011 uvc_set_video_ctrl(stream, probe, 1); in uvc_video_init()
2018 ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR); in uvc_video_init()
2025 for (i = stream->nformats; i > 0; --i) { in uvc_video_init()
2026 format = &stream->format[i-1]; in uvc_video_init()
2051 stream->def_format = format; in uvc_video_init()
2052 stream->cur_format = format; in uvc_video_init()
2053 stream->cur_frame = frame; in uvc_video_init()
2056 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in uvc_video_init()
2057 if (stream->dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT) in uvc_video_init()
2058 stream->decode = uvc_video_decode_isight; in uvc_video_init()
2059 else if (stream->intf->num_altsetting > 1) in uvc_video_init()
2060 stream->decode = uvc_video_decode_isoc; in uvc_video_init()
2062 stream->decode = uvc_video_decode_bulk; in uvc_video_init()
2064 if (stream->intf->num_altsetting == 1) in uvc_video_init()
2065 stream->decode = uvc_video_encode_bulk; in uvc_video_init()
2074 for_each_uvc_urb(uvc_urb, stream) in uvc_video_init()
2080 int uvc_video_start_streaming(struct uvc_streaming *stream) in uvc_video_start_streaming() argument
2084 ret = uvc_video_clock_init(stream); in uvc_video_start_streaming()
2089 ret = uvc_commit_video(stream, &stream->ctrl); in uvc_video_start_streaming()
2093 ret = uvc_video_start_transfer(stream, GFP_KERNEL); in uvc_video_start_streaming()
2100 usb_set_interface(stream->dev->udev, stream->intfnum, 0); in uvc_video_start_streaming()
2102 uvc_video_clock_cleanup(stream); in uvc_video_start_streaming()
2107 void uvc_video_stop_streaming(struct uvc_streaming *stream) in uvc_video_stop_streaming() argument
2109 uvc_video_stop_transfer(stream, 1); in uvc_video_stop_streaming()
2111 if (stream->intf->num_altsetting > 1) { in uvc_video_stop_streaming()
2112 usb_set_interface(stream->dev->udev, stream->intfnum, 0); in uvc_video_stop_streaming()
2119 unsigned int epnum = stream->header.bEndpointAddress in uvc_video_stop_streaming()
2121 unsigned int dir = stream->header.bEndpointAddress in uvc_video_stop_streaming()
2125 pipe = usb_sndbulkpipe(stream->dev->udev, epnum) | dir; in uvc_video_stop_streaming()
2126 usb_clear_halt(stream->dev->udev, pipe); in uvc_video_stop_streaming()
2129 uvc_video_clock_cleanup(stream); in uvc_video_stop_streaming()