Re: [PATCH 1/3] drm: Extract __setplane_check()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 28, 2018 at 04:54:55PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> 
> Pull all the error checking out from __set_plane_internal() to a helper
> function. We'll have another user of this soon.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>

> ---
>  drivers/gpu/drm/drm_plane.c | 80 +++++++++++++++++++++++++++------------------
>  1 file changed, 49 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index df0b4ebbedbf..5c97a0131484 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -583,6 +583,52 @@ int drm_plane_check_pixel_format(struct drm_plane *plane,
>  	return 0;
>  }
>  
> +static int __setplane_check(struct drm_plane *plane,
> +			    struct drm_crtc *crtc,
> +			    struct drm_framebuffer *fb,
> +			    int32_t crtc_x, int32_t crtc_y,
> +			    uint32_t crtc_w, uint32_t crtc_h,
> +			    uint32_t src_x, uint32_t src_y,
> +			    uint32_t src_w, uint32_t src_h)
> +{
> +	int ret;
> +
> +	/* Check whether this plane is usable on this CRTC */
> +	if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) {
> +		DRM_DEBUG_KMS("Invalid crtc for plane\n");
> +		return -EINVAL;
> +	}
> +
> +	/* Check whether this plane supports the fb pixel format. */
> +	ret = drm_plane_check_pixel_format(plane, fb->format->format,
> +					   fb->modifier);
> +	if (ret) {
> +		struct drm_format_name_buf format_name;
> +
> +		DRM_DEBUG_KMS("Invalid pixel format %s, modifier 0x%llx\n",
> +			      drm_get_format_name(fb->format->format,
> +						  &format_name),
> +			      fb->modifier);
> +		return ret;
> +	}
> +
> +	/* Give drivers some help against integer overflows */
> +	if (crtc_w > INT_MAX ||
> +	    crtc_x > INT_MAX - (int32_t) crtc_w ||
> +	    crtc_h > INT_MAX ||
> +	    crtc_y > INT_MAX - (int32_t) crtc_h) {
> +		DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
> +			      crtc_w, crtc_h, crtc_x, crtc_y);
> +		return -ERANGE;
> +	}
> +
> +	ret = drm_framebuffer_check_src_coords(src_x, src_y, src_w, src_h, fb);
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}
> +
>  /*
>   * __setplane_internal - setplane handler for internal callers
>   *
> @@ -616,37 +662,9 @@ static int __setplane_internal(struct drm_plane *plane,
>  		goto out;
>  	}
>  
> -	/* Check whether this plane is usable on this CRTC */
> -	if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) {
> -		DRM_DEBUG_KMS("Invalid crtc for plane\n");
> -		ret = -EINVAL;
> -		goto out;
> -	}
> -
> -	/* Check whether this plane supports the fb pixel format. */
> -	ret = drm_plane_check_pixel_format(plane, fb->format->format,
> -					   fb->modifier);
> -	if (ret) {
> -		struct drm_format_name_buf format_name;
> -		DRM_DEBUG_KMS("Invalid pixel format %s, modifier 0x%llx\n",
> -			      drm_get_format_name(fb->format->format,
> -						  &format_name),
> -			      fb->modifier);
> -		goto out;
> -	}
> -
> -	/* Give drivers some help against integer overflows */
> -	if (crtc_w > INT_MAX ||
> -	    crtc_x > INT_MAX - (int32_t) crtc_w ||
> -	    crtc_h > INT_MAX ||
> -	    crtc_y > INT_MAX - (int32_t) crtc_h) {
> -		DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
> -			      crtc_w, crtc_h, crtc_x, crtc_y);
> -		ret = -ERANGE;
> -		goto out;
> -	}
> -
> -	ret = drm_framebuffer_check_src_coords(src_x, src_y, src_w, src_h, fb);
> +	ret = __setplane_check(plane, crtc, fb,
> +			       crtc_x, crtc_y, crtc_w, crtc_h,
> +			       src_x, src_y, src_w, src_h);
>  	if (ret)
>  		goto out;
>  
> -- 
> 2.16.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux