[PATCH 05/45] media: qcom: camss: keep CSIPHY lanes active while streaming

From: Gjorgji . Rosikopulos . gjorgji . rosikopulos

Date: Tue Oct 06 2026 - 18:43:01 EST


From: Atanas Filipov <atanas.filipov@xxxxxxxxxxxxxxxx>

Add a stream_count reference counter to csiphy_device. The CSIPHY
lanes are enabled on the first stream start and disabled only when
the last stream stops, preventing a shared CSI PHY from being torn
down while another output is still active.

Signed-off-by: Atanas Filipov <atanas.filipov@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/camss/camss-csiphy.c | 12 ++++++++++--
drivers/media/platform/qcom/camss/camss-csiphy.h | 1 +
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index 9e95d04b7235..4938e56f481d 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -324,10 +324,18 @@ static int csiphy_set_stream(struct v4l2_subdev *sd, int enable)
struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
int ret = 0;

- if (enable)
+ if (enable) {
+ if (csiphy->stream_count) {
+ csiphy->stream_count++;
+ return 0;
+ }
+
ret = csiphy_stream_on(csiphy);
- else
+ if (!ret)
+ csiphy->stream_count++;
+ } else if (csiphy->stream_count && !--csiphy->stream_count) {
csiphy_stream_off(csiphy);
+ }

return ret;
}
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
index e55c098dbe67..8c1eb83de751 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.h
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
@@ -115,6 +115,7 @@ struct csiphy_device {
struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM];
const struct csiphy_subdev_resources *res;
struct csiphy_device_regs *regs;
+ unsigned int stream_count;
u64 enabled_streams[MSM_CSIPHY_PADS_NUM];
};

--
2.34.1