From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] video: fb: mirror cdev writes to shadow buffer
Date: Thu, 9 Jul 2026 09:15:25 +0200 [thread overview]
Message-ID: <20260709071526.502694-1-a.fatoum@barebox.org> (raw)
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@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
next reply other threads:[~2026-07-09 7:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 7:15 Ahmad Fatoum [this message]
2026-07-10 21:52 ` 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=20260709071526.502694-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