intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Intel GFX discussion <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t] lib: Pass tiling constant where that's expected
Date: Thu, 10 Nov 2016 16:17:12 +0000	[thread overview]
Message-ID: <8e48df8e-f3a0-9f8a-40f6-f217b7efe00b@linux.intel.com> (raw)
In-Reply-To: <1478772741-5745-1-git-send-email-tomeu.vizoso@collabora.com>


Hi,

On 10/11/2016 10:12, Tomeu Vizoso wrote:
> We were passing in two places a framebuffer modifier constant instead of
> a tiling constant.
>
> Also adds igt_fb_mod_to_tiling so tests can do that by themselves.
>
> Cc: Tvrtko Ursulin <tursulin@ursulin.net>
> Fixes: 8a1a38661f56 ("lib: Add igt_create_bo_with_dimensions")
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> ---
>  lib/igt_fb.c     | 48 +++++++++++++++++++++++++++++-------------------
>  lib/igt_fb.h     |  2 ++
>  tests/kms_flip.c |  2 +-
>  3 files changed, 32 insertions(+), 20 deletions(-)
>
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 47472f4399e9..bb87869f18ce 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -180,6 +180,32 @@ void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t tiling,
>  	*size_ret = size;
>  }
>
> +/**
> + * igt_fb_mod_to_tiling:
> + * @modifier: DRM framebuffer modifier
> + *
> + * This function converts a DRM framebuffer modifier to its corresponding
> + * tiling constant.
> + *
> + * Returns:
> + * A tiling constant
> + */
> +uint64_t igt_fb_mod_to_tiling(uint64_t modifier)
> +{
> +	switch (modifier) {
> +	case LOCAL_DRM_FORMAT_MOD_NONE:
> +		return I915_TILING_NONE;
> +	case LOCAL_I915_FORMAT_MOD_X_TILED:
> +		return I915_TILING_X;
> +	case LOCAL_I915_FORMAT_MOD_Y_TILED:
> +		return I915_TILING_Y;
> +	case LOCAL_I915_FORMAT_MOD_Yf_TILED:
> +		return I915_TILING_Yf;
> +	default:
> +		igt_assert(0);
> +	}
> +}
> +
>  /* helpers to create nice-looking framebuffers */
>  static int create_bo_for_fb(int fd, int width, int height, uint32_t format,
>  			    uint64_t tiling, unsigned size, unsigned stride,
> @@ -206,7 +232,7 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format,
>  			uint32_t *ptr;
>
>  			bo = gem_create(fd, size);
> -			gem_set_tiling(fd, bo, tiling, stride);
> +			gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride);

This is still not correct because the kernel does not know about Yf or 
Ys in the set_tiling ioctl.

Regards,

Tvrtko

>
>  			/* Ensure the framebuffer is preallocated */
>  			ptr = gem_mmap__gtt(fd, bo, size, PROT_READ);
> @@ -956,27 +982,11 @@ struct fb_blit_upload {
>  	} linear;
>  };
>
> -static unsigned int fb_mod_to_obj_tiling(uint64_t fb_mod)
> -{
> -	switch (fb_mod) {
> -	case LOCAL_DRM_FORMAT_MOD_NONE:
> -		return I915_TILING_NONE;
> -	case LOCAL_I915_FORMAT_MOD_X_TILED:
> -		return I915_TILING_X;
> -	case LOCAL_I915_FORMAT_MOD_Y_TILED:
> -		return I915_TILING_Y;
> -	case LOCAL_I915_FORMAT_MOD_Yf_TILED:
> -		return I915_TILING_Yf;
> -	default:
> -		igt_assert(0);
> -	}
> -}
> -
>  static void destroy_cairo_surface__blit(void *arg)
>  {
>  	struct fb_blit_upload *blit = arg;
>  	struct igt_fb *fb = blit->fb;
> -	unsigned int obj_tiling = fb_mod_to_obj_tiling(fb->tiling);
> +	unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->tiling);
>
>  	munmap(blit->linear.map, blit->linear.size);
>  	fb->cairo_surface = NULL;
> @@ -1005,7 +1015,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)
>  {
>  	struct fb_blit_upload *blit;
>  	cairo_format_t cairo_format;
> -	unsigned int obj_tiling = fb_mod_to_obj_tiling(fb->tiling);
> +	unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->tiling);
>
>  	blit = malloc(sizeof(*blit));
>  	igt_assert(blit);
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index e1c4c1fa1f73..4a680cefb16d 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -129,6 +129,8 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, uint32_t format
>  				  unsigned *stride_ret, unsigned *size_ret,
>  				  bool *is_dumb);
>
> +uint64_t igt_fb_mod_to_tiling(uint64_t modifier);
> +
>  /* cairo-based painting */
>  cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb);
>  void igt_paint_color(cairo_t *cr, int x, int y, int w, int h,
> diff --git a/tests/kms_flip.c b/tests/kms_flip.c
> index 6a1549e7b857..2a9fe2e3f702 100644
> --- a/tests/kms_flip.c
> +++ b/tests/kms_flip.c
> @@ -370,7 +370,7 @@ static int _emit_dummy_load__rcs(struct test_output *o, int limit, int timeout)
>  	sb[2].bo = gem_handle_to_libdrm_bo(bufmgr, drm_fd, "imported", fb_info->gem_handle);
>  	igt_assert(sb[2].bo);
>  	sb[2].size = sb[2].bo->size;
> -	sb[2].tiling = fb_info->tiling;
> +	sb[2].tiling = igt_fb_mod_to_tiling(fb_info->tiling);
>  	sb[2].data = NULL;
>  	sb[2].num_tiles = sb[2].bo->size;
>  	sb[2].stride = fb_info->stride;
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2016-11-10 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10 10:12 [PATCH i-g-t] lib: Pass tiling constant where that's expected Tomeu Vizoso
2016-11-10 16:17 ` Tvrtko Ursulin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e48df8e-f3a0-9f8a-40f6-f217b7efe00b@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tomeu.vizoso@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).