[PATCH 01/12] drm: Nuke mode->hsync

Ville Syrjala ville.syrjala at linux.intel.com
Wed Feb 19 20:35:33 UTC 2020


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Let's just calculate the hsync rate on demand. No point in wasting
space storing it and risking the cached value getting out of sync
with reality.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/drm_modes.c                  | 14 ++------------
 drivers/gpu/drm/i915/display/intel_display.c |  1 -
 include/drm/drm_modes.h                      | 10 ----------
 3 files changed, 2 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index d4d64518e11b..fe7e872a6239 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -752,24 +752,14 @@ EXPORT_SYMBOL(drm_mode_set_name);
  * @mode: mode
  *
  * Returns:
- * @modes's hsync rate in kHz, rounded to the nearest integer. Calculates the
- * value first if it is not yet set.
+ * @modes's hsync rate in kHz, rounded to the nearest integer
  */
 int drm_mode_hsync(const struct drm_display_mode *mode)
 {
-	unsigned int calc_val;
-
-	if (mode->hsync)
-		return mode->hsync;
-
 	if (mode->htotal <= 0)
 		return 0;
 
-	calc_val = (mode->clock * 1000) / mode->htotal; /* hsync in Hz */
-	calc_val += 500;				/* round to 1000Hz */
-	calc_val /= 1000;				/* truncate to kHz */
-
-	return calc_val;
+	return DIV_ROUND_CLOSEST(mode->clock, mode->htotal);
 }
 EXPORT_SYMBOL(drm_mode_hsync);
 
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index ee7d54ccd3e6..fab914819489 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -8867,7 +8867,6 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 
 	mode->clock = pipe_config->hw.adjusted_mode.crtc_clock;
 
-	mode->hsync = drm_mode_hsync(mode);
 	mode->vrefresh = drm_mode_vrefresh(mode);
 	drm_mode_set_name(mode);
 }
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 99134d4f35eb..7dab7f172431 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -390,16 +390,6 @@ struct drm_display_mode {
 	 */
 	int vrefresh;
 
-	/**
-	 * @hsync:
-	 *
-	 * Horizontal refresh rate, for debug output in human readable form. Not
-	 * used in a functional way.
-	 *
-	 * This value is in kHz.
-	 */
-	int hsync;
-
 	/**
 	 * @picture_aspect_ratio:
 	 *
-- 
2.24.1



More information about the dri-devel mailing list