[PATCH 04/14] media: qcom: camss: Introduce EOF sequence tracking
From: bryan . odonoghue
Date: Thu Oct 29 2026 - 05:56:42 EST
From: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
We want to correlate statistics buffers with data-buffers. To do that we
will need to have a sequence number driven by the EOF signal.
In fact even without correlating params, stats and data the vb.sequence
should be based on EOF not just incrementing when a data-buffer arrives.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss-csid.c | 24 +++++++++++++++++++++--
drivers/media/platform/qcom/camss/camss-csid.h | 19 ++++++++++++++++++
drivers/media/platform/qcom/camss/camss-vfe-17x.c | 5 ++++-
drivers/media/platform/qcom/camss/camss-vfe.c | 9 ++++++++-
4 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index 2f1426e77e87c..2564eeea01d73 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -779,9 +779,10 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)
}
if (csid->phy.need_vc_update) {
- for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS; i++)
+ for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS; i++) {
atomic_set(&csid->sof_seq[i], 0);
-
+ atomic_set(&csid->eof_seq[i], -1);
+ }
csid->res->hw_ops->configure_stream(csid, enable);
csid->phy.need_vc_update = false;
}
@@ -1368,6 +1369,25 @@ void csid_sof_event(struct csid_device *csid, unsigned int id)
v4l2_event_queue(csid->subdev.devnode, &event);
}
+void csid_eof_event(struct csid_device *csid, unsigned int id)
+{
+ atomic_fetch_inc(&csid->eof_seq[id]);
+}
+
+atomic_t *csid_get_eof_seq(struct media_pad *pad)
+{
+ struct csid_device *csid;
+
+ if (!pad || pad->index < MSM_CSID_PAD_FIRST_SRC)
+ return NULL;
+
+ csid = v4l2_get_subdevdata(media_entity_to_v4l2_subdev(pad->entity));
+ if (!csid->res->frame_sync_en)
+ return NULL;
+
+ return &csid->eof_seq[pad->index - MSM_CSID_PAD_FIRST_SRC];
+}
+
static const struct v4l2_subdev_core_ops csid_core_ops = {
.s_power = csid_set_power,
.subscribe_event = csid_subscribe_event,
diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
index 2e48b08b93592..7abbb602805dd 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.h
+++ b/drivers/media/platform/qcom/camss/camss-csid.h
@@ -170,6 +170,7 @@ struct csid_device {
const struct csid_subdev_resources *res;
atomic_t frame_sync_users[MSM_CSID_MAX_SRC_STREAMS];
atomic_t sof_seq[MSM_CSID_MAX_SRC_STREAMS];
+ atomic_t eof_seq[MSM_CSID_MAX_SRC_STREAMS];
};
struct camss_subdev_resources;
@@ -260,4 +261,22 @@ u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
*/
void csid_sof_event(struct csid_device *csid, unsigned int id);
+/*
+ * csid_eof_event - Track EOF
+ * @csid: CSID device
+ * @id: CSID src-stream ID
+ *
+ * Called from the CSID interrupt handler on EOF of the path driving the event.
+ */
+void csid_eof_event(struct csid_device *csid, unsigned int id);
+
+/*
+ * csid_get_eof_seq - Get a pointer to the EOF frame sequence variable.
+ * @pad: Remote pad of a consumer's sink pad
+ *
+ * Return the counter or NULL if @pad isn't a CSID or the CSID doesn't support
+ * EOF tracking.
+ */
+atomic_t *csid_get_eof_seq(struct media_pad *pad);
+
#endif /* QC_MSM_CAMSS_CSID_H */
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
index 62c2405359a06..bc791a56edbab 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
@@ -491,7 +491,10 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm)
}
ready_buf->vb.vb2_buf.timestamp = ts;
- ready_buf->vb.sequence = output->sequence++;
+ if (line->eof_seq)
+ ready_buf->vb.sequence = atomic_read(line->eof_seq);
+ else
+ ready_buf->vb.sequence = output->sequence++;
index = 0;
output->buf[0] = output->buf[1];
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 2680a9914765f..a4ecfb151242c 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -474,7 +474,10 @@ void vfe_buf_done(struct vfe_device *vfe, int wm)
}
ready_buf->vb.vb2_buf.timestamp = ts;
- ready_buf->vb.sequence = output->sequence++;
+ if (line->eof_seq)
+ ready_buf->vb.sequence = atomic_read(line->eof_seq);
+ else
+ ready_buf->vb.sequence = output->sequence++;
index = 0;
output->buf[0] = output->buf[1];
@@ -508,6 +511,7 @@ int vfe_enable_output_v2(struct vfe_line *line)
struct vfe_output *output = &line->output;
const struct vfe_hw_ops *ops = vfe->res->hw_ops;
struct media_pad *sensor_pad;
+ struct media_pad *csid_pad;
unsigned long flags;
unsigned int frame_skip = 0;
unsigned int i;
@@ -523,6 +527,9 @@ int vfe_enable_output_v2(struct vfe_line *line)
frame_skip = VFE_FRAME_DROP_VAL - 1;
}
+ csid_pad = media_pad_remote_pad_first(&line->pads[MSM_VFE_PAD_SINK]);
+ line->eof_seq = csid_get_eof_seq(csid_pad);
+
spin_lock_irqsave(&vfe->output_lock, flags);
ops->reg_update_clear(vfe, line->id);
--
2.56.0