[PATCH 16/16] video: Add a way to get the default font height

Simon Glass sjg at chromium.org
Thu Oct 6 16:36:18 CEST 2022


This is not as simple as it seems. Add a function to provide it so that
the upcoming menu feature can space lines out correctly.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/video/video-uclass.c | 11 +++++++++++
 include/video.h              |  9 +++++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index fbe1ad169e9..0ce376ca3f1 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -421,6 +421,17 @@ static int show_splash(struct udevice *dev)
 	return 0;
 }
 
+int video_default_font_height(struct udevice *dev)
+{
+	struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
+
+	if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE))
+		return IF_ENABLED_INT(CONFIG_CONSOLE_TRUETYPE,
+				      CONFIG_CONSOLE_TRUETYPE_SIZE);
+
+	return vc_priv->y_charsize;
+}
+
 /* Set up the display ready for use */
 static int video_post_probe(struct udevice *dev)
 {
diff --git a/include/video.h b/include/video.h
index 32afb26a45b..529f9685183 100644
--- a/include/video.h
+++ b/include/video.h
@@ -286,6 +286,15 @@ void video_set_flush_dcache(struct udevice *dev, bool flush);
  */
 void video_set_default_colors(struct udevice *dev, bool invert);
 
+/**
+ * video_default_font_height() - Get the default font height
+ *
+ * @dev:	video device
+ * Returns: Default font height in pixels, which depends on which console driver
+ * is in use
+ */
+int video_default_font_height(struct udevice *dev);
+
 #ifdef CONFIG_VIDEO_COPY
 /**
  * vidconsole_sync_copy() - Sync back to the copy framebuffer
-- 
2.38.0.rc1.362.ged0d419d3c-goog



More information about the U-Boot mailing list