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 D09FEC7EE30 for ; Mon, 27 Feb 2023 17:38:26 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 75B7F85ACB; Mon, 27 Feb 2023 18:37:47 +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="Vn4tzvs4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 16EB985AA1; Mon, 27 Feb 2023 18:37:31 +0100 (CET) Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 EA8A485AC2 for ; Mon, 27 Feb 2023 18:37:21 +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-x533.google.com with SMTP id i34so29006948eda.7 for ; Mon, 27 Feb 2023 09:37:21 -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=NpIcFGoOMKqWcUCcuJOIu5RB2hDsY8f5jIUgbXcUSoY=; b=Vn4tzvs4HmJ+9RmE3oW6TPicS4VyErxIYRJuxPpL2IVEgcnnLfj5B3drX56CNa3U0B +1ZQ4vGuiDYdWGsKNnuTcceWP28DI1mLO8CMPFjAC277nEzVV9RDxjvh5nKUa2Y3403M OUDAWsBKNRLIHUAMudPvcwZ8QloJXBFj8PT0SBU7++zmXUHvzNmYC8MWci8iv1WujbU7 f0qVvNk0tH4G9ccYjI+5EmJ1VTTUjtI69uloVngZErSk2eoQutVla0jaTXDgq4W61NhI kq83iIU6gX5FWb0sflMLHHrdeZcuRMGX7HDFh8M4jo1EVyO3F03g1dMCB/I5YFEL7zvu AuKg== 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=NpIcFGoOMKqWcUCcuJOIu5RB2hDsY8f5jIUgbXcUSoY=; b=Q63+pZDXWh/HtPS1nso5kmj+Y5U8Sd864Vk/I1+JKuMur+1XgevrnDtOQPsgIwtdpw TB0xk33wgaCpedhbin/Q1s3GjuRgodRuW328KWn7Tda3hvUdG2xVSelEr+525SkeGfNy B0PHTNZU/LgayGf0GcilX5CZUpaPLNqOMy6MLTlUOB6d5Es8f4pc05KjJnvOI6+f7EuJ vC5C7InZfjh+XC0PhBE7BPdwJH624H5c1Az7W5ZEDFeJLASD0BIDc8RXzs8KVL6JHMgf k1BEfz6a01wS4QZGadRXzut0eERmS95GXL/dDCoeJBOJ8/PyH8XFhO+MJjMWiISEJDMK XB6A== X-Gm-Message-State: AO0yUKWkNkVP8zpO3cSL3JO7RrdeOA2JThS7XbZ+Hif89McZcciM1sY0 lch3kAK+I9SZw+84HYaXPub7P+Qw2kA= X-Google-Smtp-Source: AK7set+v3EqxhdU5ULFPrOlQERU0LgIYz3qRqtWMBMD2CGcYWPGeiTTQF7rB1Hhnzh6ErnIESzlAtQ== X-Received: by 2002:a17:906:8601:b0:89c:d072:e33e with SMTP id o1-20020a170906860100b0089cd072e33emr31785272ejx.49.1677519441435; Mon, 27 Feb 2023 09:37:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 09:37:20 -0800 (PST) From: Dzmitry Sankouski To: u-boot@lists.denx.de Cc: Dzmitry Sankouski , Anatolij Gustschin , Simon Glass Subject: [PATCH v7 05/10] video console: move vidconsole_get_font_size() logic to driver ops Date: Mon, 27 Feb 2023 20:37:05 +0300 Message-Id: <20230227173710.1688611-6-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 Since multiple vidconsole drivers exists, vidconsole_get_font_size() implementation cannot longer live in vidconsole_uclass.c file. Move current vidconsole_get_font_size logic to truetype driver ops. Signed-off-by: Dzmitry Sankouski --- Changes for v2: N/A Changes for v3: N/A Charges for v4: N/A Charges for v5: N/A Charges for v6: N/A Charges for v7: N/A cmd/font.c | 6 +++++- drivers/video/console_truetype.c | 3 ++- drivers/video/vidconsole-uclass.c | 11 +++++++++++ include/video_console.h | 14 ++++++++++++-- test/cmd/font.c | 13 +++++++------ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/cmd/font.c b/cmd/font.c index 7b4347f32b..fe2d65caaf 100644 --- a/cmd/font.c +++ b/cmd/font.c @@ -61,7 +61,11 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) return CMD_RET_FAILURE; - font_name = vidconsole_get_font_size(dev, &size); + ret = vidconsole_get_font_size(dev, &font_name, &size); + if (ret) { + printf("Failed (error %d)\n", ret); + return CMD_RET_FAILURE; + } size = dectoul(argv[1], NULL); diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 9cac9a6de4..6b5390136a 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -724,7 +724,7 @@ static int truetype_select_font(struct udevice *dev, const char *name, return 0; } -const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep) +const char *console_truetype_get_font_size(struct udevice *dev, uint *sizep) { struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_metrics *met = priv->cur_met; @@ -773,6 +773,7 @@ struct vidconsole_ops console_truetype_ops = { .backspace = console_truetype_backspace, .entry_start = console_truetype_entry_start, .get_font = console_truetype_get_font, + .get_font_size = console_truetype_get_font_size, .select_font = truetype_select_font, }; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 72a13d3052..a5f2350ca1 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -575,6 +575,17 @@ int vidconsole_get_font(struct udevice *dev, int seq, return ops->get_font(dev, seq, info); } +int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep) +{ + struct vidconsole_ops *ops = vidconsole_get_ops(dev); + + if (!ops->get_font_size) + return -ENOSYS; + + *name = ops->get_font_size(dev, sizep); + return 0; +} + int vidconsole_select_font(struct udevice *dev, const char *name, uint size) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); diff --git a/include/video_console.h b/include/video_console.h index 9d2c0f210e..646c7e292b 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -160,6 +160,15 @@ struct vidconsole_ops { int (*get_font)(struct udevice *dev, int seq, struct vidfont_info *info); + /** + * get_font_size() - get the current font name and size + * + * @dev: vidconsole device + * @sizep: Place to put the font size (nominal height in pixels) + * Returns: Current font name + */ + const char *(*get_font_size)(struct udevice *dev, uint *sizep); + /** * select_font() - Select a particular font by name / size * @@ -303,9 +312,10 @@ void vidconsole_list_fonts(struct udevice *dev); * * @dev: vidconsole device * @sizep: Place to put the font size (nominal height in pixels) - * Returns: Current font name + * @name: pointer to font name, a placeholder for result + * Return: 0 if OK, -ENOSYS if not implemented in driver */ -const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep); +int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep); #ifdef CONFIG_VIDEO_COPY /** diff --git a/test/cmd/font.c b/test/cmd/font.c index adb353965a..40682e5ce4 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -19,6 +19,7 @@ static int font_test_base(struct unit_test_state *uts) { struct udevice *dev; + const char *name; int max_metrics; uint size; int ret; @@ -32,8 +33,8 @@ static int font_test_base(struct unit_test_state *uts) ut_assert_nextline("cantoraone_regular"); ut_assertok(ut_check_console_end(uts)); - ut_asserteq_str("nimbus_sans_l_regular", - vidconsole_get_font_size(dev, &size)); + ut_assertok(vidconsole_get_font_size(dev, &name, &size)); + ut_asserteq_str("nimbus_sans_l_regular", name); ut_asserteq(18, size); max_metrics = 1; @@ -52,15 +53,15 @@ static int font_test_base(struct unit_test_state *uts) ut_assertok(ret); ut_assertok(ut_check_console_end(uts)); - ut_asserteq_str("cantoraone_regular", - vidconsole_get_font_size(dev, &size)); + ut_assertok(vidconsole_get_font_size(dev, &name, &size)); + ut_asserteq_str("cantoraone_regular", name); ut_asserteq(40, size); ut_assertok(run_command("font size 30", 0)); ut_assertok(ut_check_console_end(uts)); - ut_asserteq_str("cantoraone_regular", - vidconsole_get_font_size(dev, &size)); + ut_assertok(vidconsole_get_font_size(dev, &name, &size)); + ut_asserteq_str("cantoraone_regular", name); ut_asserteq(30, size); return 0; -- 2.30.2