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

From: Bryan O'Donoghue

Date: Tue Nov 24 2026 - 07:28:52 EST


On 24/11/2026 12:20, Loic Poulain 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.

But pretty much every hardware implementation will have to do the above function. I'm asking for more functional decomposition.

You could pass the hi/lo for example and make the sof_timestamp() function common - called once from inside of csid_sof_event()

---
bod