diff mbox series

[U-Boot,2/2] video: Support multiple lines version string display

Message ID 1514877937-24144-2-git-send-email-peng.fan@nxp.com
State Accepted
Commit f9d891f0a903820100b42f25ba47593519b6b516
Delegated to: Anatolij Gustschin
Headers show
Series [U-Boot,1/2] video: ipu: Fix dereferencing NULL pointer problem | expand

Commit Message

Peng Fan Jan. 2, 2018, 7:25 a.m. UTC
The calculation of left space for version string is not correct, should
use VIDEO_COLS not VIDEO_LINE_LEN / 2, otherwise we will get larger space
than actual have and cause string to overlay logo picture.

Also current version string display only supports two lines words at max.
This also causes overlay when the LCD pixel colume size is not enough.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/video/cfb_console.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

Comments

Anatolij Gustschin Jan. 3, 2018, 11:31 a.m. UTC | #1
On Tue,  2 Jan 2018 15:25:37 +0800
Peng Fan peng.fan@nxp.com wrote:

> The calculation of left space for version string is not correct, should
> use VIDEO_COLS not VIDEO_LINE_LEN / 2, otherwise we will get larger space
> than actual have and cause string to overlay logo picture.
> 
> Also current version string display only supports two lines words at max.
> This also causes overlay when the LCD pixel colume size is not enough.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/video/cfb_console.c | 30 +++++++++++++++++++++++-------
>  1 file changed, 23 insertions(+), 7 deletions(-)

applied to u-boot-video/master, thanks!

--
Anatolij
diff mbox series

Patch

diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index 74cc20d653..0b25897062 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -1900,16 +1900,32 @@  static void *video_logo(void)
 	sprintf(info, " %s", version_string);
 
 #ifndef CONFIG_HIDE_LOGO_VERSION
-	space = (VIDEO_LINE_LEN / 2 - VIDEO_INFO_X) / VIDEO_FONT_WIDTH;
+	space = (VIDEO_COLS - 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;
+		int xx = VIDEO_INFO_X, yy = VIDEO_INFO_Y;
+		uchar *p = (uchar *) info;
+
+		while (len) {
+			if (len > space) {
+				video_drawchars(xx, yy, p, space);
+				len -= space;
+
+				p = (uchar *)p + space;
+
+				if (!y_off) {
+					xx += VIDEO_FONT_WIDTH;
+					space--;
+				}
+				yy += VIDEO_FONT_HEIGHT;
+
+				y_off++;
+			} else {
+				video_drawchars(xx, yy, p, len);
+				len = 0;
+			}
+		}
 	} else
 		video_drawstring(VIDEO_INFO_X, VIDEO_INFO_Y, (uchar *) info);