[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231020-uvc-event-v1-1-3baa0e9f6952@chromium.org>
Date: Fri, 20 Oct 2023 06:41:45 +0000
From: Ricardo Ribalda <ribalda@...omium.org>
To: Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Ricardo Ribalda <ribalda@...omium.org>
Cc: linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
Esker Wong <esker@...omium.org>
Subject: [PATCH] media: uvcvideo: Implement V4L2_EVENT_FRAME_SYNC
Add support for the frame_sync event, so user-space can become aware
earlier of new frames.
Suggested-by: Esker Wong <esker@...omium.org>
Tested-by: Esker Wong <esker@...omium.org>
Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
---
We have measured a latency of around 30msecs between frame sync
and dqbuf.
---
drivers/media/usb/uvc/uvc_v4l2.c | 2 ++
drivers/media/usb/uvc/uvc_video.c | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index f4988f03640a..9f3fb5fd2375 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -1352,6 +1352,8 @@ static int uvc_ioctl_subscribe_event(struct v4l2_fh *fh,
switch (sub->type) {
case V4L2_EVENT_CTRL:
return v4l2_event_subscribe(fh, sub, 0, &uvc_ctrl_sub_ev_ops);
+ case V4L2_EVENT_FRAME_SYNC:
+ return v4l2_event_subscribe(fh, sub, 0, NULL);
default:
return -EINVAL;
}
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 28dde08ec6c5..1d4b4807b005 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1073,9 +1073,15 @@ static int uvc_video_decode_start(struct uvc_streaming *stream,
* that discontinuous sequence numbers always indicate lost frames.
*/
if (stream->last_fid != fid) {
- stream->sequence++;
+ struct v4l2_event event = {
+ .type = V4L2_EVENT_FRAME_SYNC,
+ .u.frame_sync.frame_sequence = ++stream->sequence,
+ };
+
if (stream->sequence)
uvc_video_stats_update(stream);
+
+ v4l2_event_queue(&stream->vdev, &event);
}
uvc_video_clock_decode(stream, buf, data, len);
---
base-commit: ce55c22ec8b223a90ff3e084d842f73cfba35588
change-id: 20231020-uvc-event-d3d1bbbdcb2f
Best regards,
--
Ricardo Ribalda <ribalda@...omium.org>
Powered by blists - more mailing lists