Though right now modifiers are only used to specify tiling, there are different constants for them and naming them differently should help with not mixing them. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@xxxxxxxxxxxxx> --- lib/igt_fb.c | 83 +++++++++++++++++++++++++++-------------------------- lib/igt_fb.h | 4 +-- tests/kms_fbc_crc.c | 8 +++--- tests/kms_flip.c | 12 ++++---- 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index bb87869f18ce..19981f0ddf6c 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -74,10 +74,10 @@ static struct format_desc_struct { #define for_each_format(f) \ for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++) -static void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, +static void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp, unsigned *width_ret, unsigned *height_ret) { - switch (tiling) { + switch (modifier) { case LOCAL_DRM_FORMAT_MOD_NONE: *width_ret = 64; *height_ret = 1; @@ -137,22 +137,22 @@ static void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp, * @width: width of the framebuffer in pixels * @height: height of the framebuffer in pixels * @bpp: bytes per pixel of the framebuffer - * @tiling: tiling layout of the framebuffer (as framebuffer modifier) + * @modifier: framebuffer modifier * @size_ret: returned size for the framebuffer * @stride_ret: returned stride for the framebuffer * * This function returns valid stride and size values for a framebuffer with the * specified parameters. */ -void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t tiling, +void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t modifier, unsigned *size_ret, unsigned *stride_ret) { unsigned int tile_width, tile_height, stride, size; int byte_width = width * (bpp / 8); - igt_get_fb_tile_size(fd, tiling, bpp, &tile_width, &tile_height); + igt_get_fb_tile_size(fd, modifier, bpp, &tile_width, &tile_height); - if (tiling != LOCAL_DRM_FORMAT_MOD_NONE && + if (modifier != LOCAL_DRM_FORMAT_MOD_NONE && intel_gen(intel_get_drm_devid(fd)) <= 3) { int v; @@ -208,17 +208,17 @@ uint64_t igt_fb_mod_to_tiling(uint64_t modifier) /* 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, + uint64_t modifier, unsigned size, unsigned stride, unsigned *size_ret, unsigned *stride_ret, bool *is_dumb) { int bpp = igt_drm_format_to_bpp(format); int bo; - if (tiling || size || stride) { + if (modifier || size || stride) { unsigned calculated_size, calculated_stride; - igt_calc_fb_size(fd, width, height, bpp, tiling, + igt_calc_fb_size(fd, width, height, bpp, modifier, &calculated_size, &calculated_stride); if (stride == 0) stride = calculated_stride; @@ -229,10 +229,11 @@ static int create_bo_for_fb(int fd, int width, int height, uint32_t format, *is_dumb = false; if (is_i915_device(fd)) { + unsigned int tiling = igt_fb_mod_to_tiling(modifier); uint32_t *ptr; bo = gem_create(fd, size); - gem_set_tiling(fd, bo, igt_fb_mod_to_tiling(tiling), stride); + gem_set_tiling(fd, bo, tiling, stride); /* Ensure the framebuffer is preallocated */ ptr = gem_mmap__gtt(fd, bo, size, PROT_READ); @@ -598,7 +599,7 @@ void igt_paint_image(cairo_t *cr, const char *filename, * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code - * @tiling: tiling layout of the framebuffer (as framebuffer modifier) + * @modifier: framebuffer modifier * @fb: pointer to an #igt_fb structure * @bo_size: size of the backing bo (0 for automatic size) * @bo_stride: stride of the backing bo (0 for automatic stride) @@ -615,7 +616,7 @@ void igt_paint_image(cairo_t *cr, const char *filename, */ unsigned int igt_create_fb_with_bo_size(int fd, int width, int height, - uint32_t format, uint64_t tiling, + uint32_t format, uint64_t modifier, struct igt_fb *fb, unsigned bo_size, unsigned bo_stride) { @@ -623,9 +624,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height, memset(fb, 0, sizeof(*fb)); - igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%d)\n", - __func__, width, height, format, tiling, bo_size); - fb->gem_handle = create_bo_for_fb(fd, width, height, format, tiling, + igt_debug("%s(width=%d, height=%d, format=0x%x, modifier=0x%"PRIx64", size=%d)\n", + __func__, width, height, format, modifier, bo_size); + fb->gem_handle = create_bo_for_fb(fd, width, height, format, modifier, bo_size, bo_stride, &fb->size, &fb->stride, &fb->is_dumb); igt_assert(fb->gem_handle > 0); @@ -633,10 +634,10 @@ igt_create_fb_with_bo_size(int fd, int width, int height, igt_debug("%s(handle=%d, pitch=%d)\n", __func__, fb->gem_handle, fb->stride); - if (tiling != LOCAL_DRM_FORMAT_MOD_NONE && - tiling != LOCAL_I915_FORMAT_MOD_X_TILED) { + if (modifier != LOCAL_DRM_FORMAT_MOD_NONE && + modifier != LOCAL_I915_FORMAT_MOD_X_TILED) { do_or_die(__kms_addfb(fd, fb->gem_handle, width, height, - fb->stride, format, tiling, + fb->stride, format, modifier, LOCAL_DRM_MODE_FB_MODIFIERS, &fb_id)); } else { uint32_t handles[4]; @@ -657,7 +658,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, fb->width = width; fb->height = height; - fb->tiling = tiling; + fb->modifier = modifier; fb->drm_format = format; fb->fb_id = fb_id; fb->fd = fd; @@ -671,7 +672,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height, * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code - * @tiling: tiling layout of the framebuffer + * @modifier: framebuffer modifier * @fb: pointer to an #igt_fb structure * * This function allocates a gem buffer object suitable to back a framebuffer @@ -685,9 +686,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height, * The kms id of the created framebuffer. */ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, - uint64_t tiling, struct igt_fb *fb) + uint64_t modifier, struct igt_fb *fb) { - return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb, + return igt_create_fb_with_bo_size(fd, width, height, format, modifier, fb, 0, 0); } @@ -697,7 +698,7 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code - * @tiling: tiling layout of the framebuffer + * @modifier: framebuffer modifier * @r: red value to use as fill color * @g: green value to use as fill color * @b: blue value to use as fill color @@ -715,14 +716,14 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, * failure. */ unsigned int igt_create_color_fb(int fd, int width, int height, - uint32_t format, uint64_t tiling, + uint32_t format, uint64_t modifier, double r, double g, double b, struct igt_fb *fb /* out */) { unsigned int fb_id; cairo_t *cr; - fb_id = igt_create_fb(fd, width, height, format, tiling, fb); + fb_id = igt_create_fb(fd, width, height, format, modifier, fb); igt_assert(fb_id); cr = igt_get_cairo_ctx(fd, fb); @@ -739,7 +740,7 @@ unsigned int igt_create_color_fb(int fd, int width, int height, * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code - * @tiling: tiling layout of the framebuffer + * @modifier: framebuffer modifier * @fb: pointer to an #igt_fb structure * * This function allocates a gem buffer object suitable to back a framebuffer @@ -754,13 +755,13 @@ unsigned int igt_create_color_fb(int fd, int width, int height, * failure. */ unsigned int igt_create_pattern_fb(int fd, int width, int height, - uint32_t format, uint64_t tiling, + uint32_t format, uint64_t modifier, struct igt_fb *fb /* out */) { unsigned int fb_id; cairo_t *cr; - fb_id = igt_create_fb(fd, width, height, format, tiling, fb); + fb_id = igt_create_fb(fd, width, height, format, modifier, fb); igt_assert(fb_id); cr = igt_get_cairo_ctx(fd, fb); @@ -777,7 +778,7 @@ unsigned int igt_create_pattern_fb(int fd, int width, int height, * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code - * @tiling: tiling layout of the framebuffer + * @modifier: framebuffer modifier * @r: red value to use as fill color * @g: green value to use as fill color * @b: blue value to use as fill color @@ -796,14 +797,14 @@ unsigned int igt_create_pattern_fb(int fd, int width, int height, * failure. */ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, - uint32_t format, uint64_t tiling, + uint32_t format, uint64_t modifier, double r, double g, double b, struct igt_fb *fb /* out */) { unsigned int fb_id; cairo_t *cr; - fb_id = igt_create_fb(fd, width, height, format, tiling, fb); + fb_id = igt_create_fb(fd, width, height, format, modifier, fb); igt_assert(fb_id); cr = igt_get_cairo_ctx(fd, fb); @@ -821,7 +822,7 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, * @width: width of the framebuffer in pixel or 0 * @height: height of the framebuffer in pixel or 0 * @format: drm fourcc pixel format code - * @tiling: tiling layout of the framebuffer + * @modifier: framebuffer modifier * @filename: filename of the png image to draw * @fb: pointer to an #igt_fb structure * @@ -833,7 +834,7 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height, * failure. */ unsigned int igt_create_image_fb(int fd, int width, int height, - uint32_t format, uint64_t tiling, + uint32_t format, uint64_t modifier, const char *filename, struct igt_fb *fb /* out */) { @@ -849,7 +850,7 @@ unsigned int igt_create_image_fb(int fd, int width, int height, height = cairo_image_surface_get_height(image); cairo_surface_destroy(image); - fb_id = igt_create_fb(fd, width, height, format, tiling, fb); + fb_id = igt_create_fb(fd, width, height, format, modifier, fb); cr = igt_get_cairo_ctx(fd, fb); igt_paint_image(cr, filename, 0, 0, width, height); @@ -926,7 +927,7 @@ static void stereo_fb_layout_from_mode(struct stereo_fb_layout *layout, * @drm_fd: open i915 drm file descriptor * @mode: A stereo 3D mode. * @format: drm fourcc pixel format code - * @tiling: tiling layout of the framebuffer + * @modifier: framebuffer modifier * * Create a framebuffer for use with the stereo 3D mode specified by @mode. * @@ -935,7 +936,7 @@ static void stereo_fb_layout_from_mode(struct stereo_fb_layout *layout, * failure. */ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, - uint32_t format, uint64_t tiling) + uint32_t format, uint64_t modifier) { struct stereo_fb_layout layout; cairo_t *cr; @@ -944,7 +945,7 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, stereo_fb_layout_from_mode(&layout, mode); fb_id = igt_create_fb(drm_fd, layout.fb_width, layout.fb_height, format, - tiling, &fb); + modifier, &fb); cr = igt_get_cairo_ctx(drm_fd, &fb); igt_paint_image(cr, "1080p-left.png", @@ -986,7 +987,7 @@ static void destroy_cairo_surface__blit(void *arg) { struct fb_blit_upload *blit = arg; struct igt_fb *fb = blit->fb; - unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->tiling); + unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->modifier); munmap(blit->linear.map, blit->linear.size); fb->cairo_surface = NULL; @@ -1015,7 +1016,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 = igt_fb_mod_to_tiling(fb->tiling); + unsigned int obj_tiling = igt_fb_mod_to_tiling(fb->modifier); blit = malloc(sizeof(*blit)); igt_assert(blit); @@ -1127,8 +1128,8 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) static cairo_surface_t *get_cairo_surface(int fd, struct igt_fb *fb) { if (fb->cairo_surface == NULL) { - if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED || - fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) + if (fb->modifier == LOCAL_I915_FORMAT_MOD_Y_TILED || + fb->modifier == LOCAL_I915_FORMAT_MOD_Yf_TILED) create_cairo_surface__blit(fd, fb); else create_cairo_surface__gtt(fd, fb); diff --git a/lib/igt_fb.h b/lib/igt_fb.h index 4a680cefb16d..fbf02718f8ad 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -53,7 +53,7 @@ typedef struct _cairo cairo_t; * @width: width in pixels * @height: height in pixels * @stride: line stride in bytes - * @tiling: tiling mode as a DRM framebuffer modifier + * @modifier: DRM framebuffer modifier * @size: size in bytes of the underlying backing storage * @cairo_surface: optionally attached cairo drawing surface * @domain: current domain for cache flushing tracking on i915.ko @@ -69,7 +69,7 @@ typedef struct igt_fb { int width; int height; unsigned int stride; - uint64_t tiling; + uint64_t modifier; unsigned int size; cairo_surface_t *cairo_surface; unsigned int domain; diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c index 2a2c93f7ca85..06bce63cc9ca 100644 --- a/tests/kms_fbc_crc.c +++ b/tests/kms_fbc_crc.c @@ -100,7 +100,7 @@ static void fill_blt(data_t *data, pitch = fb->stride; flags = XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB; - if (fb->tiling && batch->gen >= 4) { + if (fb->modifier && batch->gen >= 4) { flags |= XY_COLOR_BLT_TILED; pitch /= 4; } @@ -333,15 +333,15 @@ static void create_fbs(data_t *data, bool tiled, struct igt_fb *fbs) { int rc; drmModeModeInfo *mode = igt_output_get_mode(data->output); - uint64_t tiling = tiled ? LOCAL_I915_FORMAT_MOD_X_TILED : + uint64_t modifier = tiled ? LOCAL_I915_FORMAT_MOD_X_TILED : LOCAL_DRM_FORMAT_MOD_NONE; rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, - DRM_FORMAT_XRGB8888, tiling, + DRM_FORMAT_XRGB8888, modifier, 0.0, 0.0, 0.0, &fbs[0]); igt_assert(rc); rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, - DRM_FORMAT_XRGB8888, tiling, + DRM_FORMAT_XRGB8888, modifier, 0.1, 0.1, 0.1, &fbs[1]); igt_assert(rc); } diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 2a9fe2e3f702..0ca81d57a67a 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 = igt_fb_mod_to_tiling(fb_info->tiling); + sb[2].tiling = igt_fb_mod_to_tiling(fb_info->modifier); sb[2].data = NULL; sb[2].num_tiles = sb[2].bo->size; sb[2].stride = fb_info->stride; @@ -1384,7 +1384,7 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, char test_name[128]; unsigned elapsed; unsigned bo_size = 0; - uint64_t tiling; + uint64_t modifier; int i; switch (crtc_count) { @@ -1426,9 +1426,9 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, if (o->flags & TEST_PAN) o->fb_width *= 2; - tiling = LOCAL_DRM_FORMAT_MOD_NONE; + modifier = LOCAL_DRM_FORMAT_MOD_NONE; if (o->flags & TEST_FENCE_STRESS) - tiling = LOCAL_I915_FORMAT_MOD_X_TILED; + modifier = LOCAL_I915_FORMAT_MOD_X_TILED; /* 256 MB is usually the maximum mappable aperture, * (make it 4x times that to ensure failure) */ @@ -1439,10 +1439,10 @@ static void run_test_on_crtc_set(struct test_output *o, int *crtc_idxs, o->fb_ids[0] = igt_create_fb(drm_fd, o->fb_width, o->fb_height, igt_bpp_depth_to_drm_format(o->bpp, o->depth), - tiling, &o->fb_info[0]); + modifier, &o->fb_info[0]); o->fb_ids[1] = igt_create_fb_with_bo_size(drm_fd, o->fb_width, o->fb_height, igt_bpp_depth_to_drm_format(o->bpp, o->depth), - tiling, &o->fb_info[1], bo_size, 0); + modifier, &o->fb_info[1], bo_size, 0); igt_assert(o->fb_ids[0]); igt_assert(o->fb_ids[1]); -- 2.7.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx