[Intel-gfx] [PATCH] drm/i915: Move the cursor rotation handling into intel_cursor_check_surface()

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Wed Oct 16 20:51:32 UTC 2019



Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>


On 15.10.2019 18.27, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Unlike other planes the cursor currently handles 180 degree rotation
> adjustment during the hardware programming phase. Let's move that
> stuff into intel_cursor_check_surface() to match how we do things
> with other plane types.
> 
> And while at we'll plop in the final src x/y coordinates (which will
> actually always be zero) into the src rect and color_plane[0].x/y,
> just for some extra consistency.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>   drivers/gpu/drm/i915/display/intel_display.c | 31 ++++++++++++++------
>   1 file changed, 22 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 7d7d1859775a..6a105dc6e168 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -10524,15 +10524,7 @@ static u32 intel_cursor_base(const struct intel_plane_state *plane_state)
>   	else
>   		base = intel_plane_ggtt_offset(plane_state);
>   
> -	base += plane_state->color_plane[0].offset;
> -
> -	/* ILK+ do this automagically */
> -	if (HAS_GMCH(dev_priv) &&
> -	    plane_state->base.rotation & DRM_MODE_ROTATE_180)
> -		base += (drm_rect_height(&plane_state->base.dst) *
> -			 drm_rect_width(&plane_state->base.dst) - 1) * fb->format->cpp[0];
> -
> -	return base;
> +	return base + plane_state->color_plane[0].offset;
>   }
>   
>   static u32 intel_cursor_position(const struct intel_plane_state *plane_state)
> @@ -10569,6 +10561,9 @@ static bool intel_cursor_size_ok(const struct intel_plane_state *plane_state)
>   
>   static int intel_cursor_check_surface(struct intel_plane_state *plane_state)
>   {
> +	struct drm_i915_private *dev_priv =
> +		to_i915(plane_state->base.plane->dev);
> +	unsigned int rotation = plane_state->base.rotation;
>   	int src_x, src_y;
>   	u32 offset;
>   	int ret;
> @@ -10592,7 +10587,25 @@ static int intel_cursor_check_surface(struct intel_plane_state *plane_state)
>   		return -EINVAL;
>   	}
>   
> +	/*
> +	 * Put the final coordinates back so that the src
> +	 * coordinate checks will see the right values.
> +	 */
> +	drm_rect_translate_to(&plane_state->base.src,
> +			      src_x << 16, src_y << 16);
> +
> +	/* ILK+ do this automagically in hardware */
> +	if (HAS_GMCH(dev_priv) && rotation & DRM_MODE_ROTATE_180) {
> +		const struct drm_framebuffer *fb = plane_state->base.fb;
> +		int src_w = drm_rect_width(&plane_state->base.src) >> 16;
> +		int src_h = drm_rect_height(&plane_state->base.src) >> 16;
> +
> +		offset += (src_h * src_w - 1) * fb->format->cpp[0];
> +	}
> +
>   	plane_state->color_plane[0].offset = offset;
> +	plane_state->color_plane[0].x = src_x;
> +	plane_state->color_plane[0].y = src_y;
>   
>   	return 0;
>   }
> 



More information about the Intel-gfx mailing list