我以这种方式在简单的帧缓冲区中实现了 1bpp:
diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
index 533a047d07a2..9c654ff10ab7 100644
--- a/drivers/video/fbdev/simplefb.c
+++ b/drivers/video/fbdev/simplefb.c
@@ -25,7 +25,8 @@
#include <linux/parser.h>
#include <linux/regulator/consumer.h>
-static const struct fb_fix_screeninfo simplefb_fix = {
+// removed const
+static struct fb_fix_screeninfo simplefb_fix = {
.id = "simple",
.type = FB_TYPE_PACKED_PIXELS,
.visual = FB_VISUAL_TRUECOLOR,
@@ -432,6 +433,10 @@ static int simplefb_probe(struct platform_device *pdev)
par = info->par;
+ if (params.format->bits_per_pixel == 1) {
+ simplefb_fix.visual = FB_VISUAL_MONO01;
+ }
+
info->fix = simplefb_fix;
info->fix.smem_start = mem->start;
info->fix.smem_len = resource_size(mem);
@@ -480,10 +485,10 @@ static int simplefb_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n",
info->fix.smem_start, info->fix.smem_len,
info->screen_base);
- dev_info(&pdev->dev, "format=%s, mode=%dx%dx%d, linelength=%d\n",
+ dev_info(&pdev->dev, "format=%s, mode=%dx%dx%d, linelength=%d, visual=%d\n",
params.format->name,
info->var.xres, info->var.yres,
- info->var.bits_per_pixel, info->fix.line_length);
+ info->var.bits_per_pixel, info->fix.line_length, simplefb_fix.visual);
ret = register_framebuffer(info);
if (ret < 0) {
diff --git a/include/linux/platform_data/simplefb.h b/include/linux/platform_data/simplefb.h
index ca8337695c2a..77714fc5f789 100644
--- a/include/linux/platform_data/simplefb.h
+++ b/include/linux/platform_data/simplefb.h
@@ -24,6 +24,7 @@
{ "a8b8g8r8", 32, {0, 8}, {8, 8}, {16, 8}, {24, 8}, DRM_FORMAT_ABGR8888 }, \
{ "x2r10g10b10", 32, {20, 10}, {10, 10}, {0, 10}, {0, 0}, DRM_FORMAT_XRGB2101010 }, \
{ "a2r10g10b10", 32, {20, 10}, {10, 10}, {0, 10}, {30, 2}, DRM_FORMAT_ARGB2101010 }, \
+ { "r1", 1, {0, 1}, {0, 0}, {0, 0}, {0, 0}, 0 }, \
}
/*
然后设备树记录以这种方式查找 256x128 单色显示:
fb0: framebuffer@43c40000 {
compatible = "simple-framebuffer";
reg = <0x43c40000 (32 * 16)>;
width = <256>;
height = <128>;
stride = <32>;
format = "r1";
status = "okay";
};