diff mbox series

[libdrm] modetest: Add support for named modes containing dashes

Message ID 509f0c272b2bf50c2bb937cf520d554ce970808e.1657302118.git.geert@linux-m68k.org (mailing list archive)
State New, archived
Headers show
Series [libdrm] modetest: Add support for named modes containing dashes | expand

Commit Message

Geert Uytterhoeven July 8, 2022, 6:22 p.m. UTC
It is fairly common for named video modes to contain dashes (e.g.
"tt-mid" on Atari, "dblntsc-ff" on Amiga).  Currently such mode names
are not recognized, as the dash is considered to be a separator between
mode name and vertical refrsh.

Fix this by skipping any dashes that are not followed immediately by a
digit when looking for the separator.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Please refer to [1] for related Linux DRM patches and background
information.

v2:
  - New.

[1] "[PATCH v3 00/10] drm: Add support for low-color frame buffer formats"
    https://lore.kernel.org/r/cover.1657294931.git.geert@linux-m68k.org
---
 tests/modetest/modetest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 7c6c21ef5174c41a..09f026764a07aad9 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1903,8 +1903,11 @@  static int parse_connector(struct pipe_arg *pipe, const char *arg)
 
 	arg = endp + 1;
 
-	/* Search for the vertical refresh or the format. */
+	/* Search for the vertical refresh or the format, */
+	/* The former must be followed by a number */
 	p = strpbrk(arg, "-@");
+	while (p && *p == '-' && !isdigit(p[1]))
+		p = strpbrk(p + 1, "-@");
 	if (p == NULL)
 		p = arg + strlen(arg);
 	len = min(sizeof pipe->mode_str - 1, (unsigned int)(p - arg));