[igt-dev] [PATCH v2 2/2] tests/fbdev: Add tests for display panning
Thomas Zimmermann
tzimmermann at suse.de
Thu Oct 14 13:45:17 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.
v2:
* set offset to respect panning offsets (Ville)
* respect FB_VMODE_YWRAP (Ville)
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
tests/fbdev.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
diff --git a/tests/fbdev.c b/tests/fbdev.c
index 2cf137d2..e1f18718 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -39,6 +39,20 @@
#include "igt.h"
+#define PANSTEP(panstep_) \
+ ((panstep_) ? (panstep_) : 1)
+
+static unsigned int __panoffset(unsigned int offset, unsigned int panstep)
+{
+ return offset - (offset % PANSTEP(panstep));
+}
+
+#define XOFFSET(offset_) \
+ __panoffset(offset_, fix_info.xpanstep)
+
+#define YOFFSET(offset_) \
+ __panoffset(offset_, fix_info.ypanstep)
+
static void mode_tests(int fd)
{
struct fb_var_screeninfo var_info;
@@ -92,6 +106,127 @@ static void mode_tests(int fd)
"vertical virtual resolution (%u) with line length %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 = XOFFSET(var_info.xres_virtual - var_info.xres - var_info.xoffset);
+ pan_var.yoffset = 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 = XOFFSET(0);
+ pan_var.yoffset = 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 = XOFFSET(var_info.xres_virtual - var_info.xres);
+ pan_var.yoffset = 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 = XOFFSET(var_info.xres_virtual - var_info.xres + PANSTEP(fix_info.xpanstep));
+ pan_var.yoffset = 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 horizontal virtual resolution */
+ pan_var.xoffset = XOFFSET(var_info.xres_virtual);
+ pan_var.yoffset = 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);
+
+ /*
+ * With FB_MODE_YWRAP set, the display is expected to wrap around when reaching
+ * the limits of the vertical resolution. Otherwise, this should fail.
+ */
+
+ if (var_info.vmode & FB_VMODE_YWRAP) {
+ /* jump beyond maximum vertical extend */
+ pan_var.xoffset = XOFFSET(0);
+ pan_var.yoffset = YOFFSET(var_info.yres_virtual - var_info.yres + PANSTEP(fix_info.ypanstep));
+ ret = ioctl(fd, FBIOPAN_DISPLAY, &pan_var);
+ igt_assert_f(ret == 0, "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(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 beyond vertical virtual resolution */
+ pan_var.xoffset = XOFFSET(0);
+ pan_var.yoffset = YOFFSET(var_info.yres_virtual);
+ 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);
+ } else {
+ /* jump beyond maximum vertical extend */
+ pan_var.xoffset = XOFFSET(0);
+ pan_var.yoffset = YOFFSET(var_info.yres_virtual - var_info.yres + PANSTEP(fix_info.ypanstep));
+ 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 = XOFFSET(0);
+ pan_var.yoffset = 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