+#ifdef CONFIG_VIDEO_BMP_GZIP
+bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp,
+ void **alloc_addr)
+{
+ void *dst;
+ unsigned long len;
+ bmp_image_t *bmp;
+
+ /*
+ * Decompress bmp image
+ */
+ len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
+ /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */
+ dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE + 3);
+ if (dst == NULL) {
+ puts("Error: malloc in gunzip failed!\n");
+ return NULL;
+ }
+
+ bmp = dst;
+
+ /* align to 32-bit-aligned-address + 2 */
+ bmp = (bmp_image_t *)((((unsigned int)dst + 1) & ~3) + 2);
+
+ if (gunzip(bmp, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) {
+ free(dst);
+ return NULL;
+ }
+ if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)
+ puts("Image could be truncated"
+ " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
+
+ /*
+ * Check for bmp mark 'BM'
+ */
+ if (!((bmp->header.signature[0] == 'B') &&
+ (bmp->header.signature[1] == 'M'))) {
+ free(dst);
+ return NULL;
+ }
+
+ debug("Gzipped BMP image detected!\n");
+
+ *alloc_addr = dst;
+ return bmp;
+}
+#else
+bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp,
+ void **alloc_addr)
+{
+ return NULL;
+}
+#endif
+
+static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+{
+ ulong addr;
+
+ switch (argc) {
+ case 1: /* use load_addr as default address */
+ addr = load_addr;
+ break;
+ case 2: /* use argument */
+ addr = simple_strtoul(argv[1], NULL, 16);
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+
+ return (bmp_info(addr));
+}
+
+static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])