video console: implement multiple fonts configuration

This needed for unit testing different fonts.

Configured fonts are placed in an array of fonts.
First font is selected by default upon console probe.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[agust: fixed build error when bmp logo disabled]
Signed-off-by: Anatolij Gustschin <agust@denx.de>
diff --git a/include/video_font.h b/include/video_font.h
index b07c076..00310d0 100644
--- a/include/video_font.h
+++ b/include/video_font.h
@@ -7,10 +7,23 @@
 #ifndef _VIDEO_FONT_
 #define _VIDEO_FONT_
 
-#ifdef CONFIG_VIDEO_FONT_4X6
+#include <video_font_data.h>
+
+#if defined(CONFIG_VIDEO_FONT_4X6)
 #include <video_font_4x6.h>
-#else
+#endif
+#if defined(CONFIG_VIDEO_FONT_8X16)
 #include <video_font_8x16.h>
 #endif
+
+static struct video_fontdata __maybe_unused fonts[] = {
+#if defined(CONFIG_VIDEO_FONT_8X16)
+	FONT_ENTRY(8, 16, 8x16),
+#endif
+#if defined(CONFIG_VIDEO_FONT_4X6)
+	FONT_ENTRY(4, 6, 4x6),
+#endif
+	{/* list terminator */}
+};
 
 #endif /* _VIDEO_FONT_ */
diff --git a/include/video_font_4x6.h b/include/video_font_4x6.h
index c7e6351..1b8c025 100644
--- a/include/video_font_4x6.h
+++ b/include/video_font_4x6.h
@@ -38,15 +38,12 @@
    MSBit to LSBit = left to right.
  */
 
-#ifndef _VIDEO_FONT_DATA_
-#define _VIDEO_FONT_DATA_
+#ifndef _VIDEO_FONT_4X6_
+#define _VIDEO_FONT_4X6_
 
-#define VIDEO_FONT_CHARS	256
-#define VIDEO_FONT_WIDTH	4
-#define VIDEO_FONT_HEIGHT	6
-#define VIDEO_FONT_SIZE		(VIDEO_FONT_CHARS * VIDEO_FONT_HEIGHT)
+#include <video_font_data.h>
 
-static unsigned char video_fontdata[VIDEO_FONT_SIZE] = {
+static unsigned char video_fontdata_4x6[VIDEO_FONT_SIZE(256, 4, 6)] = {
 
 	/*{*/
 		/*   Char 0: ' '  */
diff --git a/include/video_font_8x16.h b/include/video_font_8x16.h
index d3d4295..d8a1d90 100644
--- a/include/video_font_8x16.h
+++ b/include/video_font_8x16.h
@@ -9,13 +9,9 @@
 #ifndef _VIDEO_FONT_8X16
 #define _VIDEO_FONT_8X16
 
-#define VIDEO_FONT_CHARS	256
-#define VIDEO_FONT_WIDTH	8
-#define VIDEO_FONT_HEIGHT	16
-#define VIDEO_FONT_SIZE		(VIDEO_FONT_CHARS * VIDEO_FONT_HEIGHT)
-
-static unsigned char __maybe_unused video_fontdata[VIDEO_FONT_SIZE] = {
+#include <video_font_data.h>
 
+static unsigned char video_fontdata_8x16[VIDEO_FONT_SIZE(256, 8, 16)] = {
 	/* 0 0x00 '^@' */
 	0x00, /* 00000000 */
 	0x00, /* 00000000 */
diff --git a/include/video_font_data.h b/include/video_font_data.h
new file mode 100644
index 0000000..37c3e003
--- /dev/null
+++ b/include/video_font_data.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2023 Dzmitry Sankouski <dsankouski@gmail.com>
+ */
+
+#ifndef _VIDEO_FONT_DATA_
+#define _VIDEO_FONT_DATA_
+#define VIDEO_FONT_BYTE_WIDTH(width)	((width / 8) + (width % 8 > 0))
+#define VIDEO_FONT_CHAR_PIXEL_BYTES(width, height)	(height * VIDEO_FONT_BYTE_WIDTH(width))
+#define VIDEO_FONT_SIZE(chars, width, height)	(chars * VIDEO_FONT_CHAR_PIXEL_BYTES(width, height))
+
+struct video_fontdata {
+	const char *name;
+	int width;
+	int height;
+	int byte_width;
+	int char_pixel_bytes;
+	unsigned char *video_fontdata;
+};
+
+#define FONT_ENTRY(_font_width, _font_height, _width_x_height) \
+{	\
+	.name = #_width_x_height,	\
+	.width = _font_width,		\
+	.height = _font_height,		\
+	.byte_width = VIDEO_FONT_BYTE_WIDTH(_font_width),	\
+	.char_pixel_bytes = VIDEO_FONT_CHAR_PIXEL_BYTES(_font_width, _font_height),	\
+	.video_fontdata = video_fontdata_##_width_x_height,	\
+}
+
+#endif /* _VIDEO_FONT_DATA_ */