@@ -1751,14 +1751,6 @@ static int drm_mode_parse_cmdline_options(const char *str,
return 0;
}
-struct drm_named_mode {
- const char *name;
- unsigned int pixel_clock_khz;
- unsigned int xres;
- unsigned int yres;
- unsigned int flags;
-};
-
#define NAMED_MODE(_name, _pclk, _x, _y, _flags) \
{ \
.name = _name, \
@@ -1771,12 +1763,15 @@ struct drm_named_mode {
static const struct drm_named_mode drm_named_modes[] = {
NAMED_MODE("NTSC", 13500, 720, 480, DRM_MODE_FLAG_INTERLACE),
NAMED_MODE("PAL", 13500, 720, 576, DRM_MODE_FLAG_INTERLACE),
+ { /* sentinel */ }
};
static int drm_mode_parse_cmdline_named_mode(const char *name,
unsigned int name_end,
+ const struct drm_connector *connector,
struct drm_cmdline_mode *cmdline_mode)
{
+ const struct drm_named_mode *named_modes;
unsigned int i;
if (!name_end)
@@ -1802,8 +1797,9 @@ 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); i++) {
- const struct drm_named_mode *mode = &drm_named_modes[i];
+ named_modes = connector->named_modes ? : drm_named_modes;
+ for (i = 0; named_modes[i].name; i++) {
+ const struct drm_named_mode *mode = &named_modes[i];
int ret;
ret = str_has_prefix(name, mode->name);
@@ -1903,7 +1899,8 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
if (!mode_end)
return false;
- ret = drm_mode_parse_cmdline_named_mode(name, mode_end, mode);
+ ret = drm_mode_parse_cmdline_named_mode(name, mode_end, connector,
+ mode);
if (ret < 0)
return false;
@@ -1315,6 +1315,14 @@ struct drm_cmdline_mode {
struct drm_connector_tv_margins tv_margins;
};
+struct drm_named_mode {
+ const char *name;
+ unsigned int pixel_clock_khz;
+ unsigned int xres;
+ unsigned int yres;
+ unsigned int flags;
+};
+
/**
* struct drm_connector - central DRM connector control structure
*
@@ -1708,6 +1716,16 @@ struct drm_connector {
/** @hdr_sink_metadata: HDR Metadata Information read from sink */
struct hdr_sink_metadata hdr_sink_metadata;
+
+ /**
+ * @named_modes:
+ *
+ * Optional NULL-terminated array of names to be considered valid mode
+ * names. This lets the command line option parser distinguish between
+ * mode names and freestanding extras and/or options.
+ * If not set, a set of defaults will be used.
+ */
+ const struct drm_named_mode *named_modes;
};
#define obj_to_connector(x) container_of(x, struct drm_connector, base)