diff mbox series

[2/3] splash: fix banner output on small displays

Message ID 20200205164959.31404-2-agust@denx.de
State Deferred
Delegated to: Anatolij Gustschin
Headers show
Series [1/3] video: add support for drawing 8bpp bitmap on 32bpp framebuffer | expand

Commit Message

Anatolij Gustschin Feb. 5, 2020, 4:49 p.m. UTC
On boards with small displays (i.e. 480x272) the banner
output on video console can sometimes overwrite the logo
(depending on the logo size and banner length). Check
for free space right of the logo before drawing the
banner and adjust the starting position to draw the
banner string below the logo. Also adjust the cursor
position after banner output to avoid overwriting the
rendered banner when the user switches stdout to the
vidconsole.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 common/splash.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/common/splash.c b/common/splash.c
index e7d847726d..c12dd38975 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -123,26 +123,38 @@  void splash_get_pos(int *x, int *y)
 
 void splash_display_banner(void)
 {
+	struct vidconsole_priv *priv;
 	struct udevice *dev;
 	char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
 	int col, row, ret;
+	size_t banner_len;
 
 	ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &dev);
 	if (ret)
 		return;
 
+	priv = dev_get_uclass_priv(dev);
+	if (!priv)
+		return;
+
 #ifdef CONFIG_VIDEO_LOGO
 	col = BMP_LOGO_WIDTH / VIDEO_FONT_WIDTH + 1;
 	row = BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT + 1;
 #else
 	col = 0;
-	row = 0;
+	row = 1;
 #endif
-
 	display_options_get_banner(false, buf, sizeof(buf));
-	vidconsole_position_cursor(dev, col, 1);
+
+	banner_len = strlen(buf);
+	if (priv->cols <= (col + banner_len))
+		col = 0;
+
+	vidconsole_position_cursor(dev, col, row);
 	vidconsole_put_string(dev, buf);
-	vidconsole_position_cursor(dev, 0, row);
+	if (priv->cols < banner_len)
+		row++;
+	vidconsole_position_cursor(dev, 0, row + 1);
 }
 #endif /* CONFIG_DM_VIDEO && !CONFIG_HIDE_LOGO_VERSION */