ODROID-C5: showlogo: improve to load logo files
This patch is to look up the boot logo file in partitions of the default
boot media and replace shell commands 'load ...' to function calls.
Change-Id: Id64cda68b9686e04905ec9f239e75267f74f5468
diff --git a/cmd/showlogo.c b/cmd/showlogo.c
index 025b1ad..2ac70f1 100644
--- a/cmd/showlogo.c
+++ b/cmd/showlogo.c
@@ -10,14 +10,10 @@
#include <common.h>
#include <command.h>
+#include <fs.h>
+#include <mmc.h>
#include <vsprintf.h>
-static int boot_partition(void)
-{
- // TODO
- return 1;
-}
-
static int init_hdmi(const char* mode, bool bestmode) {
/*
* TODO reboot mode
@@ -47,11 +43,50 @@
return 0;
}
+static int load_boot_logo(void)
+{
+ const char *logofiles[] = {
+#ifdef CONFIG_VIDEO_BMP_GZIP
+ "boot-logo.bmp.gz",
+#endif
+ "boot-logo.bmp"
+ };
+
+ char *dev_type = "mmc";
+ char dev_part[16];
+ int bootdev = mmc_get_env_dev();
+ int i, j;
+ int ret;
+ loff_t len;
+ ulong addr;
+
+ addr = simple_strtoull(env_get("bootlogo_addr"), NULL, 0);
+ if (!addr)
+ return 0;
+
+ /* check boot device */
+
+ for (i = 1; i <= 3; i++) {
+ sprintf(dev_part, "%d:%d", bootdev, i);
+
+ for (j = 0; j < ARRAY_SIZE(logofiles); j++) {
+ if (file_exists(dev_type, dev_part, logofiles[j], FS_TYPE_ANY)) {
+ fs_set_blk_dev(dev_type, dev_part, FS_TYPE_ANY);
+ ret = fs_read(logofiles[j], addr, 0, 0, &len);
+ if (ret < 0) {
+ return 0;
+ }
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
static int display_logo(const char* mode, const char* bmp_width, const char* bmp_height)
{
int ret = 0;
- char str[64];
- int bootdev;
int bmp_load = false;
// TODO bestmode
@@ -61,27 +96,14 @@
return -1;
}
- /* check boot device */
- bootdev = boot_partition();
-
env_set("bootlogo_addr", env_get("loadaddr"));
-#ifdef CONFIG_VIDEO_BMP_GZIP
- sprintf(str, "load mmc %d ${bootlogo_addr} boot-logo.bmp.gz", bootdev);
- ret = run_command(str, 0);
- if (!ret) bmp_load = true;
-#endif
- sprintf(str, "load mmc %d ${bootlogo_addr} boot-logo.bmp", bootdev);
- ret = run_command(str, 0);
- if (!ret) bmp_load = true;
+ bmp_load = load_boot_logo();
if (bmp_load) {
/* color */
env_set("display_bpp", "24");
env_set("display_color_index", "24");
- // env_set("display_color_fg", "0xffff");
- // env_set("display_color_bg", "0");
- // env_set("cvbsmode", "576cvbs");
/* frame buffer */
@@ -89,7 +111,7 @@
// env_set("fb_width", env_get("display_width"));
// env_set("fb_height", env_get("display_height"));
- // else
+ // else. fb size from bmp size
env_set("fb_width", bmp_width);
env_set("fb_height", bmp_height);