[PATCH v2 1/2] media: qcom: camss: Latch buffer addresses through a single helper
From: Loic Poulain
Date: Wed Nov 25 2026 - 03:38:57 EST
Factor the buffer address latching open-coded at the three call sites
into 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 issues a single register
update after buffers latching.
Tested-by: Hangxiang Ma <hangxiang.ma@xxxxxxxxxxxxxxxx> # SM8750
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