From: Dang Huynh <danct12@riseup.net>
To: Anatolij Gustschin <agust@denx.de>,
Simon Glass <sjg@chromium.org>,
Philipp Tomsich <philipp.tomsich@vrull.eu>,
Kever Yang <kever.yang@rock-chips.com>,
Tom Rini <trini@konsulko.com>,
Nicolas Frattaroli <frattaroli.nicolas@gmail.com>,
Jonas Karlman <jonas@kwiboo.se>, Ondrej Jirman <megi@xff.cz>,
Dragan Simic <dsimic@manjaro.org>,
Svyatoslav Ryhel <clamor95@gmail.com>,
Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>
Cc: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>,
u-boot@lists.denx.de, Piotr Zalewski <pZ010001011111@proton.me>,
Dang Huynh <danct12@riseup.net>
Subject: [PATCH v3 02/12] video: rockchip: dw_mipi_dsi: Improve pixel clock calculations
Date: Sat, 12 Apr 2025 21:27:04 +0700 [thread overview]
Message-ID: <20250412-vop2-pt2-v3-2-7c796db335e9@riseup.net> (raw)
In-Reply-To: <20250412-vop2-pt2-v3-0-7c796db335e9@riseup.net>
From: Ondrej Jirman <megi@xff.cz>
Calculate burst mode overhead in one place for both internal
and external PHY use case and exit if out of range, instead
of ignoring the wrong value.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
Signed-off-by: Dang Huynh <danct12@riseup.net>
---
drivers/video/rockchip/dw_mipi_dsi_rockchip.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/video/rockchip/dw_mipi_dsi_rockchip.c b/drivers/video/rockchip/dw_mipi_dsi_rockchip.c
index fa512173510b1ee6f51e6269eb249e24d0e980f8..c47992dfb133cda029eba82e842ac824ceead64b 100644
--- a/drivers/video/rockchip/dw_mipi_dsi_rockchip.c
+++ b/drivers/video/rockchip/dw_mipi_dsi_rockchip.c
@@ -526,8 +526,6 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, struct display_timing *timings,
struct udevice *dev = device->dev;
struct dw_rockchip_dsi_priv *dsi = dev_get_priv(dev);
int bpp;
- unsigned long mpclk, tmp;
- unsigned int target_mbps = 1000;
unsigned int max_mbps = dppa_map[ARRAY_SIZE(dppa_map) - 1].max_mbps;
unsigned long best_freq = 0;
unsigned long fvco_min, fvco_max, fin, fout;
@@ -544,30 +542,28 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, struct display_timing *timings,
return bpp;
}
- mpclk = DIV_ROUND_UP(timings->pixelclock.typ, 1000);
- if (mpclk) {
- /* take 1 / 0.8, since mbps must big than bandwidth of RGB */
- tmp = (mpclk * (bpp / lanes) * 10 / 8) / 1000;
- if (tmp < max_mbps)
- target_mbps = tmp;
- else
- dev_err(dsi->dsi_host,
- "DPHY clock frequency is out of range\n");
+ fout = timings->pixelclock.typ / MSEC_PER_SEC * bpp / lanes;
+ if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST)
+ fout = fout * 12 / 10;
+ fout *= MSEC_PER_SEC;
+
+ if (fout > max_mbps * USEC_PER_SEC) {
+ dev_err(dsi->dsi_host, "DPHY clock frequency is out of range\n");
+ return -EINVAL;
}
/* for external phy only the mipi_dphy_config is necessary */
if (generic_phy_valid(&dsi->phy)) {
- phy_mipi_dphy_get_default_config(timings->pixelclock.typ * 10 / 8,
+ phy_mipi_dphy_get_default_config(fout / bpp * lanes,
bpp, lanes,
&dsi->phy_opts);
- dsi->lane_mbps = target_mbps;
+ dsi->lane_mbps = DIV_ROUND_UP(fout, USEC_PER_SEC);
*lane_mbps = dsi->lane_mbps;
return 0;
}
fin = clk_get_rate(dsi->ref);
- fout = target_mbps * USEC_PER_SEC;
/* constraint: 5Mhz <= Fref / N <= 40MHz */
min_prediv = DIV_ROUND_UP(fin, 40 * USEC_PER_SEC);
--
2.49.0
next prev parent reply other threads:[~2025-04-12 14:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-12 14:27 [PATCH v3 00/12] Rockchip VOP2 support Dang Huynh
2025-04-12 14:27 ` [PATCH v3 01/12] video: rockchip: dw-mipi-dsi: Depend on CONFIG_VIDEO_BRIDGE Dang Huynh
2025-04-12 14:27 ` Dang Huynh [this message]
2025-04-12 14:27 ` [PATCH v3 03/12] video: rockchip: dw_mipi_dsi: Proceed when external PHY is not defined Dang Huynh
2025-04-12 14:27 ` [PATCH v3 04/12] video: rockchip: dw-mipi-dsi: Add get_display_timing support Dang Huynh
2025-04-12 14:27 ` [PATCH v3 05/12] video: Add BOE TH101MB31IG002-28A MIPI-DSI panel Dang Huynh
2025-04-12 14:27 ` [PATCH v3 06/12] video: rockchip: Add VOP2 support Dang Huynh
2025-04-12 14:27 ` [PATCH v3 07/12] video: rockchip: vop2: Add video bridge support Dang Huynh
2025-04-12 14:27 ` [PATCH v3 08/12] dts: rockchip: rk356x: Prerelocate VOP in U-Boot proper Dang Huynh
2025-04-13 14:33 ` Jonas Karlman
2025-04-15 13:15 ` Dang Huynh
2025-04-12 14:27 ` [PATCH v3 09/12] configs: quartz64: Enable vidconsole Dang Huynh
2025-04-12 14:27 ` [PATCH v3 10/12] video: rockchip: Add HDMI support for RK3568 Dang Huynh
2025-04-13 15:10 ` Jonas Karlman
2025-04-12 14:27 ` [PATCH v3 11/12] configs: pinetab2-rk3566: Enable video and USB keyboard Dang Huynh
2025-04-13 15:26 ` Jonas Karlman
2025-04-15 13:29 ` Dang Huynh
2025-04-15 15:52 ` Jonas Karlman
2025-04-19 4:22 ` Dang Huynh
2025-04-12 14:27 ` [PATCH v3 12/12] clk: rockchip: rk3568: Use assigned VPLL clock when possible Dang Huynh
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=20250412-vop2-pt2-v3-2-7c796db335e9@riseup.net \
--to=danct12@riseup.net \
--cc=agust@denx.de \
--cc=clamor95@gmail.com \
--cc=dsimic@manjaro.org \
--cc=frattaroli.nicolas@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kever.yang@rock-chips.com \
--cc=lukma@denx.de \
--cc=megi@xff.cz \
--cc=pZ010001011111@proton.me \
--cc=philipp.tomsich@vrull.eu \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/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