[U-Boot-Users] [PATCH] Changes ADS5121 splash screen from hard-coded bmp to flash bmp

Martha Marx mmarx at silicontkx.com
Thu May 29 20:24:09 CEST 2008


Signed-off-by: Martha Marx <mmarx at silicontkx.com>
---
 board/ads5121/Makefile              |    1 -
 board/ads5121/ads5121_diu.c         |   66 +++++++++++++++++++++++++++++++----
 board/freescale/common/fsl_diu_fb.c |    6 +++-
 include/configs/ads5121.h           |    2 +
 4 files changed, 66 insertions(+), 9 deletions(-)

diff --git a/board/ads5121/Makefile b/board/ads5121/Makefile
index f4dacce..0e4de61 100644
--- a/board/ads5121/Makefile
+++ b/board/ads5121/Makefile
@@ -30,7 +30,6 @@ LIB	= $(obj)lib$(BOARD).a
 COBJS-y	:= $(BOARD).o
 COBJS-${CONFIG_FSL_DIU_FB} += ads5121_diu.o
 COBJS-${CONFIG_FSL_DIU_FB} += ../freescale/common/fsl_diu_fb.o
-COBJS-${CONFIG_FSL_DIU_FB} += ../freescale/common/fsl_logo_bmp.o
 COBJS-$(CONFIG_PCI) += pci.o
 
 COBJS	:= $(COBJS-y)
diff --git a/board/ads5121/ads5121_diu.c b/board/ads5121/ads5121_diu.c
index 87cf0cb..a57d505 100644
--- a/board/ads5121/ads5121_diu.c
+++ b/board/ads5121/ads5121_diu.c
@@ -26,6 +26,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/io.h>
+#include <malloc.h>
 
 #ifdef CONFIG_FSL_DIU_FB
 
@@ -61,16 +62,67 @@ void diu_set_pixel_clock(unsigned int pixclock)
 	debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *clkdvdr);
 }
 
+char *valid_bmp(char *addr)
+{
+	unsigned long h_addr;
+
+	h_addr = simple_strtoul(addr, NULL, 16);
+	if (h_addr < CFG_FLASH_BASE ||
+		h_addr >= (CFG_FLASH_BASE + CFG_FLASH_SIZE - 1)) {
+		printf("bmp addr %x is not a valid flash address\n", h_addr);
+		return 0;
+	} else if ((*(char *)(h_addr) != 'B') || (*(char *)(h_addr+1) != 'M')) {
+		printf("bmp addr is not a bmp\n");
+		return 0;
+	} else
+		return (char *)h_addr;
+}
+
 int ads5121_diu_init(void)
 {
+	int gamma_fix;
 	unsigned int pixel_format;
-
-	xres = 1024;
-	yres = 768;
-	pixel_format = 0x88883316;
-
-	return fsl_diu_init(xres, pixel_format, 0,
-		     (unsigned char *)FSL_Logo_BMP);
+	char *bmp_env, *bmp, *monitor_port;
+	unsigned char *dest;
+	long bmp_sz;
+
+	debug("ads5121_diu_init\n");
+	bmp_env = getenv("bmp_addr");
+	if (bmp_env == NULL) {
+		debug("Environment Variable bmp_addr is not set \n");
+		bmp = 0;
+	} else {
+		bmp = valid_bmp(bmp_env);
+	}
+	if (bmp) {
+		bmp_sz  = (bmp[5] << 24) | (bmp[4] << 16) |
+				(bmp[3] << 8) | bmp[2];
+		debug("bmp_sz = %u\n", bmp_sz);
+		if (bmp_sz > CFG_SPLASH_SIZE) {
+			printf("BMP exceeds size limit of %d\n",
+				CFG_SPLASH_SIZE);
+			bmp = 0;
+		} else {
+		    dest = malloc(bmp_sz);
+		    (void)memcpy((void *)dest, bmp, bmp_sz);
+		}
+	}
+	monitor_port = getenv("monitor_port");
+	if (!strncmp(monitor_port, "LCD", 3)) {
+		debug("LCD Monitor port\n");
+		xres = 1024;
+		yres = 768;
+		pixel_format = 0x88883316;
+		gamma_fix = 1;
+	} else {
+		debug("DVI Monitor port\n");
+		xres = 1024;
+		yres = 768;
+		pixel_format = 0x88883316;
+		gamma_fix = 0;
+	}
+	return fsl_diu_init(xres, pixel_format, gamma_fix,
+		     (unsigned char *)bmp);
 }
 
 int ads5121diu_init_show_bmp(cmd_tbl_t *cmdtp,
diff --git a/board/freescale/common/fsl_diu_fb.c b/board/freescale/common/fsl_diu_fb.c
index 75f782e..a3bee17 100644
--- a/board/freescale/common/fsl_diu_fb.c
+++ b/board/freescale/common/fsl_diu_fb.c
@@ -301,11 +301,15 @@ int fsl_diu_init(int xres,
 		debug("Fix gamma table\n");
 		gamma_table_base = gamma.paddr;
 		for (i = 0; i < 256*3; i++) {
+#ifdef CONFIG_ADS5121
+			gamma_table_base[i] = ((gamma_table_base[i] % 4) << 6)
+				| (gamma_table_base[i] >> 2);
+#else
 			gamma_table_base[i] = (gamma_table_base[i] << 2)
 				| ((gamma_table_base[i] >> 6) & 0x03);
+#endif
 		}
 	}
-
 	debug("update-lcdc: HW - %p\n Disabling DIU\n", hw);
 
 	/* Program DIU registers */
diff --git a/include/configs/ads5121.h b/include/configs/ads5121.h
index 21374e9..ae98359 100644
--- a/include/configs/ads5121.h
+++ b/include/configs/ads5121.h
@@ -45,6 +45,7 @@
  */
 #define CONFIG_E300		1	/* E300 Family */
 #define CONFIG_MPC512X		1	/* MPC512X family */
+#define CONFIG_ADS5121		1	/* ADS5121 board  */
 #define CONFIG_FSL_DIU_FB	1	/* FSL DIU */
 
 /* video */
@@ -222,6 +223,7 @@
 #define CFG_MONITOR_LEN		(256 * 1024)		/* Reserve 256 kB for Mon */
 #ifdef	CONFIG_FSL_DIU_FB
 #define CFG_MALLOC_LEN		(6 * 1024 * 1024)	/* Reserved for malloc */
+#define CFG_SPLASH_SIZE		(2 * 1024 * 1024)
 #else
 #define CFG_MALLOC_LEN		(512 * 1024)
 #endif
-- 
1.5.2.4





More information about the U-Boot mailing list