Skip to content

Commit 728a257

Browse files
committed
drm/modes: Fix the command line parser to take force options into account
The command line parser when it has been rewritten introduced a regression when the only thing on the command line is an option to force the detection of a connector (such as video=HDMI-A-1:d), which are completely valid. It's been further broken by the support for the named modes which take anything that is not a resolution as a named mode. Let's fix this by running the extra command line option parser on the named modes if they only take a single character. Fixes: e08ab74 ("drm/modes: Rewrite the command line parser") Reported-by: Jernej Škrabec <[email protected]> Reported-by: Thomas Graichen <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Tested-by: Thomas Graichen <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 325d0ab commit 728a257

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

drivers/gpu/drm/drm_modes.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,16 +1733,30 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
17331733
* bunch of things:
17341734
* - We need to make sure that the first character (which
17351735
* would be our resolution in X) is a digit.
1736-
* - However, if the X resolution is missing, then we end up
1737-
* with something like x<yres>, with our first character
1738-
* being an alpha-numerical character, which would be
1739-
* considered a named mode.
1736+
* - If not, then it's either a named mode or a force on/off.
1737+
* To distinguish between the two, we need to run the
1738+
* extra parsing function, and if not, then we consider it
1739+
* a named mode.
17401740
*
17411741
* If this isn't enough, we should add more heuristics here,
17421742
* and matching unit-tests.
17431743
*/
1744-
if (!isdigit(name[0]) && name[0] != 'x')
1744+
if (!isdigit(name[0]) && name[0] != 'x') {
1745+
unsigned int namelen = strlen(name);
1746+
1747+
/*
1748+
* Only the force on/off options can be in that case,
1749+
* and they all take a single character.
1750+
*/
1751+
if (namelen == 1) {
1752+
ret = drm_mode_parse_cmdline_extra(name, namelen, true,
1753+
connector, mode);
1754+
if (!ret)
1755+
return true;
1756+
}
1757+
17451758
named_mode = true;
1759+
}
17461760

17471761
/* Try to locate the bpp and refresh specifiers, if any */
17481762
bpp_ptr = strchr(name, '-');

0 commit comments

Comments
 (0)