summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2026-03-09 15:14:46 +0100
committerHelge Deller <deller@gmx.de>2026-03-09 15:47:20 +0100
commite370d84b79ad28ecf9a9e1dad967aa64dbfbd8d8 (patch)
treef7ea0d440f62e98bb8bd769a3065d719faf84183 /include/linux
parent61912c607fa9955dcf3fc018b227baa98a6776dc (diff)
vt: Calculate font-buffer size with vc_font_size()
In fbcon, fbcon_resize() computes the size of the font buffer from the values stored in vc_font. Move these calculations to the dedicated helpers vc_font_pitch() and vc_font_size(). Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/console_struct.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
index ea0cdf4278a3..771cba16cb54 100644
--- a/include/linux/console_struct.h
+++ b/include/linux/console_struct.h
@@ -83,6 +83,34 @@ struct vc_font {
const unsigned char *data;
};
+/**
+ * vc_font_pitch - Calculates the number of bytes between two adjacent scanlines
+ * @font: The VC font
+ *
+ * Returns:
+ * The number of bytes between two adjacent scanlines in the font data
+ */
+static inline unsigned int vc_font_pitch(const struct vc_font *font)
+{
+ return DIV_ROUND_UP(font->width, 8);
+}
+
+/**
+ * vc_font_size - Calculates the size of the font data in bytes
+ * @font: The VC font
+ *
+ * vc_font_size() calculates the number of bytes of font data in the
+ * font specified by @font. The function calculates the size from the
+ * font parameters.
+ *
+ * Returns:
+ * The size of the font data in bytes.
+ */
+static inline unsigned int vc_font_size(const struct vc_font *font)
+{
+ return font->height * vc_font_pitch(font) * font->charcount;
+}
+
/*
* Example: vc_data of a console that was scrolled 3 lines down.
*