[PATCH] video: fb: mirror cdev writes to shadow buffer
Ahmad Fatoum
a.fatoum at barebox.org
Thu Jul 9 00:15:25 PDT 2026
The shadow framebuffer is allocated by the framebuffer core,
but maintained by gui_screen_blit and gu_screen_blit_area.
Direct framebuffer devices currently ignore the shadow framebuffer,
which leads to surprising behavior when doing sequences like:
cp /dev/zero /dev/fb0
splash /env/data/splash.png
as the framebuffer is first cleared and then the old content appear
again as background of the splash screen.
Fix this by having writes go to both.
Reads should arguably be left out as it's useful to be able to see
the actual framebuffer used by the hardware.
Mmap is a bit hairier, but what we do here is already an improvement.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
drivers/video/fb.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fb.c b/drivers/video/fb.c
index 10d34a39e2b2..d5ab7f4088da 100644
--- a/drivers/video/fb.c
+++ b/drivers/video/fb.c
@@ -238,9 +238,22 @@ static int fb_set_modename(struct param_d *param, void *priv)
return 0;
}
+static ssize_t fb_cdev_write(struct cdev *cdev, const void *buf, size_t count,
+ loff_t offset, ulong flags)
+{
+ struct fb_info *info = cdev->priv;
+ ssize_t ret;
+
+ ret = mem_write(cdev, buf, count, offset, flags);
+ if (ret > 0 && info->screen_base_shadow)
+ memcpy(info->screen_base_shadow + offset, buf, ret);
+
+ return ret;
+}
+
static struct cdev_operations fb_ops = {
.read = mem_read,
- .write = mem_write,
+ .write = fb_cdev_write,
.memmap = generic_memmap_rw,
.ioctl = fb_ioctl,
.close = fb_close,
--
2.47.3
More information about the barebox
mailing list