mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fb: generate mode name if missing
@ 2025-05-06  6:21 Ahmad Fatoum
  2025-05-06  7:21 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-05-06  6:21 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

If a mode name is not set, the device parameters will format the NULL
mode name as <NULL>. Instead, let's just generate a name and use that.

If multiple modes have the same resolution and refresh rate, we will end
up with duplicate names, but that's ok as this is just a fallback.
Drivers can always assign proper names to their modes and most do.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/video/fb.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index fade873d1efa..64ca68e14513 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -291,6 +291,11 @@ static int fb_set_shadowfb(struct param_d *p, void *priv)
 	return fb_alloc_shadowfb(info);
 }
 
+static const char *mode_name(struct fb_videomode *mode)
+{
+	return basprintf("%dx%d@%d", mode->xres, mode->yres, mode->refresh);
+}
+
 int register_framebuffer(struct fb_info *info)
 {
 	int id;
@@ -351,10 +356,18 @@ int register_framebuffer(struct fb_info *info)
 
 	names = xzalloc(sizeof(char *) * num_modes);
 
-	for (i = 0; i < info->modes.num_modes; i++)
+	for (i = 0; i < info->modes.num_modes; i++) {
+		if (!info->modes.modes[i].name)
+			info->modes.modes[i].name = mode_name(&info->modes.modes[i]);
 		names[i] = info->modes.modes[i].name;
-	for (i = 0; i < info->edid_modes.num_modes; i++)
+	}
+
+	for (i = 0; i < info->edid_modes.num_modes; i++) {
+		if (!info->edid_modes.modes[i].name)
+			info->modes.modes[i].name = mode_name(&info->edid_modes.modes[i]);
 		names[i + info->modes.num_modes] = info->edid_modes.modes[i].name;
+	}
+
 	dev_add_param_enum(dev, "mode_name", fb_set_modename, NULL, &info->current_mode, names, num_modes, info);
 	info->shadowfb = 1;
 	dev_add_param_bool(dev, "shadowfb", fb_set_shadowfb, NULL, &info->shadowfb, info);
-- 
2.39.5




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

* Re: [PATCH] fb: generate mode name if missing
  2025-05-06  6:21 [PATCH] fb: generate mode name if missing Ahmad Fatoum
@ 2025-05-06  7:21 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-05-06  7:21 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Tue, 06 May 2025 08:21:17 +0200, Ahmad Fatoum wrote:
> If a mode name is not set, the device parameters will format the NULL
> mode name as <NULL>. Instead, let's just generate a name and use that.
> 
> If multiple modes have the same resolution and refresh rate, we will end
> up with duplicate names, but that's ok as this is just a fallback.
> Drivers can always assign proper names to their modes and most do.
> 
> [...]

Applied, thanks!

[1/1] fb: generate mode name if missing
      https://git.pengutronix.de/cgit/barebox/commit/?id=287ebad1d2be (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2025-05-06  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-06  6:21 [PATCH] fb: generate mode name if missing Ahmad Fatoum
2025-05-06  7:21 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox