All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] drm/modes: Command line mode selection improvements
@ 2022-11-25 20:30 ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-11-25 20:30 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Hans de Goede
  Cc: dri-devel, linux-fbdev, linux-m68k, linux-kernel, Geert Uytterhoeven

	Hi all,

This patch series contains improvements for specifying video modes on the
kernel command line.

I don't expect the second patch to be acceptable as-is, but it's a
dependency for posting the RFC Atari DRM driver...

Changes compared to v2[1]:
  - Drop applied and obsolete patches,
  - Add Acked-by,
  - Update for the switch from names to named mode descriptors.

Changes compared to v1[2]:
  - Add Reviewed-by, Acked-by,
  - Keep length check.

This has been tested on ARAnyM using a work-in-progress Atari DRM
driver.

Thanks for your comments!

[1] "[PATCH v2 0/5] drm/modes: Command line mode selection fixes and
    improvements"
    https://lore.kernel.org/r/cover.1657788997.git.geert@linux-m68k.org
[2] "[PATCH 0/5] drm/modes: Command line mode selection fixes and
    improvements"
    https://lore.kernel.org/r/cover.1657301107.git.geert@linux-m68k.org

Geert Uytterhoeven (2):
  drm/modes: parse_cmdline: Make mode->*specified handling more uniform
  drm/modes: Add support for driver-specific named modes

 drivers/gpu/drm/drm_modes.c | 26 +++++++++-----------------
 include/drm/drm_connector.h | 18 ++++++++++++++++++
 2 files changed, 27 insertions(+), 17 deletions(-)

-- 
2.25.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 0/2] drm/modes: Command line mode selection improvements
@ 2022-11-25 20:30 ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-11-25 20:30 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Hans de Goede
  Cc: linux-fbdev, Geert Uytterhoeven, linux-m68k, dri-devel, linux-kernel

	Hi all,

This patch series contains improvements for specifying video modes on the
kernel command line.

I don't expect the second patch to be acceptable as-is, but it's a
dependency for posting the RFC Atari DRM driver...

Changes compared to v2[1]:
  - Drop applied and obsolete patches,
  - Add Acked-by,
  - Update for the switch from names to named mode descriptors.

Changes compared to v1[2]:
  - Add Reviewed-by, Acked-by,
  - Keep length check.

This has been tested on ARAnyM using a work-in-progress Atari DRM
driver.

Thanks for your comments!

[1] "[PATCH v2 0/5] drm/modes: Command line mode selection fixes and
    improvements"
    https://lore.kernel.org/r/cover.1657788997.git.geert@linux-m68k.org
[2] "[PATCH 0/5] drm/modes: Command line mode selection fixes and
    improvements"
    https://lore.kernel.org/r/cover.1657301107.git.geert@linux-m68k.org

Geert Uytterhoeven (2):
  drm/modes: parse_cmdline: Make mode->*specified handling more uniform
  drm/modes: Add support for driver-specific named modes

 drivers/gpu/drm/drm_modes.c | 26 +++++++++-----------------
 include/drm/drm_connector.h | 18 ++++++++++++++++++
 2 files changed, 27 insertions(+), 17 deletions(-)

-- 
2.25.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/2] drm/modes: parse_cmdline: Make mode->*specified handling more uniform
  2022-11-25 20:30 ` Geert Uytterhoeven
@ 2022-11-25 20:31   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-11-25 20:31 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Hans de Goede
  Cc: dri-devel, linux-fbdev, linux-m68k, linux-kernel,
	Geert Uytterhoeven, Maxime Ripard

The various mode->*specified flags are not handled in an uniform way:
some flags are set by the corresponding drm_mode_parse_cmdline_*()
function, some flags by the caller of the function, and some flags by
both.

Make this uniform by making this the responsibility of the various
parsing helpers, i.e.
  - Move the setting of mode->specified from caller to callee,
  - Drop the duplicate setting of mode->bpp_specified and
    mode->refresh_specified from callers.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Maxime Ripard <maxime@cerno.tech>
---
v3:
  - Add Acked-by,

v2:
  - Add Reviewed-by, Acked-by,
---
 drivers/gpu/drm/drm_modes.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 3c8034a8c27bd25a..45b9e6aab766002a 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1605,6 +1605,7 @@ static int drm_mode_parse_cmdline_res_mode(const char *str, unsigned int length,
 	mode->yres = yres;
 	mode->cvt = cvt;
 	mode->rb = rb;
+	mode->specified = true;
 
 	return 0;
 }
@@ -1921,8 +1922,6 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 						      mode);
 		if (ret)
 			return false;
-
-		mode->specified = true;
 	}
 
 	/* No mode? Check for freestanding extras and/or options */
@@ -1944,8 +1943,6 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 		ret = drm_mode_parse_cmdline_bpp(bpp_ptr, &bpp_end_ptr, mode);
 		if (ret)
 			return false;
-
-		mode->bpp_specified = true;
 	}
 
 	if (refresh_ptr) {
@@ -1953,8 +1950,6 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 						     &refresh_end_ptr, mode);
 		if (ret)
 			return false;
-
-		mode->refresh_specified = true;
 	}
 
 	/*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 1/2] drm/modes: parse_cmdline: Make mode->*specified handling more uniform
@ 2022-11-25 20:31   ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-11-25 20:31 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Hans de Goede
  Cc: linux-fbdev, linux-m68k, dri-devel, linux-kernel,
	Geert Uytterhoeven, Maxime Ripard

The various mode->*specified flags are not handled in an uniform way:
some flags are set by the corresponding drm_mode_parse_cmdline_*()
function, some flags by the caller of the function, and some flags by
both.

Make this uniform by making this the responsibility of the various
parsing helpers, i.e.
  - Move the setting of mode->specified from caller to callee,
  - Drop the duplicate setting of mode->bpp_specified and
    mode->refresh_specified from callers.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Maxime Ripard <maxime@cerno.tech>
---
v3:
  - Add Acked-by,

v2:
  - Add Reviewed-by, Acked-by,
---
 drivers/gpu/drm/drm_modes.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 3c8034a8c27bd25a..45b9e6aab766002a 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1605,6 +1605,7 @@ static int drm_mode_parse_cmdline_res_mode(const char *str, unsigned int length,
 	mode->yres = yres;
 	mode->cvt = cvt;
 	mode->rb = rb;
+	mode->specified = true;
 
 	return 0;
 }
@@ -1921,8 +1922,6 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 						      mode);
 		if (ret)
 			return false;
-
-		mode->specified = true;
 	}
 
 	/* No mode? Check for freestanding extras and/or options */
@@ -1944,8 +1943,6 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 		ret = drm_mode_parse_cmdline_bpp(bpp_ptr, &bpp_end_ptr, mode);
 		if (ret)
 			return false;
-
-		mode->bpp_specified = true;
 	}
 
 	if (refresh_ptr) {
@@ -1953,8 +1950,6 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 						     &refresh_end_ptr, mode);
 		if (ret)
 			return false;
-
-		mode->refresh_specified = true;
 	}
 
 	/*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/2] drm/modes: Add support for driver-specific named modes
  2022-11-25 20:30 ` Geert Uytterhoeven
@ 2022-11-25 20:31   ` Geert Uytterhoeven
  -1 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-11-25 20:31 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Hans de Goede
  Cc: dri-devel, linux-fbdev, linux-m68k, linux-kernel, Geert Uytterhoeven

The mode parsing code recognizes named modes only if they are explicitly
listed in the internal named mode list, which is currently limited to
"NTSC" and "PAL".

Provide a mechanism for drivers to override this list to support custom
modes.

Ideally, this list should just come from the driver's actual list of
modes, but connector->probed_modes is not yet populated at the time of
parsing.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
I don't expect this patch to be acceptable as-is, but it's a dependency
for posting the RFC Atari DRM driver.

v3:
  - Update for the switch from names to named mode descriptors,

v2:
  - Add Reviewed-by.
---
 drivers/gpu/drm/drm_modes.c | 19 ++++++++-----------
 include/drm/drm_connector.h | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 45b9e6aab766002a..9ea928b35e728d13 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -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;
 
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 565cf9d3c550926f..ff78ac214e475086 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/2] drm/modes: Add support for driver-specific named modes
@ 2022-11-25 20:31   ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2022-11-25 20:31 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Hans de Goede
  Cc: linux-fbdev, Geert Uytterhoeven, linux-m68k, dri-devel, linux-kernel

The mode parsing code recognizes named modes only if they are explicitly
listed in the internal named mode list, which is currently limited to
"NTSC" and "PAL".

Provide a mechanism for drivers to override this list to support custom
modes.

Ideally, this list should just come from the driver's actual list of
modes, but connector->probed_modes is not yet populated at the time of
parsing.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
I don't expect this patch to be acceptable as-is, but it's a dependency
for posting the RFC Atari DRM driver.

v3:
  - Update for the switch from names to named mode descriptors,

v2:
  - Add Reviewed-by.
---
 drivers/gpu/drm/drm_modes.c | 19 ++++++++-----------
 include/drm/drm_connector.h | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 45b9e6aab766002a..9ea928b35e728d13 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -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;
 
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 565cf9d3c550926f..ff78ac214e475086 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-25 20:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 20:30 [PATCH v3 0/2] drm/modes: Command line mode selection improvements Geert Uytterhoeven
2022-11-25 20:30 ` Geert Uytterhoeven
2022-11-25 20:31 ` [PATCH v3 1/2] drm/modes: parse_cmdline: Make mode->*specified handling more uniform Geert Uytterhoeven
2022-11-25 20:31   ` Geert Uytterhoeven
2022-11-25 20:31 ` [PATCH v3 2/2] drm/modes: Add support for driver-specific named modes Geert Uytterhoeven
2022-11-25 20:31   ` Geert Uytterhoeven

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.