From patchwork Wed Feb 5 16:49:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 236000 List-Id: U-Boot discussion From: agust at denx.de (Anatolij Gustschin) Date: Wed, 5 Feb 2020 17:49:58 +0100 Subject: [PATCH 2/3] splash: fix banner output on small displays In-Reply-To: <20200205164959.31404-1-agust@denx.de> References: <20200205164959.31404-1-agust@denx.de> Message-ID: <20200205164959.31404-2-agust@denx.de> 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 --- common/splash.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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 */