[PATCH RESEND v2 02/12] media: qcom: camss: Add csid pad to port helper

From: Gjorgji Rosikopulos

Date: Wed Nov 25 2026 - 13:24:05 EST


The function to convert a source pad number to its port
index, and use it in csid_get_sof_seq instead of the inline
subtraction.

Signed-off-by: Gjorgji Rosikopulos <gjorgji.rosikopulos@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss-csid.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index 588122beec85..0f819c34e760 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -1356,6 +1356,17 @@ static int csid_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
return v4l2_event_subscribe(fh, sub, 0, &csid_frame_sync_ops);
}

+/*
+ * csid_pad_to_port - Convert a CSID source pad number to its port index
+ * @pad: Source pad number (MSM_CSID_PAD_FIRST_SRC or greater)
+ *
+ * Return the zero-based port index corresponding to @pad
+ */
+static inline unsigned int csid_pad_to_port(u32 pad)
+{
+ return pad - MSM_CSID_PAD_FIRST_SRC;
+}
+
atomic_t *csid_get_sof_seq(struct media_pad *pad)
{
struct csid_device *csid;
@@ -1367,7 +1378,7 @@ atomic_t *csid_get_sof_seq(struct media_pad *pad)
if (!csid->res->frame_sync_en)
return NULL;

- return &csid->sof_seq[pad->index - MSM_CSID_PAD_FIRST_SRC];
+ return &csid->sof_seq[csid_pad_to_port(pad->index)];
}

void csid_sof_event(struct csid_device *csid, unsigned int id)
--
2.34.1