mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Jai Luthra <j-luthra@ti.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Maxime Ripard <mripard@kernel.org>,
	niklas.soderlund+renesas@ragnatech.se,
	Benoit Parrot <bparrot@ti.com>,
	Vaishnav Achath <vaishnav.a@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	nm@ti.com, devarsht@ti.com
Subject: Re: [PATCH v8 08/16] media: cadence: csi2rx: Configure DPHY using link freq
Date: Wed, 2 Aug 2023 12:41:13 +0300	[thread overview]
Message-ID: <5264c7f8-5af4-fe5c-7a79-cc56150bca82@ideasonboard.com> (raw)
In-Reply-To: <20230731-upstream_csi-v8-8-fb7d3661c2c9@ti.com>

On 31/07/2023 11:29, Jai Luthra wrote:
> From: Pratyush Yadav <p.yadav@ti.com>
> 
> Some platforms like TI's J721E can have the CSI2RX paired with an
> external DPHY. Use the generic PHY framework to configure the DPHY with
> the correct link frequency.
> 
> Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
> Co-authored-by: Jai Luthra <j-luthra@ti.com>
> Signed-off-by: Jai Luthra <j-luthra@ti.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> v7->v8
> - Drop original patch in-lieu of already merged
>    https://lore.kernel.org/linux-media/20230523085626.3295-5-jack.zhu@starfivetech.com/
> - Add a new patch to configure DPHY using link_freq control from the
>    source
> 
>   drivers/media/platform/cadence/cdns-csi2rx.c | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
> index 4f9654366485..2a80c66fb547 100644
> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
> @@ -149,8 +149,33 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
>   static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
>   {
>   	union phy_configure_opts opts = { };
> +	struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy;
> +	struct v4l2_subdev_format sd_fmt = {
> +		.which	= V4L2_SUBDEV_FORMAT_ACTIVE,
> +		.pad	= CSI2RX_PAD_SINK,
> +		.stream	= 0,

I would drop the above line, as this doesn't support streams yet.

> +	};
> +	const struct csi2rx_fmt *fmt;
> +	s64 link_freq;
>   	int ret;
>   
> +	ret = v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt,
> +					    &sd_fmt);
> +	if (ret < 0)
> +		return ret;
> +
> +	fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code);
> +
> +	link_freq = v4l2_get_link_freq(csi2rx->source_subdev->ctrl_handler,
> +				       fmt->bpp, 2 * csi2rx->num_lanes);
> +	if (link_freq < 0)
> +		return link_freq;
> +
> +	ret = phy_mipi_dphy_get_default_config_for_hsclk(link_freq,
> +							 csi2rx->num_lanes, cfg);
> +	if (ret)
> +		return ret;
> +
>   	ret = phy_power_on(csi2rx->dphy);
>   	if (ret)
>   		return ret;
> 

I think this is fine, but a few things to think about:

Here you lock and unlock the active state for the duration of the 
get_fmt call (and you call it for this same subdev). If the driver 
supports active state, and you need to get the fmt of the driver's 
subdev, I think it usually makes more sense to just use the state and 
get the format from there.

And you might want to keep the active state locked for the duration of 
the s_stream operation, in which case the state would already be locked 
when csi2rx_configure_ext_dphy() gets called.

And if you implement enable_streams/disable_streams, then the state has 
already been locked by the framework. However, I think 
enable_streams/disable_streams only works if the driver actually 
supports streams.

But maybe you have already done all these with the out-of-tree streams 
support?

Anyway, I think this is fine for now:

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

  Tomi


  reply	other threads:[~2023-08-02  9:41 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31  8:29 [PATCH v8 00/16] CSI2RX support on J721E and AM62 Jai Luthra
2023-07-31  8:29 ` [PATCH v8 01/16] media: subdev: Export get_format helper for link validation Jai Luthra
2023-08-01 14:09   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 02/16] media: dt-bindings: Make sure items in data-lanes are unique Jai Luthra
2023-08-01 14:09   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 03/16] media: dt-bindings: cadence-csi2rx: Add TI compatible string Jai Luthra
2023-08-05 21:06   ` Krzysztof Kozlowski
2023-07-31  8:29 ` [PATCH v8 04/16] media: cadence: Add support for TI SoCs Jai Luthra
2023-08-05 21:06   ` Krzysztof Kozlowski
2023-08-07  7:58     ` Jai Luthra
2023-07-31  8:29 ` [PATCH v8 05/16] media: cadence: csi2rx: Unregister v4l2 async notifier Jai Luthra
2023-08-01 14:11   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 06/16] media: cadence: csi2rx: Cleanup media entity properly Jai Luthra
2023-08-01 14:11   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 07/16] media: cadence: csi2rx: Add get_fmt and set_fmt pad ops Jai Luthra
2023-08-02  8:48   ` Tomi Valkeinen
2023-08-03 11:18     ` Jai Luthra
2023-07-31  8:29 ` [PATCH v8 08/16] media: cadence: csi2rx: Configure DPHY using link freq Jai Luthra
2023-08-02  9:41   ` Tomi Valkeinen [this message]
2023-07-31  8:29 ` [PATCH v8 09/16] media: cadence: csi2rx: Soft reset the streams before starting capture Jai Luthra
2023-08-01 14:16   ` Tomi Valkeinen
2023-08-03 11:19     ` Jai Luthra
2023-07-31  8:29 ` [PATCH v8 10/16] media: cadence: csi2rx: Set the STOP bit when stopping a stream Jai Luthra
2023-08-02  9:45   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 11/16] media: cadence: csi2rx: Fix stream data configuration Jai Luthra
2023-08-01 14:17   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 12/16] media: cadence: csi2rx: Populate subdev devnode Jai Luthra
2023-08-01 14:18   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 13/16] media: cadence: csi2rx: Add link validation Jai Luthra
2023-08-01 14:19   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 14/16] media: cadence: csi2rx: Support RAW8 and RAW10 formats Jai Luthra
2023-08-02  9:46   ` Tomi Valkeinen
2023-07-31  8:29 ` [PATCH v8 15/16] media: dt-bindings: Add TI J721E CSI2RX Jai Luthra
2023-07-31  9:31   ` Rob Herring
2023-07-31  9:54     ` Jai Luthra
2023-07-31  8:29 ` [PATCH v8 16/16] media: ti: Add CSI2RX support for J721E Jai Luthra
2023-08-02 11:04   ` Tomi Valkeinen
2023-08-02 11:14     ` Sakari Ailus
2023-08-02 12:09       ` Tomi Valkeinen
2023-08-03 11:51     ` Jai Luthra
2023-07-31 12:11 ` [PATCH v8 00/16] CSI2RX support on J721E and AM62 Maxime Ripard
2023-08-08 22:55 ` Vaishnav Achath

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=5264c7f8-5af4-fe5c-7a79-cc56150bca82@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=bparrot@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=devarsht@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=j-luthra@ti.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mripard@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=nm@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=vaishnav.a@ti.com \
    --cc=vigneshr@ti.com \
    /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®