diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-09-12 15:38:42 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-25 10:15:29 +0200 |
commit | 9d73b518fc3c61640123f8499aab7f8373e41dbd (patch) | |
tree | af61e6fd5a655afb46f66aa8ca7d0d68f2026c83 /drivers | |
parent | 910d0132905ca3ff12dddbcbceb94b4b5112ab5c (diff) | |
download | barebox-9d73b518fc3c61640123f8499aab7f8373e41dbd.tar.gz barebox-9d73b518fc3c61640123f8499aab7f8373e41dbd.tar.xz |
sandbox: add sdl video support
This will allow speed up the dev on framebuffer.
By default the resolution is VGA but this can be changed via cmdline.
We use a pthread to Flip the screen every 100ms as we can not detect when
barebox update it as barebox simpliy write in a buffer.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/Kconfig | 4 | ||||
-rw-r--r-- | drivers/video/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/sdl.c | 101 |
3 files changed, 106 insertions, 0 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 519cdbf25a..4aa92c5993 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -44,6 +44,10 @@ config DRIVER_VIDEO_S3C_VERBOSE endif +config DRIVER_VIDEO_SDL + bool "SDL framebuffer driver" + depends on SANDBOX + config DRIVER_VIDEO_PXA bool "PXA27x framebuffer driver" depends on ARCH_PXA27X diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 913c78d92b..77f6682576 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_DRIVER_VIDEO_IMX) += imx.o obj-$(CONFIG_DRIVER_VIDEO_IMX_IPU) += imx-ipu-fb.o obj-$(CONFIG_DRIVER_VIDEO_S3C24XX) += s3c24xx.o obj-$(CONFIG_DRIVER_VIDEO_PXA) += pxa.o +obj-$(CONFIG_DRIVER_VIDEO_SDL) += sdl.o diff --git a/drivers/video/sdl.c b/drivers/video/sdl.c new file mode 100644 index 0000000000..ed083d76f5 --- /dev/null +++ b/drivers/video/sdl.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * GPL v2 + */ + +#include <common.h> +#include <driver.h> +#include <init.h> +#include <malloc.h> +#include <mach/linux.h> +#include <fb.h> +#include <errno.h> +#include <graphic_utils.h> + +static void sdlfb_enable(struct fb_info *info) +{ + sdl_start_timer(); +} + +static void sdlfb_disable(struct fb_info *info) +{ + sdl_stop_timer(); +} + +static struct fb_ops sdlfb_ops = { + .fb_enable = sdlfb_enable, + .fb_disable = sdlfb_disable, +}; + +static int sdlfb_probe(struct device_d *dev) +{ + struct fb_info *fb; + int ret = -EIO; + + if (!dev->platform_data) + return -EIO; + + fb = xzalloc(sizeof(*fb)); + fb->mode_list = fb->mode = dev->platform_data; + fb->num_modes = 1; + fb->bits_per_pixel = 4 << 3; + fb->xres = fb->mode->xres; + fb->yres = fb->mode->yres; + + fb->priv = fb; + fb->fbops = &sdlfb_ops, + + fb->dev.parent = dev; + fb->screen_base = xzalloc(fb->xres * fb->yres * + fb->bits_per_pixel >> 3); + + if (sdl_open(fb->xres, fb->yres, fb->bits_per_pixel, + fb->screen_base)) + goto err; + + sdl_get_bitfield_rgba(&fb->red, &fb->green, &fb->blue, &fb->transp); + + dev_dbg(dev, "red: length = %d, offset = %d\n", + fb->red.length, fb->red.offset); + dev_dbg(dev, "green: length = %d, offset = %d\n", + fb->green.length, fb->green.offset); + dev_dbg(dev, "blue: length = %d, offset = %d\n", + fb->blue.length, fb->blue.offset); + dev_dbg(dev, "transp: length = %d, offset = %d\n", + fb->transp.length, fb->transp.offset); + + /* add runtime hardware info */ + dev->priv = fb; + + ret = register_framebuffer(fb); + if (!ret) + return 0; + +err: + kfree(fb->screen_base); + kfree(fb); + sdl_close(); + return ret; +} + +static void sdlfb_remove(struct device_d *dev) +{ + struct fb_info *fb = dev->priv; + + kfree(fb->screen_base); + kfree(fb); + sdl_close(); +} + +static struct driver_d sdlfb_driver = { + .name = "sdlfb", + .probe = sdlfb_probe, + .remove = sdlfb_remove, +}; + +static int sdlfb_init(void) +{ + return register_driver(&sdlfb_driver); +} +device_initcall(sdlfb_init); |