From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fb: generate mode name if missing
Date: Tue, 6 May 2025 08:21:17 +0200 [thread overview]
Message-ID: <20250506062117.3090793-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2025-05-06 6:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 6:21 Ahmad Fatoum [this message]
2025-05-06 7:21 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250506062117.3090793-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox