From: Oscar Mateo <oscar.mateo@xxxxxxxxx> Useful for testing bigger/smaller fb-wrapped buffer objects. Cc: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> Signed-off-by: Oscar Mateo <oscar.mateo@xxxxxxxxx> --- lib/igt_fb.c | 45 ++++++++++++++++++++++++++++++++++++++------- lib/igt_fb.h | 3 +++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index 2149fcd..f43af93 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -76,7 +76,8 @@ static struct format_desc_struct { /* helpers to create nice-looking framebuffers */ static int create_bo_for_fb(int fd, int width, int height, int bpp, bool tiled, uint32_t *gem_handle_ret, - unsigned *size_ret, unsigned *stride_ret) + unsigned *size_ret, unsigned *stride_ret, + unsigned bo_size) { uint32_t gem_handle; int size, ret = 0; @@ -106,7 +107,9 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp, size = stride * height; } - gem_handle = gem_create(fd, size); + if (bo_size == 0) + bo_size = size; + gem_handle = gem_create(fd, bo_size); if (tiled) ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, stride); @@ -376,17 +379,18 @@ void igt_paint_image(cairo_t *cr, const char *filename, } /** - * igt_create_fb: + * igt_create_fb_with_bo_size: * @fd: open i915 drm file descriptor * @width: width of the framebuffer in pixel * @height: height of the framebuffer in pixel * @format: drm fourcc pixel format code * @tiled: X-tiled or linear framebuffer * @fb: pointer to an #igt_fb structure + * @bo_size: size of the backing bo (0 for minimum needed size) * * This function allocates a gem buffer object suitable to back a framebuffer * with the requested properties and then wraps it up in a drm framebuffer - * object. All metadata is stored in @fb. + * object of the requested size. All metadata is stored in @fb. * * The backing storage of the framebuffer is filled with all zeros, i.e. black * for rgb pixel formats. @@ -395,8 +399,9 @@ void igt_paint_image(cairo_t *cr, const char *filename, * The kms id of the created framebuffer on success or a negative error code on * failure. */ -unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, - bool tiled, struct igt_fb *fb) +unsigned int igt_create_fb_with_bo_size(int fd, int width, int height, + uint32_t format, bool tiled, + struct igt_fb *fb, unsigned bo_size) { uint32_t handles[4]; uint32_t pitches[4]; @@ -409,7 +414,7 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, bpp = igt_drm_format_to_bpp(format); ret = create_bo_for_fb(fd, width, height, bpp, tiled, &fb->gem_handle, - &fb->size, &fb->stride); + &fb->size, &fb->stride, bo_size); if (ret < 0) return ret; @@ -435,6 +440,32 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, } /** + * igt_create_fb: + * @fd: open i915 drm file descriptor + * @width: width of the framebuffer in pixel + * @height: height of the framebuffer in pixel + * @format: drm fourcc pixel format code + * @tiled: X-tiled or linear framebuffer + * @fb: pointer to an #igt_fb structure + * + * This function allocates a gem buffer object suitable to back a framebuffer + * with the requested properties and then wraps it up in a drm framebuffer + * object. All metadata is stored in @fb. + * + * The backing storage of the framebuffer is filled with all zeros, i.e. black + * for rgb pixel formats. + * + * Returns: + * The kms id of the created framebuffer on success or a negative error code on + * failure. + */ +unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, + bool tiled, struct igt_fb *fb) +{ + return igt_create_fb_with_bo_size(fd, width, height, format, tiled, fb, 0); +} + +/** * igt_create_color_fb: * @fd: open i915 drm file descriptor * @width: width of the framebuffer in pixel diff --git a/lib/igt_fb.h b/lib/igt_fb.h index e8bb2a8..c6558bf 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -62,6 +62,9 @@ enum igt_text_align { align_hcenter = 0x08, }; +unsigned int igt_create_fb_with_bo_size(int fd, int width, int height, + uint32_t format, bool tiled, + struct igt_fb *fb, unsigned bo_size); unsigned int igt_create_fb(int fd, int width, int height, uint32_t format, bool tiled, struct igt_fb *fb); unsigned int igt_create_color_fb(int fd, int width, int height, -- 1.9.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx