Skip to contentSkip to conversation

video: fix bug in cfb_console.c code

PATCH New Anatolij Gustschin 2 participants 2 messages Apr 23, 2009 – Apr 27, 2009 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: fix bug in cfb_console.c code

Fix bug in drawing long version/info strings:
U-Boot version string like
"U-Boot 2009.03-05647-g7c51e06 (Apr 23 2009 - 12:40:00) MPC83XX" is long and doesn't wrap around correctly while drawing beside the logo. Such long strings partially overwrite the logo. This patch is an attempt to fix it.

---
 drivers/video/cfb_console.c   |   36 +++++++++++++++++++++++++++++++++---
 include/configs/MPC8360ERDK.h |    2 +-
 2 files changed, 34 insertions(+), 4 deletions(-)
drivers/video/cfb_console.c +33 -3
index 0b5a0ee..f2a06b5 100644
@@ -1188,6 +1188,7 @@ static void *video_logo (void)
 {
 	char info[128];
 	extern char version_string;
+	int space, len, y_off = 0;
 
 #ifdef CONFIG_SPLASH_SCREEN
 	char *s;
@@ -1205,7 +1206,19 @@ static void *video_logo (void)
 	logo_plot (video_fb_address, VIDEO_COLS, 0, 0);
 
 	sprintf (info, " %s", &version_string);
-	video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *)info);
+
+	space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
+	len = strlen(info);
+
+	if (len > space) {
+		video_drawchars (VIDEO_INFO_X, VIDEO_INFO_Y,
+				 (uchar *)info, space);
+		video_drawchars (VIDEO_INFO_X + VIDEO_FONT_WIDTH,
+				 VIDEO_INFO_Y + VIDEO_FONT_HEIGHT,
+				 (uchar *)info + space, len - space);
+		y_off = 1;
+	} else
+		video_drawstring (VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *)info);
 
 #ifdef CONFIG_CONSOLE_EXTRA_INFO
 	{
@@ -1213,10 +1226,27 @@ static void *video_logo (void)
 
 		for (i = 1; i < n; i++) {
 			video_get_info_str (i, info);
-			if (*info)
+			if (!*info)
+				continue;
+
+			len = strlen(info);
+			if (len > space) {
+				video_drawchars (VIDEO_INFO_X,
+						 VIDEO_INFO_Y +
+						 (i + y_off) * VIDEO_FONT_HEIGHT,
+						 (uchar *)info, space);
+				y_off++;
+				video_drawchars (VIDEO_INFO_X + VIDEO_FONT_WIDTH,
+						 VIDEO_INFO_Y +
+						 (i + y_off) * VIDEO_FONT_HEIGHT,
+						 (uchar *)info + space,
+						 len - space);
+			} else {
 				video_drawstring (VIDEO_INFO_X,
-						  VIDEO_INFO_Y + i * VIDEO_FONT_HEIGHT,
+						  VIDEO_INFO_Y +
+						  (i + y_off) * VIDEO_FONT_HEIGHT,
 						  (uchar *)info);
+			}
 		}
 	}
 #endif
Signature · 1 line
1.5.3.3
#1 lore raw

PATCH 1/1 video: fix bug in cfb_console.c code

Dear Anatolij Gustschin,

Quoted 7 lines · In message <[email protected]> you wrote:

Fix bug in drawing long version/info strings:
U-Boot version string like
"U-Boot 2009.03-05647-g7c51e06 (Apr 23 2009 - 12:40:00) MPC83XX" is long and doesn't wrap around correctly while drawing beside the logo. Such long strings partially overwrite the logo. This patch is an attempt to fix it.

Quoted 5 lines
---
 drivers/video/cfb_console.c   |   36 +++++++++++++++++++++++++++++++++---
 include/configs/MPC8360ERDK.h |    2 +-
 2 files changed, 34 insertions(+), 4 deletions(-)

Will you send a pull request for this, please?

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"You know, after a woman's raised a family and so on,  she  wants  to
start living her own life."   "Whose life she's _been_ living, then?"
                                  - Terry Pratchett, _Witches Abroad_