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 04790C7EE23 for ; Mon, 27 Feb 2023 17:39:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 34E6485A9B; Mon, 27 Feb 2023 18:38:25 +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="NdE3iq2y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D97385A35; Mon, 27 Feb 2023 18:37:35 +0100 (CET) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (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 DAC5E85A81 for ; Mon, 27 Feb 2023 18:37:24 +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-ed1-x52e.google.com with SMTP id h16so28960925edz.10 for ; Mon, 27 Feb 2023 09:37:24 -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=V/U0dj1bxD5D7bMXflw/RTUoCSndcDATra8HGXufwZE=; b=NdE3iq2yNSINR5obUaneCLo+8n1WHDbOiC5IJlzoJDS9eoccP6J0IHVi6KQK2rCsca XRQplbw/EyyE9zVe9C3eNV3F9cXKjLb34HqEVlPUqbnWWvvsK1PpR8SYbsiU/50wMWsg ZhPyA4l4bMiYSTwqPV7lbBJf71eHsWcIui2HG+msMddP1FqVXrXLUVF+a4I4jhaEpMvd /f/YCyuqgHUHW6ShXNYgSJogbihBnj1MqRTCbRiYgemk73ddsudO07w6u1zYNtRU3MXS 1QPgsjG8ekJ4n79sEMA696jzkJY1FkaLkB3owZwrMbDTRDDCUf3M/wCaDdGqhkijeZBC fIUA== 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=V/U0dj1bxD5D7bMXflw/RTUoCSndcDATra8HGXufwZE=; b=kD2I4yAQLmoXxCABe3THcBCN/6QqhifkYGAkHqV1E8hRYsbbv/W6KuCGYCPNdLeVkz O9VD1X04zoR2YQLAseuSO8XSyhwQjAeGC7hmXfzoEdaZfF9+KP3zlZ/oc+TVVmks8OhP 3UDmJ7gHbfmqduPOiTs9wtcymPMV9nERhn6vlPb6+tqFUzWE/4RVGzqJGSC0Yb4dxAW7 mFRT2Yp7xNLI4qkB4HUp+/V/lb1BElYsRP5vpfR6zdFxvjKu6aoRcAcno7IiZKsBA9FU yh80aUNXbJUarFjaB7WnI+iBRTzzbKR5UW+ozqSO9wkO4REG3xnrxZHtkkAKMDanK1mu npOg== X-Gm-Message-State: AO0yUKV3uKrbBmYs+t/1yqjAEEsRpNCL9MjtajpYi0KdqqkRqZdzt+4l MyT8hTQ+vpuMqanKKNyFLzv2ATA6XJ4= X-Google-Smtp-Source: AK7set93zPglRIOd/TAw8k3IfzD/3K11t+bpu6Bo2a5V3Kwe+f3UC+BEdtNE/w8Epxx+cjkiWbGlPQ== X-Received: by 2002:a17:906:261a:b0:8b1:7de3:cfb3 with SMTP id h26-20020a170906261a00b008b17de3cfb3mr34914134ejc.1.1677519442835; Mon, 27 Feb 2023 09:37:22 -0800 (PST) Received: from debian.localdomain ([37.45.144.86]) by smtp.googlemail.com with ESMTPSA id c89-20020a509fe2000000b004aeeb476c5bsm3349912edf.24.2023.02.27.09.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 09:37:22 -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 v7 06/10] video console: allow font size configuration at runtime Date: Mon, 27 Feb 2023 20:37:06 +0300 Message-Id: <20230227173710.1688611-7-dsankouski@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230227173710.1688611-1-dsankouski@gmail.com> References: <20230227173710.1688611-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 Reviewed-by: Simon Glass --- 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 Charges for v4: N/A Charges for v5: N/A Charges for v6: rebase only Charges for v7: rebase only - (&fonts[seq])->name - fonts[seq].name cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 +- drivers/video/Kconfig | 1 + drivers/video/console_core.c | 30 +++++++++++++++++++++++++++++ drivers/video/console_normal.c | 3 +++ drivers/video/console_rotate.c | 9 +++++++++ drivers/video/vidconsole_internal.h | 18 +++++++++++++++++ 7 files changed, 70 insertions(+), 1 deletion(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 2caa4af71c..a3512836c1 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 ce97eb4727..e1bcc89b30 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_core.c b/drivers/video/console_core.c index b82ca6d43c..d830738427 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -180,3 +180,33 @@ int console_probe(struct udevice *dev) { return console_set_font(dev, fonts); } + +const char *console_simple_get_font_size(struct udevice *dev, uint *sizep) +{ + struct console_simple_priv *priv = dev_get_priv(dev); + + *sizep = priv->fontdata->width; + + return priv->fontdata->name; +} + +int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info *info) +{ + info->name = fonts[seq].name; + + return 0; +} + +int console_simple_select_font(struct udevice *dev, const char *name, uint size) +{ + 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; +} diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 03e859898c..413c7abee9 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -101,6 +101,9 @@ struct vidconsole_ops console_ops = { .putc_xy = console_putc_xy, .move_rows = console_move_rows, .set_row = console_set_row, + .get_font_size = console_simple_get_font_size, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, }; U_BOOT_DRIVER(vidconsole_normal) = { diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c index b924bc3459..65358a1c6e 100644 --- a/drivers/video/console_rotate.c +++ b/drivers/video/console_rotate.c @@ -262,18 +262,27 @@ 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_size = console_simple_get_font_size, + .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_size = console_simple_get_font_size, + .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_size = console_simple_get_font_size, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, }; U_BOOT_DRIVER(vidconsole_1) = { diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 99d3c876d7..c41edd4524 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -100,3 +100,21 @@ int fill_char_horizontally(uchar *pfont, void **line, struct video_priv *vid_pri * @returns 0, if success, or else error code. */ int console_probe(struct udevice *dev); + +/** + * Internal function to be used in as ops. + * See details in video_console.h get_font_size function + **/ +const char *console_simple_get_font_size(struct udevice *dev, uint *sizep); + +/** + * Internal function to be used in as ops. + * See details in video_console.h get_font function + **/ +int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info *info); + +/** + * Internal function to be used in as ops. + * See details in video_console.h select_font function + **/ +int console_simple_select_font(struct udevice *dev, const char *name, uint size); -- 2.30.2