From patchwork Fri May 17 18:22:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1101171 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 455GqP30BCz9s55 for ; Sat, 18 May 2019 04:22:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id F1D5EC21DB6; Fri, 17 May 2019 18:22:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 35D39C21D65; Fri, 17 May 2019 18:22:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 85E0CC21D56; Fri, 17 May 2019 18:22:34 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 44A9AC21C93 for ; Fri, 17 May 2019 18:22:34 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 455GqG0SgHz1rCX7; Fri, 17 May 2019 20:22:34 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 455GqG0Czfz1qqkk; Fri, 17 May 2019 20:22:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 8XMmGxiQJjk0; Fri, 17 May 2019 20:22:33 +0200 (CEST) X-Auth-Info: yLrVFTRtBMj4wQM56GCdY7B3JyPRltnMDjqchhNVdCk= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 17 May 2019 20:22:32 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Fri, 17 May 2019 20:22:31 +0200 Message-Id: <20190517182231.32535-1-marex@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH] video: Factor out vidconsole_put_string() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Pull the vidconsole_put_string() function from DM tests, make it available to e.g. boards that want to display information on the LCD on boot. Signed-off-by: Marek Vasut Cc: Anatolij Gustschin Reviewed-by: Anatolij Gustschin --- drivers/video/vidconsole-uclass.c | 17 +++++++++++++++-- include/video_console.h | 16 ++++++++++++++++ test/dm/video.c | 8 -------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index c31303b56e..af88588904 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -529,6 +529,20 @@ int vidconsole_put_char(struct udevice *dev, char ch) return 0; } +int vidconsole_put_string(struct udevice *dev, const char *str) +{ + const char *s; + int ret; + + for (s = str; *s; s++) { + ret = vidconsole_put_char(dev, *s); + if (ret) + return ret; + } + + return 0; +} + static void vidconsole_putc(struct stdio_dev *sdev, const char ch) { struct udevice *dev = sdev->priv; @@ -541,8 +555,7 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s) { struct udevice *dev = sdev->priv; - while (*s) - vidconsole_put_char(dev, *s++); + vidconsole_put_string(dev, s); video_sync(dev->parent, false); } diff --git a/include/video_console.h b/include/video_console.h index 52a41ac200..0936ceaaf1 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -214,6 +214,22 @@ int vidconsole_set_row(struct udevice *dev, uint row, int clr); */ int vidconsole_put_char(struct udevice *dev, char ch); +/** + * vidconsole_put_string() - Output a string to the current console position + * + * Outputs a string to the console and advances the cursor. This function + * handles wrapping to new lines and scrolling the console. Special + * characters are handled also: \n, \r, \b and \t. + * + * The device always starts with the cursor at position 0,0 (top left). It + * can be adjusted manually using vidconsole_position_cursor(). + * + * @dev: Device to adjust + * @str: String to write + * @return 0 if OK, -ve on error + */ +int vidconsole_put_string(struct udevice *dev, const char *str); + /** * vidconsole_position_cursor() - Move the text cursor * diff --git a/test/dm/video.c b/test/dm/video.c index 6be5defc53..3151ebb73f 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -97,14 +97,6 @@ static int select_vidconsole(struct unit_test_state *uts, const char *drv_name) return 0; } -static void vidconsole_put_string(struct udevice *dev, const char *str) -{ - const char *s; - - for (s = str; *s; s++) - vidconsole_put_char(dev, *s); -} - /* Test text output works on the video console */ static int dm_test_video_text(struct unit_test_state *uts) {