[PATCH 1/2] media: qcom: camss: Latch buffer addresses through a single helper
From: Loic Poulain
Date: Tue Nov 24 2026 - 11:48:31 EST
The buffer address written by vfe_wm_update() has to be made visible to
the hardware, and the way to do that depends on the generation, the older
ones only expose a register update, some relies on a FIFO, while the newer
ones expose a dedicated address update that triggers the latch on its own.
Both sequences are open-coded at every call site today, with the address
update being additive and always followed by a register update. This
leaves no way for a generation to tell that an address update alone is
enough, or that no latching is needed at all.
Add vfe_buf_addr_latch(), which calls the generation's addr_update() when
it provides one and falls back to reg_update() otherwise.
The write master configuration programmed by vfe_wm_start() still needs
committing, so vfe_enable_output_v2() now latches each initial buffer
address inside the loop and issues a single register update afterwards.
Signed-off-by: Loic Poulain <loic.poulain@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss-vfe.c | 33 ++++++++++++++++++++-------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index f9bd2367671f6e50c6948a6405f78b8c2b03e5f7..f39e1f303c9bb64a41c59d0d413608b5cb54a8ed 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -443,6 +443,25 @@ u32 vfe_hw_version(struct vfe_device *vfe)
return hw_version;
}
+/*
+ * vfe_buf_addr_latch - Latch a newly programmed buffer address
+ * @vfe: VFE Device
+ * @line: VFE line
+ *
+ * Make the address just written by vfe_wm_update() visible to the hardware,
+ * through a dedicated address update when the generation provides one, or
+ * through a register update otherwise.
+ */
+static void vfe_buf_addr_latch(struct vfe_device *vfe, struct vfe_line *line)
+{
+ const struct vfe_hw_ops *ops = vfe->res->hw_ops;
+
+ if (ops->addr_update)
+ ops->addr_update(vfe, line->id);
+ else
+ ops->reg_update(vfe, line->id);
+}
+
/*
* vfe_buf_done - Process write master done interrupt
* @vfe: VFE Device
@@ -491,9 +510,7 @@ void vfe_buf_done(struct vfe_device *vfe, int wm)
ops->vfe_wm_update(vfe, output->wm_idx[0],
output->buf[index]->addr[0],
line);
- if (ops->addr_update)
- ops->addr_update(vfe, line->id);
- ops->reg_update(vfe, line->id);
+ vfe_buf_addr_latch(vfe, line);
} else {
output->gen2.active_num--;
}
@@ -564,10 +581,12 @@ int vfe_enable_output_v2(struct vfe_line *line)
output->gen2.active_num++;
ops->vfe_wm_update(vfe, output->wm_idx[0],
output->buf[i]->addr[0], line);
- if (!ops->addr_update)
- ops->reg_update(vfe, line->id);
+ vfe_buf_addr_latch(vfe, line);
}
+ /* Commit the write master configuration programmed above */
+ ops->reg_update(vfe, line->id);
+
spin_unlock_irqrestore(&vfe->output_lock, flags);
return 0;
@@ -601,9 +620,7 @@ int vfe_queue_buffer_v2(struct camss_video *vid,
output->buf[output->gen2.active_num++] = buf;
ops->vfe_wm_update(vfe, output->wm_idx[0],
buf->addr[0], line);
- if (ops->addr_update)
- ops->addr_update(vfe, line->id);
- ops->reg_update(vfe, line->id);
+ vfe_buf_addr_latch(vfe, line);
} else {
vfe_buf_add_pending(output, buf);
}
--
2.34.1