Re: [PATCH 3/6] media: qcom: camss: csid-340: Report the hardware SOF timestamp

From: Loic Poulain

Date: Tue Nov 24 2026 - 07:20:21 EST


On Tue, Nov 24, 2026 at 10:57 AM Bryan O'Donoghue
<bryan.odonoghue@xxxxxxxxxx> wrote:
>
> On 23/11/2026 17:16, Loic Poulain wrote:
> > +static u64 __csid_sof_timestamp(struct csid_device *csid, enum csid_iface iface)
> > +{
> > + u32 lo, hi;
> > +
> > + /*
> > + * The pair is latched on SOF rather than counting, so it can be read
> > + * one word at a time without tearing.
> > + */
> > + lo = readl_relaxed(csid->base + CSID_TIMESTAMP_CURR0_SOF(iface));
> > + hi = readl_relaxed(csid->base + CSID_TIMESTAMP_CURR1_SOF(iface));
> > +
> > + return csid_timestamp_to_monotonic(csid, ((u64)hi << 32) | lo);
> > +}
> > +
> > static irqreturn_t csid_isr(int irq, void *dev)
> > {
> > struct csid_device *csid = dev;
> > @@ -207,7 +234,7 @@ static irqreturn_t csid_isr(int irq, void *dev)
> > iface_val |= status;
> >
> > if (status & CSID_IFACE_IRQ_INFO_INPUT_SOF)
> > - csid_sof_event(csid, i, 0);
> > + csid_sof_event(csid, i, __csid_sof_timestamp(csid, iface));
> > }
>
> I think a callback in csid_sof_event() might be cleaner or some other
> way to not have to replicate all of __csid_sof_timestamp() for each CSI
> decoder.

I added it as a parameter because it is provided in much the same way
as the sequence number, given that the timestamp is directly related
to and coupled with it. So it is not clearly obvious why the sequence
number should be passed as a parameter while the timestamp should not.

So yes we could also introduce a hw_ops callback, but that would
ultimately require replicating the implementation for each CSI decoder
anyway, or having some semi-shared helpers.

Regards,
Loic

>
> ---
> bod