summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaulo Zanoni <paulo.r.zanoni@intel.com>2015-11-05 16:39:00 -0200
committerPaulo Zanoni <paulo.r.zanoni@intel.com>2015-11-27 09:57:35 -0200
commitd63413771fc9bc77e89dacecbc1bae6192444000 (patch)
treec4de5f0c063e2b2842f16c5c03c595cda6fe1559 /lib
parent1c68a71acc1f9ddd98bc1bd6ff1da700442c21aa (diff)
lib/igt_fb: also pass the stride to igt_create_fb_with_bo_size()
If the caller is going to specify a custom size, it's likely that he will also specify a custom stride. The automatic stride picked by create_bo_for_fb() is too huge for tiled buffers, so if the caller wants smaller buffers, then he'll need a smaller stride too, otherwise the Kernel will reject the addfb IOCTL due to stride * height being bigger than the size. I want to make tests/kms_frontbuffer_tracking use igt_create_fb_with_bo_size() so I can provide smaller buffers that will fit into the CFB. I'm also planning to make all frontbuffers with the same width/height/format have the same stride and size regardless of tiling method so I can exercise specific code paths. Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_fb.c25
-rw-r--r--lib/igt_fb.h3
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 2818c9fa..3ea9915c 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -76,9 +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,
uint64_t tiling, unsigned bo_size,
- uint32_t *gem_handle_ret,
- unsigned *size_ret,
- unsigned *stride_ret)
+ unsigned bo_stride, uint32_t *gem_handle_ret,
+ unsigned *size_ret, unsigned *stride_ret)
{
uint32_t gem_handle;
int size, ret = 0;
@@ -110,12 +109,16 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,
if (bo_size == 0)
bo_size = size;
+ if (bo_stride == 0)
+ bo_stride = stride;
+
gem_handle = gem_create(fd, bo_size);
if (tiling == LOCAL_I915_FORMAT_MOD_X_TILED)
- ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, stride);
+ ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X,
+ bo_stride);
- *stride_ret = stride;
+ *stride_ret = bo_stride;
*size_ret = bo_size;
*gem_handle_ret = gem_handle;
@@ -401,6 +404,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
* @tiling: tiling layout of the framebuffer (as 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)
*
* 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
@@ -415,7 +419,8 @@ 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,
- struct igt_fb *fb, unsigned bo_size)
+ struct igt_fb *fb, unsigned bo_size,
+ unsigned bo_stride)
{
uint32_t fb_id;
int bpp;
@@ -427,7 +432,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
igt_debug("%s(width=%d, height=%d, format=0x%x [bpp=%d], tiling=0x%"PRIx64", size=%d)\n",
__func__, width, height, format, bpp, tiling, bo_size);
do_or_die(create_bo_for_fb(fd, width, height, bpp, tiling, bo_size,
- &fb->gem_handle, &fb->size, &fb->stride));
+ bo_stride, &fb->gem_handle, &fb->size,
+ &fb->stride));
igt_debug("%s(handle=%d, pitch=%d)\n",
__func__, fb->gem_handle, fb->stride);
@@ -485,7 +491,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
uint64_t tiling, struct igt_fb *fb)
{
- return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb, 0);
+ return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb,
+ 0, 0);
}
/**
@@ -714,7 +721,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)
*/
bpp = igt_drm_format_to_bpp(fb->drm_format);
ret = create_bo_for_fb(fd, fb->width, fb->height, bpp,
- LOCAL_DRM_FORMAT_MOD_NONE, 0,
+ LOCAL_DRM_FORMAT_MOD_NONE, 0, 0,
&blit->linear.handle,
&blit->linear.size,
&blit->linear.stride);
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index a07acd24..37892b50 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -72,7 +72,8 @@ enum igt_text_align {
unsigned int
igt_create_fb_with_bo_size(int fd, int width, int height,
uint32_t format, uint64_t tiling,
- struct igt_fb *fb, unsigned bo_size);
+ struct igt_fb *fb, unsigned bo_size,
+ unsigned bo_stride);
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
uint64_t tiling, struct igt_fb *fb);
unsigned int igt_create_color_fb(int fd, int width, int height,