mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Loic Poulain <loic.poulain@oss.qualcomm.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	Loic Poulain <loic.poulain@oss.qualcomm.com>
Subject: [PATCH v3 6/8] media: qcom: camss: csid-gen3: Report the hardware SOF timestamp
Date: Fri, 27 Nov 2026 17:11:56 +0100	[thread overview]
Message-ID: <20261127-camss-hw-ts-v3-6-e4b6ad98ce9c@oss.qualcomm.com> (raw)
In-Reply-To: <20261127-camss-hw-ts-v3-0-e4b6ad98ce9c@oss.qualcomm.com>

The CSID latches the ARM architected counter into TIMESTAMP_CURR0/1_SOF
on every start of frame. Implement the sof_ts operation so that the
value is used for the frame sync event and the buffer timestamp, instead
of the time at which the interrupt happened to be serviced.

The register pair is latched, not free running, so the two halves belong
to the same SOF whatever the read order.

Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
 drivers/media/platform/qcom/camss/camss-csid-gen3.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen3.c b/drivers/media/platform/qcom/camss/camss-csid-gen3.c
index 5dce6f722d05817f43341d22560cbe32def08cf0..5da77dcd3471033525f6fecde547892fff5965a8 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-gen3.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-gen3.c
@@ -118,6 +118,12 @@
 #define CSID_RDI_IRQ_SUBSAMPLE_PERIOD(rdi)	(csid_is_lite(csid) && IS_CSID_690(csid) ?\
 							(0x34C + 0x100 * (rdi)) :\
 							(0x54C + 0x100 * (rdi)))
+#define CSID_RDI_TIMESTAMP_CURR0_SOF(rdi)	(csid_is_lite(csid) && IS_CSID_690(csid) ?\
+							(0x394 + 0x100 * (rdi)) :\
+							(0x594 + 0x100 * (rdi)))
+#define CSID_RDI_TIMESTAMP_CURR1_SOF(rdi)	(csid_is_lite(csid) && IS_CSID_690(csid) ?\
+							(0x398 + 0x100 * (rdi)) :\
+							(0x598 + 0x100 * (rdi)))
 #define CSI2_RX_CFG0_PHY_SEL_BASE_IDX	1
 
 static void __csid_configure_rx(struct csid_device *csid,
@@ -391,12 +397,27 @@ static void csid_subdev_init(struct csid_device *csid)
 	csid->testgen.nmodes = CSID_PAYLOAD_MODE_DISABLED;
 }
 
+static u64 csid_sof_ts(struct csid_device *csid, unsigned int rdi)
+{
+	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_RDI_TIMESTAMP_CURR0_SOF(rdi));
+	hi = readl_relaxed(csid->base + CSID_RDI_TIMESTAMP_CURR1_SOF(rdi));
+
+	return ((u64)hi << 32) | lo;
+}
+
 const struct csid_hw_ops csid_ops_gen3 = {
 	.configure_stream = csid_configure_stream,
 	.configure_testgen_pattern = csid_configure_testgen_pattern,
 	.hw_version = csid_hw_version,
 	.isr = csid_isr,
 	.reset = csid_reset,
+	.sof_ts = csid_sof_ts,
 	.src_pad_code = csid_src_pad_code,
 	.subdev_init = csid_subdev_init,
 	.reg_update = csid_subdev_reg_update,

-- 
2.34.1


  parent reply	other threads:[~2026-11-27 16:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 16:11 [PATCH v3 0/8] media: qcom: camss: " Loic Poulain
2026-11-27 16:11 ` [PATCH v3 1/8] media: qcom: camss: csid: Add an operation to read the " Loic Poulain
2026-11-27 16:11 ` [PATCH v3 2/8] media: qcom: camss: csid-340: Report the hardware " Loic Poulain
2026-11-27 16:11 ` [PATCH v3 3/8] media: camss: Define timestamp registers for csid-gen2 Loic Poulain
2026-11-27 16:11 ` [PATCH v3 4/8] media: camss: csid-gen2: Report the hardware SOF timestamp Loic Poulain
2026-11-27 16:11 ` [PATCH v3 5/8] media: qcom: camss: csid-gen3: Fix the RDI timestamp controls on Titan 690 Loic Poulain
2026-11-27 16:11 ` Loic Poulain [this message]
2026-11-27 16:11 ` [PATCH v3 7/8] media: qcom: camss: Timestamp buffers at start of frame Loic Poulain
2026-11-27 16:11 ` [PATCH v3 8/8] media: qcom: camss: Tell userspace we're using start-of-frame timestamps Loic Poulain

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=20261127-camss-hw-ts-v3-6-e4b6ad98ce9c@oss.qualcomm.com \
    --to=loic.poulain@oss.qualcomm.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=vladimir.zapolskiy@linaro.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

all inboxes | Powered by JetHome®