Re: [PATCH v3 07/15] media: qcom: camss: Capture VFE CSID dependency in a helper function

From: Laurent Pinchart
Date: Mon Aug 28 2023 - 15:08:30 EST


Hi Bryan,

Thank you for the patch.

On Wed, Aug 23, 2023 at 11:44:36AM +0100, Bryan O'Donoghue wrote:
> From sdm845 onwards we need to ensure the VFE is powered on prior to
> switching on the CSID.

Based on the discussions with Konrad in the mail thread, I would record
here the reason for this requirement.

What happens if you unconditionally power up the VFE prior to switching
the CSID on ? Will this break something on platforms older than SDM845 ?

> Alternatively we could model up the GDSCs and clocks the CSID needs
> without the VFE but, there's a real question of the legitimacy of such a
> use-case.
>
> For now drawing a line at sdm845 and switching on the associated VFEs is
> a perfectly valid thing to do.
>
> Rather than continually extend out this clause for at least two new SoCs
> with this same model - making the vfe_get/vfe_put path start to look
> like spaghetti we can encoded the dependency in a helper function.
>
> Use csid_depends_vfe() for this purpose.
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
> ---
> .../media/platform/qcom/camss/camss-csid.c | 20 +++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
> index 08991b070bd61..fd04ed112b564 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid.c
> @@ -146,6 +146,22 @@ static int csid_set_clock_rates(struct csid_device *csid)
> return 0;
> }
>
> +static bool csid_depends_vfe(u32 version)
> +{
> + bool ret = false;
> +
> + switch (version) {
> + case CAMSS_845:
> + case CAMSS_8250:
> + ret = true;
> + break;
> + default:
> + break;
> + }
> +
> + return ret;
> +}
> +
> /*
> * csid_set_power - Power on/off CSID module
> * @sd: CSID V4L2 subdevice
> @@ -163,7 +179,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
> int ret = 0;
>
> if (on) {
> - if (version == CAMSS_8250 || version == CAMSS_845) {
> + if (csid_depends_vfe(version)) {
> ret = vfe_get(vfe);
> if (ret < 0)
> return ret;
> @@ -217,7 +233,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
> regulator_bulk_disable(csid->num_supplies,
> csid->supplies);
> pm_runtime_put_sync(dev);
> - if (version == CAMSS_8250 || version == CAMSS_845)
> + if (csid_depends_vfe(version))
> vfe_put(vfe);
> }
>

--
Regards,

Laurent Pinchart