From: Vikram Sharma <quic_vikramsa@quicinc.com>
To: <rfoss@kernel.org>, <todor.too@gmail.com>,
<bryan.odonoghue@linaro.org>, <mchehab@kernel.org>,
<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
<akapatra@quicinc.com>, <hariramp@quicinc.com>,
<andersson@kernel.org>, <konradybcio@kernel.org>,
<hverkuil-cisco@xs4all.nl>, <cros-qcom-dts-watchers@chromium.org>,
<catalin.marinas@arm.com>, <will@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
<quic_vikramsa@quicinc.com>, <linux-media@vger.kernel.org>,
<linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <kernel@quicinc.com>
Subject: [PATCH v3 6/8] media: qcom: camss: Restructure camss_link_entities
Date: Fri, 11 Oct 2024 19:39:30 +0530 [thread overview]
Message-ID: <20241011140932.1744124-7-quic_vikramsa@quicinc.com> (raw)
In-Reply-To: <20241011140932.1744124-1-quic_vikramsa@quicinc.com>
Refactor the camss_link_entities function by breaking it down into
three distinct functions. Each function will handle the linking of
a specific entity separately, enhancing readability.
Signed-off-by: Suresh Vankadara <quic_svankada@quicinc.com>
Signed-off-by: Trishansh Bhardwaj <quic_tbhardwa@quicinc.com>
Signed-off-by: Vikram Sharma <quic_vikramsa@quicinc.com>
---
drivers/media/platform/qcom/camss/camss.c | 159 ++++++++++++++--------
1 file changed, 105 insertions(+), 54 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 7ae4a1312e9f..db2710ad0d5c 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -2152,14 +2152,66 @@ static int camss_init_subdevices(struct camss *camss)
}
/*
- * camss_link_entities - Register subdev nodes and create links
+ * camss_link_entities_csid - Register subdev nodes and create links
* @camss: CAMSS device
*
* Return 0 on success or a negative error code on failure
*/
-static int camss_link_entities(struct camss *camss)
+static int camss_link_entities_csid(struct camss *camss)
{
- int i, j, k;
+ int i, j;
+ int ret, line_num;
+ u16 src_pad;
+ u16 sink_pad;
+ struct media_entity *src_entity;
+ struct media_entity *sink_entity;
+
+ for (i = 0; i < camss->res->csid_num; i++) {
+ if (camss->ispif)
+ line_num = camss->ispif->line_num;
+ else
+ line_num = camss->vfe[i].res->line_num;
+
+ src_entity = &camss->csid[i].subdev.entity;
+ for (j = 0; j < line_num; j++) {
+ if (camss->ispif) {
+ sink_entity = &camss->ispif->line[j].subdev.entity;
+ src_pad = MSM_CSID_PAD_SRC;
+ sink_pad = MSM_ISPIF_PAD_SINK;
+ } else {
+ sink_entity = &camss->vfe[i].line[j].subdev.entity;
+ src_pad = MSM_CSID_PAD_FIRST_SRC + j;
+ sink_pad = MSM_VFE_PAD_SINK;
+ }
+
+ ret = media_create_pad_link(src_entity,
+ src_pad,
+ sink_entity,
+ sink_pad,
+ 0);
+ if (ret < 0) {
+ dev_err(camss->dev,
+ "Failed to link %s->%s entities: %d\n",
+ src_entity->name,
+ sink_entity->name,
+ ret);
+ return ret;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * camss_link_entities_csiphy - Register subdev nodes and create links
+ * @camss: CAMSS device
+ *
+ * Return 0 on success or a negative error code on failure
+ */
+static int camss_link_entities_csiphy(struct camss *camss)
+{
+ int i, j;
int ret;
for (i = 0; i < camss->res->csiphy_num; i++) {
@@ -2180,71 +2232,70 @@ static int camss_link_entities(struct camss *camss)
}
}
- if (camss->ispif) {
- for (i = 0; i < camss->res->csid_num; i++) {
- for (j = 0; j < camss->ispif->line_num; j++) {
- ret = media_create_pad_link(&camss->csid[i].subdev.entity,
- MSM_CSID_PAD_SRC,
- &camss->ispif->line[j].subdev.entity,
- MSM_ISPIF_PAD_SINK,
+ return 0;
+}
+
+/*
+ * camss_link_entities_ispif - Register subdev nodes and create links
+ * @camss: CAMSS device
+ *
+ * Return 0 on success or a negative error code on failure
+ */
+static int camss_link_entities_ispif(struct camss *camss)
+{
+ int i, j, k;
+ int ret;
+
+ for (i = 0; i < camss->ispif->line_num; i++) {
+ for (k = 0; k < camss->res->vfe_num; k++) {
+ for (j = 0; j < camss->vfe[k].res->line_num; j++) {
+ struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
+ struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
+
+ ret = media_create_pad_link(&ispif->entity,
+ MSM_ISPIF_PAD_SRC,
+ &vfe->entity,
+ MSM_VFE_PAD_SINK,
0);
if (ret < 0) {
dev_err(camss->dev,
"Failed to link %s->%s entities: %d\n",
- camss->csid[i].subdev.entity.name,
- camss->ispif->line[j].subdev.entity.name,
+ ispif->entity.name,
+ vfe->entity.name,
ret);
return ret;
}
}
}
-
- for (i = 0; i < camss->ispif->line_num; i++)
- for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].res->line_num; j++) {
- struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
- struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
-
- ret = media_create_pad_link(&ispif->entity,
- MSM_ISPIF_PAD_SRC,
- &vfe->entity,
- MSM_VFE_PAD_SINK,
- 0);
- if (ret < 0) {
- dev_err(camss->dev,
- "Failed to link %s->%s entities: %d\n",
- ispif->entity.name,
- vfe->entity.name,
- ret);
- return ret;
- }
- }
- } else {
- for (i = 0; i < camss->res->csid_num; i++)
- for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].res->line_num; j++) {
- struct v4l2_subdev *csid = &camss->csid[i].subdev;
- struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
-
- ret = media_create_pad_link(&csid->entity,
- MSM_CSID_PAD_FIRST_SRC + j,
- &vfe->entity,
- MSM_VFE_PAD_SINK,
- 0);
- if (ret < 0) {
- dev_err(camss->dev,
- "Failed to link %s->%s entities: %d\n",
- csid->entity.name,
- vfe->entity.name,
- ret);
- return ret;
- }
- }
}
return 0;
}
+/*
+ * camss_link_entities - Register subdev nodes and create links
+ * @camss: CAMSS device
+ *
+ * Return 0 on success or a negative error code on failure
+ */
+static int camss_link_entities(struct camss *camss)
+{
+ int ret;
+
+ ret = camss_link_entities_csiphy(camss);
+ if (ret < 0)
+ return ret;
+
+ ret = camss_link_entities_csid(camss);
+ if (ret < 0)
+ return ret;
+
+ if (camss->ispif)
+ ret = camss_link_entities_ispif(camss);
+
+ return ret;
+}
+
/*
* camss_register_entities - Register subdev nodes and create links
* @camss: CAMSS device
--
2.25.1
next prev parent reply other threads:[~2024-10-11 14:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 14:09 [PATCH v3 0/8] media: qcom: camss: Add sc7280 support Vikram Sharma
2024-10-11 14:09 ` [PATCH v3 1/8] media: dt-bindings: media: camss: Add qcom,sc7280-camss binding Vikram Sharma
2024-10-11 14:49 ` Krzysztof Kozlowski
2024-10-21 12:22 ` Vikram Sharma
2024-10-11 14:09 ` [PATCH v3 2/8] media: dt-bindings: Add qcs6490-rb3gen2-vision-mezzanine Vikram Sharma
2024-10-11 14:50 ` Krzysztof Kozlowski
2024-10-11 15:25 ` Bryan O'Donoghue
2024-10-11 21:33 ` Dmitry Baryshkov
2024-10-11 22:31 ` Bryan O'Donoghue
2024-10-11 14:50 ` Krzysztof Kozlowski
2024-10-11 14:09 ` [PATCH v3 3/8] media: qcom: camss: Fix potential crash if domain attach fails Vikram Sharma
2024-10-11 14:09 ` [PATCH v3 4/8] media: qcom: camss: Sort CAMSS version enums and compatible strings Vikram Sharma
2024-10-11 14:09 ` [PATCH v3 5/8] media: qcom: camss: Add support for camss driver on SC7280 Vikram Sharma
2024-10-11 14:09 ` Vikram Sharma [this message]
2024-10-11 14:09 ` [PATCH v3 7/8] arm64: dts: qcom: sc7280: Add support for camss Vikram Sharma
2024-10-11 14:51 ` Krzysztof Kozlowski
2024-10-11 14:09 ` [PATCH v3 8/8] arm64: dts: qcom: qcs6490-rb3gen2-vision-mezzanine: Add vision mezzanine Vikram Sharma
2024-10-11 14:52 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241011140932.1744124-7-quic_vikramsa@quicinc.com \
--to=quic_vikramsa@quicinc.com \
--cc=akapatra@quicinc.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=cros-qcom-dts-watchers@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=hariramp@quicinc.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=kernel@quicinc.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=todor.too@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®