Skip to contentSkip to conversation

fbconsole: switch to lib/fonts framework

PATCH In review Antony Pavlov 2 participants 7 messages Jul 9, 2015 – Jul 10, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover fbconsole: switch to lib/fonts framework

Antony Pavlov (5):
for-ammend: fbconsole: FBCONSOLE -> FRAMEBUFFER_CONSOLE import lib/fonts framework from linux kernel
for-ammend: video: fbconsole: switch to lib/fonts framework lib/fonts: add "MINI4x6" font
video: fbconsole: switch to "MINI4x6" font: just for demo purposes

 drivers/video/Kconfig                              |    2 +-
 drivers/video/Makefile                             |    2 +-
 drivers/video/fbconsole.c                          |   44 +-
 include/linux/font.h                               |   29 +
 lib/Kconfig                                        |    2 +
 lib/Makefile                                       |    1 +
 lib/fonts/Kconfig                                  |   25 +
 lib/fonts/Makefile                                 |   10 +
 include/video_font_data.h => lib/fonts/font_8x16.c |  479 ++---
 lib/fonts/font_mini_4x6.c                          | 2155 ++++++++++++++++++++
 lib/fonts/fonts.c                                  |   66 +
 11 files changed, 2559 insertions(+), 256 deletions(-)
 create mode 100644 include/linux/font.h
 create mode 100644 lib/fonts/Kconfig
 create mode 100644 lib/fonts/Makefile
 rename include/video_font_data.h => lib/fonts/font_8x16.c (94%)
 create mode 100644 lib/fonts/font_mini_4x6.c
 create mode 100644 lib/fonts/fonts.c
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/5 for-ammend: fbconsole: FBCONSOLE -> FRAMEBUFFER_CONSOLE

linux kernel uses FRAMEBUFFER_CONSOLE option name.

---
 drivers/video/Kconfig  | 2 +-
 drivers/video/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/video/Kconfig +1 -1
index 4a5b15b..c6698da 100644
@@ -5,7 +5,7 @@ menuconfig VIDEO
 
 if VIDEO
 
-config FBCONSOLE
+config FRAMEBUFFER_CONSOLE
 	bool
 	select IMAGE_RENDERER
 	prompt "framebuffer console support"
drivers/video/Makefile +1 -1
index 67b87a8..359135e 100644
@@ -3,7 +3,7 @@ obj-$(CONFIG_DRIVER_VIDEO_EDID) += edid.o
 obj-$(CONFIG_OFDEVICE) += of_display_timing.o
 obj-$(CONFIG_DRIVER_VIDEO_BACKLIGHT) += backlight.o
 obj-$(CONFIG_DRIVER_VIDEO_BACKLIGHT_PWM) += backlight-pwm.o
-obj-$(CONFIG_FBCONSOLE) += fbconsole.o
+obj-$(CONFIG_FRAMEBUFFER_CONSOLE) += fbconsole.o
 
 obj-$(CONFIG_DRIVER_VIDEO_ATMEL) += atmel_lcdfb.o atmel_lcdfb_core.o
 obj-$(CONFIG_DRIVER_VIDEO_ATMEL_HLCD) += atmel_hlcdfb.o atmel_lcdfb_core.o
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/5 import lib/fonts framework from linux kernel

In reply to Antony Pavlov
---
 include/linux/font.h  |   28 +
 lib/Kconfig           |    2 +
 lib/Makefile          |    1 +
 lib/fonts/Kconfig     |   21 +
 lib/fonts/Makefile    |    9 +
 lib/fonts/font_8x16.c | 4630 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/fonts/fonts.c     |   62 +
 7 files changed, 4753 insertions(+)
include/linux/font.h new file +28 -0
new file mode 100644
index 0000000..84f77f5
@@ -0,0 +1,28 @@
+/*
+ *  font.h -- `Soft' font definitions
+ *
+ *  Created 1995 by Geert Uytterhoeven
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive
+ *  for more details.
+ */
+
+#ifndef _VIDEO_FONT_H
+#define _VIDEO_FONT_H
+
+struct font_desc {
+	const char *name;
+	int width, height;
+	const void *data;
+};
+
+extern const struct font_desc	font_vga_8x16;
+
+/* Find a font with a specific name */
+extern const struct font_desc *find_font(const char *name);
+
+/* Max. length for the name of a predefined font */
+#define MAX_FONT_NAME	32
+
+#endif /* _VIDEO_FONT_H */
lib/Kconfig +2 -0
index 62695f1..6b3c98d 100644
@@ -57,6 +57,8 @@ config STMP_DEVICE
 
 source lib/gui/Kconfig
 
+source lib/fonts/Kconfig
+
 source lib/bootstrap/Kconfig
 
 config PRINTF_UUID
lib/Makefile +1 -0
index 6a3e9fd..395214c 100644
@@ -54,3 +54,4 @@ obj-y			+= libfile.o
 obj-y			+= bitmap.o
 obj-y			+= gcd.o
 obj-y			+= hexdump.o
+obj-$(CONFIG_FONTS)	+= fonts/
lib/fonts/Kconfig new file +21 -0
new file mode 100644
index 0000000..0cf37b7
@@ -0,0 +1,21 @@
+#
+# Font configuration
+#
+
+config FONTS
+	bool "Select compiled-in fonts"
+	depends on FRAMEBUFFER_CONSOLE
+
+if FONTS
+
+config FONT_8x16
+	bool "VGA 8x16 font"
+	help
+	  This is the "high resolution" font for the VGA frame buffer (the one
+	  provided by the VGA text console 80x25 mode).
+
+config FONT_AUTOSELECT
+	def_bool y
+	select FONT_8x16
+
+endif # FONTS
lib/fonts/Makefile new file +9 -0
new file mode 100644
index 0000000..17e18e1
@@ -0,0 +1,9 @@
+# Font handling
+
+font-objs := fonts.o
+
+font-objs-$(CONFIG_FONT_8x16)      += font_8x16.o
+
+font-objs += $(font-objs-y)
+
+obj-$(CONFIG_FONTS)         += font.o
lib/fonts/font_8x16.c new file +4630 -0

2,930 lines not on this page · raw message

lib/fonts/fonts.c new file +62 -0

62 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.1.4

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH 3/5 for-ammend: video: fbconsole: switch to lib/fonts framework

In reply to Antony Pavlov
---
 drivers/video/fbconsole.c |   44 +-
 include/video_font_data.h | 4627 ---------------------------------------------
 2 files changed, 28 insertions(+), 4643 deletions(-)
drivers/video/fbconsole.c +28 -16
index 74592c5..2675193 100644
@@ -5,9 +5,7 @@
 #include <fb.h>
 #include <gui/image_renderer.h>
 #include <gui/graphic_utils.h>
-
-/* 8x16 font from U-Boot */
-#include <video_font_data.h>
+#include <linux/font.h>
 
 enum state_t {
 	LIT,				/* Literal input */
@@ -22,7 +20,11 @@ struct fbc_priv {
 	struct fb_info *fb;
 
 	struct screen sc;
+/* FIXME */
+#define VIDEO_FONT_CHARS 256
 	struct image *chars[VIDEO_FONT_CHARS];
+	int font_width, font_height;
+	const void *fontdata;
 	unsigned int cols, rows;
 	unsigned int x, y; /* cursor position */
 
@@ -51,26 +53,26 @@ static void drawchar(struct fbc_priv *priv, int x, int y, char c)
 	int bpp = priv->fb->bits_per_pixel >> 3;
 	void *adr;
 	int i;
-	char *inbuf;
+	const char *inbuf;
 	int line_length;
 	u32 color, bgcolor;
 
 	buf = gui_screen_redering_buffer(&priv->sc);
 
-	inbuf = &video_fontdata[c * VIDEO_FONT_HEIGHT];
+	inbuf = &priv->fontdata[c * priv->font_height];
 
 	line_length = priv->fb->line_length;
 
 	color = priv->invert ? 0xff000000 : priv->color;
 	bgcolor = priv->invert ? priv->color : 0xff000000;
 
-	for (i = 0; i < VIDEO_FONT_HEIGHT; i++) {
+	for (i = 0; i < priv->font_height; i++) {
 		uint8_t t = inbuf[i];
 		int j;
 
-		adr = buf + line_length * (y * VIDEO_FONT_HEIGHT + i) + x * VIDEO_FONT_WIDTH * bpp;
+		adr = buf + line_length * (y * priv->font_height + i) + x * priv->font_width * bpp;
 
-		for (j = 0; j < VIDEO_FONT_WIDTH; j++) {
+		for (j = 0; j < priv->font_width; j++) {
 			if (t & 0x80)
 				set_pixel(priv->fb, adr, color);
 			else
@@ -91,8 +93,8 @@ static void video_invertchar(struct fbc_priv *priv, int x, int y)
 
 	buf = gui_screen_redering_buffer(&priv->sc);
 
-	invert_area(priv->fb, buf, x * VIDEO_FONT_WIDTH, y * VIDEO_FONT_HEIGHT,
-			VIDEO_FONT_WIDTH, VIDEO_FONT_HEIGHT);
+	invert_area(priv->fb, buf, x * priv->font_width, y * priv->font_height,
+			priv->font_width, priv->font_height);
 }
 
 static void printchar(struct fbc_priv *priv, int c)
@@ -137,13 +139,12 @@ static void printchar(struct fbc_priv *priv, int c)
 	if (priv->y > priv->rows) {
 		void *buf;
 		u32 line_length = priv->fb->line_length;
+		int line_height = line_length * priv->font_height;
 
 		buf = gui_screen_redering_buffer(&priv->sc);
 
-		memcpy(buf, buf + line_length * VIDEO_FONT_HEIGHT,
-			line_length * VIDEO_FONT_HEIGHT * (priv->rows + 1));
-		memset(buf + line_length * VIDEO_FONT_HEIGHT * priv->rows,
-			0, line_length * VIDEO_FONT_HEIGHT);
+		memcpy(buf, buf + line_height, line_height * (priv->rows + 1));
+		memset(buf + line_height * priv->rows, 0, line_height);
 		priv->y = priv->rows;
 	}
 
@@ -272,8 +273,19 @@ static int fbc_set_active(struct console_device *cdev, unsigned flags)
 	struct fb_info *fb = priv->fb;
 	int fd;
 
-	priv->rows = fb->yres / VIDEO_FONT_HEIGHT - 1;
-	priv->cols = fb->xres / VIDEO_FONT_WIDTH - 1;
+	const struct font_desc *font;
+
+	font = find_font("VGA8x16");
+	if (!font) {
+		return -ENOENT;
+	}
+
+	priv->font_width = font->width;
+	priv->font_height = font->height;
+	priv->fontdata = font->data;
+
+	priv->rows = fb->yres / priv->font_height - 1;
+	priv->cols = fb->xres / priv->font_width - 1;
 
 	/* FIXME */
 	fd = fb_open("/dev/fb0", &priv->sc, 0);
include/video_font_data.h deleted +0 -4627

2,901 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Part of the diff is not shown here. View the raw message.

#4 lore raw

PATCH 4/5 lib/fonts: add "MINI4x6" font

In reply to Antony Pavlov
---
 include/linux/font.h      |    3 +-
 lib/fonts/Kconfig         |    4 +
 lib/fonts/Makefile        |    1 +
 lib/fonts/font_mini_4x6.c | 2155 +++++++++++++++++++++++++++++++++++++++++++++
 lib/fonts/fonts.c         |    4 +
 5 files changed, 2166 insertions(+), 1 deletion(-)
include/linux/font.h +2 -1
index 84f77f5..24d6355 100644
@@ -17,7 +17,8 @@ struct font_desc {
 	const void *data;
 };
 
-extern const struct font_desc	font_vga_8x16;
+extern const struct font_desc	font_vga_8x16,
+			font_mini_4x6;
 
 /* Find a font with a specific name */
 extern const struct font_desc *find_font(const char *name);
lib/fonts/Kconfig +4 -0
index 0cf37b7..2949a13 100644
@@ -14,8 +14,12 @@ config FONT_8x16
 	  This is the "high resolution" font for the VGA frame buffer (the one
 	  provided by the VGA text console 80x25 mode).
 
+config FONT_MINI_4x6
+	bool "Mini 4x6 font"
+
 config FONT_AUTOSELECT
 	def_bool y
+	depends on !FONT_MINI_4x6
 	select FONT_8x16
 
 endif # FONTS
lib/fonts/Makefile +1 -0
index 17e18e1..ff00b7f 100644
@@ -3,6 +3,7 @@
 font-objs := fonts.o
 
 font-objs-$(CONFIG_FONT_8x16)      += font_8x16.o
+font-objs-$(CONFIG_FONT_MINI_4x6)  += font_mini_4x6.o
 
 font-objs += $(font-objs-y)
 
lib/fonts/font_mini_4x6.c new file +2155 -0

2,155 lines not on this page · raw message

lib/fonts/fonts.c +4 -0
index f396270..dbd1813 100644
@@ -25,6 +25,10 @@ static const struct font_desc *fonts[] = {
 #undef NO_FONTS
     &font_vga_8x16,
 #endif
+#ifdef CONFIG_FONT_MINI_4x6
+#undef NO_FONTS
+    &font_mini_4x6,
+#endif
 };
 
 #define num_fonts ARRAY_SIZE(fonts)
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 5/5 video: fbconsole: switch to "MINI4x6" font: just for demo purposes

In reply to Antony Pavlov
---
 drivers/video/fbconsole.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbconsole.c +1 -1
index 2675193..b72ae84 100644
@@ -275,7 +275,7 @@ static int fbc_set_active(struct console_device *cdev, unsigned flags)
 
 	const struct font_desc *font;
 
-	font = find_font("VGA8x16");
+	font = find_font("MINI4x6");
 	if (!font) {
 		return -ENOENT;
 	}
Signature · 7 lines
2.1.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw
In reply to Antony Pavlov

Hi Antony,

Quoted 6 lines · Antony Pavlov

Antony Pavlov (5):
for-ammend: fbconsole: FBCONSOLE -> FRAMEBUFFER_CONSOLE import lib/fonts framework from linux kernel
for-ammend: video: fbconsole: switch to lib/fonts framework lib/fonts: add "MINI4x6" font
video: fbconsole: switch to "MINI4x6" font: just for demo purposes

I merged this into the next branch. I don't really consider this ready now, but I think we can use the branch to continue working on it.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox