From patchwork Mon Nov 25 13:49:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 13884922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7287BD58D4C for ; Mon, 25 Nov 2024 13:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GbS/T/h9zSMqC3sdnyIAxaPCqFU4fMlM51TlmewgPUo=; b=NGuoluhd3ukGf6UyeZkENrImKb OfMSRHOcs5W8BLl4RqTTCR/la48QRZOCEEkVJQ4+Tl6qdDDHaOKceYmwoZij3lT/foe12eHqFvIRS OElgyFnEqiY+IdnJtcuuw7UmpZ9Tjn2++KV9SvF4X24MO6kRMbACGFJIhJLDOsS4FQsRWbzwSRoUp I0/KTgSJzeLKjvcIdjedYSavFBcTw/3XaXt3QOLztblL3CTN1XyjIOvfxay0fzXO/Ib1HTkqH/xcr xW+miVt6ciRBcnWcIGdKL8kCK/K7nC7vH2B2L+3MPp17oGtd++KsljlzgwfjSjG+1qgw47ahpAYw1 Y1iAv5MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tFZWD-00000008C6R-2rlS; Mon, 25 Nov 2024 13:52:49 +0000 Received: from www530.your-server.de ([188.40.30.78]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tFZTQ-00000008Bcg-2Gle for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2024 13:49:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=GbS/T/h9zSMqC3sdnyIAxaPCqFU4fMlM51TlmewgPUo=; b=KAQdbuXsj5xCJKm50TjrtGNp+V i209reSTd1vjASfKxdLD8fBDDFo9rw7cbgKuOh/DDBW6EMo0qPOscLeGyn1M+GXrejoZvGn5K9SOS j2a8UIvr5WaMs8p4V0eGw2tpSsrW+idP/6onXmnuUfos7yNXIZjM6ANr1FSITg076CIVZF8x3LRO1 qP5jrh1DAi5vzDgFB+sCaoAKQnSbFb6M7nATGPlb63OEveVmQrYumytEoV18oGd5qGM4VaS0q0zCv EPgQXwJ0++mejMsU7xuInz2xTdUqq0DeCx2jUYXW5W88KX07VHVOJTCDDqxaEtecaTeocN3dxO43g DOLW70ow==; Received: from sslproxy08.your-server.de ([78.47.166.52]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFZTB-000CcZ-3G; Mon, 25 Nov 2024 14:49:41 +0100 Received: from [185.17.218.86] (helo=zen.localdomain) by sslproxy08.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tFZTA-000A3a-0S; Mon, 25 Nov 2024 14:49:40 +0100 From: Sean Nyekjaer Date: Mon, 25 Nov 2024 14:49:26 +0100 Subject: [PATCH v2 1/3] drm/modes: introduce drm_mode_validate_mode() helper function MIME-Version: 1.0 Message-Id: <20241125-dsi-relax-v2-1-9113419f4a40@geanix.com> References: <20241125-dsi-relax-v2-0-9113419f4a40@geanix.com> In-Reply-To: <20241125-dsi-relax-v2-0-9113419f4a40@geanix.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Yannick Fertre , Raphael Gallais-Pou , Philippe Cornu , Maxime Coquelin , Alexandre Torgue Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, Sean Nyekjaer X-Mailer: b4 0.14.2 X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27468/Mon Nov 25 10:36:56 2024) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241125_054956_711797_D2E8356F X-CRM114-Status: GOOD ( 11.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Check if the required pixel clock is in within .5% range of the desired pixel clock. This will match the requirement for HDMI where a .5% tolerance is allowed. Signed-off-by: Sean Nyekjaer --- drivers/gpu/drm/drm_modes.c | 34 ++++++++++++++++++++++++++++++++++ include/drm/drm_modes.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 6ba167a3346134072d100af0adbbe9b49e970769..4068b904759bf80502efde6e4d977b297f5d5359 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -1623,6 +1623,40 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, } EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); +/** + * drm_mode_validate_mode + * @mode: mode to check + * @rounded_rate: output pixel clock + * + * 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. + * + * Returns: + * The mode status + */ +enum drm_mode_status drm_mode_validate_mode(const struct drm_display_mode *mode, + unsigned long long rounded_rate) +{ + enum drm_mode_status status; + unsigned long long rate = mode->clock * 1000; + unsigned long long lowest, highest; + + lowest = rate * (1000 - 5); + do_div(lowest, 1000); + if (rounded_rate < lowest) + return MODE_CLOCK_LOW; + + highest = rate * (1000 + 5); + do_div(highest, 1000); + if (rounded_rate > highest) + return MODE_CLOCK_HIGH; + + return MODE_OK; +} +EXPORT_SYMBOL(drm_mode_validate_mode); + static enum drm_mode_status drm_mode_validate_basic(const struct drm_display_mode *mode) { diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h index b9bb92e4b0295a5cbe0eb0da13e77449ff04f51d..4b638992f3e50d2aba5088644744457d72dbe10a 100644 --- a/include/drm/drm_modes.h +++ b/include/drm/drm_modes.h @@ -549,6 +549,8 @@ bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2); bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2); +enum drm_mode_status drm_mode_validate_mode(const struct drm_display_mode *mode, + unsigned long long rounded_rate); /* for use by the crtc helper probe functions */ enum drm_mode_status drm_mode_validate_driver(struct drm_device *dev, From patchwork Mon Nov 25 13:49:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 13884920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4FB6D58D4B for ; Mon, 25 Nov 2024 13:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Fxz5Fki1U5+hxMHiHWwSLT/o9JnSwind+K7SOw8JtPg=; b=c18/bOZxPbLJ/9VCElefapcaSF wTu0LfFncTPHocXzJp1XaGReuef/gkHp+MJzM/b5OArDdKNMVAyQ9H5yGumJm0FNt43+Mw9c0p2qy wHnkS/CpfVjdiQ6eJCYI2u29qQkyQyPiVO2vKevD2Nmk+sgFZ1mBTsDUKdFCIwz0KzxruxG7JLDDc GGNfL6E3R6yaG5rQ9kElsDWkUeI9kprLrhejIWnUDE/tnDPMuS8zkBCLyBh85H3P2JY7EsX5eyMGW hk+Fp6KgSsdEW046tMdQn7JeUzOlKR3/lR7BGgUdZs0U1K06J+bWxu2FREoZRZvkRmgSfQBPWx0bU Mt27FhzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tFZUN-00000008Bm3-21Kd; Mon, 25 Nov 2024 13:50:55 +0000 Received: from www530.your-server.de ([188.40.30.78]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tFZTQ-00000008Bcd-1lUf for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2024 13:49:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=Fxz5Fki1U5+hxMHiHWwSLT/o9JnSwind+K7SOw8JtPg=; b=SeTmP87Ulssn1N+zq4bzaecqeE a984bOYP2C3jRAFNWKGLoTtJNY/4+PoaZ2BfVzNKGNHz97YFRdA8epnhik12eWD8ImhEn0darPJsD tfb/Gx+nMFQjKwNiATZueHa55XOeFS2/gh44Hoya7GDzP5ZpK7ZrSUHL/cV2aJB96ZTL/hoMjUxC+ vpKSEXzx4gGkOx3omj81UoWPf/eNR30qUeqU8W9JsgyNRMZoDB2NaYS2diNiztXNgbvP9sZSIN03b qqbm6aD8catHJy/wkvJ6pv3DghSMdyQr2NiW5AhTe+TTzWSYvX3dCNZP2CBn+VYpS2WAAB6qkAdUN bVUXNdDg==; Received: from sslproxy08.your-server.de ([78.47.166.52]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFZTB-000Ccj-GN; Mon, 25 Nov 2024 14:49:41 +0100 Received: from [185.17.218.86] (helo=zen.localdomain) by sslproxy08.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tFZTA-000A3a-1j; Mon, 25 Nov 2024 14:49:40 +0100 From: Sean Nyekjaer Date: Mon, 25 Nov 2024 14:49:27 +0100 Subject: [PATCH v2 2/3] drm/sun4i: use drm_mode_validate_mode() helper function MIME-Version: 1.0 Message-Id: <20241125-dsi-relax-v2-2-9113419f4a40@geanix.com> References: <20241125-dsi-relax-v2-0-9113419f4a40@geanix.com> In-Reply-To: <20241125-dsi-relax-v2-0-9113419f4a40@geanix.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Yannick Fertre , Raphael Gallais-Pou , Philippe Cornu , Maxime Coquelin , Alexandre Torgue Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, Sean Nyekjaer X-Mailer: b4 0.14.2 X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27468/Mon Nov 25 10:36:56 2024) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241125_054956_712036_E03694E7 X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use new helper function for HDMI mode validation Signed-off-by: Sean Nyekjaer Reviewed-by: Maxime Ripard --- 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"); From patchwork Mon Nov 25 13:49:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Nyekjaer X-Patchwork-Id: 13884923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 958D4D58D4B for ; Mon, 25 Nov 2024 13:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YX5YUSgQhjndAt0sb0ENmF6XZRCGd2awE/vIbYDp+ek=; b=c2DAOgS7e2k3zLtbBbuRTv3T1U FIX8LMEvEIMu7TBEkgXBlhGEUibwEM7UWnytB2PfGsow0T2c8zOacFc1T8iNMSqQjS1BYK5dNy2YC vV0XjreBC1ow3WtDLqRP7m8D09WDyFDP/OsJHN39duoH6vt7BebbIrxtOVC6FhBnmNNDCKcvyaMl/ z3g8VC5cg6+nKn3fgqJ9nmPgM47qOeOL7PhAs6qeiglvx+fcs+1BJp89Py19C+kZ+asNjCFEU2qk+ fRqiwzbP4zNUtL7m/cTgQir8caICZDRRhIyHKNiw2k0+zGbr9TDbt34ZCi+7OGCwpdHnqYZHa8T/F M6jzi6Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tFZX9-00000008CGA-461g; Mon, 25 Nov 2024 13:53:47 +0000 Received: from www530.your-server.de ([188.40.30.78]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tFZTQ-00000008Bcf-1xNZ for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2024 13:49:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=YX5YUSgQhjndAt0sb0ENmF6XZRCGd2awE/vIbYDp+ek=; b=TSWFbGXcMccB8NduNdu8UkSdyZ lDSFG2a+5IAjCK7aqlohfVijKDwMfJSBQ/MedN7pyx7L2vVaRFR3f4RxV9PgKHOiqPmEn1WPGvqPQ IFZ3V7qCXX8Lq+R8znPFwfnAXJBXsaXr8XNdZOxqTJMSwygLA07pSFs6FtpKMvyrpbWQL2VzQEEsv 5ZTtce8LhmAANataDOuslRHwm4gDeG964jZGUDjfDqc8My+9kcdJUBfARDTrfoztD5C2YRPxK6m1o xTbviSPz2PYTzz80aBLLsLa0OHzLqrL51bwLWPAeaqtDDcWork6qOlU/4AekjO1yXphEA1+wmM0uv iGeFItJw==; Received: from sslproxy08.your-server.de ([78.47.166.52]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFZTB-000Ccl-Sn; Mon, 25 Nov 2024 14:49:41 +0100 Received: from [185.17.218.86] (helo=zen.localdomain) by sslproxy08.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tFZTA-000A3a-2y; Mon, 25 Nov 2024 14:49:40 +0100 From: Sean Nyekjaer Date: Mon, 25 Nov 2024 14:49:28 +0100 Subject: [PATCH v2 3/3] drm/stm: dsi: use drm_mode_validate_mode() helper function MIME-Version: 1.0 Message-Id: <20241125-dsi-relax-v2-3-9113419f4a40@geanix.com> References: <20241125-dsi-relax-v2-0-9113419f4a40@geanix.com> In-Reply-To: <20241125-dsi-relax-v2-0-9113419f4a40@geanix.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Yannick Fertre , Raphael Gallais-Pou , Philippe Cornu , Maxime Coquelin , Alexandre Torgue Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, Sean Nyekjaer X-Mailer: b4 0.14.2 X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27468/Mon Nov 25 10:36:56 2024) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241125_054956_714473_FA47D8BF X-CRM114-Status: GOOD ( 12.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When using the DSI interface via DSI2LVDS bridge, it seems a bit harsh to reguire the requested and the actual px clock to be within 50Hz. A typical LVDS display requires the px clock to be within +-10%. In case for HDMI .5% tolerance is required. Signed-off-by: Sean Nyekjaer Reviewed-by: Maxime Ripard --- drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c index b20123854c4ad7b3a2cc973a26fc10fd433e8d09..7b32abe0d4f582eea1fbbacad48c84199be3fa23 100644 --- a/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +++ b/drivers/gpu/drm/stm/dw_mipi_dsi-stm.c @@ -484,8 +484,6 @@ dw_mipi_dsi_phy_get_timing(void *priv_data, unsigned int lane_mbps, return 0; } -#define CLK_TOLERANCE_HZ 50 - static enum drm_mode_status dw_mipi_dsi_stm_mode_valid(void *priv_data, const struct drm_display_mode *mode, @@ -525,7 +523,7 @@ dw_mipi_dsi_stm_mode_valid(void *priv_data, } if (!(mode_flags & MIPI_DSI_MODE_VIDEO_BURST)) { - unsigned int px_clock_hz, target_px_clock_hz, lane_mbps; + unsigned int px_clock_hz, lane_mbps; int dsi_short_packet_size_px, hfp, hsync, hbp, delay_to_lp; struct dw_mipi_dsi_dphy_timing dphy_timing; @@ -533,14 +531,14 @@ dw_mipi_dsi_stm_mode_valid(void *priv_data, pll_out_khz = dsi_pll_get_clkout_khz(pll_in_khz, idf, ndiv, odf); px_clock_hz = DIV_ROUND_CLOSEST_ULL(1000ULL * pll_out_khz * lanes, bpp); - target_px_clock_hz = mode->clock * 1000; /* * Filter modes according to the clock value, particularly useful for * hdmi modes that require precise pixel clocks. */ - if (px_clock_hz < target_px_clock_hz - CLK_TOLERANCE_HZ || - px_clock_hz > target_px_clock_hz + CLK_TOLERANCE_HZ) - return MODE_CLOCK_RANGE; + + ret = drm_mode_validate_mode(mode, px_clock_hz); + if (ret) + return ret; /* sync packets are codes as DSI short packets (4 bytes) */ dsi_short_packet_size_px = DIV_ROUND_UP(4 * BITS_PER_BYTE, bpp);