[U-Boot] [PATCH] cmd: bmp: manage centered display

Patrick Delaunay
2018-11-14T09:18:22Z

Allow to display BMP at the middle of the screen.

'm' means "middle" as it is done for the splashscreen variable:
splashpos=m,m

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
Example for command

load mmc 0:4 ${splashimage} splash.bmp
bmp display ${splashimage} m m

or function can be used directly

bmp_display(0xC0000000, BMP_ALIGN_CENTER, BMP_ALIGN_CENTER)

cmd/bmp.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/cmd/bmp.c b/cmd/bmp.c
index 02bdf48..1ace8a8 100644
--- a/cmd/bmp.c
+++ b/cmd/bmp.c
@@ -108,6 +108,7 @@ static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[
return (bmp_info(addr));
}

+#define BMP_ALIGN_CENTER 0x7FFF
static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
ulong addr;
@@ -124,8 +125,14 @@ static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const ar
break;
case 4:
addr = simple_strtoul(argv[1], NULL, 16);
- x = simple_strtoul(argv[2], NULL, 10);
- y = simple_strtoul(argv[3], NULL, 10);
+ if (!strcmp(argv[2], "m"))
+ x = BMP_ALIGN_CENTER;
+ else
+ x = simple_strtoul(argv[2], NULL, 10);
+ if (!strcmp(argv[3], "m"))
+ y = BMP_ALIGN_CENTER;
+ else
+ y = simple_strtoul(argv[3], NULL, 10);
break;
default:
return CMD_RET_USAGE;
@@ -249,9 +256,11 @@ int bmp_display(ulong addr, int x, int y)
if (!ret) {
bool align = false;

-# ifdef CONFIG_SPLASH_SCREEN_ALIGN
- align = true;
-# endif /* CONFIG_SPLASH_SCREEN_ALIGN */
+ if (CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) ||
+ x == BMP_ALIGN_CENTER ||
+ y == BMP_ALIGN_CENTER)
+ align = true;
+
ret = video_bmp_display(dev, addr, x, y, align);
}
#elif defined(CONFIG_LCD)
--
2.7.4