summaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/uvc/uvc_video.c
diff options
context:
space:
mode:
authorRicardo Ribalda <ribalda@chromium.org>2024-03-23 11:48:02 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-06-16 23:58:45 +0200
commita0df8d9450dff25652b628a07f9240ea66228eba (patch)
treec7ea3b73d2a23a703feadfe19d6dfde92ecee7d6 /drivers/media/usb/uvc/uvc_video.c
parentmedia: v4l: add missing MODULE_DESCRIPTION() macros (diff)
downloadlinux-a0df8d9450dff25652b628a07f9240ea66228eba.tar.xz
linux-a0df8d9450dff25652b628a07f9240ea66228eba.zip
media: uvcvideo: Support timestamp lists of any size
The tail of the list lives at the position before the head. This is mathematically noted as: ``` (head-1) mod size. ``` Unfortunately C, does not have a modulus operator, but a remainder operator (%). The reminder operation has a different result than the modulus if (head -1) is a negative number and size is not a power of two. Adding size to (head-1) allows the code to run with any value of size. This does not change the current behaviour of the driver, as the size is always a power of two, but avoid tedious debugging if we ever change its size. Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Link: https://lore.kernel.org/r/20240323-resend-hwtimestamp-v10-1-b08e590d97c7@chromium.org Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'drivers/media/usb/uvc/uvc_video.c')
-rw-r--r--drivers/media/usb/uvc/uvc_video.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 7cbf4692bd87..659c9e9880a9 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -732,7 +732,7 @@ void uvc_video_clock_update(struct uvc_streaming *stream,
goto done;
first = &clock->samples[clock->head];
- last = &clock->samples[(clock->head - 1) % clock->size];
+ last = &clock->samples[(clock->head - 1 + clock->size) % clock->size];
/* First step, PTS to SOF conversion. */
delta_stc = buf->pts - (1UL << 31);