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

Emil Velikov emil.l.velikov at gmail.com
Thu Feb 20 10:55:18 UTC 2020


On Wed, 19 Feb 2020 at 20:35, Ville Syrjala
<ville.syrjala at linux.intel.com> wrote:
>
> 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);

With this gone, we could make drm_mode_hsync() internal and move it to
drm_foo_internal.h.
Making it obvious that drivers, should be copy/pasting it.

Regardless, the patch is:
Reviewed-by: Emil Velikov <emil.velikov at collabora.com>

-Emil


More information about the dri-devel mailing list