[igt-dev] [PATCH i-g-t 15/25] lib/kms: Pass strides[] to __kms_addfb

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


Em Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Make __kms_addfb() usable with planar formats by passing in the
> stride for each plane.

I'm hoping later in this series we'll just use
drmModeAddFB2WithModifiers() :)

Or at least unify the Y vs X/linear cases below.

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                    |  7 ++++++-
>  lib/ioctl_wrappers.c            | 12 +++++++-----
>  lib/ioctl_wrappers.h            |  8 +++++---
>  tests/kms_available_modes_crc.c | 14 +++++++-------
>  tests/kms_draw_crc.c            |  6 +++---
>  tests/prime_vgem.c              |  8 ++++++--
>  6 files changed, 34 insertions(+), 21 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 0221a0b9b040..5e687b95e265 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -877,8 +877,13 @@ igt_create_fb_with_bo_size(int fd, int width,
> int height,
>  
>  	if (tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
>  	    tiling != LOCAL_I915_FORMAT_MOD_X_TILED) {
> +		uint32_t pitches[4];
> +
> +		for (i = 0; i < fb_num_planes(f); i++)
> +			pitches[i] = fb->stride;
> +
>  		do_or_die(__kms_addfb(fd, fb->gem_handle, width,
> height,
> -				      fb->stride, format, tiling,
> fb->offsets,
> +				      format, tiling, pitches, fb-
> >offsets,
>  				      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 d5d2a4e4c913..a34857266d92 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -1670,9 +1670,11 @@ void igt_require_fb_modifiers(int fd)
>  	igt_require(has_modifiers);
>  }
>  
> -int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t
> height,
> -		uint32_t stride, uint32_t pixel_format, uint64_t
> modifier,
> -		uint32_t *offsets, uint32_t flags, uint32_t *buf_id)
> +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)
>  {
>  	struct drm_mode_fb_cmd2 f;
>  	int ret, i;
> @@ -1686,12 +1688,12 @@ int __kms_addfb(int fd, uint32_t handle,
> uint32_t width, uint32_t height,
>  	f.pixel_format = pixel_format;
>  	f.flags = flags;
>  	f.handles[0] = handle;
> -	f.pitches[0] = stride;
> +	f.pitches[0] = strides[0];
>  	f.modifier[0] = modifier;
>  
>  	for (i = 1; i < 4 && offsets && offsets[i]; i++) {
>  		f.handles[i] = handle;
> -		f.pitches[i] = stride;
> +		f.pitches[i] = strides[i];
>  		f.modifier[i] = modifier;
>  		f.offsets[i] = offsets[i];
>  	}
> diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
> index 8e2cd380b575..67bf50562bf3 100644
> --- a/lib/ioctl_wrappers.h
> +++ b/lib/ioctl_wrappers.h
> @@ -235,9 +235,11 @@ void igt_require_fb_modifiers(int fd);
>   *
>   * Creates a framebuffer object.
>   */
> -int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t
> height,
> -		uint32_t stride, uint32_t pixel_format, uint64_t
> modifier,
> -		uint32_t *offsets, uint32_t flags, uint32_t
> *buf_id);
> +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);
>  
>  /**
>   * to_user_pointer:
> diff --git a/tests/kms_available_modes_crc.c
> b/tests/kms_available_modes_crc.c
> index b70ef5d7d4c0..1c843c6cf691 100644
> --- a/tests/kms_available_modes_crc.c
> +++ b/tests/kms_available_modes_crc.c
> @@ -255,7 +255,8 @@ static bool setup_fb(data_t *data, igt_output_t
> *output, igt_plane_t *plane,
>  	drmModeModeInfo *mode;
>  	uint64_t w, h;
>  	signed ret, gemsize = 0;
> -	unsigned tile_width, tile_height, stride;
> +	unsigned tile_width, tile_height;
> +	uint32_t strides[4] = {};
>  	uint32_t offsets[4] = {};
>  	uint64_t tiling;
>  	int bpp = 0;
> @@ -296,8 +297,8 @@ static bool setup_fb(data_t *data, igt_output_t
> *output, igt_plane_t *plane,
>  
>  	igt_get_fb_tile_size(data->gfx_fd, tiling, bpp,
>  			     &tile_width, &tile_height);
> -	stride = ALIGN(w * bpp / 8, tile_width);
> -	gemsize = data->size = stride * ALIGN(h, tile_height);
> +	strides[0] = ALIGN(w * bpp / 8, tile_width);
> +	gemsize = data->size = strides[0] * ALIGN(h, tile_height);
>  
>  	if (fillers[i].bpp == P010 || fillers[i].bpp == NV12) {
>  		offsets[1] = data->size;
> @@ -306,14 +307,13 @@ static bool setup_fb(data_t *data, igt_output_t
> *output, igt_plane_t *plane,
>  
>  	data->gem_handle = gem_create(data->gfx_fd, gemsize);
>  	ret = __gem_set_tiling(data->gfx_fd, data->gem_handle,
> -			       igt_fb_mod_to_tiling(tiling),
> stride);
> +			       igt_fb_mod_to_tiling(tiling),
> strides[0]);
>  
>  	igt_assert_eq(ret, 0);
>  
>  	ret = __kms_addfb(data->gfx_fd, data->gem_handle, w, h,
> -			  stride, format, tiling,
> -			  offsets, LOCAL_DRM_MODE_FB_MODIFIERS,
> -			  &data->fb.fb_id);
> +			  format, tiling, strides, offsets,
> +			  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 86dcf39285f3..fb10d7ccf8bc 100644
> --- a/tests/kms_draw_crc.c
> +++ b/tests/kms_draw_crc.c
> @@ -156,14 +156,14 @@ 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 stride;
> +	unsigned int strides[4] = {};
>  	int ret;
>  
>  	gem_handle = igt_create_bo_with_dimensions(drm_fd, 64, 64,
>  						   format, modifier,
> -						   0, NULL, &stride,
> NULL);
> +						   0, NULL,
> &strides[0], NULL);
>  	ret =  __kms_addfb(drm_fd, gem_handle, 64, 64,
> -			   stride, format, modifier, NULL,
> +			   format, modifier, strides, NULL,
>  			   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 763c62e606f6..1b7d8fb293ef 100644
> --- a/tests/prime_vgem.c
> +++ b/tests/prime_vgem.c
> @@ -709,6 +709,7 @@ static void test_flip(int i915, int vgem,
> unsigned hang)
>  	signal(SIGHUP, sighandler);
>  
>  	for (int i = 0; i < 2; i++) {
> +		uint32_t strides[4] = {};
>  		int fd;
>  
>  		bo[i].width = 1024;
> @@ -721,9 +722,12 @@ static void test_flip(int i915, int vgem,
> unsigned hang)
>  		igt_assert(handle[i]);
>  		close(fd);
>  
> +		strides[0] = bo[i].pitch;
> +
>  		do_or_die(__kms_addfb(i915, handle[i],
> -				      bo[i].width, bo[i].height,
> bo[i].pitch,
> -				      DRM_FORMAT_XRGB8888,
> I915_TILING_NONE, NULL,
> +				      bo[i].width, bo[i].height,
> +				      DRM_FORMAT_XRGB8888,
> I915_TILING_NONE,
> +				      strides, NULL,
>  				      LOCAL_DRM_MODE_FB_MODIFIERS,
> &fb_id[i]));
>  		igt_assert(fb_id[i]);
>  	}


More information about the igt-dev mailing list