summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongjin Kim <tobetter@gmail.com>2021-11-26 15:23:32 +0300
committerDongjin Kim <tobetter@gmail.com>2021-12-30 12:51:22 +0300
commit518bbfe5457d501061f872757ad6eac02842f241 (patch)
tree35b04ad1c77d38ae690a004906e28e623bd0667f
parent356906e6445378a45ac14ec184fc6e666b22338a (diff)
downloadu-boot-518bbfe5457d501061f872757ad6eac02842f241.tar.xz
ODROID-M1: add to load default splash image
This patch is to load the default splash image from a dedicated partition in SPI flash memory and use it for a default U-Boot logo image after putting into resource pool. Change-Id: I640b9db5c841ef5dfbb73e72590342b20de4a691 Signed-off-by: Dongjin Kim <tobetter@gmail.com>
-rw-r--r--board/hardkernel/odroid-m1/odroid-m1.c97
-rw-r--r--include/configs/odroid-m1.h9
-rw-r--r--include/video_rockchip.h2
3 files changed, 108 insertions, 0 deletions
diff --git a/board/hardkernel/odroid-m1/odroid-m1.c b/board/hardkernel/odroid-m1/odroid-m1.c
index 3bd23a96ae..74e3e2ee6d 100644
--- a/board/hardkernel/odroid-m1/odroid-m1.c
+++ b/board/hardkernel/odroid-m1/odroid-m1.c
@@ -10,6 +10,14 @@
#include <usb.h>
#include <mmc.h>
#include <mtd_blk.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <lcd.h>
+#include "../../../drivers/video/drm/rockchip_display.h"
+
+extern int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+extern struct rockchip_logo_cache *find_or_alloc_logo_cache(const char *bmp);
+extern void *get_display_buffer(int size);
DECLARE_GLOBAL_DATA_PTR;
@@ -86,3 +94,92 @@ int board_read_dtb_file(void *fdt_addr)
return fdt_check_header(fdt_addr);
}
+
+#ifdef CONFIG_MISC_INIT_R
+static int set_bmp_logo(const char *bmp_name, void *addr, int flip)
+{
+ struct logo_info *logo;
+ struct rockchip_logo_cache *logo_cache;
+ struct bmp_image *bmp = (struct bmp_image *)map_sysmem((ulong)addr, 0);
+ struct bmp_header *header = (struct bmp_header *)bmp;
+ void *src;
+ void *dst;
+ int stride;
+ int i;
+
+ if (!bmp_name || !addr)
+ return -EINVAL;
+
+ if (!((bmp->header.signature[0]=='B') &&
+ (bmp->header.signature[1]=='M')))
+ return -EINVAL;
+
+ logo_cache = find_or_alloc_logo_cache(bmp_name);
+ if (!logo_cache)
+ return -ENOMEM;
+
+ logo = &logo_cache->logo;
+ logo->bpp = get_unaligned_le16(&header->bit_count);
+ if (logo->bpp != 24) {
+ printf("Unsupported bpp=%d\n", logo->bpp);
+ return -EINVAL;
+ }
+
+ logo->width = get_unaligned_le32(&header->width);
+ logo->height = get_unaligned_le32(&header->height);
+ logo->offset = get_unaligned_le32(&header->data_offset);
+ logo->ymirror = 0;
+
+ logo->mem = get_display_buffer(get_unaligned_le32(&header->file_size));
+ if (!logo->mem)
+ return -ENOMEM;
+
+ src = addr + logo->offset;
+ dst = logo->mem + logo->offset;
+ stride = ALIGN(logo->width * 3, 4);
+
+ if (flip)
+ src += stride * (logo->height - 1);
+
+ for (i = 0; i < logo->height; i++) {
+ memcpy(dst, src, 3 * logo->width);
+ dst += stride;
+ src += stride;
+
+ if (flip)
+ src -= stride * 2;
+ }
+
+ flush_dcache_range((ulong)logo->mem,
+ ALIGN((ulong)logo->mem
+ + (logo->width * logo->height * logo->bpp >> 3),
+ CONFIG_SYS_CACHELINE_SIZE));
+
+ return 0;
+}
+
+int misc_init_r(void)
+{
+ void *decomp;
+ struct bmp_image *bmp;
+ unsigned int loadaddr = (unsigned int)env_get_ulong("loadaddr", 16, 0);
+ unsigned long len = 0x100000;
+ char str[80];
+ int ret;
+
+ snprintf(str, sizeof(str),
+ "mtd read nor0 0x%08x 0x300000 0x%08x",
+ loadaddr, (unsigned int)len);
+ ret = run_command(str, 0);
+ if (ret)
+ return 1;
+
+ bmp = gunzip_bmp(loadaddr, &len, &decomp);
+ if (bmp)
+ set_bmp_logo("logo.bmp", bmp, 1);
+
+ free(decomp);
+
+ return 0;
+}
+#endif
diff --git a/include/configs/odroid-m1.h b/include/configs/odroid-m1.h
index 1058122f60..eec452c328 100644
--- a/include/configs/odroid-m1.h
+++ b/include/configs/odroid-m1.h
@@ -9,6 +9,8 @@
#include <configs/rk3568_common.h>
+#define CONFIG_MISC_INIT_R
+
#undef RKIMG_BOOTCOMMAND
#ifndef CONFIG_SPL_BUILD
@@ -49,9 +51,16 @@
#define ENV_MEM_LAYOUT_SETTINGS1 \
"cramfsaddr=0x0c000000\0" \
+ "splashimage=0x05000000\0" \
"loadaddr=0x02000000\0"
#define CONFIG_ENV_SECT_SIZE 0x10000
+#define CONFIG_BMP_16BPP
+#define CONFIG_BMP_24BPP
+#define CONFIG_BMP_32BPP
+#define CONFIG_VIDEO_BMP_GZIP
+#define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE ((1920 * 1080 * 4) + 54)
+
#endif
#endif
diff --git a/include/video_rockchip.h b/include/video_rockchip.h
index 02a6178ff6..67e942fba2 100644
--- a/include/video_rockchip.h
+++ b/include/video_rockchip.h
@@ -7,6 +7,8 @@
#ifndef VIDEO_ROCKCHIP_H
#define VIDEO_ROCKCHIP_H
+#define CONFIG_DRM_ROCKCHIP_VIDEO_FRAMEBUFFER
+
#ifdef CONFIG_DRM_ROCKCHIP_VIDEO_FRAMEBUFFER
#define DRM_ROCKCHIP_FB_WIDTH 1920
#define DRM_ROCKCHIP_FB_HEIGHT 1080