vidconsole: refactoring and support for wider fonts
v7 cover vidconsole: refactoring and support for wider fonts
Version 7 has vidconsole_get_font_size() function reworked to use driver ops.
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() logic to driver ops 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 | 6 +- common/splash.c | 17 +- configs/sandbox_defconfig | 5 +- drivers/video/Kconfig | 30 + drivers/video/Makefile | 6 + drivers/video/console_core.c | 212 + drivers/video/console_normal.c | 177 +- drivers/video/console_rotate.c | 371 +- drivers/video/console_truetype.c | 3 +- drivers/video/vidconsole-uclass.c | 11 + drivers/video/vidconsole_internal.h | 120 + include/video_console.h | 14 +- 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 | 13 +- test/dm/video.c | 41 + 22 files changed, 13515 insertions(+), 5051 deletions(-) create mode 100644 drivers/video/console_core.c create mode 100644 drivers/video/vidconsole_internal.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 v7 1/10 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
Changes for v7: 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
Re: [PATCH v7 01/10] video console: refactoring and optimization
Hi Dzmitry,
Quoted 22 lines · On Mon, 27 Feb 2023 20:37:01 +0300 Dzmitry Sankouski [email protected] wrote:
- move common code to
vidconsole_internal.handconsole_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*Signed-off-by Dzmitry Sankouski <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes for v2: none
Changes for v3: none
Changes for v4:
- move common code tovidconsole_internal.h
- unite probe functions
Changes for v5:
- move common functions toconsole-core.cfile
- remove static keyword from shared functions
Changes for v6: none
Changes for v7: none
Quoted 2 lines
drivers/video/Makefile | 6 + drivers/video/console_core.c | 141 +++++++++++++
Building console_core.c fails for board configs without CONFIG_VIDEO_COPY, i.e.:
https://source.denx.de/u-boot/custodians/u-boot-video/-/jobs/587261
I fixed it for further build testing by additionally applying:
include/video_console.h +3 -0
@@ -340,6 +340,9 @@ int vidconsole_sync_copy(struct udevice *dev, void *from, void *to);int vidconsole_memmove (struct udevice *dev,void *dst,const void *src,int size);#else + +#include <string.h> +static inline int vidconsole_sync_copy (struct udevice *dev,void *from,void *to) {
--
Anatolij
PATCH v7 2/10 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
Charges for v7: none
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 v7 3/10 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
Charges for v7: none
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 v7 4/10 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
Charges for v7:
- place 8x16 font first in list as default
- &fonts[0] - fonts
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; + + 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_8X16 ) + FONT_ENTRY(8, 16, 8x16), +#endif +#if defined(CONFIG_VIDEO_FONT_4X6 ) + FONT_ENTRY(4, 6, 4x6), +#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 v7 5/10 video console: move vidconsole_get_font_size() logic to driver ops
In reply to Dzmitry SankouskiSince multiple vidconsole drivers exists, vidconsole_get_font_size() implementation cannot longer live in vidconsole_uclass.c file.
Move current vidconsole_get_font_size logic to truetype driver ops.
---
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
Charges for v7: N/A
cmd/font.c | 6 +++++- drivers/video/console_truetype.c | 3 ++- drivers/video/vidconsole-uclass.c | 11 +++++++++++ include/video_console.h | 14 ++++++++++++-- test/cmd/font.c | 13 +++++++------ 5 files changed, 37 insertions(+), 10 deletions(-)
cmd/font.c +5 -1
@@ -61,7 +61,11 @@ 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); + ret =vidconsole_get_font_size (dev, &font_name, &size); +if (ret) { +printf ("Failed (error %d)\n" , ret); +return CMD_RET_FAILURE ; + } size =dectoul (argv[1 ],NULL );
drivers/video/console_truetype.c +2 -1
@@ -724,7 +724,7 @@ static int truetype_select_font(struct udevice *dev, const char *name,return 0 ; } -const char *vidconsole_get_font_size (struct udevice *dev,uint *sizep) +const char *console_truetype_get_font_size (struct udevice *dev,uint *sizep) {struct console_tt_priv *priv =dev_get_priv (dev);struct console_tt_metrics *met = priv->cur_met;
@@ -773,6 +773,7 @@ struct vidconsole_ops console_truetype_ops = { .backspace = console_truetype_backspace, .entry_start = console_truetype_entry_start, .get_font = console_truetype_get_font, + .get_font_size = console_truetype_get_font_size, .select_font = truetype_select_font, };
drivers/video/vidconsole-uclass.c +11 -0
@@ -575,6 +575,17 @@ int vidconsole_get_font(struct udevice *dev, int seq,return ops->get_font (dev, seq, info); } +int vidconsole_get_font_size (struct udevice *dev,const char **name,uint *sizep) +{ +struct vidconsole_ops *ops =vidconsole_get_ops (dev); + +if (!ops->get_font_size) +return -ENOSYS ; + + *name = ops->get_font_size (dev, sizep); +return 0 ; +} +int vidconsole_select_font (struct udevice *dev,const char *name,uint size) {struct vidconsole_ops *ops =vidconsole_get_ops (dev);
include/video_console.h +12 -2
@@ -160,6 +160,15 @@ struct vidconsole_ops {int (*get_font)(struct udevice *dev,int seq,struct vidfont_info *info); +/** +* 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 *(*get_font_size)(struct udevice *dev,uint *sizep); +/** * select_font() - Select a particular font by name / size *
@@ -303,9 +312,10 @@ void vidconsole_list_fonts(struct udevice *dev);* * @dev: vidconsole device * @sizep: Place to put the font size (nominal height in pixels) -* Returns: Current font name +* @name: pointer to font name, a placeholder for result +* Return: 0 if OK, -ENOSYS if not implemented in driver */ -const char *vidconsole_get_font_size (struct udevice *dev,uint *sizep); +int vidconsole_get_font_size (struct udevice *dev,const char **name,uint *sizep);#ifdef CONFIG_VIDEO_COPY /**
test/cmd/font.c +7 -6
@@ -19,6 +19,7 @@static int font_test_base (struct unit_test_state *uts) {struct udevice *dev; +const char *name;int max_metrics;uint size;int ret;
@@ -32,8 +33,8 @@ static int font_test_base(struct unit_test_state *uts)ut_assert_nextline ("cantoraone_regular" );ut_assertok (ut_check_console_end (uts)); -ut_asserteq_str ("nimbus_sans_l_regular" , -vidconsole_get_font_size (dev, &size)); +ut_assertok (vidconsole_get_font_size (dev, &name, &size)); +ut_asserteq_str ("nimbus_sans_l_regular" , name);ut_asserteq (18 , size); max_metrics =1 ;
@@ -52,15 +53,15 @@ static int font_test_base(struct unit_test_state *uts)ut_assertok (ret);ut_assertok (ut_check_console_end (uts)); -ut_asserteq_str ("cantoraone_regular" , -vidconsole_get_font_size (dev, &size)); +ut_assertok (vidconsole_get_font_size (dev, &name, &size)); +ut_asserteq_str ("cantoraone_regular" , name);ut_asserteq (40 , size);ut_assertok (run_command ("font size 30" ,0 ));ut_assertok (ut_check_console_end (uts)); -ut_asserteq_str ("cantoraone_regular" , -vidconsole_get_font_size (dev, &size)); +ut_assertok (vidconsole_get_font_size (dev, &name, &size)); +ut_asserteq_str ("cantoraone_regular" , name);ut_asserteq (30 , size);return 0 ;
Signature · 1 line
2.30.2
Re: [PATCH v7 05/10] video console: move vidconsole_get_font_size() logic to driver ops
Quoted 15 lines · Dzmitry Sankouski
Since multiple vidconsole drivers exists,
vidconsole_get_font_size()implementation cannot longer live invidconsole_uclass.cfile.Move current
vidconsole_get_font_sizelogic to truetype driver ops.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
Charges for v7: N/A
Quoted 6 lines
cmd/font.c | 6 +++++- drivers/video/console_truetype.c | 3 ++- drivers/video/vidconsole-uclass.c | 11 +++++++++++ include/video_console.h | 14 ++++++++++++-- test/cmd/font.c | 13 +++++++------ 5 files changed, 37 insertions(+), 10 deletions(-)
PATCH v7 6/10 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
Charges for v7: rebase only
- (&fonts[seq])->name - fonts[seq].name
cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 +- drivers/video/Kconfig | 1 + drivers/video/console_core.c | 30 +++++++++++++++++++++++++++++ drivers/video/console_normal.c | 3 +++ drivers/video/console_rotate.c | 9 +++++++++ drivers/video/vidconsole_internal.h | 18 +++++++++++++++++ 7 files changed, 70 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 +30 -0
@@ -180,3 +180,33 @@ int console_probe(struct udevice *dev) {return console_set_font (dev, fonts); } + +const char *console_simple_get_font_size (struct udevice *dev,uint *sizep) +{ +struct console_simple_priv *priv =dev_get_priv (dev); + + *sizep = priv->fontdata->width; + +return priv->fontdata->name; +} + +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 +3 -0
@@ -101,6 +101,9 @@ struct vidconsole_ops console_ops = { .putc_xy = console_putc_xy, .move_rows = console_move_rows, .set_row = console_set_row, + .get_font_size = console_simple_get_font_size, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, };U_BOOT_DRIVER (vidconsole_normal) = {
drivers/video/console_rotate.c +9 -0
@@ -262,18 +262,27 @@ 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_size = console_simple_get_font_size, + .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_size = console_simple_get_font_size, + .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_size = console_simple_get_font_size, + .get_font = console_simple_get_font, + .select_font = console_simple_select_font, };U_BOOT_DRIVER (vidconsole_1) = {
drivers/video/vidconsole_internal.h +18 -0
@@ -100,3 +100,21 @@ 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_size function +**/ +const char *console_simple_get_font_size (struct udevice *dev,uint *sizep); + +/** +* 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 v7 7/10 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
Charges for v7: none
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_8X16 )
@@ -22,6 +25,9 @@ static struct video_fontdata __maybe_unused fonts[] = {#endif #if defined(CONFIG_VIDEO_FONT_4X6 ) FONT_ENTRY(4, 6, 4x6), +#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 v7 8/10 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
Charges for v7: none
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_8X16 )
@@ -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
PATCH v7 9/10 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
Charges for v7: none
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
Re: [PATCH v7 09/10] video console: sandbox_defconfig: add 12x22 font
Quoted 13 lines · Dzmitry Sankouski
Add 12x22 font in order to write a test for it.
Run savedefconfig.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
Charges for v7: none
Quoted 3 lines
configs/sandbox_defconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
PATCH v7 10/10 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
Charges for v7: none
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
Re: [PATCH v7 10/10] video console: add 12x22 console simple font test
Hi Dzmitry,
Quoted 15 lines · On Mon, 27 Feb 2023 20:37:10 +0300 Dzmitry Sankouski [email protected] wrote:
Tests fonts wider than a byte.
Signed-off-by Dzmitry Sankouski <[email protected]>Reviewed-by Simon Glass <[email protected]>---
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
Charges for v7: none
Quoted 2 lines
test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
I've applied this patch series for build testing, this test fails:
https://source.denx.de/u-boot/custodians/u-boot-video/-/jobs/587666
Could you please fix it? Thanks!
--
Anatolij
Re: [PATCH v7 10/10] video console: add 12x22 console simple font test
чт, 2 мар. 2023 г. в 01:20, Anatolij Gustschin <[email protected]>:
Quoted 21 lines
Hi Dzmitry,
Quoted 15 lines · On Mon, 27 Feb 2023 20:37:10 +0300 Dzmitry Sankouski [email protected] wrote:
Tests fonts wider than a byte.
Signed-off-by Dzmitry Sankouski <[email protected]>Reviewed-by Simon Glass <[email protected]>---
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
Charges for v7: none
Quoted 9 lines
Quoted 2 lines
test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)I've applied this patch series for build testing, this test fails:
https://source.denx.de/u-boot/custodians/u-boot-video/-/jobs/587666
Could you please fix it? Thanks!
Seems like CONFIG_VIDEO_FONT_SUN12X22 should be enabled somewhere