drm/i915: Round TMDS clock to nearest
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 7 Sep 2022 09:10:57 +0000 (12:10 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 8 Sep 2022 11:23:38 +0000 (14:23 +0300)
Use round-to-nearest behavour when calculating the TMDS clock.
Matches what we do for most other clock related things.

Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220907091057.11572-18-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_hdmi.c

index c57b5b1d6940b677a3e62f12ff783c5f47312095..b0261d0e5228f1903b85d4d837f972d2f06c5a5b 100644 (file)
@@ -4505,7 +4505,8 @@ int intel_crtc_dotclock(const struct intel_crtc_state *pipe_config)
                dotclock = intel_dotclock_calculate(pipe_config->port_clock,
                                                    &pipe_config->dp_m_n);
        else if (pipe_config->has_hdmi_sink && pipe_config->pipe_bpp > 24)
-               dotclock = pipe_config->port_clock * 24 / pipe_config->pipe_bpp;
+               dotclock = DIV_ROUND_CLOSEST(pipe_config->port_clock * 24,
+                                            pipe_config->pipe_bpp);
        else
                dotclock = pipe_config->port_clock;
 
index 09f85afeb2d494882da5db5a4e700435adfd8b9d..7816b2a33feeb76b0ec805f53642c2c43aa13c79 100644 (file)
@@ -1892,7 +1892,7 @@ int intel_hdmi_tmds_clock(int clock, int bpc, bool ycbcr420_output)
         *  1.5x for 12bpc
         *  1.25x for 10bpc
         */
-       return clock * bpc / 8;
+       return DIV_ROUND_CLOSEST(clock * bpc, 8);
 }
 
 static bool intel_hdmi_source_bpc_possible(struct drm_i915_private *i915, int bpc)