[PATCH 2/5] video: simplefb-fixup: use shared SIMPLEFB_FORMATS table
Ahmad Fatoum
a.fatoum at barebox.org
Mon Apr 13 03:06:57 PDT 2026
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 at 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
More information about the barebox
mailing list