summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2021-01-31 21:18:40 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-08 10:57:05 +0100
commit12ad41f91f1824eb141e368294d97860644ab777 (patch)
tree032da73369f4cf1e2a4614c87b358a87fa64659b /drivers
parentf38f34a2f41e5981f2995231d94688d31104befc (diff)
downloadbarebox-12ad41f91f1824eb141e368294d97860644ab777.tar.gz
barebox-12ad41f91f1824eb141e368294d97860644ab777.tar.xz
sandbox: migrate to SDL 2.0
SDL 2.0 has been released more than 7 years ago and should be available everywhere. Replace barebox's SDL 1.2 with SDL 2.0 instead: - better maintained - At least on Debian, you can't install x86_64 and i386 libsdl-dev at the same time, which makes a quick use of CONFIG_SANDBOX_LINUX_I386 harder as the user needs to reinstall libraries. With SDL 2.0, it works - SDL 2.0 has easier audio API, which will be used in a later commit - Wayland support for sandbox video driver Port to SDL 2.0 and as we touch everything anyway, rename the sdl_ functions to start with sdl_video_ to differentiate from upcoming sdl_sound_. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/Kconfig1
-rw-r--r--drivers/video/sdl.c37
2 files changed, 24 insertions, 14 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 9ec6ea4248..b6d468c63c 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -82,6 +82,7 @@ endif
config DRIVER_VIDEO_SDL
bool "SDL framebuffer driver"
depends on SANDBOX
+ select SDL
config DRIVER_VIDEO_PXA
bool "PXA27x framebuffer driver"
diff --git a/drivers/video/sdl.c b/drivers/video/sdl.c
index 9811b2cf12..e9debc51b1 100644
--- a/drivers/video/sdl.c
+++ b/drivers/video/sdl.c
@@ -13,23 +13,25 @@
#include <errno.h>
#include <gui/graphic_utils.h>
+#define to_mask(color) GENMASK(color.length - 1, color.offset)
+
static void sdlfb_enable(struct fb_info *info)
{
- int ret;
-
- ret = sdl_open(info->xres, info->yres, info->bits_per_pixel,
- info->screen_base);
- if (ret)
- return;
- sdl_get_bitfield_rgba(&info->red, &info->green, &info->blue, &info->transp);
-
- sdl_start_timer();
+ struct sdl_fb_info sdl_info = {
+ .screen_base = info->screen_base,
+ .xres = info->xres, .yres = info->yres, .bpp = info->bits_per_pixel,
+ .rmask = to_mask(info->red),
+ .gmask = to_mask(info->green),
+ .bmask = to_mask(info->blue),
+ .amask = to_mask(info->transp),
+ };
+
+ sdl_video_open(&sdl_info);
}
static void sdlfb_disable(struct fb_info *info)
{
- sdl_stop_timer();
- sdl_close();
+ sdl_video_close();
}
static struct fb_ops sdlfb_ops = {
@@ -48,10 +50,19 @@ static int sdlfb_probe(struct device_d *dev)
fb = xzalloc(sizeof(*fb));
fb->modes.modes = fb->mode = dev->platform_data;
fb->modes.num_modes = 1;
- fb->bits_per_pixel = 4 << 3;
fb->xres = fb->mode->xres;
fb->yres = fb->mode->yres;
+ fb->bits_per_pixel = 32;
+ fb->transp.length = 8;
+ fb->red.length = 8;
+ fb->green.length = 8;
+ fb->blue.length = 8;
+ fb->transp.offset = 24;
+ fb->red.offset = 16;
+ fb->green.offset = 8;
+ fb->blue.offset = 0;
+
fb->priv = fb;
fb->fbops = &sdlfb_ops;
@@ -68,7 +79,6 @@ static int sdlfb_probe(struct device_d *dev)
kfree(fb->screen_base);
kfree(fb);
- sdl_close();
return ret;
}
@@ -78,7 +88,6 @@ static void sdlfb_remove(struct device_d *dev)
kfree(fb->screen_base);
kfree(fb);
- sdl_close();
}
static struct driver_d sdlfb_driver = {