summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@bootlin.com>2019-02-08 14:18:54 +0100
committerPaul Kocialkowski <paul.kocialkowski@bootlin.com>2019-02-11 10:53:07 +0100
commitd6e7907dcb71f97691f8bceb9b4206c077ff9802 (patch)
treeacbf0af294b0e9a014ac93397e52eb9b18857b7e
parent77c6f0abef7136b45b32db4064531cd098de9f22 (diff)
igt: fb: Account for all planes bpp
When allocating a dumb buffer for a format with multiple plane, we need to account for all plane's bpp in order to allocate the proper size. Let's add all the planes bpp and use the result to allocate our buffer. Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Lyude Paul <lyude@redhat.com>
-rw-r--r--lib/igt_fb.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ca4865519..ca19c034f 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -528,6 +528,9 @@ static void clear_yuv_buffer(struct igt_fb *fb)
/* helpers to create nice-looking framebuffers */
static int create_bo_for_fb(struct igt_fb *fb)
{
+ const struct format_desc_struct *fmt = lookup_drm_format(fb->drm_format);
+ unsigned int bpp = 0;
+ unsigned int plane;
int fd = fb->fd;
if (fb->tiling || fb->size || fb->strides[0] || igt_format_is_yuv(fb->drm_format)) {
@@ -570,11 +573,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
igt_assert(fb->strides[0] == 0);
fb->size = calc_fb_size(fb);
+ for (plane = 0; plane < fb->num_planes; plane++)
+ bpp += DIV_ROUND_UP(fb->plane_bpp[plane],
+ plane ? fmt->hsub * fmt->vsub : 1);
fb->is_dumb = true;
fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height,
- fb->plane_bpp[0],
- &fb->strides[0], &fb->size);
+ bpp, &fb->strides[0], &fb->size);
return fb->gem_handle;
}