mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] video: ramfb: support multiple resolutions via mode_name parameter
Date: Fri,  1 May 2026 10:51:01 +0200	[thread overview]
Message-ID: <20260501085102.1029483-1-a.fatoum@barebox.org> (raw)

Replace the single hardcoded 640x480 mode with a static mode list
covering common resolutions (640x480, 800x600, 1280x720, 1920x1080).
The default remains 640x480 (index 0).

Users can now switch to e.g. 1080p before enabling the framebuffer:

  fb0.mode_name=1920x1080

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/video/ramfb.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/video/ramfb.c b/drivers/video/ramfb.c
index cc490496175b..7d0413afb5e2 100644
--- a/drivers/video/ramfb.c
+++ b/drivers/video/ramfb.c
@@ -18,7 +18,6 @@ struct ramfb {
 	int fd;
 	struct fb_info info;
 	dma_addr_t screen_dma;
-	struct fb_videomode mode;
 };
 
 struct fw_cfg_etc_ramfb {
@@ -30,22 +29,6 @@ struct fw_cfg_etc_ramfb {
 	u32 stride;
 } __packed;
 
-static void ramfb_populate_modes(struct ramfb *ramfb)
-{
-	struct fb_info *info = &ramfb->info;
-
-	ramfb->mode.name = "x8r8g8b8";
-	info->xres = ramfb->mode.xres = 640;
-	info->yres = ramfb->mode.yres = 480;
-
-	info->mode = &ramfb->mode;
-	info->bits_per_pixel = 32;
-	info->red	= (struct fb_bitfield) {16, 8};
-	info->green	= (struct fb_bitfield) {8, 8};
-	info->blue	= (struct fb_bitfield) {0, 8};
-	info->transp	= (struct fb_bitfield) {0, 0};
-}
-
 static int ramfb_activate_var(struct fb_info *fbi)
 {
 	struct ramfb *ramfb = fbi->priv;
@@ -81,6 +64,13 @@ static void ramfb_enable(struct fb_info *fbi)
 	dma_free(etc_ramfb);
 }
 
+static struct fb_videomode ramfb_modes[] = {
+	{ .name = "640x480",   .xres =  640, .yres =  480 },
+	{ .name = "800x600",   .xres =  800, .yres =  600 },
+	{ .name = "1280x720",  .xres = 1280, .yres =  720 },
+	{ .name = "1920x1080", .xres = 1920, .yres = 1080 },
+};
+
 static struct fb_ops ramfb_ops = {
 	.fb_activate_var = ramfb_activate_var,
 	.fb_enable = ramfb_enable,
@@ -101,7 +91,15 @@ static int ramfb_probe(struct device *dev)
 	fbi->fbops = &ramfb_ops;
 	fbi->dev.parent = dev;
 
-	ramfb_populate_modes(ramfb);
+	fbi->modes.modes = ramfb_modes;
+	fbi->modes.num_modes = ARRAY_SIZE(ramfb_modes);
+	/* current_mode = 0 (640x480) from xzalloc */
+
+	fbi->bits_per_pixel = 32;
+	fbi->red	= (struct fb_bitfield) {16, 8};
+	fbi->green	= (struct fb_bitfield) {8, 8};
+	fbi->blue	= (struct fb_bitfield) {0, 8};
+	fbi->transp	= (struct fb_bitfield) {0, 0};
 
 	ret = register_framebuffer(fbi);
 	if (ret < 0) {
-- 
2.47.3




             reply	other threads:[~2026-05-01  8:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01  8:51 Ahmad Fatoum [this message]
2026-05-07 10:38 ` 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=20260501085102.1029483-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --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