From: Yannick FERTRE <yannick.fertre@st.com>
To: Philippe CORNU <philippe.cornu@st.com>,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
Vincent ABRIOU <vincent.abriou@st.com>,
David Airlie <airlied@linux.ie>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Archit Taneja <architt@codeaurora.org>,
Andrzej Hajda <a.hajda@samsung.com>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Mickael REULIER <mickael.reulier@st.com>,
Ludovic BARRE <ludovic.barre@st.com>,
Fabien DESSENNE <fabien.dessenne@st.com>,
Alexandre TORGUE <alexandre.torgue@st.com>
Subject: Re: [PATCH] drm/stm: ltdc: use crtc_mode_fixup to update adjusted_mode clock
Date: Mon, 29 Jan 2018 09:46:21 +0000 [thread overview]
Message-ID: <abe9ba40-fbcd-a69e-7d2b-2adb01d309ea@st.com> (raw)
In-Reply-To: <20180125160101.9102-1-philippe.cornu@st.com>
On 01/25/2018 05:01 PM, Philippe Cornu wrote:
> There is a difference between the panel/bridge requested pixel clock
> value and the real one due to the hw platform clock preciseness (pll,
> dividers...). This patch updates the adjusted_mode clock value with
> the real hw clock value so then attached encoder & connector can use
> it for precise timing computations.
Reviewed-by: Yannick Fertré <yannick.fertre@st.com>
> Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
> ---
> drivers/gpu/drm/stm/ltdc.c | 35 +++++++++++++++++++++++++----------
> 1 file changed, 25 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index b48589343ae1..90b3de516c91 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -428,12 +428,35 @@ static void ltdc_crtc_atomic_disable(struct drm_crtc *crtc,
> reg_set(ldev->regs, LTDC_SRCR, SRCR_IMR);
> }
>
> +static bool ltdc_crtc_mode_fixup(struct drm_crtc *crtc,
> + const struct drm_display_mode *mode,
> + struct drm_display_mode *adjusted_mode)
> +{
> + struct ltdc_device *ldev = crtc_to_ltdc(crtc);
> + int rate = mode->clock * 1000;
> +
> + /*
> + * TODO clk_round_rate() does not work yet. When ready, it can
> + * be used instead of clk_set_rate() then clk_get_rate().
> + */
> +
> + clk_disable(ldev->pixel_clk);
> + if (clk_set_rate(ldev->pixel_clk, rate) < 0) {
> + DRM_ERROR("Cannot set rate (%dHz) for pixel clk\n", rate);
> + return false;
> + }
> + clk_enable(ldev->pixel_clk);
> +
> + adjusted_mode->clock = clk_get_rate(ldev->pixel_clk) / 1000;
> +
> + return true;
> +}
> +
> static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
> {
> struct ltdc_device *ldev = crtc_to_ltdc(crtc);
> struct drm_display_mode *mode = &crtc->state->adjusted_mode;
> struct videomode vm;
> - int rate = mode->clock * 1000;
> u32 hsync, vsync, accum_hbp, accum_vbp, accum_act_w, accum_act_h;
> u32 total_width, total_height;
> u32 val;
> @@ -456,15 +479,6 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
> total_width = accum_act_w + vm.hfront_porch;
> total_height = accum_act_h + vm.vfront_porch;
>
> - clk_disable(ldev->pixel_clk);
> -
> - if (clk_set_rate(ldev->pixel_clk, rate) < 0) {
> - DRM_ERROR("Cannot set rate (%dHz) for pixel clk\n", rate);
> - return;
> - }
> -
> - clk_enable(ldev->pixel_clk);
> -
> /* Configures the HS, VS, DE and PC polarities. Default Active Low */
> val = 0;
>
> @@ -528,6 +542,7 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
> }
>
> static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
> + .mode_fixup = ltdc_crtc_mode_fixup,
> .mode_set_nofb = ltdc_crtc_mode_set_nofb,
> .atomic_flush = ltdc_crtc_atomic_flush,
> .atomic_enable = ltdc_crtc_atomic_enable,
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Yannick FERTRE <yannick.fertre@st.com>
To: Philippe CORNU <philippe.cornu@st.com>,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
Vincent ABRIOU <vincent.abriou@st.com>,
"David Airlie" <airlied@linux.ie>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Archit Taneja <architt@codeaurora.org>,
Andrzej Hajda <a.hajda@samsung.com>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Fabien DESSENNE <fabien.dessenne@st.com>,
Mickael REULIER <mickael.reulier@st.com>,
Ludovic BARRE <ludovic.barre@st.com>,
"Alexandre TORGUE" <alexandre.torgue@st.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>
Subject: Re: [PATCH] drm/stm: ltdc: use crtc_mode_fixup to update adjusted_mode clock
Date: Mon, 29 Jan 2018 09:46:21 +0000 [thread overview]
Message-ID: <abe9ba40-fbcd-a69e-7d2b-2adb01d309ea@st.com> (raw)
In-Reply-To: <20180125160101.9102-1-philippe.cornu@st.com>
On 01/25/2018 05:01 PM, Philippe Cornu wrote:
> There is a difference between the panel/bridge requested pixel clock
> value and the real one due to the hw platform clock preciseness (pll,
> dividers...). This patch updates the adjusted_mode clock value with
> the real hw clock value so then attached encoder & connector can use
> it for precise timing computations.
Reviewed-by: Yannick Fertré <yannick.fertre@st.com>
> Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
> ---
> drivers/gpu/drm/stm/ltdc.c | 35 +++++++++++++++++++++++++----------
> 1 file changed, 25 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index b48589343ae1..90b3de516c91 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -428,12 +428,35 @@ static void ltdc_crtc_atomic_disable(struct drm_crtc *crtc,
> reg_set(ldev->regs, LTDC_SRCR, SRCR_IMR);
> }
>
> +static bool ltdc_crtc_mode_fixup(struct drm_crtc *crtc,
> + const struct drm_display_mode *mode,
> + struct drm_display_mode *adjusted_mode)
> +{
> + struct ltdc_device *ldev = crtc_to_ltdc(crtc);
> + int rate = mode->clock * 1000;
> +
> + /*
> + * TODO clk_round_rate() does not work yet. When ready, it can
> + * be used instead of clk_set_rate() then clk_get_rate().
> + */
> +
> + clk_disable(ldev->pixel_clk);
> + if (clk_set_rate(ldev->pixel_clk, rate) < 0) {
> + DRM_ERROR("Cannot set rate (%dHz) for pixel clk\n", rate);
> + return false;
> + }
> + clk_enable(ldev->pixel_clk);
> +
> + adjusted_mode->clock = clk_get_rate(ldev->pixel_clk) / 1000;
> +
> + return true;
> +}
> +
> static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
> {
> struct ltdc_device *ldev = crtc_to_ltdc(crtc);
> struct drm_display_mode *mode = &crtc->state->adjusted_mode;
> struct videomode vm;
> - int rate = mode->clock * 1000;
> u32 hsync, vsync, accum_hbp, accum_vbp, accum_act_w, accum_act_h;
> u32 total_width, total_height;
> u32 val;
> @@ -456,15 +479,6 @@ static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
> total_width = accum_act_w + vm.hfront_porch;
> total_height = accum_act_h + vm.vfront_porch;
>
> - clk_disable(ldev->pixel_clk);
> -
> - if (clk_set_rate(ldev->pixel_clk, rate) < 0) {
> - DRM_ERROR("Cannot set rate (%dHz) for pixel clk\n", rate);
> - return;
> - }
> -
> - clk_enable(ldev->pixel_clk);
> -
> /* Configures the HS, VS, DE and PC polarities. Default Active Low */
> val = 0;
>
> @@ -528,6 +542,7 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
> }
>
> static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
> + .mode_fixup = ltdc_crtc_mode_fixup,
> .mode_set_nofb = ltdc_crtc_mode_set_nofb,
> .atomic_flush = ltdc_crtc_atomic_flush,
> .atomic_enable = ltdc_crtc_atomic_enable,
next prev parent reply other threads:[~2018-01-29 9:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 16:01 [PATCH] drm/stm: ltdc: use crtc_mode_fixup to update adjusted_mode clock Philippe Cornu
2018-01-25 16:01 ` Philippe Cornu
2018-01-29 9:46 ` Yannick FERTRE [this message]
2018-01-29 9:46 ` Yannick FERTRE
2018-01-29 10:15 ` Benjamin Gaignard
2018-01-29 10:15 ` Benjamin Gaignard
2018-01-29 10:43 ` Laurent Pinchart
2018-01-29 10:43 ` Laurent Pinchart
2018-01-29 10:47 ` Benjamin Gaignard
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=abe9ba40-fbcd-a69e-7d2b-2adb01d309ea@st.com \
--to=yannick.fertre@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=dri-devel@lists.freedesktop.org \
--cc=fabien.dessenne@st.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.barre@st.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mickael.reulier@st.com \
--cc=philippe.cornu@st.com \
--cc=vincent.abriou@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 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.