All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: igt-dev@lists.freedesktop.org, ville.syrjala@linux.intel.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Subject: [igt-dev] [PATCH v2 1/2] tests/fbdev: Test for validity of video mode settings
Date: Thu, 14 Oct 2021 15:45:16 +0200	[thread overview]
Message-ID: <20211014134517.26473-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20211014134517.26473-1-tzimmermann@suse.de>

Add basic tests for video mode resolution and color on fbdev
devices.

v2:
	* respect FB_VMODE_YWRAP (Ville)
	* test horizontal resolution against line length

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 tests/fbdev.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 41 insertions(+), 8 deletions(-)

diff --git a/tests/fbdev.c b/tests/fbdev.c
index 443a43dc..2cf137d2 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -27,6 +27,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
@@ -50,14 +51,46 @@ static void mode_tests(int fd)
 
 	igt_describe("Check if screeninfo is valid");
 	igt_subtest("info") {
-		unsigned long size;
-
-		size = var_info.yres * fix_info.line_length;
-		igt_assert_f(size <= fix_info.smem_len,
-			     "screen size (%d x %d) of pitch %d does not fit within mappable area of size %u\n",
-			     var_info.xres, var_info.yres,
-			     fix_info.line_length,
-			     fix_info.smem_len);
+		unsigned long nbits, nlines;
+
+		/* video memory configuration */
+		igt_assert_f(fix_info.line_length, "line length not set\n");
+		igt_assert_f(fix_info.smem_len, "size of video memory not set\n");
+		igt_assert_f(fix_info.line_length <= fix_info.smem_len,
+			     "line length (%u) exceeds available video memory (%u)\n",
+			     fix_info.line_length, fix_info.smem_len);
+
+		/* color format */
+		igt_assert_f(var_info.bits_per_pixel, "bits-per-pixel not set\n");
+
+		/* horizontal resolution */
+		igt_assert_f(var_info.xres, "horizontal resolution not set\n");
+		igt_assert_f(var_info.xres_virtual, "horizontal virtual resolution not set\n");
+		igt_assert_f(var_info.xres <= var_info.xres_virtual,
+			     "horizontal virtual resolution (%u) less than horizontal resolution (%u)\n",
+			     var_info.xres_virtual, var_info.xres);
+		igt_assert_f(var_info.xoffset <= (var_info.xres_virtual - var_info.xres),
+			     "screen horizontal offset (%u) overflow\n",
+			     var_info.xoffset);
+		nbits = fix_info.line_length * CHAR_BIT;
+		igt_assert_f((var_info.xres_virtual * var_info.bits_per_pixel) <= nbits,
+			     "vertical virtual resolution (%u) with bpp %u exceeds line length %u\n",
+			     var_info.yres_virtual, var_info.bits_per_pixel, fix_info.line_length);
+
+		/* vertical resolution */
+		igt_assert_f(var_info.yres, "vertical resolution not set\n");
+		igt_assert_f(var_info.yres_virtual, "vertical virtual resolution not set\n");
+		igt_assert_f(var_info.yres <= var_info.yres_virtual,
+			     "vertical virtual resolution (%u) less than vertical resolution (%u)\n",
+			     var_info.yres_virtual, var_info.yres);
+		igt_assert_f((var_info.vmode & FB_VMODE_YWRAP) ||
+			     (var_info.yoffset <= (var_info.yres_virtual - var_info.yres)),
+			     "screen vertical offset (%u) overflow\n",
+			     var_info.yoffset);
+		nlines = fix_info.smem_len / fix_info.line_length;
+		igt_assert_f(var_info.yres_virtual <= nlines,
+			     "vertical virtual resolution (%u) with line length %u exceeds available video memory\n",
+			     var_info.yres_virtual, fix_info.line_length);
 	}
 }
 
-- 
2.33.0

  reply	other threads:[~2021-10-14 13:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 13:45 [igt-dev] [PATCH v2 0/2] tests/fbdev: Additional tests for resolution and panning Thomas Zimmermann
2021-10-14 13:45 ` Thomas Zimmermann [this message]
2021-10-14 13:45 ` [igt-dev] [PATCH v2 2/2] tests/fbdev: Add tests for display panning Thomas Zimmermann
2021-10-20 14:17   ` Ville Syrjälä
2021-10-22  7:55     ` Thomas Zimmermann
2021-10-14 18:21 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/fbdev: Additional tests for resolution and panning (rev2) Patchwork
2021-10-14 22:02 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2021-10-20 14:08 ` [igt-dev] [PATCH v2 0/2] tests/fbdev: Additional tests for resolution and panning Thomas Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211014134517.26473-2-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.