[Intel-gfx] [PATCH 1/2] drm/i915: Extract intel_adjusted_rate()

Jani Nikula jani.nikula at linux.intel.com
Thu Apr 1 12:43:37 UTC 2021


On Tue, 30 Mar 2021, Ville Syrjala <ville.syrjala at linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> Extract a small helper to calculate the downscaling
> adjusted pixel rate/data rate/etc.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  .../gpu/drm/i915/display/intel_atomic_plane.c | 27 +++++++++++++------
>  1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> index c3f2962aa1eb..3f830b70b0c1 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> @@ -133,25 +133,36 @@ intel_plane_destroy_state(struct drm_plane *plane,
>  	kfree(plane_state);
>  }
>  
> -unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> -				    const struct intel_plane_state *plane_state)
> +static unsigned int intel_adjusted_rate(const struct drm_rect *src,
> +					const struct drm_rect *dst,
> +					unsigned int rate)
>  {
>  	unsigned int src_w, src_h, dst_w, dst_h;
> -	unsigned int pixel_rate = crtc_state->pixel_rate;
>  
> -	src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
> -	src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
> -	dst_w = drm_rect_width(&plane_state->uapi.dst);
> -	dst_h = drm_rect_height(&plane_state->uapi.dst);
> +	src_w = drm_rect_width(src) >> 16;
> +	src_h = drm_rect_height(src) >> 16;
> +	dst_w = drm_rect_width(dst);
> +	dst_h = drm_rect_height(dst);
>  
>  	/* Downscaling limits the maximum pixel rate */
>  	dst_w = min(src_w, dst_w);
>  	dst_h = min(src_h, dst_h);
>  
> -	return DIV_ROUND_UP_ULL(mul_u32_u32(pixel_rate, src_w * src_h),
> +	return DIV_ROUND_UP_ULL(mul_u32_u32(rate, src_w * src_h),
>  				dst_w * dst_h);
>  }
>  
> +unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> +				    const struct intel_plane_state *plane_state)
> +{
> +	if (!plane_state->uapi.visible)

Potential functional change not covered in the commit message? Makes
sense, but the rabbit hole is too deep to find out if this could
actually make a difference.

If mentioned in the commit message,

Reviewed-by: Jani Nikula <jani.nikula at intel.com>


> +		return 0;
> +
> +	return intel_adjusted_rate(&plane_state->uapi.src,
> +				   &plane_state->uapi.dst,
> +				   crtc_state->pixel_rate);
> +}
> +
>  unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
>  				   const struct intel_plane_state *plane_state)
>  {

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the Intel-gfx mailing list