Re: [PATCH v4 08/14] media: qcom: camss: Timestamp buffers at start of frame
From: Gjorgji Rosikopulos (Consultant)
Date: Fri Dec 04 2026 - 03:00:07 EST
Hi Loic,
On 12/3/2026 6:53 PM, Loic Poulain wrote:
> Buffers are stamped from the write master done interrupt, once the frame
> has been written out to memory, while V4L2 defines vb2_buf.timestamp as
> the time the first data byte was captured. Use the SOF time the CSID
> already computes instead, handed to the VFE the same way as the SOF
> sequence number. Hardware without SOF tracking keeps using the buf done
> time.
>
> Signed-off-by: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>
> ---
> drivers/media/platform/qcom/camss/camss-vfe-17x.c | 9 +++++----
> drivers/media/platform/qcom/camss/camss-vfe.c | 9 +++++----
> 2 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> index 75f83601da8ef671d8a9f63e8df264729bf256f2..25840100a6565aef25140c7c472cd302573c9477 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> @@ -472,7 +472,6 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm)
> struct vfe_output *output;
> unsigned long flags;
> u32 index;
> - u64 ts = ktime_get_ns();
>
> spin_lock_irqsave(&vfe->output_lock, flags);
>
> @@ -490,11 +489,13 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm)
> goto out_unlock;
> }
>
> - ready_buf->vb.vb2_buf.timestamp = ts;
> - if (line->sof)
> + if (line->sof) {
> + ready_buf->vb.vb2_buf.timestamp = atomic64_read(&line->sof->ts);
> ready_buf->vb.sequence = atomic_read(&line->sof->seq);
> - else
> + } else {
> + ready_buf->vb.vb2_buf.timestamp = ktime_get_ns();
> ready_buf->vb.sequence = output->sequence++;
> + }
>
> index = 0;
> output->buf[0] = output->buf[1];
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
> index 73320bffcd48936372a2b2c4f79b09d3575bdcec..87fc09f7849c6e147d2a3a8fc85233c2e1f52ebb 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c
> @@ -456,7 +456,6 @@ void vfe_buf_done(struct vfe_device *vfe, int wm)
> struct vfe_output *output;
> unsigned long flags;
> u32 index;
> - u64 ts = ktime_get_ns();
>
> spin_lock_irqsave(&vfe->output_lock, flags);
>
> @@ -474,11 +473,13 @@ void vfe_buf_done(struct vfe_device *vfe, int wm)
> goto out_unlock;
> }
>
> - ready_buf->vb.vb2_buf.timestamp = ts;
> - if (line->sof)
> + if (line->sof) {
> + ready_buf->vb.vb2_buf.timestamp = atomic64_read(&line->sof->ts);
> ready_buf->vb.sequence = atomic_read(&line->sof->seq);
> - else
> + } else {
> + ready_buf->vb.vb2_buf.timestamp = ktime_get_ns();
> ready_buf->vb.sequence = output->sequence++;
> + }
>
> index = 0;
> output->buf[0] = output->buf[1];
Looks good to me.
Reviewed-by: Gjorgji Rosikopulos <gjorgji.rosikopulos@xxxxxxxxxxxxxxxx>
~Gjorgji
>