[PATCH 11/16] video: Add a function to select the truetype metrics

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


Move this code into a function so we can call it later when we want to
change the font.

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

 drivers/video/console_truetype.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 6ef3fae8a32..5fc737a9ff2 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -624,9 +624,24 @@ static int vidconsole_add_metrics(struct udevice *dev, const char *font_name,
 	return priv->num_metrics++;
 }
 
-static int console_truetype_probe(struct udevice *dev)
+static void select_metrics(struct udevice *dev, struct console_tt_metrics *met)
 {
 	struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
+	struct console_tt_priv *priv = dev_get_priv(dev);
+	struct udevice *vid_dev = dev_get_parent(dev);
+	struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
+
+	priv->cur_met = met;
+	vc_priv->x_charsize = met->font_size;
+	vc_priv->y_charsize = met->font_size;
+	vc_priv->xstart_frac = VID_TO_POS(2);
+	vc_priv->cols = vid_priv->xsize / met->font_size;
+	vc_priv->rows = vid_priv->ysize / met->font_size;
+	vc_priv->tab_width_frac = VID_TO_POS(met->font_size) * 8 / 2;
+}
+
+static int console_truetype_probe(struct udevice *dev)
+{
 	struct console_tt_priv *priv = dev_get_priv(dev);
 	struct udevice *vid_dev = dev->parent;
 	struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
@@ -650,12 +665,7 @@ static int console_truetype_probe(struct udevice *dev)
 		return log_msg_ret("add", ret);
 	priv->cur_met = &priv->metrics[ret];
 
-	vc_priv->x_charsize = font_size;
-	vc_priv->y_charsize = font_size;
-	vc_priv->xstart_frac = VID_TO_POS(2);
-	vc_priv->cols = vid_priv->xsize / font_size;
-	vc_priv->rows = vid_priv->ysize / font_size;
-	vc_priv->tab_width_frac = VID_TO_POS(font_size) * 8 / 2;
+	select_metrics(dev, &priv->metrics[ret]);
 
 	debug("%s: ready\n", __func__);
 
-- 
2.38.0.rc1.362.ged0d419d3c-goog



More information about the U-Boot mailing list