[U-Boot-Users] [PATCH] add splashimage positioning support

Matthias Fuchs matthias.fuchs at esd-electronics.com
Wed Jul 4 12:12:41 CEST 2007


This patch adds positioning support the video console's splashimage.
The new feature must be enabled via CONFIG_SPLASH_SCREEN_ALIGN

Please see README for more details.

Signed-off-by: Matthias Fuchs <matthias.fuchs at esd-electronics.com>

---
commit a2d4f0317552af68f86e8981aaef6c324bfbc157
tree 7229d0a193964b252f60ad1eff4c7af4ab71d94a
parent 98c440bee623ecdd5322852732b883e696fb2140
author Matthias Fuchs <matthias.fuchs at esd-electronics.com> Wed, 04 Jul 2007 12:09:27 +0200
committer Matthias Fuchs <matthias.fuchs at esd-electronics.com> Wed, 04 Jul 2007 12:09:27 +0200

 README                |   15 ++++++++
 drivers/cfb_console.c |   92 ++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 98 insertions(+), 9 deletions(-)

diff --git a/README b/README
index bb5b46e..205b370 100644
--- a/README
+++ b/README
@@ -1047,6 +1047,21 @@ The following options need to be configu
 		allows for a "silent" boot where a splash screen is
 		loaded very quickly after power-on.
 
+		When CONFIG_SPLASH_SCREEN_ALIGN is additionally defined,
+		it is possible to align a small splashimage on a huge
+		display. This option extends the splashimage variable 
+		syntax with an x and y position suffix. Beside absolute 
+		positioning the characters 'l' (left), 'r' (right), 
+		't' (top), 'b' (bottom) and 'c' (center) are supported:
+
+			splashimage=<address>[,<xpos>[,<pos>]]
+
+		Example:
+			splashimage=fff00000,c,c
+
+		This aligns our bitmap at address 0xfff00000 
+		vertically and horizontally.
+
 - Gzip compressed BMP image support: CONFIG_VIDEO_BMP_GZIP
 
 		If this option is set, additionally to standard BMP
diff --git a/drivers/cfb_console.c b/drivers/cfb_console.c
index 9727aeb..9753b07 100644
--- a/drivers/cfb_console.c
+++ b/drivers/cfb_console.c
@@ -183,6 +183,15 @@ CONFIG_VIDEO_HW_CURSOR:	     - Uses the
 #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
 #include <watchdog.h>
 #include <bmp_layout.h>
+
+#ifdef CONFIG_SPLASH_SCREEN_ALIGN
+#define BMP_ALIGN_CENTER        -1
+#define BMP_ALIGN_RIGHT         -2
+#define BMP_ALIGN_BOTTOM        -3
+#define BMP_ALIGN_LEFT          0
+#define BMP_ALIGN_TOP           0
+#endif
+
 #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
 
 /*****************************************************************************/
@@ -755,6 +764,8 @@ void video_puts (const char *s)
 int video_display_bitmap (ulong bmp_image, int x, int y)
 {
 	ushort xcount, ycount;
+	int xc = x;
+	int yc = y;
 	uchar *fb;
 	bmp_image_t *bmp = (bmp_image_t *) bmp_image;
 	uchar *bmap;
@@ -825,15 +836,35 @@ int video_display_bitmap (ulong bmp_imag
 
 	padded_line = (((width * bpp + 7) / 8) + 3) & ~0x3;
 
-	if ((x + width) > VIDEO_VISIBLE_COLS)
-		width = VIDEO_VISIBLE_COLS - x;
-	if ((y + height) > VIDEO_VISIBLE_ROWS)
-		height = VIDEO_VISIBLE_ROWS - y;
+#ifdef CONFIG_SPLASH_SCREEN_ALIGN
+	switch(xc) {
+	case BMP_ALIGN_CENTER:
+		xc = (VIDEO_VISIBLE_COLS - width) >> 1;
+		break;
+	case BMP_ALIGN_RIGHT:
+		xc = VIDEO_VISIBLE_COLS - width;
+		break;
+	}
+
+	switch(yc) {
+	case BMP_ALIGN_CENTER:
+		yc = (VIDEO_VISIBLE_ROWS - height) >> 1;
+		break;
+	case BMP_ALIGN_BOTTOM:
+		yc = VIDEO_VISIBLE_ROWS - height;
+		break;
+	}
+#endif
+
+	if ((xc + width) > VIDEO_VISIBLE_COLS)
+		width = VIDEO_VISIBLE_COLS - xc;
+	if ((yc + height) > VIDEO_VISIBLE_ROWS)
+		height = VIDEO_VISIBLE_ROWS - yc;
 
 	bmap = (uchar *) bmp + le32_to_cpu (bmp->header.data_offset);
 	fb = (uchar *) (video_fb_address +
-			((y + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
-			x * VIDEO_PIXEL_SIZE);
+			((yc + height - 1) * VIDEO_COLS * VIDEO_PIXEL_SIZE) +
+			xc * VIDEO_PIXEL_SIZE);
 
 	/* We handle only 8bpp or 24 bpp bitmap */
 	switch (le16_to_cpu (bmp->header.bit_count)) {
@@ -1106,11 +1137,54 @@ static void *video_logo (void)
 #ifdef CONFIG_SPLASH_SCREEN
 	char *s;
 	ulong addr;
-
+	char *c;
+	int x = 0;
+	int y = 0;
 	if ((s = getenv ("splashimage")) != NULL) {
-		addr = simple_strtoul (s, NULL, 16);
+		addr = simple_strtoul (s, &c, 16);
+
+#ifdef CONFIG_SPLASH_SCREEN_ALIGN
+		if ((c != NULL) && (*c == ',')) {
+			c++;
+			switch(*c) {
+			case 'c':
+				x = BMP_ALIGN_CENTER;
+				c++;
+				break;
+			case 'r':
+				x = BMP_ALIGN_RIGHT;
+				c++;
+				break;
+			case 'l':
+				x = BMP_ALIGN_LEFT;
+				c++;
+				break;
+			default:
+				x = (int)simple_strtoul(c, &c, 10);
+			}
+			if ((c != NULL) && (*c == ',')) {
+				c++;
+				switch(*c) {
+				case 'c':
+					y = BMP_ALIGN_CENTER;
+					c++;
+					break;
+				case 'b':
+					y = BMP_ALIGN_BOTTOM;
+					c++;
+					break;
+				case 't':
+					y = BMP_ALIGN_TOP;
+					c++;
+					break;
+				default:
+					y = (int)simple_strtoul(c, NULL, 10);
+				}
+			}
+		}
+#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
-		if (video_display_bitmap (addr, 0, 0) == 0) {
+		if (video_display_bitmap (addr, x, y) == 0) {
 			return ((void *) (video_fb_address));
 		}
 	}




More information about the U-Boot mailing list