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 5E84BC636D4 for ; Mon, 13 Feb 2023 16:59:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CEB8C8582C; Mon, 13 Feb 2023 17:58:53 +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="XJnA2RIR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8AC2E84CFA; Mon, 13 Feb 2023 17:57:48 +0100 (CET) Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) (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 138FA8573B for ; Mon, 13 Feb 2023 17:57:08 +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-x52f.google.com with SMTP id eq11so13809495edb.6 for ; Mon, 13 Feb 2023 08:57:08 -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=oV6h+4La0UmtnaSNCPNjLOdp9LHgQWAWDPkpDYWihh0=; b=XJnA2RIR12GEU3y+MtCNdnKzkerwVb1PCCHJy+4wkokvnYFz0hljOn3RCPecPkcntH QArMbicex/MJuC6hKekmjjmtrdV2wa0MKDir82h6OyfaF+ru6EFKv1L+UpV3Qn9zEDjJ euy6Y/mTqpsob5rAivPp5VVzpyDURofgKcY4sfKCtskDkR3GwavoMvUbjrG1eA4iUWqN fRzOVcpY/P6AWkSoyCEL+avsoDe368DOiaBQ63b+2aR6r2Sy9YpLLPhvqPRQerEQiZDj ftTjWd/ywTCttjVNeyOw04mvt6LaNBu8ZP6XkAtrlMEvEYqCT1av946WmDDk2Sn68M5w aDGA== 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=oV6h+4La0UmtnaSNCPNjLOdp9LHgQWAWDPkpDYWihh0=; b=hWuqhvKFBSQEQVBHWG/pfW/EU7E20h01JNP4bVyWs8Rs1TZQy/dZdYgC5rluR3qx4o 0OlAJ2Z8dX26LL3C5GcTHv3E9h8clOu6IX/cfyRbEwOL88pQGuNpLg7fm64VqYSm9H// ZTS4uIO8fusMq1Jy1zV7/hXdUnUMsNzZdoqLSCUfQN+uMS8kbtJUvr9LPsFpRBB/RWby DhXQRpi1KTQLX9ZMuM5b5zt012U+tcBhSS6Fm0NYWOj0FGSYIFsyJ6QeXZ21EPg/siDF 3/g65y21p2rIyakSsuiiKSa6diAT4btd5mYdRPzSOgrkjTryiSQh/PhGXWxB650yMPqg unCw== X-Gm-Message-State: AO0yUKXQSzLCGCjz9wraD9PQTdFtXd4Y74SescUzcGeQ+OYZMz37KIAY Im0uLb6t8YF2zBTg3lluLaCdQhYXtwE= X-Google-Smtp-Source: AK7set94AB55pz3nk+YOOR2sDXSY4YiCSKkO+bpXjbrllh95FbfGWzt7P4eI/ZDtWnugvGICs9tbyA== X-Received: by 2002:a50:9e4b:0:b0:4ab:1625:908d with SMTP id z69-20020a509e4b000000b004ab1625908dmr17914733ede.16.1676307427695; Mon, 13 Feb 2023 08:57:07 -0800 (PST) Received: from debian.localdomain ([37.45.245.36]) by smtp.googlemail.com with ESMTPSA id v1-20020a50c401000000b004a249a97d84sm6897592edf.23.2023.02.13.08.57.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 08:57:07 -0800 (PST) From: Dzmitry Sankouski To: u-boot@lists.denx.de Cc: Dzmitry Sankouski , Anatolij Gustschin , Simon Glass Subject: [PATCH v2 4/8] video console: add select font logic to vidconsole uclass driver Date: Mon, 13 Feb 2023 19:56:56 +0300 Message-Id: <20230213165700.982691-5-dsankouski@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230213165700.982691-1-dsankouski@gmail.com> References: <20230213165700.982691-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 Select font logic at runtime needed to unit test different fonts. This commit is a preparation to enable runtime font selection in console_simple driver. - move console true type select font logic to driver ops - add select font logic to vidconsole-uclass.c Signed-off-by: Dzmitry Sankouski --- Changes for v2: N/A cmd/font.c | 7 ++++++- drivers/video/console_truetype.c | 6 ++++-- drivers/video/vidconsole-uclass.c | 22 ++++++++++++++++++++++ include/video.h | 1 + include/video_console.h | 18 +++++++++++++++++- 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/cmd/font.c b/cmd/font.c index 3e522f3aaa..769796c5ec 100644 --- a/cmd/font.c +++ b/cmd/font.c @@ -15,7 +15,12 @@ static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - vidconsole_list_fonts(); + struct udevice *dev; + + if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) + return CMD_RET_FAILURE; + + vidconsole_list_fonts(dev); return 0; } diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 6859c9fa11..389fa483fc 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -584,7 +584,7 @@ static struct font_info *console_truetype_find_font(void) return NULL; } -void vidconsole_list_fonts(void) +void console_truetype_list_fonts(struct udevice __maybe_unused *dev) { struct font_info *tab; @@ -674,7 +674,7 @@ static void select_metrics(struct udevice *dev, struct console_tt_metrics *met) vc_priv->tab_width_frac = VID_TO_POS(met->font_size) * 8 / 2; } -int vidconsole_select_font(struct udevice *dev, const char *name, uint size) +int console_truetype_select_font(struct udevice *dev, const char *name, uint size) { struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_metrics *met; @@ -763,6 +763,8 @@ struct vidconsole_ops console_truetype_ops = { .set_row = console_truetype_set_row, .backspace = console_truetype_backspace, .entry_start = console_truetype_entry_start, + .list_fonts = console_truetype_list_fonts, + .select_font = console_truetype_select_font, }; U_BOOT_DRIVER(vidconsole_truetype) = { diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 6bdfb6e37d..5a08fdd689 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -85,6 +85,28 @@ static int vidconsole_back(struct udevice *dev) return video_sync(dev->parent, false); } +void vidconsole_list_fonts(struct udevice *dev) +{ + struct vidconsole_ops *ops = vidconsole_get_ops(dev); + + if (ops->select_font) + ops->list_fonts(dev); +} + +int vidconsole_select_font(struct udevice *dev, const char *name, uint size) +{ + struct vidconsole_ops *ops = vidconsole_get_ops(dev); + int ret; + + if (ops->select_font) { + ret = ops->select_font(dev, name, size); + if (ret != -ENOSYS) + return ret; + } + + return 0; +} + /* Move to a newline, scrolling the display if necessary */ static void vidconsole_newline(struct udevice *dev) { diff --git a/include/video.h b/include/video.h index 43f2e2c02f..91c05fa9f0 100644 --- a/include/video.h +++ b/include/video.h @@ -115,6 +115,7 @@ struct video_priv { bool flush_dcache; u8 fg_col_idx; u8 bg_col_idx; + struct video_fontdata *fontdata; }; /** diff --git a/include/video_console.h b/include/video_console.h index d755eb73cf..fc702cc165 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -133,6 +133,22 @@ struct vidconsole_ops { * characters. */ int (*backspace)(struct udevice *dev); + + /** + * list_fonts() - List the available fonts + * + * This shows a list on the console + */ + void (*list_fonts)(struct udevice *dev); + + /** + * select_font() - Select a font to use + * + * @dev: vidconsole device + * @name: Font name + * @size: Size of the font (norminal pixel height) or 0 for default + */ + int (*select_font)(struct udevice *dev, const char *name, uint size); }; /* Get a pointer to the driver operations for a video console device */ @@ -236,7 +252,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y); * * This shows a list on the console */ -void vidconsole_list_fonts(void); +void vidconsole_list_fonts(struct udevice *dev); /** * vidconsole_select_font() - Select a font to use -- 2.30.2