]> git.sur5r.net Git - u-boot/commitdiff
dm: video: sandbox: Convert sandbox to use driver model for video
authorSimon Glass <sjg@chromium.org>
Tue, 19 Jan 2016 02:52:25 +0000 (19:52 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 21 Jan 2016 02:10:16 +0000 (19:10 -0700)
Now that driver model support is available, convert sandbox over to use it.
We can remove a few of the special hooks that sandbox currently has.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Anatolij Gustschin <agust@denx.de>
arch/sandbox/dts/sandbox.dts
board/sandbox/sandbox.c
common/lcd.c
configs/sandbox_defconfig
drivers/serial/sandbox.c
drivers/video/sandbox_sdl.c
include/configs/sandbox.h
include/fdtdec.h
lib/fdtdec.c

index d2addb4cf0ba0d8066e809ac7abbbc53569a69bf..e3f02bf13cacd6ad5f739433674337a45b5d5b58 100644 (file)
        };
 
        lcd {
+               u-boot,dm-pre-reloc;
                compatible = "sandbox,lcd-sdl";
                xres = <1366>;
                yres = <768>;
index 592f7728c02d5c72f0e842b61296ea5fbcf14012..b41e9decb306b0e5d05d57f14e51ccfb43b7533f 100644 (file)
@@ -47,23 +47,6 @@ int dram_init(void)
        return 0;
 }
 
-#ifdef CONFIG_BOARD_EARLY_INIT_F
-int board_early_init_f(void)
-{
-#ifdef CONFIG_VIDEO_SANDBOX_SDL
-       int ret;
-
-       ret = sandbox_lcd_sdl_early_init();
-       if (ret) {
-               puts("Could not init sandbox LCD emulation\n");
-               return ret;
-       }
-#endif
-
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
index d29308aeb6a8ab32d5c5f73c91af37f287333e20..2f3594a4176cb673bc9bfa095a58b6c22098d059 100644 (file)
 #endif
 #endif
 
-#ifdef CONFIG_SANDBOX
-#include <asm/sdl.h>
-#endif
-
 #ifndef CONFIG_LCD_ALIGNMENT
 #define CONFIG_LCD_ALIGNMENT PAGE_SIZE
 #endif
@@ -72,13 +68,6 @@ void lcd_sync(void)
        if (lcd_flush_dcache)
                flush_dcache_range((u32)lcd_base,
                        (u32)(lcd_base + lcd_get_size(&line_length)));
-#elif defined(CONFIG_SANDBOX) && defined(CONFIG_VIDEO_SANDBOX_SDL)
-       static ulong last_sync;
-
-       if (get_timer(last_sync) > 10) {
-               sandbox_sdl_sync(lcd_base);
-               last_sync = get_timer(0);
-       }
 #endif
 }
 
index 65184c8e853ed7de2b483e57b7fbdb523987cfab..898c5f47ac8ee2574baef08e630c15042eb9f4b9 100644 (file)
@@ -76,6 +76,7 @@ CONFIG_USB_EMUL=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_KEYBOARD=y
 CONFIG_SYS_USB_EVENT_POLL=y
+CONFIG_DM_VIDEO=y
 CONFIG_VIDEO_SANDBOX_SDL=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
index cd2f91e28e8f96b0d651cac208cbbe1c4fb12303..45dff98d9d10cea6e28bc2c7ce89723cc8ea7526 100644 (file)
@@ -16,6 +16,7 @@
 #include <lcd.h>
 #include <os.h>
 #include <serial.h>
+#include <video.h>
 #include <linux/compiler.h>
 #include <asm/state.h>
 
@@ -114,9 +115,7 @@ static int sandbox_serial_pending(struct udevice *dev, bool input)
                return 0;
 
        os_usleep(100);
-#ifdef CONFIG_LCD
-       lcd_sync();
-#endif
+       video_sync_all();
        if (next_index == serial_buf_read)
                return 1;       /* buffer full */
 
index ba4578e9d1530b30fea8c65b972198f4dc61b756..450628e07c4a7f846aef7d6e526cb38e10a17e96 100644 (file)
@@ -5,75 +5,76 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <fdtdec.h>
-#include <lcd.h>
-#include <malloc.h>
+#include <video.h>
 #include <asm/sdl.h>
 #include <asm/u-boot-sandbox.h>
+#include <dm/test.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 enum {
-       /* Maximum LCD size we support */
+       /* Default LCD size we support */
        LCD_MAX_WIDTH           = 1366,
        LCD_MAX_HEIGHT          = 768,
-       LCD_MAX_LOG2_BPP        = 4,            /* 2^4 = 16 bpp */
 };
 
-vidinfo_t panel_info;
 
-void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
-{
-}
+/* This platform data is needed in tests, so declare it here */
+struct sandbox_sdl_plat {
+       int xres;
+       int yres;
+       int bpix;
+       int rot;
+};
 
-void lcd_ctrl_init(void *lcdbase)
+static int sandbox_sdl_probe(struct udevice *dev)
 {
-       /*
-        * Allocate memory to keep BMP color conversion map. This is required
-        * for 8 bit BMPs only (hence 256 colors). If malloc fails - keep
-        * going, it is not even clear if displyaing the bitmap will be
-        * required on the way up.
-        */
-       panel_info.cmap = malloc(256 * NBITS(panel_info.vl_bpix) / 8);
-}
+       struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
+       struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+       int ret;
 
-void lcd_enable(void)
-{
-       if (sandbox_sdl_init_display(panel_info.vl_col, panel_info.vl_row,
-                                    panel_info.vl_bpix))
+       ret = sandbox_sdl_init_display(plat->xres, plat->yres, plat->bpix);
+       if (ret) {
                puts("LCD init failed\n");
+               return ret;
+       }
+       uc_priv->xsize = plat->xres;
+       uc_priv->ysize = plat->yres;
+       uc_priv->bpix = plat->bpix;
+       uc_priv->rot = plat->rot;
+
+       return 0;
 }
 
-int sandbox_lcd_sdl_early_init(void)
+static int sandbox_sdl_bind(struct udevice *dev)
 {
+       struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
+       struct sandbox_sdl_plat *plat = dev_get_platdata(dev);
        const void *blob = gd->fdt_blob;
-       int xres = LCD_MAX_WIDTH, yres = LCD_MAX_HEIGHT;
-       int node;
+       int node = dev->of_offset;
        int ret = 0;
 
-       /*
-        * The code in common/lcd.c does not cope with not being able to
-        * set up a frame buffer. It will just happily keep writing to
-        * invalid memory. So here we make sure that at least some buffer
-        * is available even if it actually won't be displayed.
-        */
-       node = fdtdec_next_compatible(blob, 0, COMPAT_SANDBOX_LCD_SDL);
-       if (node >= 0) {
-               xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
-               yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
-               if (xres < 0 || xres > LCD_MAX_WIDTH) {
-                       xres = LCD_MAX_WIDTH;
-                       ret = -EINVAL;
-               }
-               if (yres < 0 || yres > LCD_MAX_HEIGHT) {
-                       yres = LCD_MAX_HEIGHT;
-                       ret = -EINVAL;
-               }
-       }
-
-       panel_info.vl_col = xres;
-       panel_info.vl_row = yres;
-       panel_info.vl_bpix = LCD_COLOR16;
+       plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
+       plat->yres = fdtdec_get_int(blob, node, "yres", LCD_MAX_HEIGHT);
+       plat->bpix = VIDEO_BPP16;
+       uc_plat->size = plat->xres * plat->yres * (1 << plat->bpix) / 8;
+       debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
 
        return ret;
 }
+
+static const struct udevice_id sandbox_sdl_ids[] = {
+       { .compatible = "sandbox,lcd-sdl" },
+       { }
+};
+
+U_BOOT_DRIVER(sdl_sandbox) = {
+       .name   = "sdl_sandbox",
+       .id     = UCLASS_VIDEO,
+       .of_match = sandbox_sdl_ids,
+       .bind   = sandbox_sdl_bind,
+       .probe  = sandbox_sdl_probe,
+       .platdata_auto_alloc_size       = sizeof(struct sandbox_sdl_plat),
+};
index e1be60369845a1a9669b5946d533ee9960e53589..23ae44c8a0390dd4fce6f59f774ef6d3020c4693 100644 (file)
 
 /* LCD and keyboard require SDL support */
 #ifdef CONFIG_SANDBOX_SDL
-#define CONFIG_LCD
 #define CONFIG_CMD_BMP
-#define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 #define LCD_BPP                        LCD_COLOR16
 #define CONFIG_KEYBOARD
 
 #define SANDBOX_SERIAL_SETTINGS                "stdin=serial,cros-ec-keyb,usbkbd\0" \
-                                       "stdout=serial,lcd\0" \
-                                       "stderr=serial,lcd\0"
+                                       "stdout=serial,lcd.vidconsole\0" \
+                                       "stderr=serial,lcd.vidconsole\0"
 #else
 #define SANDBOX_SERIAL_SETTINGS                "stdin=serial\0" \
-                                       "stdout=serial,lcd\0" \
-                                       "stderr=serial,lcd\0"
+                                       "stdout=serial,lcd.vidconsole\0" \
+                                       "stderr=serial,lcd.vidconsole\0"
 #endif
 
 #define SANDBOX_ETH_SETTINGS           "ethaddr=00:00:11:22:33:44\0" \
index 27b350e241279ad2906c65954e9028d390e10644..25e98c9c9e1ae2e3f0c73fd069c05374e8f54c3d 100644 (file)
@@ -151,7 +151,6 @@ enum fdt_compat_id {
        COMPAT_GENERIC_SPI_FLASH,       /* Generic SPI Flash chip */
        COMPAT_MAXIM_98095_CODEC,       /* MAX98095 Codec */
        COMPAT_SAMSUNG_EXYNOS5_I2C,     /* Exynos5 High Speed I2C Controller */
-       COMPAT_SANDBOX_LCD_SDL,         /* Sandbox LCD emulation with SDL */
        COMPAT_SAMSUNG_EXYNOS_SYSMMU,   /* Exynos sysmmu */
        COMPAT_INTEL_MICROCODE,         /* Intel microcode update */
        COMPAT_MEMORY_SPD,              /* Memory SPD information */
index b50d10516105cc0c1c4c8a72a25eec24207a6916..d56e1b11f01d43d784be9120c7dbef14b8cd0361 100644 (file)
@@ -56,7 +56,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(GENERIC_SPI_FLASH, "spi-flash"),
        COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),
        COMPAT(SAMSUNG_EXYNOS5_I2C, "samsung,exynos5-hsi2c"),
-       COMPAT(SANDBOX_LCD_SDL, "sandbox,lcd-sdl"),
        COMPAT(SAMSUNG_EXYNOS_SYSMMU, "samsung,sysmmu-v3.3"),
        COMPAT(INTEL_MICROCODE, "intel,microcode"),
        COMPAT(MEMORY_SPD, "memory-spd"),