[igt-dev] [PATCH i-g-t v2 2/2] chamelium: Pass and use stride for xr24 pattern paint

Paul Kocialkowski paul.kocialkowski at bootlin.com
Fri Nov 16 08:05:54 UTC 2018


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 <paul.kocialkowski at bootlin.com>
Reviewed-by: Maxime Ripard <maxime.ripard at bootlin.com>
---
 tests/kms_chamelium.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 4f1977c3..a8d8aeee 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -487,7 +487,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,
@@ -498,7 +499,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,
@@ -516,7 +517,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;
-- 
2.19.1



More information about the igt-dev mailing list