Radix cross Linux

Radix Linux distribution for embedded systems.

637 Commits   4 Branches   3 Tags
author: Andrey V.Kosteltsev <kx@radix.pro> 2016-09-16 19:25:43 +0000 committer: Andrey V.Kosteltsev <kx@radix.pro> 2016-09-16 19:25:43 +0000 commit: b83003cf196a519a0c0a2e3d0b0cb2da2054c633 parent: fce92046f9ba3ee0598e3e7f85ec43d1dfe2d94e
Commit Summary:
M201: U-Boot ARGB 32bpp display mode
Diffstat:
5 files changed, 844 insertions, 13 deletions
diff --git a/boot/u-boot/s805/2011.03-20150117/Makefile b/boot/u-boot/s805/2011.03-20150117/Makefile
index cda73d4f3..376f201fd 100644
--- a/boot/u-boot/s805/2011.03-20150117/Makefile
+++ b/boot/u-boot/s805/2011.03-20150117/Makefile
@@ -108,11 +108,12 @@ AML_COMLILERS += FW_TOOLCHAIN_PATH=$(AMLOGIC_S805_TOOLCHAIN_PATH)
 
 
 logos_path    = $(CURDIR)/logo
-logo_fname    = radix-2CPU-224x96-16bpp.bmp
+logo_fname    = radix-2CPU-224x96-32bpp.bmp
 
 u_boot_logos  = radix-2CPU-224x96.bmp
 u_boot_logos += radix-2CPU-224x96-16bpp.bmp
-
+u_boot_logos += radix-2CPU-224x96-24bpp.bmp
+u_boot_logos += radix-2CPU-224x96-32bpp.bmp
 
 hdmi_display_width  = 1920
 hdmi_display_height = 1080
diff --git a/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-32bpp.bmp b/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-32bpp.bmp
index fea25f7e5..44d1ac04f 100644
Binary files a/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-32bpp.bmp and b/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-32bpp.bmp differ
diff --git a/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-argb.xcf b/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-argb.xcf
new file mode 100644
index 000000000..8539b21c1
Binary files /dev/null and b/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-argb.xcf differ
diff --git a/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96.xcf b/boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-xrgb.xcf
similarity index 100%
rename from boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96.xcf
rename to boot/u-boot/s805/2011.03-20150117/logo/radix-2CPU-224x96-xrgb.xcf
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/file.list b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/file.list
index efdc66671..a4cb52ada 100644
--- a/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/file.list
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/file.list
@@ -1 +1,3 @@
 u-boot-aml-2011.03-20150117/board/amlogic/configs/m8b_m201_v1.h
+u-boot-aml-2011.03-20150117/common/cmd_bmp.c
+u-boot-aml-2011.03-20150117/drivers/video/aml_video.c
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/board/amlogic/configs/m8b_m201_v1.h b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/board/amlogic/configs/m8b_m201_v1.h
index e17509dad..bebe6a9b2 100644
--- a/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/board/amlogic/configs/m8b_m201_v1.h
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/board/amlogic/configs/m8b_m201_v1.h
@@ -29,10 +29,18 @@
 //#define CONFIG_AML_I2C      1
 
 //Enable HDMI Tx
-//#define CONFIG_VIDEO_AMLTVOUT 1
+#define CONFIG_AML_HDMI_TX  1
+#define CONFIG_VIDEO_AML 1
+//Enable TV Output
+#define CONFIG_VIDEO_AMLTVOUT 1
 //Enable LCD output
 //#define CONFIG_VIDEO_AMLLCD
-#define LCD_BPP LCD_COLOR16
+//Enable CVBS
+#define CONFIG_ENABLE_CVBS 1
+
+#define LCD_BPP LCD_COLOR32
+
+#define CONFIG_OSD_SCALE_ENABLE 1
 
 #define CONFIG_ACS
 #ifdef CONFIG_ACS
@@ -53,11 +61,7 @@
 
 //Enable storage devices
 #define CONFIG_CMD_NAND  1
-#define CONFIG_VIDEO_AML 1
 #define CONFIG_CMD_BMP 1
-#define CONFIG_VIDEO_AMLTVOUT 1
-#define CONFIG_AML_HDMI_TX  1
-#define CONFIG_OSD_SCALE_ENABLE 1
 
 //Enable storage devices
 #define CONFIG_CMD_SF    1
@@ -120,8 +124,6 @@
 	#define CONFIG_USB_DWC_OTG_294	1
 #endif //#if defined(CONFIG_CMD_USB)
 
-#define CONFIG_ENABLE_CVBS 1
-
 #define CONFIG_UCL 1
 #define CONFIG_SELF_COMPRESS 
 //#define CONFIG_PREBOOT "mw da004004 80000510;mw c81000014 4000;mw c1109900 0"
@@ -157,10 +159,10 @@
 	"video_dev=tvout\0" \
 	"display_width=1920\0" \
 	"display_height=1080\0" \
-	"display_bpp=16\0" \
-	"display_color_format_index=16\0" \
+	"display_bpp=32\0" \
+	"display_color_format_index=32\0" \
 	"display_layer=osd2\0" \
-	"display_color_fg=0xffff\0" \
+	"display_color_fg=0xffffffff\0" \
 	"display_color_bg=0\0" \
 	"fb_addr=0x7900000\0" \
 	"fb_width=1920\0"\
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/common/cmd_bmp.c b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/common/cmd_bmp.c
new file mode 100644
index 000000000..729d678ad
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/common/cmd_bmp.c
@@ -0,0 +1,355 @@
+/*
+ * (C) Copyright 2002
+ * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * BMP handling routines
+ */
+
+#include <common.h>
+#include <lcd.h>
+#include <bmp_layout.h>
+#include <command.h>
+#include <asm/byteorder.h>
+#include <malloc.h>
+
+static int bmp_info (ulong addr);
+static int bmp_display (ulong addr, int x, int y);
+#ifdef CONFIG_OSD_SCALE_ENABLE
+static int bmp_scale(void);
+#else
+static int bmp_scale(ulong src_addr, ulong dst_addr, unsigned int new_width,unsigned new_height);
+#endif
+
+/*
+ * Allocate and decompress a BMP image using gunzip().
+ *
+ * Returns a pointer to the decompressed image data. Must be freed by
+ * the caller after use.
+ *
+ * Returns NULL if decompression failed, or if the decompressed data
+ * didn't contain a valid BMP signature.
+ */
+#ifdef CONFIG_VIDEO_BMP_GZIP
+bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp)
+{
+	void *dst;
+	unsigned long len;
+	bmp_image_t *bmp;
+
+	/*
+	 * Decompress bmp image
+	 */
+	len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
+	dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
+	if (dst == NULL) {
+		puts("Error: malloc in gunzip failed!\n");
+		return NULL;
+	}
+	if (gunzip(dst, 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");
+
+	bmp = dst;
+
+	/*
+	 * 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");
+
+	return bmp;
+}
+#else
+bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp)
+{
+	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_usage(cmdtp);
+	}
+
+	return (bmp_info(addr));
+}
+
+static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+{
+	ulong addr;
+	int x = 0, y = 0;
+
+	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);
+		x = -1;
+		y = -1;
+		break;
+
+        case 5://Added by Sam, to control whether disable OSD in 'bmp display'
+	case 4:
+		addr = simple_strtoul(argv[1], NULL, 16);
+	        x = simple_strtoul(argv[2], NULL, 10);
+	        y = simple_strtoul(argv[3], NULL, 10);
+	        break;
+	default:
+		return cmd_usage(cmdtp);
+	}
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+        setenv("bmp_osd_control", argc > 4 ? argv[4] : "");//Added by Sam, to control whether disable OSD in 'bmp display'
+#endif//#ifdef CONFIG_OSD_SCALE_ENABLE
+
+	 return (bmp_display(addr, x, y));
+}
+
+static int do_bmp_scale(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+{
+#ifndef CONFIG_OSD_SCALE_ENABLE
+	ulong src_addr,dst_addr;
+	unsigned width,height;
+
+	switch (argc) {
+	case 3:
+		src_addr = simple_strtoul(argv[1], NULL, 16);
+		dst_addr = simple_strtoul(argv[2], NULL, 16);
+		width = simple_strtoul(getenv("display_width"), NULL, 0);
+		height = simple_strtoul(getenv("display_height"), NULL, 0);
+		printf("src_addr=0x%x,dst_addr=0x%x,w=%d,h=%d\n",(uint)src_addr,(uint)dst_addr,width,height);
+		break;
+	default:
+		return cmd_usage(cmdtp);
+		break;
+	}
+	return (bmp_scale(src_addr, dst_addr, width,height));
+#else
+	return (bmp_scale());
+#endif
+}
+
+static cmd_tbl_t cmd_bmp_sub[] = {
+	U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
+	U_BOOT_CMD_MKENT(display, 6, 0, do_bmp_display, "", ""),
+	U_BOOT_CMD_MKENT(scale, 4, 0, do_bmp_scale, "", ""),
+};
+
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+void bmp_reloc(void) {
+	fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub));
+}
+#endif
+
+/*
+ * Subroutine:  do_bmp
+ *
+ * Description: Handler for 'bmp' command..
+ *
+ * Inputs:	argv[1] contains the subcommand
+ *
+ * Return:      None
+ *
+ */
+static int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	cmd_tbl_t *c;
+
+	/* Strip off leading 'bmp' command argument */
+	argc--;
+	argv++;
+
+	c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
+
+	if (c)
+		return  c->cmd(cmdtp, flag, argc, argv);
+	else
+		return cmd_usage(cmdtp);
+}
+
+U_BOOT_CMD(
+	bmp,	6,	1,	do_bmp,
+	"manipulate BMP image data",
+	"info <imageAddr>          - display image info\n"
+	"bmp display <imageAddr> [x y] - display image at x,y\n"
+	"bmp scale imageaddr scaleaddr 	- scale image\n"
+);
+
+/*
+ * Subroutine:  bmp_info
+ *
+ * Description: Show information about bmp file in memory
+ *
+ * Inputs:	addr		address of the bmp file
+ *
+ * Return:      None
+ *
+ */
+static int bmp_info(ulong addr)
+{
+	bmp_image_t *bmp=(bmp_image_t *)addr;
+	unsigned long len;
+
+	if (!((bmp->header.signature[0]=='B') &&
+	      (bmp->header.signature[1]=='M')))
+		bmp = gunzip_bmp(addr, &len);
+
+	if (bmp == NULL) {
+		printf("bmp_info(): There is no valid bmp file at the given address: 0x%08X\n", addr);
+		return 1;
+	}
+
+	printf("Image size    : %d x %d\n", le32_to_cpu(bmp->header.width),
+	       le32_to_cpu(bmp->header.height));
+	printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count));
+	printf("Compression   : %d\n", le32_to_cpu(bmp->header.compression));
+
+	if ((unsigned long)bmp != addr)
+		free(bmp);
+
+	return(0);
+}
+
+/*
+ * Subroutine:  bmp_display
+ *
+ * Description: Display bmp file located in memory
+ *
+ * Inputs:	addr		address of the bmp file
+ *
+ * Return:      None
+ *
+ */
+static int bmp_display(ulong addr, int x, int y)
+{
+	int ret;
+	bmp_image_t *bmp = (bmp_image_t *)addr;
+	unsigned long len;
+
+	if (!((bmp->header.signature[0]=='B') &&
+	      (bmp->header.signature[1]=='M')))
+		bmp = gunzip_bmp(addr, &len);
+
+	if (!bmp) {
+		printf("bmp_display(): There is no valid bmp file at the given address: 0x%08X\n", addr);
+		return 1;
+	}
+    
+#if (defined(CONFIG_LCD) || defined(CONFIG_VIDEO_AMLLCD) || defined(CONFIG_VIDEO) || defined(CONFIG_VIDEO_AML))
+	extern int video_display_bitmap (ulong, int, int);
+    ret = video_display_bitmap ((unsigned long)bmp, x, y);
+#else
+# error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO
+#endif
+
+	if ((unsigned long)bmp != addr)
+		free(bmp);
+
+	return ret;
+}
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+static int bmp_scale(void)
+{
+	int ret = 0;
+	extern int video_scale_bitmap (void);
+	ret = video_scale_bitmap();
+	return 0;
+}
+#else
+static int bmp_scale(ulong src_addr, ulong dst_addr, unsigned int new_width,unsigned new_height)
+{
+	//ulong new_width,new_height;
+	bmp_image_t *bmp = (bmp_image_t *)src_addr;
+	bmp_image_t *bmp_dst = (bmp_image_t *)dst_addr;	
+	unsigned long len;
+
+	char *pBuf = (char*)bmp+bmp->header.data_offset;
+	printf("Begin bmp scale ...\n");
+
+	if (!((bmp->header.signature[0]=='B') &&
+		      (bmp->header.signature[1]=='M')))
+			bmp = gunzip_bmp(src_addr, &len);
+
+	if (!bmp) {
+		printf("bmp_scale(): There is no valid bmp file at the given address: 0x%08X\n", src_addr);
+		return 1;
+	}	      
+
+	memcpy(bmp_dst, bmp, sizeof(bmp_image_t));
+	bmp_dst->header.width=new_width;
+	bmp_dst->header.height=new_height;
+	char *pBuf_dst = (char*)bmp_dst+bmp_dst->header.data_offset;
+
+#if 1//Fast scale
+	int   nWidth   ,   nHeight	 ,	 nNewWidth	 ,	 nNewHeight   ,   nNewWidthBit; 
+	float m_xscale,m_yscale;
+	int i,j,x,y,oldoffset;	
+	char *pNewTmp = NULL; 
+	
+	m_xscale = (float)bmp_dst->header.width/(float)bmp->header.width;
+	m_yscale = (float)bmp_dst->header.height/(float)bmp->header.height;
+	nWidth = bmp->header.width;
+	nHeight = bmp->header.height;
+	nNewHeight = bmp_dst->header.width;
+	nNewWidth =	bmp_dst->header.width;
+	nNewWidthBit = ( 4 - nNewWidth * 3 % 4 )%4 + nNewWidth * 3;
+
+	for( i=0; i<nNewHeight; i++ )
+	{ 
+		pNewTmp = pBuf_dst + nNewWidthBit * i; 
+		for( j=0; j<nNewWidth * 3; j += 3 ) 
+		{ 
+			x = (int) (j/m_xscale); 
+			y = (int) (i/m_yscale); 
+			oldoffset = (y*nWidth*3 + x) - (y*nWidth*3 + x)%3; //correct positon in 3 byte mode
+			memcpy(pNewTmp+j, pBuf + oldoffset, 3);
+		} 
+	} 
+#endif
+	printf("End bmp scale \n");
+	return 0;
+}
+#endif
+
+
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/drivers/video/aml_video.c b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/drivers/video/aml_video.c
new file mode 100644
index 000000000..fdce76855
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20150117-m8b_m201-fbset-patch/u-boot-aml-2011.03-20150117-new/drivers/video/aml_video.c
@@ -0,0 +1,564 @@
+/*-----------------------------------------------------------------------------
+ * aml_video.c -- Elvis Yu
+ *-----------------------------------------------------------------------------
+ */
+
+#include <common.h>
+#include <video_fb.h>
+#include <asm/arch/osd.h>
+#include <asm/arch/osd_hw.h>
+#include <stdio_dev.h>
+#include <bmp_layout.h>
+#include <amlogic/aml_tv.h>
+#include <amlogic/vinfo.h>
+#include <malloc.h>
+
+
+GraphicDevice aml_gdev;
+
+//set default LCD_BPP
+#ifndef LCD_BPP
+#define LCD_BPP LCD_COLOR24
+#endif
+
+/*-----------------------------------------------------------------------------
+ * osd_init --
+ *-----------------------------------------------------------------------------
+ */
+static void osd_layer_init(GraphicDevice gdev, int layer)
+{
+//	printf("%s\n", __FUNCTION__);
+	osd_init_hw();
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	osd_setup(0,
+                0,
+                gdev.fb_width,
+                gdev.fb_height,
+                gdev.fb_width,
+                gdev.fb_height * 2,
+                0,
+                0,
+                gdev.fb_width- 1,
+                gdev.fb_height- 1,
+                gdev.frameAdrs,
+                &default_color_format_array[gdev.gdfIndex],
+                layer);
+#else
+	osd_setup(0,
+                0,
+                gdev.winSizeX,
+                gdev.winSizeY,
+                gdev.winSizeX,
+                gdev.winSizeY * 2,
+                0,
+                0,
+                gdev.winSizeX- 1,
+                gdev.winSizeY- 1,
+                gdev.frameAdrs,
+                &default_color_format_array[gdev.gdfIndex],
+                layer);
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+ * osd_init --
+ *-----------------------------------------------------------------------------
+ */
+static void video_layer_init(GraphicDevice gdev)
+{
+	return;
+}
+
+
+/*-----------------------------------------------------------------------------
+ * video_hw_init --
+ *-----------------------------------------------------------------------------
+ */
+void *video_hw_init (void)
+{	
+	u32 fb_addr, display_width, display_height, display_bpp, color_format_index, fg, bg;
+	u32 fb_width, fb_height;
+	char *layer_str;
+	fb_addr = simple_strtoul (getenv ("fb_addr"), NULL, 16);
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	fb_width = simple_strtoul (getenv ("fb_width"), NULL, 10 );
+	fb_height = simple_strtoul (getenv ("fb_height"), NULL, 10);
+#else
+	fb_width = 0;
+	fb_height = 0;
+#endif
+	display_width = simple_strtoul (getenv ("display_width"), NULL, 10);
+	display_height = simple_strtoul (getenv ("display_height"), NULL, 10);
+	display_bpp = simple_strtoul (getenv ("display_bpp"), NULL, 10);
+	color_format_index = simple_strtoul (getenv ("display_color_format_index"), NULL, 10);
+	layer_str = getenv ("display_layer");
+	fg = simple_strtoul (getenv ("display_color_fg"), NULL, 10);
+	bg = simple_strtoul (getenv ("display_color_bg"), NULL, 10);
+	
+	/* fill in Graphic Device */
+	aml_gdev.frameAdrs = fb_addr;
+	aml_gdev.fb_width = fb_width;
+	aml_gdev.fb_height = fb_height;
+	aml_gdev.winSizeX = display_width;
+	aml_gdev.winSizeY = display_height;
+	aml_gdev.gdfBytesPP = display_bpp/8;
+	aml_gdev.fg = fg;
+	aml_gdev.bg = bg;
+
+	//different method with other video gdfIndex
+	//if((color_format_index < ARRAY_SIZE(default_color_format_array)) && (default_color_format_array[color_format_index] != INVALID_BPP_ITEM))
+	if((color_format_index < ARRAY_SIZE(default_color_format_array)) && (default_color_format_array[color_format_index].color_index != COLOR_INDEX_NULL))
+	{
+		aml_gdev.gdfIndex = color_format_index;
+	}
+	else
+	{
+		printf("ERROR:env color_format_index invalid! color_format_index is %d\n", color_format_index);
+		return NULL;
+	}
+
+	if(strcmp(layer_str, "osd1") == 0)
+	{
+		osd_layer_init(aml_gdev, OSD1);
+	}
+	else if(strcmp(layer_str, "osd2") == 0)
+	{
+		osd_layer_init(aml_gdev, OSD2);
+	}
+	else if(strcmp(layer_str, "video") == 0)
+	{
+		video_layer_init(aml_gdev);
+	}
+	else
+	{
+		printf("ERROR:env display_layer invalid! display_layer is %d\n", display_bpp);
+		return NULL;
+	}
+
+	return (void *) &aml_gdev;
+
+}
+
+/*-----------------------------------------------------------------------------
+ * video_set_lut --
+ *-----------------------------------------------------------------------------
+ */
+void video_set_lut (
+	unsigned int index,           /* color number */
+	unsigned char r,              /* red */
+	unsigned char g,              /* green */
+	unsigned char b               /* blue */
+	)
+{
+	return;
+}
+
+
+int video_display_bitmap(ulong bmp_image, int x, int y)
+{
+    vidinfo_t * info = NULL;
+#if defined CONFIG_VIDEO_AMLLCD
+    extern vidinfo_t panel_info;
+    info = & panel_info;
+#endif
+#if defined CONFIG_VIDEO_AMLTVOUT
+    extern vidinfo_t tv_info;
+    info = & tv_info;
+#endif
+#if(LCD_BPP ==LCD_COLOR8)	
+	ushort *cmap_base = NULL;
+	unsigned long byte_width;
+#endif	
+	ushort i, j;
+	uchar *fb;
+	bmp_image_t *bmp=(bmp_image_t *)bmp_image;
+	uchar *bmap;
+	ushort padded_line;
+	unsigned long width, height;
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	unsigned long pheight = aml_gdev.fb_height;
+	unsigned long pwidth = aml_gdev.fb_width;
+#else
+	unsigned long pwidth = info->vl_col;
+#endif
+	unsigned colors, bpix, bmp_bpix;
+	unsigned long compression;
+	int lcd_line_length = (pwidth * NBITS (info->vl_bpix)) / 8;
+	char *layer_str = NULL;
+	int osd_index = -1;
+
+	layer_str = getenv ("display_layer");
+	if(strcmp(layer_str, "osd1") == 0)
+	{
+		osd_index = 0;
+	}
+	else if(strcmp(layer_str, "osd2") == 0)
+	{
+		osd_index = 1;
+	}
+
+	if (!((bmp->header.signature[0]=='B') &&
+		(bmp->header.signature[1]=='M'))) {
+		printf ("Error: no valid bmp image at %lx\n", bmp_image);
+		return 1;
+	}
+
+	width = le32_to_cpu (bmp->header.width);
+	height = le32_to_cpu (bmp->header.height);
+	bmp_bpix = le16_to_cpu(bmp->header.bit_count);
+	colors = 1 << bmp_bpix;
+	compression = le32_to_cpu (bmp->header.compression);
+
+	bpix = NBITS(info->vl_bpix);
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	if((x == -1) &&(y == -1))
+	{
+		if((width > pwidth) || (height > pheight))
+		{
+			x = 0;
+			y = 0;
+		}
+		else
+		{
+			x = (pwidth - width) / 2;
+			y = (pheight - height) / 2;
+		}
+	}
+#else
+	if((x == -1) &&(y == -1))
+	{
+		if((width > info->vl_col) || (height > info->vl_row))
+		{
+			x = 0;
+			y = 0;
+		}
+		else
+		{
+			x = (info->vl_col - width) / 2;
+			y = (info->vl_row - height) / 2;
+		}
+	}
+#endif
+
+	if ((bpix != 1) && (bpix != 8) && (bpix != 16) && (bpix != 24) && (bpix != 32)) {
+		printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
+			bpix, bmp_bpix);
+		return 1;
+	}
+
+	/* We support displaying 8bpp BMPs on 16bpp LCDs */
+	if (bpix != bmp_bpix && (bmp_bpix != 8 || bpix != 16)) {
+		printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
+			bpix,
+			le16_to_cpu(bmp->header.bit_count));
+		return 1;
+	}
+
+	debug ("Display-bmp: %d x %d  with %d colors\n",
+		(int)width, (int)height, (int)colors);
+
+
+	/*
+	 *  BMP format for Monochrome assumes that the state of a
+	 * pixel is described on a per Bit basis, not per Byte.
+	 *  So, in case of Monochrome BMP we should align widths
+	 * on a byte boundary and convert them from Bit to Byte
+	 * units.
+	 *  Probably, PXA250 and MPC823 process 1bpp BMP images in
+	 * their own ways, so make the converting to be MCC200
+	 * specific.
+	 */
+	padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
+
+#ifdef CONFIG_SPLASH_SCREEN_ALIGN
+	if (x == BMP_ALIGN_CENTER)
+		x = max(0, (pwidth - width) / 2);
+	else if (x < 0)
+		x = max(0, pwidth - width + x + 1);
+
+	if (y == BMP_ALIGN_CENTER)
+		y = max(0, (info->vl_row - height) / 2);
+	else if (y < 0)
+		y = max(0, info->vl_row - height + y + 1);
+#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	if ((x + width)>pwidth)
+		width = pwidth - x;
+	if ((y + height)>pheight)
+		height = pheight - y;
+#else
+	if ((x + width)>pwidth)
+		width = pwidth - x;
+	if ((y + height)>info->vl_row)
+		height = info->vl_row - y;
+#endif
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+        if(getenv("bmp_osd_control")) {
+                osd_enable_hw(simple_strtoul(getenv("bmp_osd_control"), NULL, 10), osd_index);
+        }
+        else{
+                osd_enable_hw(0, osd_index);//default to close osd in 'bmp display'
+        }
+#endif
+	bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
+	fb   = (uchar *) (info->vd_base +
+		(y + height - 1) * lcd_line_length + x*(LCD_BPP/8));
+
+	debug("fb=0x%08x; bmap=0x%08x, width=%d, height= %d, lcd_line_length=%d, padded_line=%d\n",
+			fb, bmap, width, height, lcd_line_length, padded_line);
+	switch (bmp_bpix) {
+#if(LCD_BPP ==LCD_COLOR8)
+	case 8:
+		if (bpix != 16)
+			byte_width = width;
+		else
+			byte_width = width * 2;
+
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+				if (bpix != 16) {
+					*(fb++) = *(bmap++);
+				} else {
+					*(uint16_t *)fb = cmap_base[*(bmap++)];
+					fb += sizeof(uint16_t) / sizeof(*fb);
+				}
+			}
+			bmap += (width - padded_line);
+			fb   -= (byte_width + lcd_line_length);
+		}
+		break;
+#endif /* LCD_BPP ==LCD_COLOR8 */
+
+#if(LCD_BPP ==LCD_COLOR16)
+	case 16:
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+			}
+			bmap += (padded_line - width) * 2;
+			fb   -= (width * 2 + lcd_line_length);
+		}
+		break;
+#endif /* LCD_BPP ==LCD_COLOR16 */
+
+#if(LCD_BPP ==LCD_COLOR24)
+	case 24:
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+			}
+			bmap += (padded_line - width);
+			fb   -= (width * 3 + lcd_line_length);
+		}
+		break;
+#endif /* LCD_BPP ==LCD_COLOR24 */
+#if(LCD_BPP ==LCD_COLOR32)
+		case 32:
+			for (i = 0; i < height; ++i) {
+				for (j = 0; j < width; j++) {
+
+					*(fb++) = *(++bmap); /* B */
+					*(fb++) = *(++bmap); /* G */
+					*(fb++) = *(++bmap); /* R */
+					*(fb++) = *(++bmap - 4); /* A */
+				}
+				bmap += (padded_line - width);
+				fb   -= (width * 4 + lcd_line_length);
+			}
+			break;
+#endif /* LCD_BPP ==LCD_COLOR32 */
+
+	default:
+		printf("ERROR LCD_BPP is %d\n", LCD_BPP);
+		return (-1);
+	};
+	flush_cache((unsigned long)info->vd_base, info->vl_col*info->vl_row*info->vl_bpix/8);
+
+	return (0);
+}
+
+int my_atoi(const char *str){
+    int result = 0;
+    int signal = 1;
+	
+    if((*str >= '0' && *str<='9') || *str == '-' || *str == '+'){
+        if(*str == '-' || *str == '+'){  
+            if(*str=='-')
+                signal = -1; 
+            str++;
+        } 
+    }else 
+		return 0;
+	
+    while(*str >= '0' && *str <= '9')
+        result = result * 10 + (*str++ -'0');
+
+	return signal * result;
+}
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+int getenv_int(char *env, int def){
+    if (getenv(env) == NULL) {
+		//printf("bmp scale:  def=%d\n", def);
+        return def;
+    } else {
+    	//printf("bmp scale:   %s=%s\n", env, getenv(env));
+        return my_atoi(getenv(env));
+    }
+}
+
+int* get_window_axis(void) {
+    char *mode = getenv("outputmode");
+    int* axis = (int *)malloc(4*4);
+
+    if (strcmp(mode, "480i") == 0 || strcmp(mode, "480cvbs") == 0) {
+        axis[0] = getenv_int("480ioutputx", 0);
+        axis[1] = getenv_int("480ioutputy", 0);
+        axis[2] = getenv_int("480ioutputwidth", 720);
+        axis[3] = getenv_int("480ioutputheight", 480);
+    } else if (strcmp(mode, "480p") == 0) {
+        axis[0] = getenv_int("480poutputx", 0);
+        axis[1] = getenv_int("480poutputy", 0);
+        axis[2] = getenv_int("480poutputwidth", 720);
+        axis[3] = getenv_int("480poutputheight", 480);
+    } else if (strcmp(mode, "576i") == 0 || strcmp(mode, "576cvbs") == 0) {
+        axis[0] = getenv_int("576ioutputx", 0);
+        axis[1] = getenv_int("576ioutputy", 0);
+        axis[2] = getenv_int("576ioutputwidth", 720);
+        axis[3] = getenv_int("576ioutputheight", 576);
+    } else if (strcmp(mode, "576p") == 0) {
+        axis[0] = getenv_int("576poutputx", 0);
+        axis[1] = getenv_int("576poutputy", 0);
+        axis[2] = getenv_int("576poutputwidth", 720);
+        axis[3] = getenv_int("576poutputheight", 576);
+    } else if (strcmp(mode, "720p") == 0 || strcmp(mode, "720p50hz") == 0) {
+        axis[0] = getenv_int("720poutputx", 0);
+        axis[1] = getenv_int("720poutputy", 0);
+        axis[2] = getenv_int("720poutputwidth", 1280);
+        axis[3] = getenv_int("720poutputheight", 720);
+    } else if (strcmp(mode, "1080i") == 0 || strcmp(mode, "1080i50hz") == 0) { 
+        axis[0] = getenv_int("1080ioutputx", 0);
+        axis[1] = getenv_int("1080ioutputy", 0);
+        axis[2] = getenv_int("1080ioutputwidth", 1920);
+        axis[3] = getenv_int("1080ioutputheight", 1080);
+    } else if (strcmp(mode, "4k2k24hz") == 0) {
+        axis[0] = getenv_int("4k2k24hz_x", 0);
+        axis[1] = getenv_int("4k2k24hz_y", 0);
+        axis[2] = getenv_int("4k2k24hz_width", 3840);
+        axis[3] = getenv_int("4k2k24hz_height", 2160);
+    } else if (strcmp(mode, "4k2k25hz") == 0) {
+        axis[0] = getenv_int("4k2k25hz_x", 0);
+        axis[1] = getenv_int("4k2k25hz_y", 0);
+        axis[2] = getenv_int("4k2k25hz_width", 3840);
+        axis[3] = getenv_int("4k2k25hz_height", 2160);
+    } else if (strcmp(mode, "4k2k30hz") == 0) {
+        axis[0] = getenv_int("4k2k30hz_x", 0);
+        axis[1] = getenv_int("4k2k30hz_y", 0);
+        axis[2] = getenv_int("4k2k30hz_width", 3840);
+        axis[3] = getenv_int("4k2k30hz_height", 2160);
+    }  else if (strcmp(mode, "4k2k50hz420") == 0) {
+        axis[0] = getenv_int("4k2k420_x", 0);
+        axis[1] = getenv_int("4k2k420_y", 0);
+        axis[2] = getenv_int("4k2k420_w", 3840);
+        axis[3] = getenv_int("4k2k420_h", 2160);
+    } else if (strcmp(mode, "4k2k60hz420") == 0) {
+        axis[0] = getenv_int("4k2k420_x", 0);
+        axis[1] = getenv_int("4k2k420_y", 0);
+        axis[2] = getenv_int("4k2k420_w", 3840);
+        axis[3] = getenv_int("4k2k420_h", 2160);
+    } else if (strcmp(mode, "4k2ksmpte") == 0) {
+        axis[0] = getenv_int("4k2ksmpte_x", 0);
+        axis[1] = getenv_int("4k2ksmpte_y", 0);
+        axis[2] = getenv_int("4k2ksmpte_width", 4096);
+        axis[3] = getenv_int("4k2ksmpte_height", 2160);
+    } else if (strcmp(mode, "4k2k50hz") == 0) {
+        axis[0] = getenv_int("4k2k50hz_x", 0);
+        axis[1] = getenv_int("4k2k50hz_y", 0);
+        axis[2] = getenv_int("4k2k50hz_w", 3840);
+        axis[3] = getenv_int("4k2k50hz_h", 2160);
+    } else if (strcmp(mode, "4k2k60hz") == 0) {
+        axis[0] = getenv_int("4k2k60hz_x", 0);
+        axis[1] = getenv_int("4k2k60hz_y", 0);
+        axis[2] = getenv_int("4k2k60hz_w", 3840);
+        axis[3] = getenv_int("4k2k60hz_h", 2160);
+    } else if (strcmp(mode, "1080p") == 0 || strcmp(mode, "1080p50hz") == 0 || strcmp(mode, "1080p24hz") == 0) {
+        axis[0] = getenv_int("1080poutputx", 0);
+        axis[1] = getenv_int("1080poutputy", 0);
+        axis[2] = getenv_int("1080poutputwidth", 1920);
+        axis[3] = getenv_int("1080poutputheight", 1080);
+    } else if ((strcmp(mode, "768p50hz") == 0) || (strcmp(mode, "768p60hz") == 0) ){
+        axis[0] = getenv_int("768p_x", 0);
+        axis[1] = getenv_int("768p_y", 0);
+        axis[2] = getenv_int("768p_w", 1366);
+        axis[3] = getenv_int("768p_h", 768);
+    } else {
+        axis[0] = getenv_int("1080poutputx", 0);
+        axis[1] = getenv_int("1080poutputy", 0);
+        axis[2] = getenv_int("1080poutputwidth", 1920);
+        axis[3] = getenv_int("1080poutputheight", 1080);
+    }
+    printf("bmp scale:  mode=%s , x=%d, y=%d, w=%d, h=%d\n", mode, axis[0], axis[1], axis[2], axis[3]);
+    return axis;
+}
+
+
+int video_scale_bitmap(void)
+{
+//	printf("video_scale_bitmap src width is %d, height is %d, dst width is %d, dst height is %d\n",
+//			aml_gdev.fb_width, aml_gdev.fb_height, aml_gdev.winSizeX, aml_gdev.winSizeY);
+	char *layer_str = NULL;
+	int osd_index = -1;
+	layer_str = getenv ("display_layer");
+	int *axis = get_window_axis();
+	if(strcmp(layer_str, "osd1") == 0)
+	{
+		osd_index = 0;
+	}
+	else if(strcmp(layer_str, "osd2") == 0)
+	{
+		osd_index = 1;
+	}
+#ifdef CONFIG_OSD_SUPERSCALE_ENABLE
+	if ((aml_gdev.fb_width*2 != aml_gdev.winSizeX) || (aml_gdev.fb_height*2 != aml_gdev.winSizeY)) {
+		osd_enable_hw(1, osd_index);
+		return (-1);
+	}
+	osd_free_scale_mode_hw(osd_index, 2);
+#else
+	osd_free_scale_mode_hw(osd_index, 1);
+#endif
+	osd_set_free_scale_axis_hw(osd_index, 0,0,aml_gdev.fb_width-1,aml_gdev.fb_height-1);
+	osd_set_window_axis_hw(osd_index,axis[0],axis[1],axis[0]+axis[2]-1,axis[1]+axis[3]-1);
+	free(axis);
+	osd_free_scale_enable_hw(osd_index, 0x10001);
+	osd_enable_hw(1, osd_index);
+	return (1);
+}
+#endif
+
+void reset_console(void)
+{
+    vidinfo_t * info = NULL;
+#if defined CONFIG_VIDEO_AMLLCD
+    extern vidinfo_t panel_info;
+    info = & panel_info;
+#endif
+#if defined CONFIG_VIDEO_AMLTVOUT
+    extern vidinfo_t tv_info;
+    info = & tv_info;
+#endif
+	info->console_col = 0;
+#ifdef CONFIG_LCD_INFO_BELOW_LOGO
+	info->console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
+#else
+	info->console_row = 1;	/* leave 1 blank line below logo */
+#endif
+}