[PATCH v2 0/7] media: qcom: camss: Report the hardware SOF timestamp

From: Loic Poulain

Date: Wed Nov 25 2026 - 05:19:41 EST


The CAMSS CSID latches the ARM architected counter on every start of
frame. This series exposes that time to userspace, both through the
V4L2_EVENT_FRAME_SYNC event and as the buffer timestamp.

Until now both were taken when the interrupt was handled, or worse, when
the frame had finished being written out to memory, which is about a
frame period late. The hardware value is free of interrupt latency and
is directly comparable with CLOCK_MONOTONIC, so it can be correlated
with other timestamped data such as IMU samples.

Patch 1 lets a driver fill in the timestamp of a V4L2 event instead of
having the core take it. Patch 2 adds a CSID operation for reading the
counter latched at SOF, converts it to CLOCK_MONOTONIC and puts it in
the event. Patches 3 to 5 implement that operation on csid-340 and
csid-gen2. Patch 6 uses the same time to stamp the captured buffers and
patch 7 reports the new source to userspace.

Patches 4 and 5 are picked from the timestamp support Bryan shared
earlier, with patch 5 adapted to the operation added in patch 2 rather
than doing its own conversion.

Tested on QCM2290 (Arduino UNO Q) with an IMX219 sensor.

Signed-off-by: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>
---
Changes in v2:
- Patch 2: read the latched counter through a new csid_hw_ops operation
and do the conversion once in the CSID core, instead of passing the
time into csid_sof_event() and open coding the register read in every
CSI decoder (Bryan).
- New patch 7: report the timestamp source as V4L2_BUF_FLAG_TSTAMP_SRC_SOE
on the SoCs that can track SOF, rather than leaving the queue
advertising V4L2_BUF_FLAG_TSTAMP_SRC_EOF.
- Link to v1: https://lore.kernel.org/r/20261123-camss-hw-ts-v1-0-7b62dda6d7a9@xxxxxxxxxxxxxxxx

---
Bryan O'Donoghue (2):
media: camss: Define timestamp registers for csid-gen2
media: camss: csid-gen2: Report the hardware SOF timestamp

Loic Poulain (5):
media: v4l2-event: Allow drivers to provide the event timestamp
media: qcom: camss: csid: Add an operation to read the SOF timestamp
media: qcom: camss: csid-340: Report the hardware SOF timestamp
media: qcom: camss: Timestamp buffers at start of frame
media: qcom: camss: Tell userspace we're using start-of-frame timestamps

drivers/media/platform/qcom/camss/camss-csid-340.c | 37 ++++++++-
.../media/platform/qcom/camss/camss-csid-gen2.c | 31 +++++++
drivers/media/platform/qcom/camss/camss-csid.c | 94 +++++++++++++++++++++-
drivers/media/platform/qcom/camss/camss-csid.h | 19 +++++
drivers/media/platform/qcom/camss/camss-vfe-17x.c | 7 +-
drivers/media/platform/qcom/camss/camss-vfe.c | 8 +-
drivers/media/platform/qcom/camss/camss-vfe.h | 1 +
drivers/media/platform/qcom/camss/camss-video.c | 2 +
drivers/media/platform/qcom/camss/camss.c | 12 +++
drivers/media/platform/qcom/camss/camss.h | 1 +
drivers/media/v4l2-core/v4l2-event.c | 20 ++++-
include/media/v4l2-event.h | 9 ++-
12 files changed, 228 insertions(+), 13 deletions(-)
---
base-commit: 2ad58ca589da80990b7afbcff018777851577f89
change-id: 20261123-camss-hw-ts-e0297adb69d9

Best regards,
--
Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>