All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ray Wu <ray.wu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
	Tom Chung <chiahsuan.chung@amd.com>,
	"Fangzhi Zuo" <jerry.zuo@amd.com>,
	Zaeem Mohamed <zaeem.mohamed@amd.com>,
	"Daniel Wheeler" <daniel.wheeler@amd.com>,
	Alex Hung <alex.hung@amd.com>, Harold Sun <Harold.Sun@amd.com>,
	Jun Lei <jun.lei@amd.com>, Ray Wu <ray.wu@amd.com>
Subject: [PATCH 06/11] drm/amd/display: Added case for when RR equals panel's max RR using freesync
Date: Wed, 25 Jun 2025 12:02:24 +0800	[thread overview]
Message-ID: <20250625040420.886013-7-ray.wu@amd.com> (raw)
In-Reply-To: <20250625040420.886013-1-ray.wu@amd.com>

From: Harold Sun <Harold.Sun@amd.com>

[WHY]
Rounding error sometimes occurs when the refresh rate is equal to a panel's
max refresh rate, causing HDMI compliance failures.

[HOW]
Added a case so that we round up to avoid v_total_min to be below a panel's
minimum bound.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Signed-off-by: Harold Sun <Harold.Sun@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
---
 drivers/gpu/drm/amd/display/dc/dc_hw_types.h            | 1 +
 drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
index 809fc696962d..667852517246 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
@@ -974,6 +974,7 @@ struct dc_crtc_timing {
 	uint32_t pix_clk_100hz;
 
 	uint32_t min_refresh_in_uhz;
+	uint32_t max_refresh_in_uhz;
 
 	uint32_t vic;
 	uint32_t hdmi_vic;
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 6a939f2f2fb9..71efd2770c99 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -155,6 +155,14 @@ unsigned int mod_freesync_calc_v_total_from_refresh(
 		v_total = div64_u64(div64_u64(((unsigned long long)(
 				frame_duration_in_ns) * (stream->timing.pix_clk_100hz / 10)),
 				stream->timing.h_total), 1000000);
+	} else if (refresh_in_uhz >= stream->timing.max_refresh_in_uhz) {
+		/* When the target refresh rate is the maximum panel refresh rate
+		 * round up the vtotal value to prevent off-by-one error causing
+		 * v_total_min to be below the panel's lower bound
+		 */
+		v_total = div64_u64(div64_u64(((unsigned long long)(
+				frame_duration_in_ns) * (stream->timing.pix_clk_100hz / 10)),
+				stream->timing.h_total) + (1000000 - 1), 1000000);
 	} else {
 		v_total = div64_u64(div64_u64(((unsigned long long)(
 				frame_duration_in_ns) * (stream->timing.pix_clk_100hz / 10)),
-- 
2.43.0


  parent reply	other threads:[~2025-06-25  4:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25  4:02 [PATCH 00/11] DC Patches June 30 2025 Ray Wu
2025-06-25  4:02 ` [PATCH 01/11] drm/amd/display: add null check Ray Wu
2025-06-25  4:02 ` [PATCH 02/11] drm/amd/display: Remove unused tunnel BW validation Ray Wu
2025-06-25  4:02 ` [PATCH 03/11] drm/amd/display: prepare for new platform Ray Wu
2025-06-25  4:02 ` [PATCH 04/11] drm/amd/display: Refactor DML21 Initialization and Configuration Ray Wu
2025-06-25  4:02 ` [PATCH 05/11] drm/amd/display: Separate set_gsl from set_gsl_source_select Ray Wu
2025-06-25  4:02 ` Ray Wu [this message]
2025-06-25  4:02 ` [PATCH 07/11] drm/amd/display: Don't allow OLED to go down to fully off Ray Wu
2025-06-25  4:02 ` [PATCH 08/11] drm/amd/display: Fix Link Override Sequencing When Switching Between DIO/HPO Ray Wu
2025-06-25  4:02 ` [PATCH 09/11] drm/amd/display: Add DPP & HUBP reset if power gate enabled on DCN314 Ray Wu
2025-06-25  4:02 ` [PATCH 10/11] drm/amd/display: [FW Promotion] Release 0.1.17.0 Ray Wu
2025-06-25  4:02 ` [PATCH 11/11] drm/amd/display: Promote DAL to 3.2.340 Ray Wu

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=20250625040420.886013-7-ray.wu@amd.com \
    --to=ray.wu@amd.com \
    --cc=Harold.Sun@amd.com \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=daniel.wheeler@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=jun.lei@amd.com \
    --cc=roman.li@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wayne.lin@amd.com \
    --cc=zaeem.mohamed@amd.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.