aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-11-19 13:23:48 -0700
committerAnatolij Gustschin <agust@denx.de>2021-12-26 23:02:19 +0100
commit301af2388af36b62ddec08b547300f5b5464df47 (patch)
treea3d9a932191a22daf3082608e90c50e68f75f035 /drivers
parent4057e2772d043ecfa0efc4d16bd8ab664afb69a0 (diff)
downloadu-boot-301af2388af36b62ddec08b547300f5b5464df47.zip
u-boot-301af2388af36b62ddec08b547300f5b5464df47.tar.gz
u-boot-301af2388af36b62ddec08b547300f5b5464df47.tar.bz2
video: sandbox: Set a maximum frame-buffer size
If U-Boot starts with the frame buffer set to 16bpp but then runs a test that uses 32bpp, there is not enough space. Update the driver to use the maximum possible frame-buffer size, to avoid this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/sandbox_sdl.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c
index 6e430b2..de8c660 100644
--- a/drivers/video/sandbox_sdl.c
+++ b/drivers/video/sandbox_sdl.c
@@ -55,10 +55,26 @@ static void set_bpp(struct udevice *dev, enum video_log2_bpp l2bpp)
plat->bpix = l2bpp;
- uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
+ uc_plat->size = plat->xres * plat->yres * VNBYTES(plat->bpix);
+
+ /*
+ * Set up to the maximum size we'll ever need. This is a strange case.
+ * The video memory is allocated by video_post_bind() called from
+ * board_init_r(). If a test changes the reoslution so it needs more
+ * memory later (with sandbox_sdl_set_bpp()), it is too late to make
+ * the frame buffer larger.
+ *
+ * So use a maximum size here.
+ */
+ uc_plat->size = max(uc_plat->size, 1920U * 1080 * VNBYTES(VIDEO_BPP32));
/* Allow space for two buffers, the lower one being the copy buffer */
log_debug("Frame buffer size %x\n", uc_plat->size);
+
+ /*
+ * If a copy framebuffer is used, double the size and use the last half
+ * as the copy, with the first half as the normal frame buffer.
+ */
if (IS_ENABLED(CONFIG_VIDEO_COPY))
uc_plat->size *= 2;
}