[igt-dev] [PATCH i-g-t 16/25] lib/kms: Pass the number of planes explicitly to __kms_addfb()

Paulo Zanoni paulo.r.zanoni at intel.com
Fri Sep 21 22:54:39 UTC 2018


Em Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Currently __kms_addfb() assumes that only the first plane can be
> at offset 0. I don't particularly like such assumptions so let's
> just pass in the number of planes explicitly.
> 
> We'll also require offsets[] to be passed in always. Nothing really
> to gain by making it optional.

Reviewed-by: Paulo Zanoni <paulo.r.zanoni at intel.com>

> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  lib/igt_fb.c                    | 1 +
>  lib/ioctl_wrappers.c            | 9 +++------
>  lib/ioctl_wrappers.h            | 2 +-
>  tests/kms_available_modes_crc.c | 5 ++++-
>  tests/kms_draw_crc.c            | 3 ++-
>  tests/prime_vgem.c              | 3 ++-
>  6 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 5e687b95e265..77611b593a7e 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -884,6 +884,7 @@ igt_create_fb_with_bo_size(int fd, int width, int
> height,
>  
>  		do_or_die(__kms_addfb(fd, fb->gem_handle, width,
> height,
>  				      format, tiling, pitches, fb-
> >offsets,
> +				      fb_num_planes(f),
>  				      LOCAL_DRM_MODE_FB_MODIFIERS,
> &fb_id));
>  	} else {
>  		uint32_t handles[4];
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index a34857266d92..d992e015b9c8 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -1674,7 +1674,7 @@ int __kms_addfb(int fd, uint32_t handle,
>  		uint32_t width, uint32_t height,
>  		uint32_t pixel_format, uint64_t modifier,
>  		uint32_t strides[4], uint32_t offsets[4],
> -		uint32_t flags, uint32_t *buf_id)
> +		int num_planes, uint32_t flags, uint32_t *buf_id)
>  {
>  	struct drm_mode_fb_cmd2 f;
>  	int ret, i;
> @@ -1687,14 +1687,11 @@ int __kms_addfb(int fd, uint32_t handle,
>  	f.height = height;
>  	f.pixel_format = pixel_format;
>  	f.flags = flags;
> -	f.handles[0] = handle;
> -	f.pitches[0] = strides[0];
> -	f.modifier[0] = modifier;
>  
> -	for (i = 1; i < 4 && offsets && offsets[i]; i++) {
> +	for (i = 0; i < num_planes; i++) {
>  		f.handles[i] = handle;
> -		f.pitches[i] = strides[i];
>  		f.modifier[i] = modifier;
> +		f.pitches[i] = strides[i];
>  		f.offsets[i] = offsets[i];
>  	}
>  
> diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
> index 67bf50562bf3..872e3056314b 100644
> --- a/lib/ioctl_wrappers.h
> +++ b/lib/ioctl_wrappers.h
> @@ -239,7 +239,7 @@ int __kms_addfb(int fd, uint32_t handle,
>  		uint32_t width, uint32_t height,
>  		uint32_t pixel_format, uint64_t modifier,
>  		uint32_t strides[4], uint32_t offsets[4],
> -		uint32_t flags, uint32_t *buf_id);
> +		int num_planes, uint32_t flags, uint32_t *buf_id);
>  
>  /**
>   * to_user_pointer:
> diff --git a/tests/kms_available_modes_crc.c
> b/tests/kms_available_modes_crc.c
> index 1c843c6cf691..14170ef711e3 100644
> --- a/tests/kms_available_modes_crc.c
> +++ b/tests/kms_available_modes_crc.c
> @@ -258,6 +258,7 @@ static bool setup_fb(data_t *data, igt_output_t
> *output, igt_plane_t *plane,
>  	unsigned tile_width, tile_height;
>  	uint32_t strides[4] = {};
>  	uint32_t offsets[4] = {};
> +	int num_planes = 1;
>  	uint64_t tiling;
>  	int bpp = 0;
>  	int i;
> @@ -303,6 +304,7 @@ static bool setup_fb(data_t *data, igt_output_t
> *output, igt_plane_t *plane,
>  	if (fillers[i].bpp == P010 || fillers[i].bpp == NV12) {
>  		offsets[1] = data->size;
>  		gemsize = data->size * 2;
> +		num_planes = 2;
>  	}
>  
>  	data->gem_handle = gem_create(data->gfx_fd, gemsize);
> @@ -313,7 +315,8 @@ static bool setup_fb(data_t *data, igt_output_t
> *output, igt_plane_t *plane,
>  
>  	ret = __kms_addfb(data->gfx_fd, data->gem_handle, w, h,
>  			  format, tiling, strides, offsets,
> -			  LOCAL_DRM_MODE_FB_MODIFIERS, &data-
> >fb.fb_id);
> +			  num_planes, LOCAL_DRM_MODE_FB_MODIFIERS,
> +			  &data->fb.fb_id);
>  
>  	if(ret < 0) {
>  		igt_info("Creating fb for format %s failed, return
> code %d\n",
> diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c
> index fb10d7ccf8bc..90904714283c 100644
> --- a/tests/kms_draw_crc.c
> +++ b/tests/kms_draw_crc.c
> @@ -156,6 +156,7 @@ static void get_method_crc(enum igt_draw_method
> method, uint32_t drm_format,
>  static bool format_is_supported(uint32_t format, uint64_t modifier)
>  {
>  	uint32_t gem_handle, fb_id;
> +	unsigned int offsets[4] = {};
>  	unsigned int strides[4] = {};
>  	int ret;
>  
> @@ -163,7 +164,7 @@ static bool format_is_supported(uint32_t format,
> uint64_t modifier)
>  						   format, modifier,
>  						   0, NULL,
> &strides[0], NULL);
>  	ret =  __kms_addfb(drm_fd, gem_handle, 64, 64,
> -			   format, modifier, strides, NULL,
> +			   format, modifier, strides, offsets, 1,
>  			   LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id);
>  	drmModeRmFB(drm_fd, fb_id);
>  	gem_close(drm_fd, gem_handle);
> diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
> index 1b7d8fb293ef..d06aa24b5ef2 100644
> --- a/tests/prime_vgem.c
> +++ b/tests/prime_vgem.c
> @@ -710,6 +710,7 @@ static void test_flip(int i915, int vgem,
> unsigned hang)
>  
>  	for (int i = 0; i < 2; i++) {
>  		uint32_t strides[4] = {};
> +		uint32_t offsets[4] = {};
>  		int fd;
>  
>  		bo[i].width = 1024;
> @@ -727,7 +728,7 @@ static void test_flip(int i915, int vgem,
> unsigned hang)
>  		do_or_die(__kms_addfb(i915, handle[i],
>  				      bo[i].width, bo[i].height,
>  				      DRM_FORMAT_XRGB8888,
> I915_TILING_NONE,
> -				      strides, NULL,
> +				      strides, offsets, 1,
>  				      LOCAL_DRM_MODE_FB_MODIFIERS,
> &fb_id[i]));
>  		igt_assert(fb_id[i]);
>  	}


More information about the igt-dev mailing list