drm/modes: Switch to named mode descriptors
authorMaxime Ripard <maxime@cerno.tech>
Mon, 14 Nov 2022 13:00:29 +0000 (14:00 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Tue, 15 Nov 2022 09:09:44 +0000 (10:09 +0100)
The current named mode parsing relies only on the mode name, and doesn't
allow to specify any other parameter.

Let's convert that string list to an array of a custom structure that will
hold the name and some additional parameters in the future.

Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Tested-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
Link: https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v9-10-24b168e5bcd5@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/drm_modes.c

index 757a5db..f404f3c 100644 (file)
@@ -1750,9 +1750,13 @@ static int drm_mode_parse_cmdline_options(const char *str,
        return 0;
 }
 
-static const char * const drm_named_modes_whitelist[] = {
-       "NTSC",
-       "PAL",
+struct drm_named_mode {
+       const char *name;
+};
+
+static const struct drm_named_mode drm_named_modes[] = {
+       { "NTSC", },
+       { "PAL", },
 };
 
 static int drm_mode_parse_cmdline_named_mode(const char *name,
@@ -1784,14 +1788,15 @@ static int drm_mode_parse_cmdline_named_mode(const char *name,
         * We're sure we're a named mode at this point, iterate over the
         * list of modes we're aware of.
         */
-       for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++) {
+       for (i = 0; i < ARRAY_SIZE(drm_named_modes); i++) {
+               const struct drm_named_mode *mode = &drm_named_modes[i];
                int ret;
 
-               ret = str_has_prefix(name, drm_named_modes_whitelist[i]);
+               ret = str_has_prefix(name, mode->name);
                if (ret != name_end)
                        continue;
 
-               strcpy(cmdline_mode->name, drm_named_modes_whitelist[i]);
+               strcpy(cmdline_mode->name, mode->name);
                cmdline_mode->specified = true;
 
                return 1;