From acaaa8eaf2d02357dd6e05a09ff5fd7cdc085daf Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Thu, 27 Dec 2018 15:57:37 +0100 Subject: chamelium: Pass and use stride for xr24 pattern paint Using the width from the selected mode is not sufficient to correctly paint a pattern on the framebuffer memory: the stride also has to be taken in account for proper line start alignment. Pass the stride and use it in chamelium_paint_xr24_pattern. Signed-off-by: Paul Kocialkowski Reviewed-by: Maxime Ripard --- tests/kms_chamelium.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/kms_chamelium.c') diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c index ee7580b5..ebca5eef 100644 --- a/tests/kms_chamelium.c +++ b/tests/kms_chamelium.c @@ -489,7 +489,8 @@ enable_output(data_t *data, } static void chamelium_paint_xr24_pattern(uint32_t *data, - size_t width, size_t height) + size_t width, size_t height, + size_t stride) { uint32_t colors[] = { 0xff000000, 0xffff0000, @@ -500,7 +501,7 @@ static void chamelium_paint_xr24_pattern(uint32_t *data, for (i = 0; i < height; i++) for (j = 0; j < width; j++) - *(data + i * width + j) = colors[((j / 64) + (i / 64)) % 5]; + *(data + i * stride / 4 + j) = colors[((j / 64) + (i / 64)) % 5]; } static int chamelium_get_pattern_fb(data_t *data, drmModeModeInfo *mode, @@ -518,7 +519,8 @@ static int chamelium_get_pattern_fb(data_t *data, drmModeModeInfo *mode, ptr = igt_fb_map_buffer(fb->fd, fb); igt_assert(ptr); - chamelium_paint_xr24_pattern(ptr, mode->hdisplay, mode->vdisplay); + chamelium_paint_xr24_pattern(ptr, mode->hdisplay, mode->vdisplay, + fb->strides[0]); igt_fb_unmap_buffer(fb, ptr); return fb_id; -- cgit v1.2.3