Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB294C636D4 for ; Wed, 15 Feb 2023 11:45:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 665F185A72; Wed, 15 Feb 2023 12:44:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cMaFhZ8A"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 997BD85A19; Wed, 15 Feb 2023 12:43:34 +0100 (CET) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 35A0F85A3C for ; Wed, 15 Feb 2023 12:43:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dsankouski@gmail.com Received: by mail-ej1-x634.google.com with SMTP id k16so15951723ejv.10 for ; Wed, 15 Feb 2023 03:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L7yAYfV1WPNkgUp6hgy74H+hTjS8e6SbrbY+65GN/Ag=; b=cMaFhZ8AKl7FH9TWBV53K7XxXNE3co/lQNnxfOGSDIQ7G+LViSZsh6+D1wF4cZjA9V FqPfNcpATndypWuO+/s0ZxuF8OqUz9KCMU5MnqQMWD/tc6hXWZYLuW7nRHxrd2EVfxGp XQrXNev8pIC5LBBCqpS7uBu1vjom0n9CztbCZwFo2sK7abnmdwPI5D+vBi/49b2MCKX+ qAIMd61Je/pu9cVkDSJC/PoPHwOnqagQ87yWDc3KiSB1QO5hdr4swHiphH3IRqK0bMxm DTzwQ7lJ/7ZGul9wB96eLnGOVGDsqJql3nrefeB5zcwFaozfrNmuRehTlvEqrSGUvjAs Drlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L7yAYfV1WPNkgUp6hgy74H+hTjS8e6SbrbY+65GN/Ag=; b=s1fUnzOIeC3CJLizbOCtEnOuNqVplJhLreJQ0kmeYtVWmG0aUHF22FiQO8/Bn+DKED vlhs06KSAwRhUHD83d6cJl5usyRx8m5FxNkQpgHgwQ3ZVXYyrfWB+hkSlFMjouB7J04D HW2olo7N0wbF+sjttwOafHN06URTHAbYv1ukRA6D9+x124okvR2dnTeu/vWOjB5ieaxi RaPFKdiY8Q6y5BH4px7wndDOdgNTkUzvuZpSqcWxwobAXyu9esNWs0Vk6IfYls1+UDxA un7JVQU5dWR6mPgFMWToGcujXutVmQGYjl+JMrJXJHq/Pyb3Xg2UOjZe6c5AAPHVTVq1 diKQ== X-Gm-Message-State: AO0yUKW2VJmhVzTPbCGOiamxoRYLUTrCKRSQ0G6TeD/Z3hOFI7I0Df4f x/0qayd5q+9g80BX3rqItX7uuGpUHzs= X-Google-Smtp-Source: AK7set+QkI98sEvHV+/cFFAv51gBadIwZjKs2sdh71IcUF+Wut4pelafxHPestbS4qYPJFjNkFhaqQ== X-Received: by 2002:a17:906:19d7:b0:87b:3d29:2990 with SMTP id h23-20020a17090619d700b0087b3d292990mr1661033ejd.9.1676461389655; Wed, 15 Feb 2023 03:43:09 -0800 (PST) Received: from debian.localdomain ([37.45.175.233]) by smtp.googlemail.com with ESMTPSA id gz19-20020a170906f2d300b008b14b63d3besm299247ejb.197.2023.02.15.03.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 03:43:09 -0800 (PST) From: Dzmitry Sankouski To: u-boot@lists.denx.de Cc: Dzmitry Sankouski , Anatolij Gustschin , Simon Glass , Ilias Apalodimas , Heinrich Schuchardt , Masahisa Kojima , John Keeping , Neil Armstrong , Roger Knecht , Alexey Romanov Subject: [PATCH v3 6/9] video console: allow font size configuration at runtime Date: Wed, 15 Feb 2023 14:42:57 +0300 Message-Id: <20230215114300.1151303-7-dsankouski@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230215114300.1151303-1-dsankouski@gmail.com> References: <20230215114300.1151303-1-dsankouski@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean Allow font size configuration at runtime for console_simple.c driver. This needed for unit testing different fonts. Configuring is done by `font` command, also used for font selection in true type console. Signed-off-by: Dzmitry Sankouski --- Changes for v2: N/A Changes for v3: - move 8x16 font patch extracted - implement multiple fonts patch extracted - add static modifiers, where needed - remove list fonts operation - put fontdata in local var cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 +- drivers/video/Kconfig | 1 + drivers/video/console_simple.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 2caa4af71c..f368ee7e9b 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2226,6 +2226,14 @@ config CMD_VIDCONSOLE The name 'lcdputs' is a bit of a misnomer, but so named because the video device is often an LCD. +config CMD_SELECT_FONT + bool "select font size" + depends on VIDEO + default n + help + Enabling this will provide 'font' command. + Allows font selection at runtime. + endmenu source "cmd/ti/Kconfig" diff --git a/cmd/Makefile b/cmd/Makefile index 36d2daf22a..2d8bb4fc05 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -78,7 +78,7 @@ obj-$(CONFIG_CMD_EXT2) += ext2.o obj-$(CONFIG_CMD_FAT) += fat.o obj-$(CONFIG_CMD_FDT) += fdt.o obj-$(CONFIG_CMD_SQUASHFS) += sqfs.o -obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o +obj-$(CONFIG_CMD_SELECT_FONT) += font.o obj-$(CONFIG_CMD_FLASH) += flash.o obj-$(CONFIG_CMD_FPGA) += fpga.o obj-$(CONFIG_CMD_FPGAD) += fpgad.o diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 47428ecb6c..419c53418d 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -165,6 +165,7 @@ config CONSOLE_ROTATION config CONSOLE_TRUETYPE bool "Support a console that uses TrueType fonts" + select CMD_SELECT_FONT help TrueTrype fonts can provide outline-drawing capability rather than needing to provide a bitmap for each font and size that is needed. diff --git a/drivers/video/console_simple.c b/drivers/video/console_simple.c index 402d67f85f..2b39d724f4 100644 --- a/drivers/video/console_simple.c +++ b/drivers/video/console_simple.c @@ -56,6 +56,28 @@ static int console_set_font(struct udevice *dev, struct video_fontdata *fontdata return 0; } +static int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info *info) +{ + info->name = (&fonts[seq])->name; + + return 0; +} + +static int console_simple_select_font(struct udevice *dev, const char *name, uint size) +{ + console_set_font(dev, &fonts[1]); + struct video_fontdata *font; + + for (font = fonts; font->name; font++) { + if (!strcmp(name, font->name)) { + console_set_font(dev, font); + return 0; + } + }; + printf("no such font: %s, make sure it's name has x format\n", name); + return -ENOENT; +} + /** * Checks if bits per pixel supported. * @@ -352,6 +374,8 @@ struct vidconsole_ops console_ops = { .putc_xy = console_putc_xy, .move_rows = console_move_rows, .set_row = console_set_row, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, }; U_BOOT_DRIVER(vidconsole_normal) = { @@ -612,18 +636,24 @@ struct vidconsole_ops console_ops_1 = { .putc_xy = console_putc_xy_1, .move_rows = console_move_rows_1, .set_row = console_set_row_1, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, }; struct vidconsole_ops console_ops_2 = { .putc_xy = console_putc_xy_2, .move_rows = console_move_rows_2, .set_row = console_set_row_2, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, }; struct vidconsole_ops console_ops_3 = { .putc_xy = console_putc_xy_3, .move_rows = console_move_rows_3, .set_row = console_set_row_3, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, }; U_BOOT_DRIVER(vidconsole_1) = { -- 2.30.2