From patchwork Sat Feb 27 13:08:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1445175 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=l8qnd3IT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dnn272CXTz9sRN for ; Sun, 28 Feb 2021 00:10:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1EACA8270D; Sat, 27 Feb 2021 14:10:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="l8qnd3IT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B8F2E82016; Sat, 27 Feb 2021 14:09:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7B1828204A for ; Sat, 27 Feb 2021 14:09:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1614431345; bh=j41U5mdUFgpf9vopfSiIgbopDKfBe0D3OAR7OZLKbzA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=l8qnd3ITzgDY+kOz3wjINtuTxvbcxUXjK68V0q9MZAYdrdx+FVYuhUlyv5uf1NnyB brh+Gx9jWaptBZN8xWWNKVCEwPKPUukmZWNyRonwCrHWiir3zwhJJJpkcpAJmL+Nkl avuHxfPex/ohfyk8XWUHDaZXa8zQGo+awJ0EqPPM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.246.89]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1M9Fjb-1lCQha2bdX-006OEQ; Sat, 27 Feb 2021 14:09:05 +0100 From: Heinrich Schuchardt To: Alexander Graf , Anatolij Gustschin Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 6/6] video: support Unicode in video console Date: Sat, 27 Feb 2021 14:08:40 +0100 Message-Id: <20210227130840.166193-7-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210227130840.166193-1-xypron.glpk@gmx.de> References: <20210227130840.166193-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03: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SrJdrt3XPlkUwVXRjHzpk7SNV9WvkPA ByW1lXge/UqzJvpywvA3GaXdzgYnFeRuZvEvWWxqtkjUWQSepgQNdrx07/jGGzVh0TMyRsHHz KDkWsbH20F6QkhpUkf1w== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean UEFI programs use Unicode for console output, e.g. GRUB uses characters from the 0x2500 code block to draw a box around the menu. The TrueType console supports UTF-32. The normal console supports code page 437. We have to convert the UTF-8 stream passed to putc() accordingly. Signed-off-by: Heinrich Schuchardt --- drivers/video/vidconsole-uclass.c | 22 +++++++++++++++++----- include/video_console.h | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) -- 2.30.0 diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index a355328851..d5095f69e0 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -32,7 +32,7 @@ struct vid_rgb { #define CONFIG_CONSOLE_SCROLL_LINES 1 #endif -int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch) +int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int ch) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); @@ -479,8 +479,14 @@ error: priv->escape = 0; } -/* Put that actual character on the screen (using the CP437 code page). */ -static int vidconsole_output_glyph(struct udevice *dev, char ch) +/* + * vidconsole_output_glyph() - put the actual character on the screen + * + * @dev: video device + * @ch: character: Unicode for Truetype, codepage 437 otherwise + * Return: 0 for success + */ +static int vidconsole_output_glyph(struct udevice *dev, int ch) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); int ret; @@ -505,17 +511,23 @@ static int vidconsole_output_glyph(struct udevice *dev, char ch) return 0; } -int vidconsole_put_char(struct udevice *dev, char ch) +int vidconsole_put_char(struct udevice *dev, char c) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + int ch; int ret; if (IS_ENABLED(CONFIG_EFI_LOADER)) { static char buffer[5]; - ch = utf8_to_cp437_stream(ch, buffer); + if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE)) + ch = utf8_to_utf32_stream(c, buffer); + else + ch = utf8_to_cp437_stream(c, buffer); if (!ch) return 0; + } else { + ch = c; } if (priv->escape) { diff --git a/include/video_console.h b/include/video_console.h index 5e6eb3cc81..8747299d61 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -174,7 +174,7 @@ struct vidconsole_ops { * if all is OK, -EAGAIN if we ran out of space on this line, other -ve * on error */ -int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, char ch); +int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int ch); /** * vidconsole_move_rows() - Move text rows from one place to another