From patchwork Tue Mar 7 10:21:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 1753043 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=GM4MdMXs; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PWBN82ZHNz1yXD for ; Tue, 7 Mar 2023 21:22:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B40D85BD5; Tue, 7 Mar 2023 11:22: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=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="GM4MdMXs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 752AB85C0D; Tue, 7 Mar 2023 11:22:01 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (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 E186985B55 for ; Tue, 7 Mar 2023 11:21:51 +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-wm1-x336.google.com with SMTP id d41-20020a05600c4c2900b003e9e066550fso6848782wmp.4 for ; Tue, 07 Mar 2023 02:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678184511; 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=opIeOFaWoWZlfU23IW9YQqu0nBPrSM2JW/zYuTM8QD4=; b=GM4MdMXsqfCYlF7TDVFRTo40zsXYLibC0e5u9ORhW0A31OM22uqrUzzvxt3f55V4ci HSDg+9UxkL1kJuZlM82Cut/Ts5/xoNHxSSCsKsPQMcWX0crljG7qyo2wNs1uneZTjVAO 4sW/zPgbw/n4RveBhjflLO2KZOcggyNe+oXMTh2+Lj7+lOd7wonRmOsHGzf3LzLlx2Ef UwZEKfI3sjh3lcMwGJtQ3g4XxpwIadsZR7iqsktIwBSnvrUQeBlwyql6re2d+ULEsDeM 4xIGZtzMpJ7KizMAg/tGOgZS+cNxtCpjL6hprNDeo6c43Xl/GRDi/1DajOdjmU56X3Rw aUMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678184511; 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=opIeOFaWoWZlfU23IW9YQqu0nBPrSM2JW/zYuTM8QD4=; b=2LQONh5OY5RCatZuPVQX0MbNbO5Gdusks+ua4p+4PSZTreRXIokE4R5N1E/KfKiRpv Hnl7yfA2JW+g5xBDUqoyS3Jimw+JUDj4pFYs4NTRc4GgSc5glA/LAtFsugeqc6kZ4zWc HQiHC62MnaA0gJaWdKLEvtI6VSpLCCfvQx20XVRY6UxBtJqEtF4JhyOLbdRpxSz1Hxjw emGcrXB+JQWLcCxI4xvzXKmd7bSPA0uL+jomgE/pEDzNZaU4Cyzqx3CcN9+kLwPY9QxM hn9kkGOpBPcP0595oAdawiAX7d68FVqNfrFJ/FHP3Kkh2LbLXYweixRBrps10p0lgRp7 SH3g== X-Gm-Message-State: AO0yUKXbFdfWc3tDvH6J+1in5wtc74LHKieSHNnHLwJAIi4cCX5c6a2b uF1ULmDEsy9pPG2YXR0YF3oPk2CZJyg= X-Google-Smtp-Source: AK7set9rfctmOpNnSft9Xei6ppTIcPXE+laXuqYeGnNLp5Eb1tHW0PUUtvKsd7DxduuUtCXNrmQOVA== X-Received: by 2002:a05:600c:4511:b0:3ea:e554:7808 with SMTP id t17-20020a05600c451100b003eae5547808mr12137448wmo.19.1678184511453; Tue, 07 Mar 2023 02:21:51 -0800 (PST) Received: from debian.localdomain ([37.45.231.77]) by smtp.googlemail.com with ESMTPSA id d42-20020a05600c4c2a00b003e6efc0f91csm12306258wmp.42.2023.03.07.02.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 02:21:51 -0800 (PST) From: Dzmitry Sankouski To: U-Boot Mailing List Cc: Dzmitry Sankouski , Simon Glass , Alexey Romanov , Anatolij Gustschin , Heinrich Schuchardt , Ilias Apalodimas , John Keeping , Masahisa Kojima , Neil Armstrong , Roger Knecht Subject: [PATCH v8 06/10] video console: allow font size configuration at runtime Date: Tue, 7 Mar 2023 13:21:16 +0300 Message-Id: <20230307102121.1925581-7-dsankouski@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230307102121.1925581-1-dsankouski@gmail.com> References: <20230307102121.1925581-1-dsankouski@gmail.com> MIME-Version: 1.0 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.8 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 in v8: none Changes in v7: - (&fonts[seq])->name - fonts[seq].name Changes in v6: rebase only Changes in v5: N/A Changes in v4: N/A Changes in 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 Changes in v2: N/A 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 d019b985b4..d4f79c656a 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);