]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Added case for when RR equals panel's max RR using freesync
authorHarold Sun <Harold.Sun@amd.com>
Thu, 19 Jun 2025 18:52:54 +0000 (14:52 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 30 Jun 2025 15:59:00 +0000 (11:59 -0400)
[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>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dc_hw_types.h
drivers/gpu/drm/amd/display/modules/freesync/freesync.c

index 809fc696962d54c6cd05533262ff0387a47236bd..6678525172461f80d6bd57b31cee36ad44fa0886 100644 (file)
@@ -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;
index 6a939f2f2fb9ac9c68f0b50373f026909ce09299..71efd2770c99c2c48cbbb14fffde7713b6e88449 100644 (file)
@@ -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)),