From 77c6f0abef7136b45b32db4064531cd098de9f22 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Fri, 8 Feb 2019 14:18:53 +0100 Subject: igt: fb: Add size checks and recalculation before dumb allocation Since we want to use the dumb buffers to store frames in formats with multiple planes, we need to add checks for unsupported corner cases, and we need to calculate the offsets and sizes of each planes. Let's use calc_fb_size for that. Signed-off-by: Maxime Ripard Reviewed-by: Paul Kocialkowski Reviewed-by: Lyude Paul --- lib/igt_fb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/igt_fb.c b/lib/igt_fb.c index c61e6805f..ca4865519 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -561,6 +561,16 @@ static int create_bo_for_fb(struct igt_fb *fb) } } + /* + * The current dumb buffer allocation API doesn't really allow to + * specify a custom size or stride. Yet the caller is free to specify + * them, so we need to make sure to error out in this case. + */ + igt_assert(fb->size == 0); + igt_assert(fb->strides[0] == 0); + + fb->size = calc_fb_size(fb); + fb->is_dumb = true; fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height, fb->plane_bpp[0], -- cgit v1.2.3