From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
To: Romain TISSERAND <romain.tisserand@gmail.com>
Cc: 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>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Heiko Stuebner <heiko@sntech.de>, Liu Ying <victor.liu@nxp.com>,
dri-devel@lists.freedesktop.org,
linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: use the lane rate for lbcc when lanes run faster
Date: Mon, 26 Oct 2026 10:17:58 +0800 [thread overview]
Message-ID: <9e3dc854-b2f5-459c-8267-55e88e87f5b5@rock-chips.com> (raw)
In-Reply-To: <20261025142639.3454322-1-romain.tisserand@gmail.com>
Hi Romain,
On 10/25/2026 10:26 PM, Romain TISSERAND wrote:
> Commit ac87d23694f4 ("drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock
> rate to calculate lbcc") counts HSA, HBP and HLINE from the pixel clock,
> which is only right when the lanes run at the pixel bandwidth (pixel
> clock * bpp / lanes). Commit 93e82bb4de01 ("drm/bridge: synopsys:
> dw-mipi-dsi: Fix hcomponent lbcc for burst mode") went back to the lane
> rate for burst mode, where the lanes are faster on purpose.
>
> The Rockchip glue runs the lanes faster in every mode: it adds 25% to
> the pixel bandwidth, or uses the rate the panel asks for. In non-burst
> video mode the line programmed in lane byte clocks is then shorter than
> the DPI line. On the GPD XD (RK3288, ILI9881C panel, 4 lanes at
> 752 Mbps, 59.5 MHz pixel clock, htotal 747) HLINE was 561 lane byte
> clocks (6.0 us) for a 12.55 us line: the DPI payload FIFO overflows
> (dpi_pld_wr_err in DSI_INT_ST1) and the panel shows garbage as soon as
> a client page-flips.
>
> Use the lane rate when it is clearly above the pixel bandwidth (more
> than 1/8), and keep the pixel clock formula when both match, as on
> i.MX93, Meson and STM in non-burst mode, where lane_mbps is the pixel
> bandwidth rounded up to the next MHz. On the GPD XD this gives HLINE
> 1181, HSA 21 and HBP 7, and the picture is stable.
>
> Fixes: ac87d23694f4 ("drm/bridge: synopsys: dw-mipi-dsi: Use pixel clock rate to calculate lbcc")
> Signed-off-by: Romain TISSERAND <romain.tisserand@gmail.com>
> ---
> Notes for reviewers (not for the changelog):
> - The 1/8 threshold separates glues that report the pixel bandwidth
> rounded up to the next MHz (i.MX93, Meson; STM in non-burst mode) from
> Rockchip, which adds 25% in every mode. If a per-glue flag is
> preferred instead of a threshold, I can rework it that way.
Adding different glue code for each implementation seems like a good
idea.
Maybe you should try to add a new callback in dw_mipi_dsi_plat_data ?
> - Testing: built with W=1 for arm (multi_v7) and arm64 (defconfig),
> DRM_DW_MIPI_DSI=y and =m, no warnings. Tested live on the GPD XD
> (RK3288, ILI9881C, non-burst with sync pulses), 6.18.54 with this
> exact change applied: HLINE 1181, HSA 21, HBP 7 read back from the
> DSI host, no dpi_pld_wr_err in DSI_INT_ST1 while the UI page-flips,
> and a clean picture in the UI and in games (before the change: garbage
> as soon as a client page-flips).
> Not tested on i.MX93, Meson or STM hardware; for them the computation
> is unchanged unless the lane rate is more than 1/8 above the pixel
> bandwidth.
> - Tool disclosure: this patch was prepared with Claude Opus 5.5
> (Anthropic) as a coding assistant, in an interactive session where I
> asked it to bring up the GPD XD display and then to prepare the fix
> for upstream. It located the cause from the DSI host registers, went
> through the history of the lbcc computation (ac87d23694f4,
> 93e82bb4de01) and the lane rates of the other dw-mipi-dsi glues, and
> drafted the code change and the changelog. I reviewed and understand
> both, and tested the patch on the GPD XD as described above.
>
> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 23 +++++++++++++------
> 1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index 22d1b8cbe1..b026b602ab 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -781,19 +781,28 @@ static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
> u32 hcomponent)
> {
> u32 frac, lbcc, minimum_lbcc;
> + u64 pixel_kbps;
> int bpp;
>
> - if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) {
> + bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
> + if (bpp < 0) {
> + dev_err(dsi->dev, "failed to get bpp\n");
> + return 0;
> + }
> +
> + /*
> + * Use the lane rate when it is above the pixel bandwidth (burst, or
> + * glues adding margin in all modes); the 1/8 slack ignores lane_mbps
> + * being rounded up to the next MHz. Otherwise the pixel clock is more
> + * precise.
> + */
> + pixel_kbps = div_u64((u64)mode->clock * bpp, dsi->lanes);
> + if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST ||
> + (u64)dsi->lane_mbps * MSEC_PER_SEC > pixel_kbps + pixel_kbps / 8) {
> /* lbcc based on lane_mbps */
> lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
> } else {
> /* lbcc based on pixel clock rate */
> - bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
> - if (bpp < 0) {
> - dev_err(dsi->dev, "failed to get bpp\n");
> - return 0;
> - }
> -
> lbcc = div_u64((u64)hcomponent * mode->clock * bpp, dsi->lanes * 8);
> }
>
>
> base-commit: cf61bef3801c3c9d0d8c39026b7b2fb242898a3a
--
Best,
Chaoyi
prev parent reply other threads:[~2026-10-26 2:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 14:26 Romain TISSERAND
[not found] ` <sashiko-outbox-184251@kernel.org>
2026-10-25 15:24 ` Romain TISSERAND
2026-10-26 2:17 ` Chaoyi Chen [this message]
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=9e3dc854-b2f5-459c-8267-55e88e87f5b5@rock-chips.com \
--to=chaoyi.chen@rock-chips.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=romain.tisserand@gmail.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--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 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®