vidconsole: refactoring and support for wider fonts
v6 cover vidconsole: refactoring and support for wider fonts
Version 6 contains entire rebased patch series. New patch 'move vidconsole_get_font_size() to test.h' added.
Version 5 contain minor changes:
- move common functions to console-core.c file
- remove static keyword from shared functions
In version 4, only first patch sent, because review fixes to this would add large rebase & patch formatting overhead. When it'll receive reviewed tag, I'll resent entire rebased series.
Modern mobile phones typically have high pixel density. Bootmenu is hardly readable on those with 8x16 font.
This patch series aims to add wider fonts for devices with high ppi.
Add 16x32, 12x22 fonts from linux, and allow font size configuration.
There was significant changes in version 2:
- fix video tests failures
- add runtime font size configuration
- add test for 12x22 font
In version 3,
'video console: add select font logic to vidconsole uclass driver' patch was removed in favor of already merged patch 'video: Add font functions to the vidconsole API'
Dzmitry Sankouski (10):
video console: refactoring and optimization video console: add support for fonts wider than 1 byte video console: move 8x16 font data in named header video console: implement multiple fonts configuration video console: move vidconsole_get_font_size() to test.h video console: allow font size configuration at runtime video console: add 12x22 Sun font from linux video console: add 16x32 Terminus font from linux video console: sandbox_defconfig: add 12x22 font video console: add 12x22 console simple font test
cmd/Kconfig | 8 + cmd/Makefile | 2 +- cmd/font.c | 5 +- common/splash.c | 17 +- configs/sandbox_defconfig | 5 +- drivers/video/Kconfig | 30 + drivers/video/Makefile | 6 + drivers/video/console_core.c | 203 + drivers/video/console_normal.c | 176 +- drivers/video/console_rotate.c | 368 +- drivers/video/console_truetype.c | 8 +- drivers/video/vidconsole_internal.h | 114 + include/cmd/test.h | 19 + include/video_console.h | 9 - include/video_font.h | 31 +- include/video_font_4x6.h | 11 +- include/video_font_8x16.h | 4624 ++++++++++++++++++++ include/video_font_data.h | 4644 +------------------- include/video_font_sun12x22.h | 6158 +++++++++++++++++++++++++++ include/video_font_ter16x32.h | 2062 +++++++++ test/cmd/font.c | 1 + test/dm/video.c | 41 + 22 files changed, 13488 insertions(+), 5054 deletions(-) create mode 100644 drivers/video/console_core.c create mode 100644 drivers/video/vidconsole_internal.h create mode 100644 include/cmd/test.h create mode 100644 include/video_font_8x16.h create mode 100644 include/video_font_sun12x22.h create mode 100644 include/video_font_ter16x32.h
Signature · 1 line
2.30.2
PATCH v6 1/9 video console: refactoring and optimization
- move common code to vidconsole_internal.h and console_core.c
- unite probe functions
- get rid of code duplications in switch across bpp values
- extract common pixel fill logic in two functions one per horizontal and vertical filling
- rearrange statements in put_xy* methods in unified way
- replace types - uint*_t to u*
---
Changes for v2: none
Changes for v3: none
Changes for v4:
- move common code to vidconsole_internal.h
- unite probe functions
Changes for v5:
- move common functions to console-core.c file
- remove static keyword from shared functions
Changes for v6: none
drivers/video/Makefile | 6 + drivers/video/console_core.c | 141 +++++++++++++ drivers/video/console_normal.c | 150 ++++---------- drivers/video/console_rotate.c | 308 ++++------------------------ drivers/video/vidconsole_internal.h | 95 +++++++++ 5 files changed, 324 insertions(+), 376 deletions(-) create mode 100644 drivers/video/console_core.c create mode 100644 drivers/video/vidconsole_internal.h
drivers/video/Makefile +6 -0
@@ -9,6 +9,12 @@ obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o obj-$(CONFIG_BACKLIGHT_PWM) += pwm_backlight.o obj-$(CONFIG_CONSOLE_NORMAL) += console_normal.o obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o +ifdef CONFIG_CONSOLE_NORMAL +obj-y += console_core.o +else ifdef CONFIG_CONSOLE_ROTATION +obj-y += console_core.o +endif +obj-$(CONFIG_CONSOLE_ROTATION) += console_core.o obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/ obj-$(CONFIG_DISPLAY) += display-uclass.o obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi-host-uclass.o
drivers/video/console_core.c new file +141 -0
141 lines not on this page · raw message
drivers/video/console_normal.c +38 -112
202 lines not on this page · raw message
drivers/video/console_rotate.c +44 -264
427 lines not on this page · raw message
drivers/video/vidconsole_internal.h new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v6 2/9 video console: add support for fonts wider than 1 byte
In reply to Dzmitry SankouskiDevices with high ppi may benefit from wider fonts.
Current width implementation is limited by 1 byte, i.e. 8 bits. New version iterates VIDEO_FONT_BYTE_WIDTH times, to process all width bytes, thus allowing fonts wider than 1 byte.
---
Charges for v2:
- replace TAIL_BIT_COUNT macro with c code
- rename refactoring
Charges for v3: none
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only
drivers/video/console_core.c | 84 ++++++++++++++++++----------- drivers/video/console_normal.c | 2 +- drivers/video/console_rotate.c | 6 +-- drivers/video/vidconsole_internal.h | 1 + 4 files changed, 59 insertions(+), 34 deletions(-)
drivers/video/console_core.c +54 -30
@@ -45,7 +45,7 @@ inline void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int steint fill_char_vertically (uchar *pfont,void **line,struct video_priv *vid_priv,bool direction) { -int step, line_step, pbytes, ret; +int step, line_step, pbytes, bitcount, width_remainder, ret;void *dst; ret =check_bpix_support (vid_priv->bpix);
@@ -61,23 +61,36 @@ int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vid_priv, line_step = vid_priv->line_length; } + width_remainder =VIDEO_FONT_WIDTH %8 ;for (int row =0 ; row <VIDEO_FONT_HEIGHT ; row++) { +uchar bits; + + bitcount =8 ; dst = *line; -uchar bits = pfont[row]; - -for (int i =0 ; i <VIDEO_FONT_WIDTH ; i++) { -u32 value = (bits &0x80 ) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - -fill_pixel_and_goto_next (&dst, - value, - pbytes, - step - ); - bits <<=1 ; +for (int col =0 ; col <VIDEO_FONT_BYTE_WIDTH ; col++) { +if (width_remainder) { +bool is_last_iteration = (VIDEO_FONT_BYTE_WIDTH - col ==1 ); + +if (is_last_iteration) + bitcount = width_remainder; + } + bits = pfont[col]; + +for (int bit =0 ; bit < bitcount; bit++) { +u32 value = (bits &0x80 ) ? + vid_priv->colour_fg : + vid_priv->colour_bg; + +fill_pixel_and_goto_next (&dst, + value, + pbytes, + step + ); + bits <<=1 ; + } } *line += line_step; + pfont +=VIDEO_FONT_BYTE_WIDTH ; }return ret; }
@@ -85,9 +98,9 @@ int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vid_priv,int fill_char_horizontally (uchar *pfont,void **line,struct video_priv *vid_priv,bool direction) { -int step, line_step, pbytes, ret; +int step, line_step, pbytes, bitcount =8 , width_remainder, ret;void *dst; -u8 mask =0x80 ; +u8 mask; ret =check_bpix_support (vid_priv->bpix);if (ret)
@@ -101,21 +114,32 @@ int fill_char_horizontally(uchar *pfont, void **line, struct video_priv *vid_pri step = pbytes; line_step = -vid_priv->line_length; } -for (int col =0 ; col <VIDEO_FONT_WIDTH ; col++) { - dst = *line; -for (int row =0 ; row <VIDEO_FONT_HEIGHT ; row++) { -u32 value = (pfont[row *VIDEO_FONT_BYTE_WIDTH ] & mask) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - -fill_pixel_and_goto_next (&dst, - value, - pbytes, - step - ); + + width_remainder =VIDEO_FONT_WIDTH %8 ; +for (int col =0 ; col <VIDEO_FONT_BYTE_WIDTH ; col++) { + mask =0x80 ; +if (width_remainder) { +bool is_last_iteration = (VIDEO_FONT_BYTE_WIDTH - col ==1 ); + +if (is_last_iteration) + bitcount = width_remainder; + } +for (int bit =0 ; bit < bitcount; bit++) { + dst = *line; +for (int row =0 ; row <VIDEO_FONT_HEIGHT ; row++) { +u32 value = (pfont[row *VIDEO_FONT_BYTE_WIDTH ] & mask) ? + vid_priv->colour_fg : + vid_priv->colour_bg; + +fill_pixel_and_goto_next (&dst, + value, + pbytes, + step + ); + } + *line += line_step; + mask >>=1 ; } - *line += line_step; - mask >>=1 ; }return ret; }
drivers/video/console_normal.c +1 -1
@@ -67,7 +67,7 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, char ch)int pbytes =VNBYTES (vid_priv->bpix);int x, linenum, ret;void *start, *line; -uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_CHAR_PIXEL_BYTES ;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ;
drivers/video/console_rotate.c +3 -3
@@ -71,7 +71,7 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)int pbytes =VNBYTES (vid_priv->bpix);int x, linenum, ret;void *start, *line; -uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_CHAR_PIXEL_BYTES ;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ;
@@ -142,7 +142,7 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)int pbytes =VNBYTES (vid_priv->bpix);int linenum, x, ret;void *start, *line; -uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_CHAR_PIXEL_BYTES ;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ;
@@ -217,7 +217,7 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)int pbytes =VNBYTES (vid_priv->bpix);int linenum, x, ret;void *start, *line; -uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_CHAR_PIXEL_BYTES ;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ;
drivers/video/vidconsole_internal.h +1 -0
@@ -9,6 +9,7 @@#include <video_font.h> /* Get font data, width and height */ #define VIDEO_FONT_BYTE_WIDTH ((VIDEO_FONT_WIDTH / 8) + (VIDEO_FONT_WIDTH % 8 > 0)) +#define VIDEO_FONT_CHAR_PIXEL_BYTES (VIDEO_FONT_HEIGHT * VIDEO_FONT_BYTE_WIDTH)#define FLIPPED_DIRECTION 1#define NORMAL_DIRECTION 0
Signature · 1 line
2.30.2
PATCH v6 3/9 video console: move 8x16 font data in named header
In reply to Dzmitry SankouskiConsistent font data header names needed to add new fonts.
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only
include/video_font.h | 2 +-
include/{video_font_data.h => video_font_8x16.h} | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
rename include/{video_font_data.h => video_font_8x16.h} (99%)include/video_font.h +1 -1
@@ -10,7 +10,7 @@#ifdef CONFIG_VIDEO_FONT_4X6 #include <video_font_4x6.h> #else -#include <video_font_data.h> +#include <video_font_8x16.h> #endif #endif /* _VIDEO_FONT_ */
include/video_font_8x16.h renamed from include/video_font_data.h +2 -3
@@ -6,8 +6,8 @@* This file contains an 8x16 bitmap font for code page 437. */ -#ifndef _VIDEO_FONT_DATA_ -#define _VIDEO_FONT_DATA_ +#ifndef _VIDEO_FONT_8X16 +#define _VIDEO_FONT_8X16#define VIDEO_FONT_CHARS 256#define VIDEO_FONT_WIDTH 8
@@ -4623,7 +4623,6 @@ static unsigned char __maybe_unused video_fontdata[VIDEO_FONT_SIZE] = {0x00 ,/* 00000000 */ 0x00 ,/* 00000000 */ 0x00, /* 00000000 */ - };#endif
Signature · 1 line
2.30.2
PATCH v6 4/9 video console: implement multiple fonts configuration
In reply to Dzmitry SankouskiThis needed for unit testing different fonts.
Configured fonts are placed in an array of fonts. First font is selected by default upon console probe.
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only
common/splash.c | 17 +++--- drivers/video/Kconfig | 15 ++++++ drivers/video/console_core.c | 81 +++++++++++++++++------------ drivers/video/console_normal.c | 32 +++++++----- drivers/video/console_rotate.c | 72 ++++++++++++++++--------- drivers/video/vidconsole_internal.h | 20 ++++--- include/video_font.h | 17 +++++- include/video_font_4x6.h | 11 ++-- include/video_font_8x16.h | 8 +-- include/video_font_data.h | 31 +++++++++++ 10 files changed, 207 insertions(+), 97 deletions(-) create mode 100644 include/video_font_data.h
common/splash.c +10 -7
@@ -127,6 +127,7 @@ void splash_get_pos(int *x, int *y)#include <dm.h> #include <video_console.h> #include <video_font.h> +#include <video_font_data.h> void splash_display_banner (void ) {
@@ -138,13 +139,15 @@ void splash_display_banner(void)if (ret)return ; -#ifdef CONFIG_VIDEO_LOGO - col =BMP_LOGO_WIDTH /VIDEO_FONT_WIDTH +1 ; - row =BMP_LOGO_HEIGHT /VIDEO_FONT_HEIGHT +1 ; -#else - col =0 ; - row =0 ; -#endif +if (IS_ENABLED (CONFIG_VIDEO_LOGO )) { +struct video_fontdata *fontdata = &fonts[0 ]; + + col =BMP_LOGO_WIDTH / fontdata->width +1 ; + row =BMP_LOGO_HEIGHT / fontdata->height +1 ; + }else { + col =0 ; + row =0 ; + }display_options_get_banner (false, buf,sizeof (buf));vidconsole_position_cursor (dev, col,1 );
drivers/video/Kconfig +15 -0
@@ -16,6 +16,21 @@ config VIDEO if VIDEO +config VIDEO_FONT_4X6 + bool "4 x 6 font size" + help + Font for video console driver, 4 x 6 pixels. + Provides character bitmap data in header file. + When selecting multiple fonts, you may want to enable CMD_SELECT_FONT too. + +config VIDEO_FONT_8X16 + bool "8 x 16 font size" + default y + help + Font for video console driver, 8 x 16 pixels + Provides character bitmap data in header file. + When selecting multiple fonts, you may want to enable CMD_SELECT_FONT too. + config VIDEO_LOGO bool "Show the U-Boot logo on the display" default y if !SPLASH_SCREEN
drivers/video/console_core.c +49 -32
135 lines not on this page · raw message
drivers/video/console_normal.c +20 -12
@@ -16,8 +16,10 @@static int console_set_row (struct udevice *dev,uint row,int clr) {struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent); +struct console_simple_priv *priv =dev_get_priv (dev); +struct video_fontdata *fontdata = priv->fontdata;void *line, *dst, *end; -int pixels =VIDEO_FONT_HEIGHT * vid_priv->xsize; +int pixels = fontdata->height * vid_priv->xsize;int ret;int i;int pbytes;
@@ -26,7 +28,7 @@ static int console_set_row(struct udevice *dev, uint row, int clr)if (ret)return ret; - line = vid_priv->fb + row *VIDEO_FONT_HEIGHT * vid_priv->line_length; + line = vid_priv->fb + row * fontdata->height * vid_priv->line_length; dst = line; pbytes =VNBYTES (vid_priv->bpix);for (i =0 ; i < pixels; i++)
@@ -44,14 +46,16 @@ static int console_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, uint count) {struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent); +struct console_simple_priv *priv =dev_get_priv (dev); +struct video_fontdata *fontdata = priv->fontdata;void *dst;void *src;int size;int ret; - dst = vid_priv->fb + rowdst *VIDEO_FONT_HEIGHT * vid_priv->line_length; - src = vid_priv->fb + rowsrc *VIDEO_FONT_HEIGHT * vid_priv->line_length; - size =VIDEO_FONT_HEIGHT * vid_priv->line_length * count; + dst = vid_priv->fb + rowdst * fontdata->height * vid_priv->line_length; + src = vid_priv->fb + rowsrc * fontdata->height * vid_priv->line_length; + size = fontdata->height * vid_priv->line_length * count; ret =vidconsole_memmove (dev, dst, src, size);if (ret)return ret;
@@ -64,10 +68,13 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, char ch)struct vidconsole_priv *vc_priv =dev_get_uclass_priv (dev);struct udevice *vid = dev->parent;struct video_priv *vid_priv =dev_get_uclass_priv (vid); +struct console_simple_priv *priv =dev_get_priv (dev); +struct video_fontdata *fontdata = priv->fontdata;int pbytes =VNBYTES (vid_priv->bpix);int x, linenum, ret;void *start, *line; -uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_CHAR_PIXEL_BYTES ; +uchar *pfont = fontdata->video_fontdata + + (u8 )ch * fontdata->char_pixel_bytes;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ;
@@ -79,7 +86,7 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, char ch)if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ; - ret =fill_char_vertically (pfont, &line, vid_priv,NORMAL_DIRECTION ); + ret =fill_char_vertically (pfont, &line, vid_priv, fontdata,NORMAL_DIRECTION );if (ret)return ret;
@@ -87,7 +94,7 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, char ch)if (ret)return ret; -return VID_TO_POS (VIDEO_FONT_WIDTH ); +return VID_TO_POS (fontdata->width); }struct vidconsole_ops console_ops = {
@@ -97,8 +104,9 @@ struct vidconsole_ops console_ops = { };U_BOOT_DRIVER (vidconsole_normal) = { - .name ="vidconsole0" , - .id =UCLASS_VIDEO_CONSOLE , - .ops = &console_ops, - .probe = console_probe, + .name ="vidconsole0" , + .id =UCLASS_VIDEO_CONSOLE , + .ops = &console_ops, + .probe = console_probe, + .priv_auto =sizeof (struct console_simple_priv ), };
drivers/video/console_rotate.c +48 -24
233 lines not on this page · raw message
drivers/video/vidconsole_internal.h +13 -7
@@ -6,14 +6,18 @@* (C) Copyright 2023 Dzmitry Sankouski <[email protected]> */ -#include <video_font.h> /* Get font data, width and height */ - -#define VIDEO_FONT_BYTE_WIDTH ((VIDEO_FONT_WIDTH / 8) + (VIDEO_FONT_WIDTH % 8 > 0)) -#define VIDEO_FONT_CHAR_PIXEL_BYTES (VIDEO_FONT_HEIGHT * VIDEO_FONT_BYTE_WIDTH) -#define FLIPPED_DIRECTION 1#define NORMAL_DIRECTION 0 +/** +* struct console_simple_priv - Private data for this driver +* +* @video_fontdata font graphical representation data +*/ +struct console_simple_priv { +struct video_fontdata *fontdata; +}; +/** * Checks if bits per pixel supported. *
@@ -41,6 +45,7 @@ void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step);* @param pfont a pointer to character font data. * @param line a pointer to pointer to framebuffer. It's a point for upper left char corner * @param vid_priv driver private data. +* @fontdata font graphical representation data * @param direction controls character orientation. Can be normal or flipped. * When normal: When flipped: *|-----------------------------------------------|
@@ -59,7 +64,7 @@ void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step);* @returns 0, if success, or else error code. */ int fill_char_vertically (uchar *pfont,void **line,struct video_priv *vid_priv, -bool direction); +struct video_fontdata *fontdata,bool direction);/** * Fills 1 character in framebuffer horizontally.
@@ -68,6 +73,7 @@ int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vid_priv,* @param pfont a pointer to character font data. * @param line a pointer to pointer to framebuffer. It's a point for upper left char corner * @param vid_priv driver private data. +* @fontdata font graphical representation data * @param direction controls character orientation. Can be normal or flipped. * When normal: When flipped: *|-----------------------------------------------|
@@ -84,7 +90,7 @@ int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vid_priv,* @returns 0, if success, or else error code. */ int fill_char_horizontally (uchar *pfont,void **line,struct video_priv *vid_priv, -bool direction); +struct video_fontdata *fontdata,bool direction);/** * console probe function.
include/video_font.h +15 -2
@@ -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_4X6 ) + FONT_ENTRY(4, 6, 4x6), +#endif +#if defined(CONFIG_VIDEO_FONT_8X16 ) + FONT_ENTRY(8, 16, 8x16), +#endif + {/* list terminator */ } +}; +#endif /* _VIDEO_FONT_ */
include/video_font_4x6.h +4 -7
@@ -38,15 +38,12 @@ __END__;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: ' ' */
include/video_font_8x16.h +2 -6
@@ -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 */
include/video_font_data.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* (C) Copyright 2023 Dzmitry Sankouski <[email protected]> +*/ + +#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_ */
Signature · 1 line
2.30.2
PATCH v6 5/9 video console: move vidconsole_get_font_size() to test.h
In reply to Dzmitry Sankouskividconsole_get_font_size is only used in tests and in font command. It's role in 'font size' command was to only fetch current font name, to be used in select font function. This is redundant, because it's easy to check for empty string, and reuse current name right in select function.
Test functions in public API use memory and clutter interface.
Move vidconsole_get_font_size to new cmd/test.h file. Wrap it's implementation with #ifdef only when tests enabled.
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: N/A
cmd/font.c | 5 ++--- drivers/video/console_truetype.c | 8 +++++++- include/cmd/test.h | 19 +++++++++++++++++++ include/video_console.h | 9 --------- test/cmd/font.c | 1 + 5 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 include/cmd/test.h
cmd/font.c +2 -3
@@ -51,7 +51,7 @@ static int do_font_select(struct cmd_tbl *cmdtp, int flag, int argc,static int do_font_size (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) { -const char *font_name; +const char *empty_name = {'\0' };struct udevice *dev;uint size;int ret;
@@ -61,11 +61,10 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc,if (uclass_first_device_err (UCLASS_VIDEO_CONSOLE , &dev))return CMD_RET_FAILURE ; - font_name =vidconsole_get_font_size (dev, &size); size =dectoul (argv[1 ],NULL ); - ret =vidconsole_select_font (dev, font_name, size); + ret =vidconsole_select_font (dev, empty_name, size);if (ret) {printf ("Failed (error %d)\n" , ret);return CMD_RET_FAILURE ;
drivers/video/console_truetype.c +7 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (c) 2016 Google, Inc +* (C) Copyright 2023 Dzmitry Sankouski <[email protected]> */ #include <common.h>
@@ -9,6 +10,9 @@#include <malloc.h> #include <video.h> #include <video_console.h> +#if IS_ENABLED (CONFIG_UT_DM ) +#include <cmd/test.h> +#endif /* Functions needed by stb_truetype.h */ static int tt_floor (double val)
@@ -691,7 +695,7 @@ static int truetype_select_font(struct udevice *dev, const char *name,if (!size) size =CONFIG_CONSOLE_TRUETYPE_SIZE ;if (!name) - name = font_table->name; + name = priv->cur_met->font_name; met =find_metrics (dev, name, size);if (!met) {
@@ -724,6 +728,7 @@ static int truetype_select_font(struct udevice *dev, const char *name,return 0 ; } +#if IS_ENABLED (CONFIG_UT_DM )const char *vidconsole_get_font_size (struct udevice *dev,uint *sizep) {struct console_tt_priv *priv =dev_get_priv (dev);
@@ -733,6 +738,7 @@ const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep) return met->font_name; } +#endif static int console_truetype_probe (struct udevice *dev) {
include/cmd/test.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2015 Google, Inc +* (C) Copyright 2023 Dzmitry Sankouski <[email protected]> +*/ + +#ifndef __cmd_test_h +#define __cmd_test_h + +/** +* vidconsole_get_font_size() - get the current font name and size +* +* @dev: vidconsole device +* @sizep: Place to put the font size (nominal height in pixels) +* Returns: Current font name +*/ +const char *vidconsole_get_font_size (struct udevice *dev,uint *sizep); + +#endif
include/video_console.h +0 -9
@@ -298,15 +298,6 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y);*/ void vidconsole_list_fonts (struct udevice *dev); -/** -* vidconsole_get_font_size() - get the current font name and size -* -* @dev: vidconsole device -* @sizep: Place to put the font size (nominal height in pixels) -* Returns: Current font name -*/ -const char *vidconsole_get_font_size (struct udevice *dev,uint *sizep); -#ifdef CONFIG_VIDEO_COPY /** * vidconsole_sync_copy() - Sync back to the copy framebuffer
test/cmd/font.c +1 -0
@@ -11,6 +11,7 @@#include <video_console.h> #include <test/suites.h> #include <test/ut.h> +#include <cmd/test.h> /* Declare a new fdt test */ #define FONT_TEST (_name, _flags) UNIT_TEST(_name, _flags, font_test)
Signature · 1 line
2.30.2
Re: [PATCH v6 5/9] video console: move vidconsole_get_font_size() to test.h
Hi Dzmitry,
Quoted 20 lines · Dzmitry Sankouski
vidconsole_get_font_sizeis only used in tests and in font command. It's role in 'font size' command was to only fetch current font name, to be used in select font function. This is redundant, because it's easy to check for empty string, and reuse current name right in select function.Test functions in public API use memory and clutter interface.
Move
vidconsole_get_font_sizeto newcmd/test.hfile. Wrap it's implementation with #ifdef only when tests enabled.Signed-off-by Dzmitry Sankouski <[email protected]>---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: N/A
Quoted 7 lines
cmd/font.c | 5 ++--- drivers/video/console_truetype.c | 8 +++++++- include/cmd/test.h | 19 +++++++++++++++++++ include/video_console.h | 9 --------- test/cmd/font.c | 1 + 5 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 include/cmd/test.h
I'm not a fan of this for three reasons:
- it changes the current select_font() API, in which NULL currently means to select the default font, not the current one (although that seems to be broken in the code!)
- we may want to allow checking the size of a font
- don't want #ifdefs for test in console_truetype.c (tests should ideally just work with the normal plumbing)
Regards,
Simon
PATCH v6 1/2 video console: sandbox_defconfig: add 12x22 font
In reply to Dzmitry SankouskiAdd 12x22 font in order to write a test for it.
Run savedefconfig.
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: N/A
configs/sandbox_defconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
configs/sandbox_defconfig +2 -3
@@ -2,6 +2,7 @@ CONFIG_TEXT_BASE=0 CONFIG_NR_DRAM_BANKS=1 CONFIG_ENV_SIZE=0x2000 CONFIG_DEFAULT_DEVICE_TREE="sandbox" +CONFIG_DM_RESET=y CONFIG_PRE_CON_BUF_ADDR=0xf0000 CONFIG_BOOTSTAGE_STASH_ADDR=0x0 CONFIG_SYS_LOAD_ADDR=0x0
@@ -100,7 +101,6 @@ CONFIG_CMD_ETHSW=y CONFIG_CMD_BMP=y CONFIG_CMD_BOOTCOUNT=y CONFIG_CMD_EFIDEBUG=y -CONFIG_CMD_EFICONFIG=y CONFIG_CMD_RTC=y CONFIG_CMD_TIME=y CONFIG_CMD_PAUSE=y
@@ -263,7 +263,6 @@ CONFIG_DM_REBOOT_MODE=y CONFIG_DM_REBOOT_MODE_GPIO=y CONFIG_DM_REBOOT_MODE_RTC=y CONFIG_REMOTEPROC_SANDBOX=y -CONFIG_DM_RESET=y CONFIG_SANDBOX_RESET=y CONFIG_RESET_SYSCON=y CONFIG_RESET_SCMI=y
@@ -299,10 +298,10 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_USB_ETHER=y CONFIG_USB_ETH_CDC=y CONFIG_VIDEO=y +CONFIG_VIDEO_FONT_SUN12X22=y CONFIG_VIDEO_COPY=y CONFIG_CONSOLE_ROTATION=y CONFIG_CONSOLE_TRUETYPE=y -CONFIG_CONSOLE_TRUETYPE_MAX_METRICS=10 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y CONFIG_I2C_EDID=y CONFIG_VIDEO_SANDBOX_SDL=y
Signature · 1 line
2.30.2
PATCH v6 2/2 video console: add 12x22 console simple font test
In reply to Dzmitry SankouskiTests fonts wider than a byte.
---
Changes for v2: N/A
Changes for v2: none
Charges for v4: N/A
Charges for v5: N/A
Charges for v6:
- rebase
- move sandbox defconfig change to separate patch
- run savedefconfig
test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
test/dm/video.c +41 -0
@@ -151,6 +151,8 @@ static int dm_test_video_text(struct unit_test_state *uts)ut_assertok (select_vidconsole (uts,"vidconsole0" ));ut_assertok (video_get_nologo (uts, &dev)); +ut_assertok (uclass_get_device (UCLASS_VIDEO_CONSOLE ,0 , &con)); +ut_assertok (vidconsole_select_font (con,"8x16" ,0 ));ut_asserteq (46 ,compress_frame_buffer (uts, dev));ut_assertok (uclass_get_device (UCLASS_VIDEO_CONSOLE ,0 , &con));
@@ -175,6 +177,42 @@ static int dm_test_video_text(struct unit_test_state *uts) }DM_TEST (dm_test_video_text,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT ); +static int dm_test_video_text_12x22 (struct unit_test_state *uts) +{ +struct udevice *dev, *con; +int i; + +#define WHITE 0xffff +#define SCROLL_LINES 100 + +ut_assertok (select_vidconsole (uts,"vidconsole0" )); +ut_assertok (video_get_nologo (uts, &dev)); +ut_assertok (uclass_get_device (UCLASS_VIDEO_CONSOLE ,0 , &con)); +ut_assertok (vidconsole_select_font (con,"12x22" ,0 )); +ut_asserteq (46 ,compress_frame_buffer (uts, dev)); + +ut_assertok (uclass_get_device (UCLASS_VIDEO_CONSOLE ,0 , &con)); +vidconsole_putc_xy (con,0 ,0 ,'a' ); +ut_asserteq (89 ,compress_frame_buffer (uts, dev)); + +vidconsole_putc_xy (con,0 ,0 ,' ' ); +ut_asserteq (46 ,compress_frame_buffer (uts, dev)); + +for (i =0 ; i <20 ; i++) +vidconsole_putc_xy (con,VID_TO_POS (i *8 ),0 ,' ' + i); +ut_asserteq (363 ,compress_frame_buffer (uts, dev)); + +vidconsole_set_row (con,0 ,WHITE ); +ut_asserteq (46 ,compress_frame_buffer (uts, dev)); + +for (i =0 ; i <20 ; i++) +vidconsole_putc_xy (con,VID_TO_POS (i *8 ),0 ,' ' + i); +ut_asserteq (363 ,compress_frame_buffer (uts, dev)); + +return 0 ; +} +DM_TEST (dm_test_video_text_12x22,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT ); +/* Test handling of special characters in the console */ static int dm_test_video_chars (struct unit_test_state *uts) {
@@ -184,6 +222,7 @@ static int dm_test_video_chars(struct unit_test_state *uts)ut_assertok (select_vidconsole (uts,"vidconsole0" ));ut_assertok (video_get_nologo (uts, &dev));ut_assertok (uclass_get_device (UCLASS_VIDEO_CONSOLE ,0 , &con)); +ut_assertok (vidconsole_select_font (con,"8x16" ,0 ));vidconsole_put_string (con, test_string);ut_asserteq (466 ,compress_frame_buffer (uts, dev));
@@ -201,6 +240,7 @@ static int dm_test_video_ansi(struct unit_test_state *uts)ut_assertok (select_vidconsole (uts,"vidconsole0" ));ut_assertok (video_get_nologo (uts, &dev));ut_assertok (uclass_get_device (UCLASS_VIDEO_CONSOLE ,0 , &con)); +ut_assertok (vidconsole_select_font (con,"8x16" ,0 ));/* reference clear: */ video_clear (con->parent);
@@ -249,6 +289,7 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot,ut_assertok (video_get_nologo (uts, &dev));ut_assertok (uclass_get_device (UCLASS_VIDEO_CONSOLE ,0 , &con)); +ut_assertok (vidconsole_select_font (con,"8x16" ,0 ));ut_asserteq (46 ,compress_frame_buffer (uts, dev));/* Check display wrap */
Signature · 1 line
2.30.2
PATCH v6 6/9 video console: allow font size configuration at runtime
In reply to Dzmitry SankouskiAllow font size configuration at runtime for console_simple.c driver. This needed for unit testing different fonts.
Configuring is done by font command, also used for font selection in true type console.
---
Changes for v2: N/A
Changes for v3:
- move 8x16 font patch extracted
- implement multiple fonts patch extracted
- add static modifiers, where needed
- remove list fonts operation
- put fontdata in local var
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only
cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 +- drivers/video/Kconfig | 1 + drivers/video/console_core.c | 21 +++++++++++++++++++++ drivers/video/console_normal.c | 2 ++ drivers/video/console_rotate.c | 6 ++++++ drivers/video/vidconsole_internal.h | 12 ++++++++++++ 7 files changed, 51 insertions(+), 1 deletion(-)
cmd/Kconfig +8 -0
@@ -2226,6 +2226,14 @@ config CMD_VIDCONSOLE The name 'lcdputs' is a bit of a misnomer, but so named because the video device is often an LCD. +config CMD_SELECT_FONT + bool "select font size" + depends on VIDEO + default n + help + Enabling this will provide 'font' command. + Allows font selection at runtime. + endmenu source "cmd/ti/Kconfig"
cmd/Makefile +1 -1
@@ -78,7 +78,7 @@ obj-$(CONFIG_CMD_EXT2) += ext2.o obj-$(CONFIG_CMD_FAT) += fat.o obj-$(CONFIG_CMD_FDT) += fdt.o obj-$(CONFIG_CMD_SQUASHFS) += sqfs.o -obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o +obj-$(CONFIG_CMD_SELECT_FONT) += font.o obj-$(CONFIG_CMD_FLASH) += flash.o obj-$(CONFIG_CMD_FPGA) += fpga.o obj-$(CONFIG_CMD_FPGAD) += fpgad.o
drivers/video/Kconfig +1 -0
@@ -165,6 +165,7 @@ config CONSOLE_ROTATION config CONSOLE_TRUETYPE bool "Support a console that uses TrueType fonts" + select CMD_SELECT_FONT help TrueTrype fonts can provide outline-drawing capability rather than needing to provide a bitmap for each font and size that is needed.
drivers/video/console_core.c +21 -0
@@ -180,3 +180,24 @@ int console_probe(struct udevice *dev) {return console_set_font (dev, &fonts[0 ]); } + +int console_simple_get_font (struct udevice *dev,int seq,struct vidfont_info *info) +{ + info->name = (&fonts[seq])->name; + +return 0 ; +} + +int console_simple_select_font (struct udevice *dev,const char *name,uint size) +{ +struct video_fontdata *font; + +for (font = fonts; font->name; font++) { +if (!strcmp (name, font->name)) { +console_set_font (dev, font); +return 0 ; + } + }; +printf ("no such font: %s, make sure it's name has <width>x<height> format\n" , name); +return -ENOENT ; +}
drivers/video/console_normal.c +2 -0
@@ -101,6 +101,8 @@ struct vidconsole_ops console_ops = { .putc_xy = console_putc_xy, .move_rows = console_move_rows, .set_row = console_set_row, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, };U_BOOT_DRIVER (vidconsole_normal) = {
drivers/video/console_rotate.c +6 -0
@@ -262,18 +262,24 @@ struct vidconsole_ops console_ops_1 = { .putc_xy = console_putc_xy_1, .move_rows = console_move_rows_1, .set_row = console_set_row_1, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, };struct vidconsole_ops console_ops_2 = { .putc_xy = console_putc_xy_2, .move_rows = console_move_rows_2, .set_row = console_set_row_2, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, };struct vidconsole_ops console_ops_3 = { .putc_xy = console_putc_xy_3, .move_rows = console_move_rows_3, .set_row = console_set_row_3, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, };U_BOOT_DRIVER (vidconsole_1) = {
drivers/video/vidconsole_internal.h +12 -0
@@ -100,3 +100,15 @@ int fill_char_horizontally(uchar *pfont, void **line, struct video_priv *vid_pri* @returns 0, if success, or else error code. */ int console_probe (struct udevice *dev); + +/** +* Internal function to be used in as ops. +* See details in video_console.h get_font function +**/ +int console_simple_get_font (struct udevice *dev,int seq,struct vidfont_info *info); + +/** +* Internal function to be used in as ops. +* See details in video_console.h select_font function +**/ +int console_simple_select_font (struct udevice *dev,const char *name,uint size);
Signature · 1 line
2.30.2
PATCH v6 7/9 video console: add 12x22 Sun font from linux
In reply to Dzmitry SankouskiModern mobile phones typically have high pixel density. Bootmenu is hardly readable on those with 8x16 font.
---
Changes for v2: N/A
Changes for v3: none
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only
drivers/video/Kconfig | 7 + include/video_font.h | 6 + include/video_font_sun12x22.h | 6158 +++++++++++++++++++++++++++++++++ 3 files changed, 6171 insertions(+) create mode 100644 include/video_font_sun12x22.h
drivers/video/Kconfig +7 -0
@@ -31,6 +31,13 @@ config VIDEO_FONT_8X16 Provides character bitmap data in header file. When selecting multiple fonts, you may want to enable CMD_SELECT_FONT too. +config VIDEO_FONT_SUN12X22 + bool "12 x 22 font size" + help + Font for video console driver, 12 x 22 pixels + Provides character bitmap data in header file. + When selecting multiple fonts, you may want to enable CMD_SELECT_FONT too. + config VIDEO_LOGO bool "Show the U-Boot logo on the display" default y if !SPLASH_SCREEN
include/video_font.h +6 -0
@@ -15,6 +15,9 @@#if defined(CONFIG_VIDEO_FONT_8X16 )#include <video_font_8x16.h> #endif +#if defined(CONFIG_VIDEO_FONT_SUN12X22 ) +#include <video_font_sun12x22.h> +#endif static struct video_fontdata __maybe_unused fonts[] = {#if defined(CONFIG_VIDEO_FONT_4X6 )
@@ -22,6 +25,9 @@ static struct video_fontdata __maybe_unused fonts[] = {#endif #if defined(CONFIG_VIDEO_FONT_8X16 ) FONT_ENTRY(8, 16, 8x16), +#endif +#if defined(CONFIG_VIDEO_FONT_SUN12X22 ) + FONT_ENTRY(12, 22, 12x22),#endif {/* list terminator */ } };
include/video_font_sun12x22.h new file +6158 -0
2,969 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.30.2
Part of the diff is not shown here. View the raw message.
PATCH v6 8/9 video console: add 16x32 Terminus font from linux
In reply to Dzmitry SankouskiModern mobile phones typically have high pixel density. Bootmenu is hardly readable on those with 8x16 font.
---
Changes for v2:
- edit for runtime configuration
Changes for v3: none
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only
drivers/video/Kconfig | 7 + include/video_font.h | 6 + include/video_font_ter16x32.h | 2062 +++++++++++++++++++++++++++++++++ 3 files changed, 2075 insertions(+) create mode 100644 include/video_font_ter16x32.h
drivers/video/Kconfig +7 -0
@@ -38,6 +38,13 @@ config VIDEO_FONT_SUN12X22 Provides character bitmap data in header file. When selecting multiple fonts, you may want to enable CMD_SELECT_FONT too. +config VIDEO_FONT_16X32 + bool "16 x 32 font size" + help + Font for video console driver, 16 x 32 pixels + Provides character bitmap data in header file. + When selecting multiple fonts, you may want to enable CMD_SELECT_FONT too. + config VIDEO_LOGO bool "Show the U-Boot logo on the display" default y if !SPLASH_SCREEN
include/video_font.h +6 -0
@@ -18,6 +18,9 @@#if defined(CONFIG_VIDEO_FONT_SUN12X22 )#include <video_font_sun12x22.h> #endif +#if defined(CONFIG_VIDEO_FONT_16X32 ) +#include <video_font_ter16x32.h> +#endif static struct video_fontdata __maybe_unused fonts[] = {#if defined(CONFIG_VIDEO_FONT_4X6 )
@@ -28,6 +31,9 @@ static struct video_fontdata __maybe_unused fonts[] = {#endif #if defined(CONFIG_VIDEO_FONT_SUN12X22 ) FONT_ENTRY(12, 22, 12x22), +#endif +#if defined(CONFIG_VIDEO_FONT_16X32 ) + FONT_ENTRY(16, 32, 16x32),#endif {/* list terminator */ } };
include/video_font_ter16x32.h new file +2062 -0
2,062 lines not on this page · raw message
Signature · 1 line
2.30.2
Hi Dzmitry,
Quoted 62 lines · Dzmitry Sankouski
Version 6 contains entire rebased patch series. New patch 'move
vidconsole_get_font_size()totest.h' added.Version 5 contain minor changes:
- move common functions toconsole-core.cfile
- remove static keyword from shared functionsIn version 4, only first patch sent, because review fixes to this would add large rebase & patch formatting overhead. When it'll receive reviewed tag, I'll resent entire rebased series.
Modern mobile phones typically have high pixel density. Bootmenu is hardly readable on those with 8x16 font.
This patch series aims to add wider fonts for devices with high ppi.
Add 16x32, 12x22 fonts from linux, and allow font size configuration.
There was significant changes in version 2:
- fix video tests failures
- add runtime font size configuration
- add test for 12x22 fontIn version 3,
'video console: add select font logic to vidconsole uclass driver' patch was removed in favor of already merged patch 'video: Add font functions to the vidconsole API'Dzmitry Sankouski (10):
video console: refactoring and optimization video console: add support for fonts wider than 1 byte video console: move 8x16 font data in named header video console: implement multiple fonts configuration video console: movevidconsole_get_font_size()totest.hvideo console: allow font size configuration at runtime video console: add 12x22 Sun font from linux video console: add 16x32 Terminus font from linux video console:sandbox_defconfig: add 12x22 font video console: add 12x22 console simple font testcmd/Kconfig | 8 + cmd/Makefile | 2 +- cmd/font.c | 5 +- common/splash.c | 17 +- configs/sandbox_defconfig | 5 +- drivers/video/Kconfig | 30 + drivers/video/Makefile | 6 + drivers/video/console_core.c | 203 + drivers/video/console_normal.c | 176 +- drivers/video/console_rotate.c | 368 +- drivers/video/console_truetype.c | 8 +- drivers/video/vidconsole_internal.h | 114 + include/cmd/test.h | 19 + include/video_console.h | 9 - include/video_font.h | 31 +- include/video_font_4x6.h | 11 +- include/video_font_8x16.h | 4624 ++++++++++++++++++++ include/video_font_data.h | 4644 +------------------- include/video_font_sun12x22.h | 6158 +++++++++++++++++++++++++++ include/video_font_ter16x32.h | 2062 +++++++++ test/cmd/font.c | 1 +
Quoted 8 lines
test/dm/video.c | 41 + 22 files changed, 13488 insertions(+), 5054 deletions(-) create mode 100644 drivers/video/console_core.c create mode 100644 drivers/video/vidconsole_internal.h create mode 100644 include/cmd/test.h create mode 100644 include/video_font_8x16.h create mode 100644 include/video_font_sun12x22.h create mode 100644 include/video_font_ter16x32.h
Apart from my comment on the test code, some minor nits here:
If I do this to sandbox_defconfig:
#CONFIG_CONSOLE_TRUETYPE=yCONFIG_CMD_SELECT_FONT=yCONFIG_VIDEO_FONT_4X6=yCONFIG_VIDEO_FONT_SUN12X22=yCONFIG_VIDEO_FONT_16X32=y
then the 'font list' command crashes. I think console_simple_get_font() needs to check if it is in range.
Some odd C code I noticed so please check that:
&fonts[0] - fonts
(&fonts[seq])->name - fonts[seq].name
Try to keep in 80cols unless it is painful or splits a string.
Could we make the 8x16 font first in the list so it is the default? At present if 4x6 is enabled too it comes up, which is a bit hard to read.
It would be great if we could get this over the line soon!
Regards,
Simon