[igt-dev] [PATCH i-g-t v6 06/10] igt: fb: Rework YUV i915 allocation path

Deepak Singh Rawat drawat at vmware.com
Fri Feb 8 17:09:49 UTC 2019


This looks good to me.

Reviewed-by: Deepak Rawat <drawat at vmware.com>

On Fri, 2019-02-08 at 14:18 +0100, Maxime Ripard wrote:
> We only need to allocate a buffer using the GEM API when we're in the
> condition that we currently test, and that we're running on i915.
> 
> All the other cases can be handled by a fallback to a dumb buffer
> allocation. Let's simplify the code a bit to reflect that.
> 
> Reviewed-by: Lyude Paul <lyude at redhat.com>
> Reviewed-by: Paul Kocialkowski <paul.kocialkowski at bootlin.com>
> Signed-off-by: Maxime Ripard <maxime.ripard at bootlin.com>
> ---
>  lib/igt_fb.c | 27 ++++++++-------------------
>  1 file changed, 8 insertions(+), 19 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 6fe0d0847aef..e9728c0c03f4 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -534,7 +534,8 @@ static int create_bo_for_fb(struct igt_fb *fb)
>  	unsigned *strides = &fb->strides[0];
>  	int fd = fb->fd;
>  
> -	if (fb->tiling || fb->size || fb->strides[0] ||
> igt_format_is_yuv(fb->drm_format)) {
> +	if (is_i915_device(fd) &&
> +	   (fb->tiling || fb->size || fb->strides[0] ||
> igt_format_is_yuv(fb->drm_format))) {
>  		uint64_t size;
>  
>  		size = calc_fb_size(fb);
> @@ -544,25 +545,12 @@ static int create_bo_for_fb(struct igt_fb *fb)
>  			fb->size = size;
>  
>  		fb->is_dumb = false;
> +		fb->gem_handle = gem_create(fd, fb->size);
> +		gem_set_tiling(fd, fb->gem_handle,
> +			       igt_fb_mod_to_tiling(fb->tiling),
> +			       fb->strides[0]);
>  
> -		if (is_i915_device(fd)) {
> -
> -			fb->gem_handle = gem_create(fd, fb->size);
> -
> -			gem_set_tiling(fd, fb->gem_handle,
> -				       igt_fb_mod_to_tiling(fb-
> >tiling),
> -				       fb->strides[0]);
> -
> -			if (igt_format_is_yuv(fb->drm_format))
> -				clear_yuv_buffer(fb);
> -
> -			return fb->gem_handle;
> -		} else {
> -			bool driver_has_gem_api = false;
> -
> -			igt_require(driver_has_gem_api);
> -			return -EINVAL;
> -		}
> +		goto out;
>  	}
>  
>  	/*
> @@ -596,6 +584,7 @@ static int create_bo_for_fb(struct igt_fb *fb)
>  	fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height,
>  					     bpp, strides, &fb->size);
>  
> +out:
>  	if (igt_format_is_yuv(fb->drm_format))
>  		clear_yuv_buffer(fb);
>  



More information about the igt-dev mailing list