diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2016-11-10 10:25:24 +0100 |
---|---|---|
committer | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2016-11-10 11:14:44 +0100 |
commit | ae6496307c3ebe6409eb9b9f60355516faeefa88 (patch) | |
tree | f72d4308f67d4d073af9c3aa17540c226bb86a07 /lib/igt_fb.c | |
parent | d0795466cdc983c6bf0af257af081b5f12d58c6e (diff) |
lib: Pass tiling constant where that's expected
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>
Diffstat (limited to 'lib/igt_fb.c')
-rw-r--r-- | lib/igt_fb.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 47472f43..bb87869f 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); /* 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); |