From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Nikolaus Voss <nv@vosn.de>
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>,
Liu Ying <victor.liu@nxp.com>, Fabio Estevam <festevam@denx.de>,
Marek Vasut <marex@denx.de>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
nikolaus.voss@haag-streit.com,
Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH] drm: bridge: fsl-ldb: fixup mode on freq mismatch
Date: Tue, 26 Nov 2024 19:20:31 +0100 [thread overview]
Message-ID: <20241126192031.34884a76@booty> (raw)
In-Reply-To: <20241126172610.AD8B51622C@mail.steuer-voss.de>
+Cc: Miquèl, who is actively working on imx8mp video clock rates.
On Tue, 26 Nov 2024 16:45:54 +0100
Nikolaus Voss <nv@vosn.de> wrote:
> LDB clock has to be a fixed multiple of the pixel clock.
> As LDB and pixel clock are derived from different clock sources
> (at least on imx8mp), this constraint cannot be satisfied for
> any pixel clock, which leads to flickering and incomplete
> lines on the attached display.
>
> To overcome this, check this condition in mode_fixup() and
> adapt the pixel clock accordingly.
>
> Cc: <stable@vger.kernel.org>
>
> Signed-off-by: Nikolaus Voss <nv@vosn.de>
> ---
> drivers/gpu/drm/bridge/fsl-ldb.c | 40 ++++++++++++++++++++++++++++----
> 1 file changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/fsl-ldb.c b/drivers/gpu/drm/bridge/fsl-ldb.c
> index 0e4bac7dd04ff..e341341b8c600 100644
> --- a/drivers/gpu/drm/bridge/fsl-ldb.c
> +++ b/drivers/gpu/drm/bridge/fsl-ldb.c
> @@ -104,12 +104,14 @@ static inline struct fsl_ldb *to_fsl_ldb(struct drm_bridge *bridge)
> return container_of(bridge, struct fsl_ldb, bridge);
> }
>
> +static unsigned int fsl_ldb_link_freq_factor(const struct fsl_ldb *fsl_ldb)
> +{
> + return fsl_ldb_is_dual(fsl_ldb) ? 3500 : 7000;
> +}
> +
> static unsigned long fsl_ldb_link_frequency(struct fsl_ldb *fsl_ldb, int clock)
> {
> - if (fsl_ldb_is_dual(fsl_ldb))
> - return clock * 3500;
> - else
> - return clock * 7000;
> + return clock * fsl_ldb_link_freq_factor(fsl_ldb);
> }
>
> static int fsl_ldb_attach(struct drm_bridge *bridge,
> @@ -121,6 +123,35 @@ static int fsl_ldb_attach(struct drm_bridge *bridge,
> bridge, flags);
> }
>
> +static bool fsl_ldb_mode_fixup(struct drm_bridge *bridge,
> + const struct drm_display_mode *mode,
> + struct drm_display_mode *adjusted_mode)
> +{
> + const struct fsl_ldb *fsl_ldb = to_fsl_ldb(bridge);
> + unsigned long requested_link_freq =
> + mode->clock * fsl_ldb_link_freq_factor(fsl_ldb);
> + unsigned long freq = clk_round_rate(fsl_ldb->clk, requested_link_freq);
> +
> + if (freq != requested_link_freq) {
> + /*
> + * this will lead to flicker and incomplete lines on
> + * the attached display, adjust the CRTC clock
> + * accordingly.
> + */
> + int pclk = freq / fsl_ldb_link_freq_factor(fsl_ldb);
> +
> + if (adjusted_mode->clock != pclk) {
> + dev_warn(fsl_ldb->dev, "Adjusted pixel clk to match LDB clk (%d kHz -> %d kHz)!\n",
> + adjusted_mode->clock, pclk);
> +
> + adjusted_mode->clock = pclk;
> + adjusted_mode->crtc_clock = pclk;
> + }
> + }
> +
> + return true;
> +}
> +
> static void fsl_ldb_atomic_enable(struct drm_bridge *bridge,
> struct drm_bridge_state *old_bridge_state)
> {
> @@ -280,6 +311,7 @@ fsl_ldb_mode_valid(struct drm_bridge *bridge,
>
> static const struct drm_bridge_funcs funcs = {
> .attach = fsl_ldb_attach,
> + .mode_fixup = fsl_ldb_mode_fixup,
> .atomic_enable = fsl_ldb_atomic_enable,
> .atomic_disable = fsl_ldb_atomic_disable,
> .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2024-11-26 18:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 15:45 [PATCH] drm: bridge: fsl-ldb: fixup mode on freq mismatch Nikolaus Voss
2024-11-26 18:20 ` Luca Ceresoli [this message]
2024-11-30 9:35 ` Dmitry Baryshkov
2024-11-30 18:57 ` Nikolaus Voss
2024-11-30 20:14 ` Dmitry Baryshkov
2024-12-02 6:32 ` Liu Ying
2024-12-02 10:13 ` Nikolaus Voss
2024-12-03 2:22 ` Liu Ying
2024-12-03 3:12 ` Marek Vasut
2024-12-03 7:20 ` Nikolaus Voss
2024-12-03 23:40 ` Marek Vasut
2024-12-04 10:55 ` Nikolaus Voss
2024-12-07 11:30 ` Marek Vasut
2024-12-09 8:46 ` Nikolaus Voss
2024-12-09 21:46 ` Marek Vasut
2024-12-11 16:54 ` Nikolaus Voss
2024-12-03 7:54 ` Nikolaus Voss
2024-12-23 9:44 ` Liu Ying
2024-12-09 7:41 ` Martin Kepplinger
2024-12-02 12:56 ` Marek Vasut
2024-12-02 17:03 ` Nikolaus Voss
2024-12-02 19:11 ` Marek Vasut
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=20241126192031.34884a76@booty \
--to=luca.ceresoli@bootlin.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=andrzej.hajda@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@denx.de \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=marex@denx.de \
--cc=miquel.raynal@bootlin.com \
--cc=neil.armstrong@linaro.org \
--cc=nikolaus.voss@haag-streit.com \
--cc=nv@vosn.de \
--cc=rfoss@kernel.org \
--cc=victor.liu@nxp.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.