[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241125-dsi-relax-v2-2-9113419f4a40@geanix.com>
Date: Mon, 25 Nov 2024 14:49:27 +0100
From: Sean Nyekjaer <sean@...nix.com>
To: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Chen-Yu Tsai <wens@...e.org>, Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>,
Yannick Fertre <yannick.fertre@...s.st.com>,
Raphael Gallais-Pou <raphael.gallais-pou@...s.st.com>,
Philippe Cornu <philippe.cornu@...s.st.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
linux-stm32@...md-mailman.stormreply.com, Sean Nyekjaer <sean@...nix.com>
Subject: [PATCH v2 2/3] drm/sun4i: use drm_mode_validate_mode() helper
function
Use new helper function for HDMI mode validation
Signed-off-by: Sean Nyekjaer <sean@...nix.com>
---
drivers/gpu/drm/sun4i/sun4i_rgb.c | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c b/drivers/gpu/drm/sun4i/sun4i_rgb.c
index dfb6acc42f02efc40f36914e2925510cd8056d0b..4f8100e32769cf31c25f5dd849a18f5b77376090 100644
--- a/drivers/gpu/drm/sun4i/sun4i_rgb.c
+++ b/drivers/gpu/drm/sun4i/sun4i_rgb.c
@@ -51,14 +51,6 @@ static int sun4i_rgb_get_modes(struct drm_connector *connector)
return drm_panel_get_modes(rgb->panel, connector);
}
-/*
- * VESA DMT defines a tolerance of 0.5% on the pixel clock, while the
- * CVT spec reuses that tolerance in its examples, so it looks to be a
- * good default tolerance for the EDID-based modes. Define it to 5 per
- * mille to avoid floating point operations.
- */
-#define SUN4I_RGB_DOTCLOCK_TOLERANCE_PER_MILLE 5
-
static enum drm_mode_status sun4i_rgb_mode_valid(struct drm_encoder *crtc,
const struct drm_display_mode *mode)
{
@@ -67,8 +59,8 @@ static enum drm_mode_status sun4i_rgb_mode_valid(struct drm_encoder *crtc,
u32 hsync = mode->hsync_end - mode->hsync_start;
u32 vsync = mode->vsync_end - mode->vsync_start;
unsigned long long rate = mode->clock * 1000;
- unsigned long long lowest, highest;
unsigned long long rounded_rate;
+ int ret;
DRM_DEBUG_DRIVER("Validating modes...\n");
@@ -122,15 +114,9 @@ static enum drm_mode_status sun4i_rgb_mode_valid(struct drm_encoder *crtc,
tcon->dclk_max_div = 127;
rounded_rate = clk_round_rate(tcon->dclk, rate);
- lowest = rate * (1000 - SUN4I_RGB_DOTCLOCK_TOLERANCE_PER_MILLE);
- do_div(lowest, 1000);
- if (rounded_rate < lowest)
- return MODE_CLOCK_LOW;
-
- highest = rate * (1000 + SUN4I_RGB_DOTCLOCK_TOLERANCE_PER_MILLE);
- do_div(highest, 1000);
- if (rounded_rate > highest)
- return MODE_CLOCK_HIGH;
+ ret = drm_mode_validate_mode(mode, rounded_rate);
+ if (ret)
+ return ret;
out:
DRM_DEBUG_DRIVER("Clock rate OK\n");
--
2.46.2
Powered by blists - more mailing lists