[PATCH v4 12/14] media: qcom: camss: vfe-gen3: Report the address of the current frame
From: Loic Poulain
Date: Thu Dec 03 2026 - 11:54:24 EST
Titan gen3 write masters report the start address of the frame they are
writing in their address status block. Implement the operation reading
it.
Extract the shift the write master expects on an address while here, so
the readback can undo it.
Signed-off-by: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss-vfe-gen3.c | 36 +++++++++++++++++++---
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-gen3.c b/drivers/media/platform/qcom/camss/camss-vfe-gen3.c
index 22579617def78457d057e5ba413ae481843a18ad..34e4af8cf471703653afdc6d5ae33150c27011fa 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-gen3.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-gen3.c
@@ -70,6 +70,16 @@
#define VFE_BUS_WM_MMU_PREFETCH_CFG(n) (BUS_REG_BASE + 0x260 + (n) * 0x100)
#define VFE_BUS_WM_MMU_PREFETCH_MAX_OFFSET(n) (BUS_REG_BASE + 0x264 + (n) * 0x100)
+/*
+ * What the write master reports about the addresses it is using:
+ * 0: Start of the frame it finished last, written at buf done
+ * 1: Same for the frame header
+ * 2: How many addresses are still queued up in hardware
+ * 3: Start of the frame it is writing, written when that frame starts
+ */
+#define VFE_BUS_WM_ADDR_STATUS(n, k) (BUS_REG_BASE + 0x270 + (k) * 4 + (n) * 0x100)
+#define ADDR_STATUS_CURR_FRAME 3
+
static void vfe_wm_start(struct vfe_device *vfe, u8 wm, struct vfe_line *line)
{
struct v4l2_pix_format_mplane *pix =
@@ -118,20 +128,37 @@ static void vfe_wm_stop(struct vfe_device *vfe, u8 wm)
writel(0, vfe->base + VFE_BUS_WM_CFG(wm));
}
+/* How the write master wants a buffer address presented to it */
+static u32 vfe_wm_addr(struct vfe_device *vfe, u32 addr)
+{
+ return IS_VFE_690(vfe) ? addr : addr >> 8;
+}
+
static void vfe_wm_update(struct vfe_device *vfe, u8 wm, u32 addr,
struct vfe_line *line)
{
wm = RDI_WM(wm);
- if (IS_VFE_690(vfe))
- writel(addr, vfe->base + VFE_BUS_WM_IMAGE_ADDR(wm));
- else
- writel((addr >> 8), vfe->base + VFE_BUS_WM_IMAGE_ADDR(wm));
+ writel(vfe_wm_addr(vfe, addr), vfe->base + VFE_BUS_WM_IMAGE_ADDR(wm));
dev_dbg(vfe->camss->dev, "wm:%d, image buf addr:0x%x\n",
wm, addr);
}
+/* The address the write master reports for the frame it is filling */
+static u32 vfe_wm_curr_addr(struct vfe_device *vfe, u8 wm)
+{
+ u32 addr;
+
+ wm = RDI_WM(wm);
+
+ addr = readl_relaxed(vfe->base +
+ VFE_BUS_WM_ADDR_STATUS(wm, ADDR_STATUS_CURR_FRAME));
+
+ /* Inverse of vfe_wm_addr(), so a programmed address reads back as is */
+ return IS_VFE_690(vfe) ? addr : addr << 8;
+}
+
static void vfe_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
{
int port_id = line_id;
@@ -189,5 +216,6 @@ const struct vfe_hw_ops vfe_ops_gen3 = {
.vfe_wm_start = vfe_wm_start,
.vfe_wm_stop = vfe_wm_stop,
.vfe_buf_done = vfe_buf_done,
+ .vfe_wm_curr_addr = vfe_wm_curr_addr,
.vfe_wm_update = vfe_wm_update,
};
--
2.34.1