summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOscar Mateo <oscar.mateo@intel.com>2014-05-16 14:07:11 +0100
committerVille Syrjälä <ville.syrjala@linux.intel.com>2014-05-16 17:45:14 +0300
commit5bdd4d9b5e371735e0d76339989a9af9bd046702 (patch)
treedaf23368ff2c63bc2840791af3b836c7aca65c84 /lib
parentace8a9e10c7516c7298658a73c3096aa21b5986e (diff)
lib/igt_fb: igt_create_fb_with_bo_size
Useful for testing bigger/smaller fb-wrapped buffer objects. Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_fb.c45
-rw-r--r--lib/igt_fb.h3
2 files changed, 41 insertions, 7 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 2149fcd0..f43af930 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 e8bb2a86..c6558bfc 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,