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 C47BBC636D6 for ; Thu, 23 Feb 2023 18:12:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6768685B46; Thu, 23 Feb 2023 19:12:18 +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="ZLACq0Gj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 125C08537F; Thu, 23 Feb 2023 19:11:01 +0100 (CET) Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 4DEE68598E for ; Thu, 23 Feb 2023 19:10:39 +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-x531.google.com with SMTP id i34so20018762eda.7 for ; Thu, 23 Feb 2023 10:10:39 -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=4tiZXhGBj+ICacIxzcSDHKnUipgNC1YrBIN/n9GpwJM=; b=ZLACq0Gj/jtyRI9PRIw1i5e3l1ly7zWuEKU+G9e2JiNGImeTeInVAgMjqmFOPhc0rA 2tarm4RNvOHVZDY57WUrNXXfkVehUwlhPZ8+oTGONDi6Zb6GI67XeiUF47vcJWkA0XPC sGEMz3dK7XxXNz+XVZqDpfLCes50rG5PwxZVoPTXlYun+qMjKLyy7efkIPiupCvOJVyE cRu6hh+F3oKf79Ripzb8T7eDG0aewKxElRPn/v9SWXS7/AxTY26VgUHyYuyHUxpVCsmS PrRcc9d3P1cJfuYkzddSTlV10yQ7qKWXDDiR5MeXa1YzvAEzbClAo81VcYtJMkg0lEeJ 5hdg== 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=4tiZXhGBj+ICacIxzcSDHKnUipgNC1YrBIN/n9GpwJM=; b=2H/vPmD2MdE+3aOuNsJJlpYqgY+SZ94r69SznOL5e5asmJUMABwqUMgibUBfxVKM/W JRHv5n+Kj2vvN3LuAOSrcRp6tGgnFJWTcu4989AA6bY0Q3Ph4XiA5DC4bNbvk/szWP5O LwOotF8FVcVy1n8sNrQQrrb6DYUJPMmq2Z9c6b1xkw0yeUjOplspP7oobS6jpCri+B/S cbtZalGsd4/QZOnYq0BS9G8Asm2dNzdkqBF0fm2ZJ3Pu7FzVdQFk0n3Fh+jXiALD/Hpv S+qHqbMz3WLiu0sHa603p9862C2cRdOtMLrjbj53U7ALGotUjj7sSU8yrpyzbLR6XE5x CKdw== X-Gm-Message-State: AO0yUKUMYeSgaxD/Ln/C/R6QxySjK8PR9fN+3AUspNv6WwAfjgs24cC1 rHvUwzv4OdjrfyiFAEoiRRdQMaEGrRw= X-Google-Smtp-Source: AK7set96IKhW8OUPaqEHIXfuYBSpskwfZi56bof0qX+2FNfUlC/gIBpLYIxwv9LupWtwjUBcQY+P5A== X-Received: by 2002:a05:6402:291:b0:4ad:5276:8ea4 with SMTP id l17-20020a056402029100b004ad52768ea4mr11903375edv.20.1677175838876; Thu, 23 Feb 2023 10:10:38 -0800 (PST) Received: from debian.localdomain ([178.127.181.53]) by smtp.googlemail.com with ESMTPSA id j10-20020a50d00a000000b004af516b5010sm3822989edf.94.2023.02.23.10.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 10:10:38 -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 v6 6/9] video console: allow font size configuration at runtime Date: Thu, 23 Feb 2023 21:10:26 +0300 Message-Id: <20230223181030.1596976-7-dsankouski@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230223181030.1596976-1-dsankouski@gmail.com> References: <20230223181030.1596976-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 cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 +- drivers/video/Kconfig | 1 + drivers/video/console_core.c | 21 +++++++++++++++++++++ drivers/video/console_normal.c | 2 ++ drivers/video/console_rotate.c | 6 ++++++ drivers/video/vidconsole_internal.h | 12 ++++++++++++ 7 files changed, 51 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..ee340b1528 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -180,3 +180,24 @@ int console_probe(struct udevice *dev) { return console_set_font(dev, &fonts[0]); } + +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..79eaa53b2d 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -101,6 +101,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) = { diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c index b924bc3459..f9f96835ee 100644 --- a/drivers/video/console_rotate.c +++ b/drivers/video/console_rotate.c @@ -262,18 +262,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) = { diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 99d3c876d7..47a24b583c 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -100,3 +100,15 @@ 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 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