From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 2/5] video: simplefb-fixup: use shared SIMPLEFB_FORMATS table
Date: Mon, 13 Apr 2026 12:06:57 +0200 [thread overview]
Message-ID: <20260413100710.1459468-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260413100710.1459468-1-a.fatoum@barebox.org>
The driver maintained a private 2-entry format table covering only r5g6b5
and a8r8g8b8. The shared SIMPLEFB_FORMATS macro in
<linux/platform_data/simplefb.h> covers all formats defined by the DT
binding.
Replace the private struct simplefb_mode and simplefb_modes[] with
the shared struct simplefb_format and SIMPLEFB_FORMATS and while at it,
drop <common.h> in favour of the specific headers actually needed.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
drivers/video/simplefb-fixup.c | 50 +++++++++-------------------------
1 file changed, 13 insertions(+), 37 deletions(-)
diff --git a/drivers/video/simplefb-fixup.c b/drivers/video/simplefb-fixup.c
index 94cf5a788450..ab85d2282efc 100644
--- a/drivers/video/simplefb-fixup.c
+++ b/drivers/video/simplefb-fixup.c
@@ -8,7 +8,6 @@
#define pr_fmt(fmt) "simplefb: " fmt
-#include <common.h>
#include <errno.h>
#include <fb.h>
#include <fcntl.h>
@@ -16,38 +15,15 @@
#include <of.h>
#include <init.h>
#include <xfuncs.h>
-
-struct simplefb_mode {
- const char *format;
- u32 bpp;
- struct fb_bitfield red;
- struct fb_bitfield green;
- struct fb_bitfield blue;
- struct fb_bitfield transp;
-};
+#include <linux/io.h>
+#include <linux/array_size.h>
+#include <linux/platform_data/simplefb.h>
/*
* These values have to match the kernel's simplefb driver.
- * See Documentation/devicetree/bindings/video/simple-framebuffer.txt
+ * See dts/Bindings/display/simple-framebuffer.yaml
*/
-static const struct simplefb_mode simplefb_modes[] = {
- {
- .format = "r5g6b5",
- .bpp = 16,
- .red = { .length = 5, .offset = 11 },
- .green = { .length = 6, .offset = 5 },
- .blue = { .length = 5, .offset = 0 },
- .transp = { .length = 0, .offset = 0 },
- }, {
- .format = "a8r8g8b8",
- .bpp = 32,
- .red = { .length = 8, .offset = 16 },
- .green = { .length = 8, .offset = 8 },
- .blue = { .length = 8, .offset = 0 },
- .transp = { .length = 8, .offset = 24 },
- },
-
-};
+static const struct simplefb_format simplefb_formats[] = SIMPLEFB_FORMATS;
static bool simplefb_bitfield_cmp(const struct fb_bitfield *a,
const struct fb_bitfield *b)
@@ -62,15 +38,15 @@ static bool simplefb_bitfield_cmp(const struct fb_bitfield *a,
return true;
}
-static const struct simplefb_mode *simplefb_find_mode(const struct fb_info *fbi)
+static const struct simplefb_format *simplefb_find_mode(const struct fb_info *fbi)
{
- const struct simplefb_mode *mode;
+ const struct simplefb_format *mode;
u32 i;
- for (i = 0; i < ARRAY_SIZE(simplefb_modes); ++i) {
- mode = &simplefb_modes[i];
+ for (i = 0; i < ARRAY_SIZE(simplefb_formats); ++i) {
+ mode = &simplefb_formats[i];
- if (fbi->bits_per_pixel != mode->bpp)
+ if (fbi->bits_per_pixel != mode->bits_per_pixel)
continue;
if (!simplefb_bitfield_cmp(&fbi->red, &mode->red))
continue;
@@ -154,7 +130,7 @@ static int simplefb_create_node(struct device_node *root,
static int simplefb_of_fixup(struct device_node *root, void *ctx)
{
struct fb_info *info = ctx;
- const struct simplefb_mode *mode;
+ const struct simplefb_format *mode;
int ret;
/* only create node if we are requested to */
@@ -171,11 +147,11 @@ static int simplefb_of_fixup(struct device_node *root, void *ctx)
return -EINVAL;
}
- ret = simplefb_create_node(root, info, mode->format);
+ ret = simplefb_create_node(root, info, mode->name);
if (ret)
dev_err(&info->dev, "failed to create node: %d\n", ret);
else
- dev_info(&info->dev, "created %s node\n", mode->format);
+ dev_info(&info->dev, "created %s node\n", mode->name);
return ret;
}
--
2.47.3
next prev parent reply other threads:[~2026-04-13 10:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 10:06 [PATCH 1/5] video: simplefb: add r5g5b5a1 and x8b8g8r8 formats to SIMPLEFB_FORMATS Ahmad Fatoum
2026-04-13 10:06 ` Ahmad Fatoum [this message]
2026-04-13 10:06 ` [PATCH 3/5] parameter: allow enum params to be set by numeric index Ahmad Fatoum
2026-04-13 10:06 ` [PATCH 4/5] video: simplefb-fixup: add stdout-path mode to register_simplefb param Ahmad Fatoum
2026-04-13 10:07 ` [PATCH 5/5] Documentation: add OpenBSD booting guide Ahmad Fatoum
2026-04-13 12:48 ` [PATCH 1/5] video: simplefb: add r5g5b5a1 and x8b8g8r8 formats to SIMPLEFB_FORMATS Sascha Hauer
2026-04-13 14:56 ` 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=20260413100710.1459468-2-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