[igt-dev] [PATCH 2/2] tests/fbdev: Add tests for display panning

Thomas Zimmermann tzimmermann at suse.de
Mon Oct 11 14:07:19 UTC 2021


Add tests that perform panning / page flip operations on an fbdev
device. Panning should work when the viewport wi within the virtual
screen and fail otherwise.

Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
 tests/fbdev.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/tests/fbdev.c b/tests/fbdev.c
index c9903f8b..17727cd0 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -86,6 +86,98 @@ static void mode_tests(int fd)
 			     "vertical virtual resolution (%u) with pitch %u exceeds available video memory\n",
 			     var_info.yres_virtual, fix_info.line_length);
 	}
+
+	igt_describe("Check panning / page flipping");
+	igt_subtest("pan") {
+		struct fb_var_screeninfo pan_var, new_var;
+		int ret;
+
+		/* jump to opposite end of virtual screen */
+		pan_var.xoffset = var_info.xres_virtual - var_info.xres - var_info.xoffset;
+		pan_var.yoffset = var_info.yres_virtual - var_info.yres - var_info.yoffset;
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		ret = ioctl(fd, FBIOGET_VSCREENINFO, &new_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		igt_assert_f(pan_var.xoffset == new_var.xoffset && pan_var.yoffset == new_var.yoffset,
+			     "panning to (%u, %u) moved to (%u, %u)\n",
+			     pan_var.xoffset, pan_var.yoffset, new_var.xoffset, new_var.yoffset);
+
+		/* jump to (0, 0) */
+		pan_var.xoffset = 0;
+		pan_var.yoffset = 0;
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		ret = ioctl(fd, FBIOGET_VSCREENINFO, &new_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		igt_assert_f(pan_var.xoffset == new_var.xoffset && pan_var.yoffset == new_var.yoffset,
+			     "panning to (%u, %u) moved to (%u, %u)\n",
+			     pan_var.xoffset, pan_var.yoffset, new_var.xoffset, new_var.yoffset);
+
+		/* jump to maximum extend */
+		pan_var.xoffset = var_info.xres_virtual - var_info.xres;
+		pan_var.yoffset = var_info.yres_virtual - var_info.yres;
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		ret = ioctl(fd, FBIOGET_VSCREENINFO, &new_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		igt_assert_f(pan_var.xoffset == new_var.xoffset && pan_var.yoffset == new_var.yoffset,
+			     "panning to (%u, %u) moved to (%u, %u)\n",
+			     pan_var.xoffset, pan_var.yoffset, new_var.xoffset, new_var.yoffset);
+
+		/* return to original offsets for next tests */
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &var_info);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+
+		/* jump beyond maximum horizontal extend */
+		pan_var.xoffset = var_info.xres_virtual - var_info.xres + 1;
+		pan_var.yoffset = 0;
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+		igt_assert_f(ret == -1, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		ret = ioctl(fd, FBIOGET_VSCREENINFO, &new_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		igt_assert_f(var_info.xoffset == new_var.xoffset && var_info.yoffset == new_var.yoffset,
+			     "panning to (%u, %u) moved to (%u, %u)\n",
+			     pan_var.xoffset, pan_var.yoffset, new_var.xoffset, new_var.yoffset);
+
+		/* jump beyond maximum vertical extend */
+		pan_var.xoffset = 0;
+		pan_var.yoffset = var_info.yres_virtual - var_info.yres + 1;
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+		igt_assert_f(ret == -1, "ioctl(FBIOPAN_DISPLAY), ret=%d\n", ret);
+		ret = ioctl(fd, FBIOGET_VSCREENINFO, &new_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		igt_assert_f(var_info.xoffset == new_var.xoffset && var_info.yoffset == new_var.yoffset,
+			     "panning to (%u, %u) moved to (%u, %u)\n",
+			     pan_var.xoffset, pan_var.yoffset, new_var.xoffset, new_var.yoffset);
+
+		/* jump beyond horizontal virtual resolution */
+		pan_var.xoffset = var_info.xres_virtual;
+		pan_var.yoffset = 0;
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+		igt_assert_f(ret == -1, "ioctl(FBIOPAN_DISPLAY), ret=%d\n", ret);
+		ret = ioctl(fd, FBIOGET_VSCREENINFO, &new_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		igt_assert_f(var_info.xoffset == new_var.xoffset && var_info.yoffset == new_var.yoffset,
+			     "panning to (%u, %u) moved to (%u, %u)\n",
+			     pan_var.xoffset, pan_var.yoffset, new_var.xoffset, new_var.yoffset);
+
+		/* jump beyond vertical virtual resolution */
+		pan_var.xoffset = 0;
+		pan_var.yoffset = var_info.yres_virtual;
+		ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+		igt_assert_f(ret == -1, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		ret = ioctl(fd, FBIOGET_VSCREENINFO, &new_var);
+		igt_assert_f(ret == 0, "ioctl(FBIOPAN_DISPLAY) failed, ret=%d\n", ret);
+		igt_assert_f(var_info.xoffset == new_var.xoffset && var_info.yoffset == new_var.yoffset,
+			     "panning to (%u, %u) moved to (%u, %u)\n",
+			     pan_var.xoffset, pan_var.yoffset, new_var.xoffset, new_var.yoffset);
+	}
+
+	igt_fixture {
+		/* restore original panning offsets */
+		ioctl(fd, FBIOPAN_DISPLAY, &var_info);
+	}
 }
 
 static void framebuffer_tests(int fd)
-- 
2.33.0



More information about the igt-dev mailing list