summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Matheus Andrade Torrente <igormtorrente@gmail.com>2021-10-07 14:20:11 -0300
committerPetri Latvala <petri.latvala@intel.com>2021-10-08 13:25:08 +0300
commitb232a092b9e1b10a8be13601acaa440903b226bc (patch)
treea12acd360976cad2585d069bc1af65c25e5dcd6f
parent4bb153a5ba98baa14e04b079d0523913bf3e0344 (diff)
tests/kms_writeback.c: fix the `fill_fb` function
Currently, the `fill_fb` function, instead of filling the framebuffer with the whole pixel, is only filling it with the rightmost byte. This is happening because, even though the memset accepts an int as a parameter, it's casting the value to unsigned char and will fill the memory with this 8 bits value. If we setup the pixel to 0xff0000|f0|, the buffer will filled with: | addr | = 0f | addr + 1 | = 0f | addr + 2 | = 0f | addr + 3 | = 0f ... | addr + N | = 0f This patch address this issue by manually copying the entire integer. Signed-off-by: Igor Torrente <igormtorrente@gmail.com> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
-rw-r--r--tests/kms_writeback.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
index 60dbda2a..a033b44f 100644
--- a/tests/kms_writeback.c
+++ b/tests/kms_writeback.c
@@ -227,14 +227,17 @@ static void writeback_fb_id(igt_output_t *output, igt_fb_t *valid_fb, igt_fb_t *
static void fill_fb(igt_fb_t *fb, uint32_t pixel)
{
- void *ptr;
+ uint32_t *ptr;
+ int64_t pixel_count, i;
igt_assert(fb->drm_format == DRM_FORMAT_XRGB8888);
ptr = igt_fb_map_buffer(fb->fd, fb);
igt_assert(ptr);
- memset(ptr, pixel, fb->strides[0] * fb->height);
+ pixel_count = fb->strides[0] * fb->height / sizeof(uint32_t);
+ for (i = 0; i < pixel_count; i++)
+ ptr[i] = pixel;
igt_fb_unmap_buffer(fb, ptr);
}