From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
"hn.chen" <hn.chen@sunplusit.com>,
Hans Verkuil <hverkuil@xs4all.nl>,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH v10 1/6] media: uvcvideo: Support timestamp lists of any size
Date: Mon, 10 Jun 2024 14:38:00 +0300 [thread overview]
Message-ID: <20240610113800.GQ18479@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20240323-resend-hwtimestamp-v10-1-b08e590d97c7@chromium.org>
Hi Ricardo,
Thank you for the patch.
On Sat, Mar 23, 2024 at 10:48:02AM +0000, Ricardo Ribalda wrote:
> 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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/media/usb/uvc/uvc_video.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 7cbf4692bd875..659c9e9880a99 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);
>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2024-06-10 11:38 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-23 10:48 [PATCH v10 0/6] uvcvideo: Fixes for hw timestamping Ricardo Ribalda
2024-03-23 10:48 ` [PATCH v10 1/6] media: uvcvideo: Support timestamp lists of any size Ricardo Ribalda
2024-05-29 6:13 ` Tomasz Figa
2024-06-10 11:38 ` Laurent Pinchart [this message]
2024-03-23 10:48 ` [PATCH v10 2/6] media: uvcvideo: Ignore empty TS packets Ricardo Ribalda
2024-05-29 6:19 ` Tomasz Figa
2024-03-23 10:48 ` [PATCH v10 3/6] media: uvcvideo: Quirk for invalid dev_sof in Logitech C922 Ricardo Ribalda
2024-03-23 12:16 ` Oleksandr Natalenko
2024-03-25 7:52 ` Ricardo Ribalda
2024-03-25 9:23 ` Oleksandr Natalenko
2024-03-25 9:25 ` Ricardo Ribalda
2024-03-25 12:50 ` Oleksandr Natalenko
2024-03-25 14:13 ` Ricardo Ribalda
2024-05-29 7:20 ` Tomasz Figa
2024-03-23 10:48 ` [PATCH v10 4/6] media: uvcvideo: Allow hw clock updates with buffers not full Ricardo Ribalda
2024-05-29 8:03 ` Tomasz Figa
2024-06-10 11:43 ` Laurent Pinchart
2024-06-12 3:28 ` Tomasz Figa
2024-06-12 7:43 ` Laurent Pinchart
2024-06-12 7:47 ` Ricardo Ribalda
2024-06-12 8:20 ` Laurent Pinchart
2024-06-12 8:47 ` Tomasz Figa
2024-06-12 8:35 ` Tomasz Figa
2024-06-12 9:21 ` Laurent Pinchart
2024-03-23 10:48 ` [PATCH v10 5/6] media: uvcvideo: Refactor clock circular buffer Ricardo Ribalda
2024-05-29 8:13 ` Tomasz Figa
2024-03-23 10:48 ` [PATCH v10 6/6] media: uvcvideo: Fix hw timestamp handling for slow FPS Ricardo Ribalda
2024-05-29 8:30 ` Tomasz Figa
2024-06-10 12:52 ` Laurent Pinchart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240610113800.GQ18479@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=hn.chen@sunplusit.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox