From: Philippe CORNU <philippe.cornu@st.com>
To: Andrzej Hajda <a.hajda@samsung.com>,
Archit Taneja <architt@codeaurora.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
David Airlie <airlied@linux.ie>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
Bhumika Goyal <bhumirks@gmail.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Yannick FERTRE <yannick.fertre@st.com>,
Vincent ABRIOU <vincent.abriou@st.com>,
Alexandre TORGUE <alexandre.torgue@st.com>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
Gabriel FERNANDEZ <gabriel.fernandez@st.com>,
Ludovic BARRE <ludovic.barre@st.com>,
"Fabien DESSENNE" <fabien.dessenne@st.com>,
Mickael REULIER <mickael.reulier@st.com>
Subject: Re: [PATCH] drm/bridge/synopsys: dsi: add optional pixel clock
Date: Fri, 27 Oct 2017 15:02:05 +0000 [thread overview]
Message-ID: <82647736-4606-9cd9-676b-e6f705ea2c58@st.com> (raw)
In-Reply-To: <9e4b9bd7-8728-49c4-e0e1-91c68b8eac7c@samsung.com>
Hi Andrzej,
On 10/27/2017 08:41 AM, Andrzej Hajda wrote:
> On 26.10.2017 18:09, Philippe Cornu wrote:
>> The pixel clock is optional. When available, it offers a better
>> preciseness for timing computations.
>>
>> Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
>> ---
>> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 24 ++++++++++++++++++------
>> 1 file changed, 18 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>> index d9cca4f..8b3787d 100644
>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>> @@ -225,6 +225,7 @@ struct dw_mipi_dsi {
>> void __iomem *base;
>>
>> struct clk *pclk;
>> + struct clk *px_clk;
>>
>> unsigned int lane_mbps; /* per lane */
>> u32 channel;
>> @@ -753,24 +754,28 @@ void dw_mipi_dsi_bridge_mode_set(struct drm_bridge *bridge,
>> struct dw_mipi_dsi *dsi = bridge_to_dsi(bridge);
>> const struct dw_mipi_dsi_phy_ops *phy_ops = dsi->plat_data->phy_ops;
>> void *priv_data = dsi->plat_data->priv_data;
>> + struct drm_display_mode px_clk_mode = *mode;
>> int ret;
>>
>> clk_prepare_enable(dsi->pclk);
>>
>> - ret = phy_ops->get_lane_mbps(priv_data, mode, dsi->mode_flags,
>> + if (dsi->px_clk)
>> + px_clk_mode.clock = clk_get_rate(dsi->px_clk) / 1000;
>> +
>> + ret = phy_ops->get_lane_mbps(priv_data, &px_clk_mode, dsi->mode_flags,
>> dsi->lanes, dsi->format, &dsi->lane_mbps);
>
> Just small suggestion: if pixel clock rate matters, maybe better is to
> fix it in adjusted_mode in mode_fixup callback.
>
Well, it was my first idea but unfortunately, "_adjusted_" stuffs are
not used by many drivers, and it means that other drivers using this
generic dw dsi driver will have to handle the "_adjusted_" stuffs too in
their own crtc or dsi specific parts...
So that is why I have chosen to use the "optional" pixel clock (as
defined in the documentation): as it is optional, it is up to the
"specific dt part" to use it or not, whatever the "crtc" driver (often
handling the set rate, like in stm32 ltdc.c), avoiding then more patches
in the specific parts and more importantly in the crtc parts...
What is your opinion then?
>> if (ret)
>> DRM_DEBUG_DRIVER("Phy get_lane_mbps() failed\n");
>>
>> pm_runtime_get_sync(dsi->dev);
>> dw_mipi_dsi_init(dsi);
>> - dw_mipi_dsi_dpi_config(dsi, mode);
>> + dw_mipi_dsi_dpi_config(dsi, &px_clk_mode);
>> dw_mipi_dsi_packet_handler_config(dsi);
>> dw_mipi_dsi_video_mode_config(dsi);
>> - dw_mipi_dsi_video_packet_config(dsi, mode);
>> + dw_mipi_dsi_video_packet_config(dsi, &px_clk_mode);
>> dw_mipi_dsi_command_mode_config(dsi);
>> - dw_mipi_dsi_line_timer_config(dsi, mode);
>> - dw_mipi_dsi_vertical_timing_config(dsi, mode);
>> + dw_mipi_dsi_line_timer_config(dsi, &px_clk_mode);
>> + dw_mipi_dsi_vertical_timing_config(dsi, &px_clk_mode);
>>
>> dw_mipi_dsi_dphy_init(dsi);
>> dw_mipi_dsi_dphy_timing_config(dsi);
>> @@ -784,7 +789,7 @@ void dw_mipi_dsi_bridge_mode_set(struct drm_bridge *bridge,
>>
>> dw_mipi_dsi_dphy_enable(dsi);
>>
>> - dw_mipi_dsi_wait_for_two_frames(mode);
>> + dw_mipi_dsi_wait_for_two_frames(&px_clk_mode);
>>
>> /* Switch to cmd mode for panel-bridge pre_enable & panel prepare */
>> dw_mipi_dsi_set_mode(dsi, 0);
>> @@ -878,6 +883,13 @@ static int dw_mipi_dsi_bridge_attach(struct drm_bridge *bridge)
>> return ERR_PTR(ret);
>> }
>>
>> + dsi->px_clk = devm_clk_get(dev, "px_clk");
>> + if (IS_ERR(dsi->px_clk)) {
>> + ret = PTR_ERR(dsi->px_clk);
>> + dev_dbg(dev, "Unable to get optional px_clk: %d\n", ret);
>> + dsi->px_clk = NULL;
>> + }
>> +
>
> devm_clk_get is called from bridge::attach callback, do we have
> guarantee that in ::detach callback the clock will be removed?
> And what if the clock is defined in dts, but it cannot be get due to
> other reasons? I guess the code should fail then, ie you should have
> different paths for -ENOENT and for other errors.
>
I will do more tests related to your above comments,
Many thanks for your comments and support,
Philippe :-)
> --
> Regards
> Andrzej
>
>> /*
>> * Note that the reset was not defined in the initial device tree, so
>> * we have to be prepared for it not being found.
>
>
next prev parent reply other threads:[~2017-10-27 15:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171026161013epcas2p2a127f113bf4db8f2922bbf4b0874e8b5@epcas2p2.samsung.com>
2017-10-26 16:09 ` Philippe Cornu
2017-10-27 6:41 ` Andrzej Hajda
2017-10-27 15:02 ` Philippe CORNU [this message]
2017-10-27 8:06 ` Philipp Zabel
2017-10-27 15:16 ` Philippe CORNU
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=82647736-4606-9cd9-676b-e6f705ea2c58@st.com \
--to=philippe.cornu@st.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=alexandre.torgue@st.com \
--cc=architt@codeaurora.org \
--cc=benjamin.gaignard@linaro.org \
--cc=bhumirks@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fabien.dessenne@st.com \
--cc=gabriel.fernandez@st.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.barre@st.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mickael.reulier@st.com \
--cc=p.zabel@pengutronix.de \
--cc=vincent.abriou@st.com \
--cc=yannick.fertre@st.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
Powered by JetHome