aboutsummaryrefslogtreecommitdiff
path: root/drivers/video/vidconsole-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-10-01 19:13:18 -0600
committerTom Rini <trini@konsulko.com>2023-10-11 15:43:55 -0400
commit9e55d09596a5b6ec1f8cbfc3e97d29b9929dee86 (patch)
tree60d65c291d5979adf7595f8d3f41aa29a63facde /drivers/video/vidconsole-uclass.c
parent39ee32166f607d4e30a74d46f82adb39e4134ec4 (diff)
downloadu-boot-9e55d09596a5b6ec1f8cbfc3e97d29b9929dee86.zip
u-boot-9e55d09596a5b6ec1f8cbfc3e97d29b9929dee86.tar.gz
u-boot-9e55d09596a5b6ec1f8cbfc3e97d29b9929dee86.tar.bz2
video: Allow obtaining the nominal size of a string size
At present there is a method for measuring text, but if the actual text string is not known, it cannot be used. For text editor we want to set the size of the entry box to cover the expected text size. Add the concept of a 'norminal' size with a method to calculate that for the vidconsole. If the method is not implemented, fall back to using the font size, which is sufficient for fixed-width fonts. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/video/vidconsole-uclass.c')
-rw-r--r--drivers/video/vidconsole-uclass.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index b5b3b66..23b1b81 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -618,6 +618,28 @@ int vidconsole_measure(struct udevice *dev, const char *name, uint size,
return 0;
}
+int vidconsole_nominal(struct udevice *dev, const char *name, uint size,
+ uint num_chars, struct vidconsole_bbox *bbox)
+{
+ struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+ struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+ int ret;
+
+ if (ops->measure) {
+ ret = ops->nominal(dev, name, size, num_chars, bbox);
+ if (ret != -ENOSYS)
+ return ret;
+ }
+
+ bbox->valid = true;
+ bbox->x0 = 0;
+ bbox->y0 = 0;
+ bbox->x1 = priv->x_charsize * num_chars;
+ bbox->y1 = priv->y_charsize;
+
+ return 0;
+}
+
void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg,
enum colour_idx bg, struct vidconsole_colour *old)
{