All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org,
	mchehab@kernel.org, hverkuil@xs4all.nl, robert.foss@linaro.org
Cc: jonathan@marek.ca, andrey.konovalov@linaro.org,
	todor.too@gmail.com, agross@kernel.org,
	bjorn.andersson@linaro.org, jgrahsl@snap.com, hfink@snap.com,
	vladimir.zapolskiy@linaro.org, dmitry.baryshkov@linaro.org,
	bryan.odonoghue@linaro.org
Subject: [PATCH v3 18/19] media: camss: Do vfe_get/vfe_put for csid on sm8250
Date: Wed, 22 Dec 2021 00:37:50 +0000	[thread overview]
Message-ID: <20211222003751.2461466-19-bryan.odonoghue@linaro.org> (raw)
In-Reply-To: <20211222003751.2461466-1-bryan.odonoghue@linaro.org>

The sm8250 CAMSS CSID depends on the VFE it is attached to being powered on
and clocked prior to taking the CSID out of reset.

It is possible to open just the CSID subdev from libcamera and attempt to
bring the CSID block up.

If we do not first bring up the VFE the CSID will fail to come out of
reset.

Tested-by: Julian Grahsl <jgrahsl@snap.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Robert Foss <robert.foss@linaro.org>
---
 drivers/media/platform/qcom/camss/camss-csid.c | 12 +++++++++++-
 drivers/media/platform/qcom/camss/camss-vfe.c  |  4 ++--
 drivers/media/platform/qcom/camss/camss-vfe.h  |  3 +++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index 9ef6fbbeeddf3..e6835b92695b6 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -156,10 +156,18 @@ static int csid_set_clock_rates(struct csid_device *csid)
 static int csid_set_power(struct v4l2_subdev *sd, int on)
 {
 	struct csid_device *csid = v4l2_get_subdevdata(sd);
-	struct device *dev = csid->camss->dev;
+	struct camss *camss = csid->camss;
+	struct device *dev = camss->dev;
+	struct vfe_device *vfe = &camss->vfe[csid->id];
 	int ret;
 
 	if (on) {
+		if (camss->version == CAMSS_8250) {
+			ret = vfe_get(vfe);
+			if (ret < 0)
+				return ret;
+		}
+
 		ret = pm_runtime_resume_and_get(dev);
 		if (ret < 0)
 			return ret;
@@ -204,6 +212,8 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 		camss_disable_clocks(csid->nclocks, csid->clock);
 		ret = csid->vdda ? regulator_disable(csid->vdda) : 0;
 		pm_runtime_put_sync(dev);
+		if (camss->version == CAMSS_8250)
+			vfe_put(vfe);
 	}
 
 	return ret;
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 5b5fe620914d0..703ea39f12628 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -575,7 +575,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe)
  *
  * Return 0 on success or a negative error code otherwise
  */
-static int vfe_get(struct vfe_device *vfe)
+int vfe_get(struct vfe_device *vfe)
 {
 	int ret;
 
@@ -637,7 +637,7 @@ static int vfe_get(struct vfe_device *vfe)
  * vfe_put - Power down VFE module
  * @vfe: VFE Device
  */
-static void vfe_put(struct vfe_device *vfe)
+void vfe_put(struct vfe_device *vfe)
 {
 	mutex_lock(&vfe->power_lock);
 
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h
index 6500474a749e7..0eba04eb9b77c 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.h
+++ b/drivers/media/platform/qcom/camss/camss-vfe.h
@@ -203,4 +203,7 @@ extern const struct vfe_hw_ops vfe_ops_4_8;
 extern const struct vfe_hw_ops vfe_ops_170;
 extern const struct vfe_hw_ops vfe_ops_480;
 
+int vfe_get(struct vfe_device *vfe);
+void vfe_put(struct vfe_device *vfe);
+
 #endif /* QC_MSM_CAMSS_VFE_H */
-- 
2.33.0


  parent reply	other threads:[~2021-12-22  0:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22  0:37 [PATCH v3 00/19] CAMSS: Add SM8250 support Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 01/19] media: dt-bindings: media: camss: Add qcom,sm8250-camss binding Bryan O'Donoghue
2022-01-04 13:42   ` Vladimir Zapolskiy
2022-01-04 15:28     ` Bryan O'Donoghue
2022-01-04 20:44       ` Bryan O'Donoghue
2022-01-05  1:15         ` Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 02/19] media: camss: csiphy-3ph: don't print HW version as an error Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 03/19] media: camss: csiphy-3ph: disable interrupts Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 04/19] media: camss: csiphy-3ph: add support for SM8250 CSI DPHY Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 05/19] media: camss: csid-170: fix non-10bit formats Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 06/19] media: camss: csid-170: don't enable unused irqs Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 07/19] media: camss: csid-170: remove stray comment Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 08/19] media: camss: csid-170: support more than one lite vfe Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 09/19] media: camss: csid-170: set the right HALT_CMD when disabled Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 10/19] media: camss: csid: allow csid to work without a regulator Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 11/19] media: camss: remove vdda-csiN from sdm845 resources Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 12/19] media: camss: fix VFE irq name Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 13/19] media: camss: vfe-170: fix "VFE halt timeout" error Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 14/19] media: camss: Add initial support for VFE hardware version Titan 480 Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 15/19] media: camss: add support for V4L2_PIX_FMT_GREY for sdm845 HW Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 16/19] media: camss: add support for SM8250 camss Bryan O'Donoghue
2021-12-22  0:37 ` [PATCH v3 17/19] media: camss: Add SM8250 bandwdith configuration support Bryan O'Donoghue
2021-12-22  0:37 ` Bryan O'Donoghue [this message]
2021-12-22  0:37 ` [PATCH v3 19/19] media: camss: Apply vfe_get/vfe_put fix to SDM845 Bryan O'Donoghue
2021-12-23 10:59 ` [PATCH v3 00/19] CAMSS: Add SM8250 support Vladimir Zapolskiy

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=20211222003751.2461466-19-bryan.odonoghue@linaro.org \
    --to=bryan.odonoghue@linaro.org \
    --cc=agross@kernel.org \
    --cc=andrey.konovalov@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=hfink@snap.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jgrahsl@snap.com \
    --cc=jonathan@marek.ca \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robert.foss@linaro.org \
    --cc=todor.too@gmail.com \
    --cc=vladimir.zapolskiy@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.