vidconsole: refactoring and support for wider fonts
v3 cover vidconsole: refactoring and support for wider fonts
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 (9):
video console: unite normal and rotated files 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: allow font size configuration at runtime video console: add 12x22 Sun font from linux video console: add 16x32 Terminus font from linux video console: add 12x22 console simple font test
cmd/Kconfig | 8 + cmd/Makefile | 2 +- common/splash.c | 17 +- configs/sandbox_defconfig | 3 + drivers/video/Kconfig | 38 +- drivers/video/Makefile | 3 +- drivers/video/console_normal.c | 178 - drivers/video/console_rotate.c | 497 --- drivers/video/console_simple.c | 682 ++++ 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/dm/video.c | 41 + 16 files changed, 13679 insertions(+), 5320 deletions(-) delete mode 100644 drivers/video/console_normal.c delete mode 100644 drivers/video/console_rotate.c create mode 100644 drivers/video/console_simple.c 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 v3 1/9 video console: unite normal and rotated files
Unite console_normal.c and console_rotate.c files. Those files have similar logic, and common logic may be extracted after putting code in single file.
---
Changes for v2: none
Changes for v3: none
drivers/video/Kconfig | 8 +-
drivers/video/Makefile | 3 +-
drivers/video/console_normal.c | 178 ------------------
.../{console_rotate.c => console_simple.c} | 166 ++++++++++++++++
4 files changed, 171 insertions(+), 184 deletions(-)
delete mode 100644 drivers/video/console_normal.c
rename drivers/video/{console_rotate.c => console_simple.c} (75%)drivers/video/Kconfig +4 -4
@@ -127,17 +127,17 @@ config VIDEO_MIPI_DSI The MIPI Display Serial Interface (MIPI DSI) defines a high-speed serial interface between a host processor and a display module. -config CONSOLE_NORMAL +config VIDEO_CONSOLE bool "Support a simple text console" default y help Support drawing text on the frame buffer console so that it can be - used as a console. Rotation is not supported by this driver (see - CONFIG_CONSOLE_ROTATION for that). A built-in 8x16 font is used - for the display. + used as a console. See CONFIG_CONSOLE_ROTATION for rotation support. + A built-in 8x16 font is used for the display. config CONSOLE_ROTATION bool "Support rotated displays" + depends on VIDEO_CONSOLE help Sometimes, for example if the display is mounted in portrait mode or even if it's mounted landscape but rotated by 180degree,
drivers/video/Makefile +1 -2
@@ -7,8 +7,7 @@ ifdef CONFIG_DM obj-$(CONFIG_BACKLIGHT) += backlight-uclass.o 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 +obj-$(CONFIG_VIDEO_CONSOLE) += console_simple.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_normal.c deleted +0 -178
178 lines not on this page · raw message
drivers/video/console_simple.c renamed from drivers/video/console_rotate.c +166 -0
175 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v3 1/9] video console: unite normal and rotated files
Hi Dzmitry,
Quoted 10 lines · Dzmitry Sankouski
Unite
console_normal.candconsole_rotate.cfiles. Those files have similar logic, and common logic may be extracted after putting code in single file.Signed-off-by Dzmitry Sankouski <[email protected]>---
Changes for v2: none
Changes for v3: none
Quoted 7 lines
drivers/video/Kconfig | 8 +-
drivers/video/Makefile | 3 +-
drivers/video/console_normal.c | 178 ------------------
.../{console_rotate.c => console_simple.c} | 166 ++++++++++++++++
4 files changed, 171 insertions(+), 184 deletions(-)
delete mode 100644 drivers/video/console_normal.c
rename drivers/video/{console_rotate.c => console_simple.c} (75%)I would prefer to keep these separate, rather than adding an #ifdef. Could you add an internal header file like drivers/video/video_internal.h to export the shared functions?
Regards,
Simon
PATCH v3 2/9 video console: refactoring and optimization
In reply to Dzmitry Sankouski- 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:
- move width and pixel data size macros to console_simple.c
- performance: move if statement out of pixel fill loops
- document new functions
- remove console_probe_2 function
- make fill_pixel_and_goto_next void
- fix video unit tests failures
Changes for v3: none
drivers/video/console_simple.c | 598 ++++++++++++++------------------- 1 file changed, 258 insertions(+), 340 deletions(-)
drivers/video/console_simple.c +258 -340
@@ -3,6 +3,7 @@* Copyright (c) 2015 Google, Inc * (C) Copyright 2015 * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com +* (C) Copyright 2023 Dzmitry Sankouski <[email protected]> */ #include <common.h>
@@ -11,46 +12,209 @@#include <video_console.h> #include <video_font.h> /* Get font data, width and height */ -static int console_normal_set_row (struct udevice *dev,uint row,int clr) -{ -struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent); -void *line, *end; -int pixels =VIDEO_FONT_HEIGHT * vid_priv->xsize; -int ret; -int i; +#define VIDEO_FONT_BYTE_WIDTH ((VIDEO_FONT_WIDTH / 8) + (VIDEO_FONT_WIDTH % 8 > 0)) - line = vid_priv->fb + row *VIDEO_FONT_HEIGHT * vid_priv->line_length; -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; +#define FLIPPED_DIRECTION 1 +#define NORMAL_DIRECTION 0 -for (i =0 ; i < pixels; i++) - *dst++ = clr; - end = dst; -break ; - } +/** +* Checks if bits per pixel supported. +* +* @param bpix framebuffer bits per pixel. +* +* @returns 0, if supported, or else -ENOSYS. +*/ +static int check_bpix_support (int bpix) +{ +switch (bpix) { +case VIDEO_BPP8 : +if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) +return 0 ;case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; +if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) +return 0 ; +case VIDEO_BPP32 : +if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) +return 0 ; +default : +return -ENOSYS ; + } +} + +/** +* Fill 1 pixel in framebuffer, and go to next one. +* +* @param dstp a pointer to pointer to framebuffer. +* @param value value to write to framebuffer. +* @param pbytes framebuffer bytes per pixel. +* @param step framebuffer pointer increment. Usually is equal to pbytes, +* and may be negative to control filling direction. +*/ +static inline void fill_pixel_and_goto_next (void **dstp,u32 value,int pbytes,int step) +{ +u8 *dst_byte = *dstp; + +if (pbytes ==4 ) { +u32 *dst = *dstp; + *dst = value; + } +if (pbytes ==2 ) { +u16 *dst = *dstp; + *dst = value; + } +if (pbytes ==1 ) { +u8 *dst = *dstp; + *dst = value; + } + *dstp = dst_byte + step; +} + +#if (CONFIG_IS_ENABLED (CONSOLE_ROTATION )) +/** +* Fills 1 character in framebuffer horizontally. +* Horizontally means we're filling char font data columns across the lines. +* +* @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. +* @param direction controls character orientation. Can be normal or flipped. +* When normal: When flipped: +*|-----------------------------------------------| +*| * | line stepping | +*| ^ * * * * * | | | +*| | * * | v * * | +*| | | * * * * * | +*| line stepping | * | +*| | | +*| stepping -> | <- stepping | +*|---!!we're starting from upper left char corner| +*|-----------------------------------------------| +* +* @returns 0, if success, or else error code. +*/ +static int fill_char_horizontally (uchar *pfont,void **line,struct video_priv *vid_priv, +bool direction) +{ +int step, line_step, pbytes, ret; +void *dst; +u8 mask =0x80 ; + + ret =check_bpix_support (vid_priv->bpix); +if (ret) +return ret; + + pbytes =VNBYTES (vid_priv->bpix); +if (direction) { + step = -pbytes; + line_step = vid_priv->line_length; + }else { + 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; -for (i =0 ; i < pixels; i++) - *dst++ = clr; - end = dst; -break ; +fill_pixel_and_goto_next (&dst, + value, + pbytes, + step + ); } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; + *line += line_step; + mask >>=1 ; + } +return ret; +} +#endif -for (i =0 ; i < pixels; i++) - *dst++ = clr; - end = dst; -break ; +/** +* Fills 1 character in framebuffer vertically. Vertically means we're filling char font data rows +* across the lines. +* +* @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. +* @param direction controls character orientation. Can be normal or flipped. +* When normal: When flipped: +*|-----------------------------------------------| +*| line stepping | | +*| | | stepping -> | +*| * | | * * * | +*| * * v | * | +*| * | * | +*| * | * * ^ | +*| * * * | * | | +*| | | | +*| stepping -> | line stepping | +*|---!!we're starting from upper left char corner| +*|-----------------------------------------------| +* +* @returns 0, if success, or else error code. +*/ +static int fill_char_vertically (uchar *pfont,void **line,struct video_priv *vid_priv, +bool direction) +{ +int step, line_step, pbytes, ret; +void *dst; + + ret =check_bpix_support (vid_priv->bpix); +if (ret) +return ret; + + pbytes =VNBYTES (vid_priv->bpix); +if (direction) { + step = -pbytes; + line_step = -vid_priv->line_length; + }else { + step = pbytes; + line_step = vid_priv->line_length; + } + +for (int row =0 ; row <VIDEO_FONT_HEIGHT ; row++) { + 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 ; } -default : -return -ENOSYS ; + *line += line_step; } +return ret; +} + +static int console_set_row (struct udevice *dev,uint row,int clr) +{ +struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent); +void *line, *dst, *end; +int pixels =VIDEO_FONT_HEIGHT * vid_priv->xsize; +int ret; +int i; +int pbytes; + + ret =check_bpix_support (vid_priv->bpix); +if (ret) +return ret; + + line = vid_priv->fb + row *VIDEO_FONT_HEIGHT * vid_priv->line_length; + dst = line; + pbytes =VNBYTES (vid_priv->bpix); +for (i =0 ; i < pixels; i++) +fill_pixel_and_goto_next (&dst, clr, pbytes, pbytes); + end = dst; + ret =vidconsole_sync_copy (dev, line, end);if (ret)return ret;
@@ -58,8 +222,8 @@ static int console_normal_set_row(struct udevice *dev, uint row, int clr)return 0 ; } -static int console_normal_move_rows (struct udevice *dev,uint rowdst, -uint rowsrc,uint count) +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);void *dst;
@@ -77,70 +241,30 @@ static int console_normal_move_rows(struct udevice *dev, uint rowdst,return 0 ; } -static int console_normal_putc_xy (struct udevice *dev,uint x_frac,uint y, -char ch) +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); -int i, row; -void *start; -void *line; -int ret; +int pbytes =VNBYTES (vid_priv->bpix); +int x, linenum, ret; +void *start, *line; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ; - start = vid_priv->fb + y * vid_priv->line_length + -VID_TO_PIXEL (x_frac) *VNBYTES (vid_priv->bpix); +if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac) +return -EAGAIN ; + linenum = y; + x =VID_TO_PIXEL (x_frac); + start = vid_priv->fb + linenum * vid_priv->line_length + x * pbytes; line = start;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ; -for (row =0 ; row <VIDEO_FONT_HEIGHT ; row++) { -unsigned int idx = (u8 )ch *VIDEO_FONT_HEIGHT + row; -uchar bits = video_fontdata[idx]; - -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; + ret =fill_char_vertically (pfont, &line, vid_priv,NORMAL_DIRECTION ); +if (ret) +return ret; -for (i =0 ; i <VIDEO_FONT_WIDTH ; i++) { - *dst++ = (bits &0x80 ) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - bits <<=1 ; - } -break ; - } -case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_WIDTH ; i++) { - *dst++ = (bits &0x80 ) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - bits <<=1 ; - } -break ; - } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_WIDTH ; i++) { - *dst++ = (bits &0x80 ) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - bits <<=1 ; - } -break ; - } -default : -return -ENOSYS ; - } - line += vid_priv->line_length; - } ret =vidconsole_sync_copy (dev, start, line);if (ret)return ret;
@@ -148,7 +272,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,return VID_TO_POS (VIDEO_FONT_WIDTH ); } -static int console_normal_probe (struct udevice *dev) +static int console_probe (struct udevice *dev) {struct vidconsole_priv *vc_priv =dev_get_uclass_priv (dev);struct udevice *vid_dev = dev->parent;
@@ -162,25 +286,25 @@ static int console_normal_probe(struct udevice *dev)return 0 ; } -struct vidconsole_ops console_normal_ops = { - .putc_xy = console_normal_putc_xy, - .move_rows = console_normal_move_rows, - .set_row = console_normal_set_row, +struct vidconsole_ops console_ops = { + .putc_xy = console_putc_xy, + .move_rows = console_move_rows, + .set_row = console_set_row, };U_BOOT_DRIVER (vidconsole_normal) = { .name ="vidconsole0" , .id =UCLASS_VIDEO_CONSOLE , - .ops = &console_normal_ops, - .probe = console_normal_probe, + .ops = &console_ops, + .probe = console_probe, }; -#if defined(CONFIG_CONSOLE_ROTATION ) +#if (CONFIG_IS_ENABLED (CONSOLE_ROTATION ))static int console_set_row_1 (struct udevice *dev,uint row,int clr) {struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent);int pbytes =VNBYTES (vid_priv->bpix); -void *start, *line; +void *start, *dst, *line;int i, j;int ret;
@@ -188,34 +312,9 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) (row +1 ) *VIDEO_FONT_HEIGHT * pbytes; line = start;for (j =0 ; j < vid_priv->ysize; j++) { -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) - *dst++ = clr; -break ; - } -case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) - *dst++ = clr; -break ; - } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) - *dst++ = clr; -break ; - } -default : -return -ENOSYS ; - } + dst = line; +for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) +fill_pixel_and_goto_next (&dst, clr, pbytes, pbytes); line += vid_priv->line_length; } ret =vidconsole_sync_copy (dev, start, line);
@@ -226,7 +325,7 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) }static int console_move_rows_1 (struct udevice *dev,uint rowdst,uint rowsrc, -uint count) +uint count) {struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent);int pbytes =VNBYTES (vid_priv->bpix);
@@ -241,7 +340,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,for (j =0 ; j < vid_priv->ysize; j++) { ret =vidconsole_memmove (dev, dst, src, -VIDEO_FONT_HEIGHT * pbytes * count); +VIDEO_FONT_HEIGHT * pbytes * count);if (ret)return ret; src += vid_priv->line_length;
@@ -256,60 +355,22 @@ static int console_putc_xy_1(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); -uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ;int pbytes =VNBYTES (vid_priv->bpix); -int i, col, x, linenum, ret; -int mask =0x80 ; +int x, linenum, ret;void *start, *line; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ; +if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac) +return -EAGAIN ; linenum =VID_TO_PIXEL (x_frac) +1 ; x = y +1 ; start = vid_priv->fb + linenum * vid_priv->line_length - x * pbytes; line = start; -if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac) -return -EAGAIN ; -for (col =0 ; col <VIDEO_FONT_HEIGHT ; col++) { -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; + ret =fill_char_horizontally (pfont, &line, vid_priv,FLIPPED_DIRECTION ); +if (ret) +return ret; -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { - *dst-- = (pfont[i] & mask) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - } -break ; - } -case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { - *dst-- = (pfont[i] & mask) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - } -break ; - } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { - *dst-- = (pfont[i] & mask) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - } -break ; - } -default : -return -ENOSYS ; - } - line += vid_priv->line_length; - mask >>=1 ; - }/* We draw backwards from 'start, so account for the first line */ ret =vidconsole_sync_copy (dev, start - vid_priv->line_length, line);if (ret)
@@ -322,44 +383,18 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)static int console_set_row_2 (struct udevice *dev,uint row,int clr) {struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent); -void *start, *line, *end; +void *start, *line, *dst, *end;int pixels =VIDEO_FONT_HEIGHT * vid_priv->xsize;int i, ret; +int pbytes =VNBYTES (vid_priv->bpix); start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length - (row +1 ) *VIDEO_FONT_HEIGHT * vid_priv->line_length; line = start; -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; - -for (i =0 ; i < pixels; i++) - *dst++ = clr; - end = dst; -break ; - } -case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; - -for (i =0 ; i < pixels; i++) - *dst++ = clr; - end = dst; -break ; - } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; - -for (i =0 ; i < pixels; i++) - *dst++ = clr; - end = dst; -break ; - } -default : -return -ENOSYS ; - } + dst = line; +for (i =0 ; i < pixels; i++) +fill_pixel_and_goto_next (&dst, clr, pbytes, pbytes); + end = dst; ret =vidconsole_sync_copy (dev, start, end);if (ret)return ret;
@@ -392,8 +427,9 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)struct udevice *vid = dev->parent;struct video_priv *vid_priv =dev_get_uclass_priv (vid);int pbytes =VNBYTES (vid_priv->bpix); -int i, row, x, linenum, ret; +int linenum, x, ret;void *start, *line; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ;
@@ -402,52 +438,10 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch) start = vid_priv->fb + linenum * vid_priv->line_length + x * pbytes; line = start; -for (row =0 ; row <VIDEO_FONT_HEIGHT ; row++) { -unsigned int idx = (u8 )ch *VIDEO_FONT_HEIGHT + row; -uchar bits = video_fontdata[idx]; - -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; + ret =fill_char_vertically (pfont, &line, vid_priv,FLIPPED_DIRECTION ); +if (ret) +return ret; -for (i =0 ; i <VIDEO_FONT_WIDTH ; i++) { - *dst-- = (bits &0x80 ) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - bits <<=1 ; - } -break ; - } -case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_WIDTH ; i++) { - *dst-- = (bits &0x80 ) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - bits <<=1 ; - } -break ; - } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_WIDTH ; i++) { - *dst-- = (bits &0x80 ) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - bits <<=1 ; - } -break ; - } -default : -return -ENOSYS ; - } - line -= vid_priv->line_length; - }/* Add 4 bytes to allow for the first pixel writen */ ret =vidconsole_sync_copy (dev, start +4 , line);if (ret)
@@ -460,40 +454,15 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr) {struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent);int pbytes =VNBYTES (vid_priv->bpix); -void *start, *line; +void *start, *dst, *line;int i, j, ret; start = vid_priv->fb + row *VIDEO_FONT_HEIGHT * pbytes; line = start;for (j =0 ; j < vid_priv->ysize; j++) { -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) - *dst++ = clr; -break ; - } -case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) - *dst++ = clr; -break ; - } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) - *dst++ = clr; -break ; - } -default : -return -ENOSYS ; - } + dst = line; +for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) +fill_pixel_and_goto_next (&dst, clr, pbytes, pbytes); line += vid_priv->line_length; } ret =vidconsole_sync_copy (dev, start, line);
@@ -517,7 +486,7 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,for (j =0 ; j < vid_priv->ysize; j++) { ret =vidconsole_memmove (dev, dst, src, -VIDEO_FONT_HEIGHT * pbytes * count); +VIDEO_FONT_HEIGHT * pbytes * count);if (ret)return ret; src += vid_priv->line_length;
@@ -532,58 +501,21 @@ static int console_putc_xy_3(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); -uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ;int pbytes =VNBYTES (vid_priv->bpix); -int i, col, x, ret; -int mask =0x80 ; +int linenum, x, ret;void *start, *line; +uchar *pfont = video_fontdata + (u8 )ch *VIDEO_FONT_HEIGHT ;if (x_frac +VID_TO_POS (vc_priv->x_charsize) > vc_priv->xsize_frac)return -EAGAIN ; - x = vid_priv->ysize -VID_TO_PIXEL (x_frac) -1 ; - start = vid_priv->fb + x * vid_priv->line_length + y * pbytes; + x = y; + linenum = vid_priv->ysize -VID_TO_PIXEL (x_frac) -1 ; + start = vid_priv->fb + linenum * vid_priv->line_length + y * pbytes; line = start; -for (col =0 ; col <VIDEO_FONT_HEIGHT ; col++) { -switch (vid_priv->bpix) { -case VIDEO_BPP8 : -if (IS_ENABLED (CONFIG_VIDEO_BPP8 )) { -uint8_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { - *dst++ = (pfont[i] & mask) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - } -break ; - } -case VIDEO_BPP16 : -if (IS_ENABLED (CONFIG_VIDEO_BPP16 )) { -uint16_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { - *dst++ = (pfont[i] & mask) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - } -break ; - } -case VIDEO_BPP32 : -if (IS_ENABLED (CONFIG_VIDEO_BPP32 )) { -uint32_t *dst = line; - -for (i =0 ; i <VIDEO_FONT_HEIGHT ; i++) { - *dst++ = (pfont[i] & mask) ? - vid_priv->colour_fg : - vid_priv->colour_bg; - } -break ; - } -default : -return -ENOSYS ; - } - line -= vid_priv->line_length; - mask >>=1 ; - } + + ret =fill_char_horizontally (pfont, &line, vid_priv,NORMAL_DIRECTION ); +if (ret) +return ret;/* Add a line to allow for the first pixels writen */ ret =vidconsole_sync_copy (dev, start + vid_priv->line_length, line);if (ret)
@@ -593,20 +525,6 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch) } -static int console_probe_2 (struct udevice *dev) -{ -struct vidconsole_priv *vc_priv =dev_get_uclass_priv (dev); -struct udevice *vid_dev = dev->parent; -struct video_priv *vid_priv =dev_get_uclass_priv (vid_dev); - - vc_priv->x_charsize =VIDEO_FONT_WIDTH ; - vc_priv->y_charsize =VIDEO_FONT_HEIGHT ; - vc_priv->cols = vid_priv->xsize /VIDEO_FONT_WIDTH ; - vc_priv->rows = vid_priv->ysize /VIDEO_FONT_HEIGHT ; - -return 0 ; -} -static int console_probe_1_3 (struct udevice *dev) {struct vidconsole_priv *vc_priv =dev_get_uclass_priv (dev);
@@ -651,7 +569,7 @@ U_BOOT_DRIVER(vidconsole_2) = { .name = "vidconsole2", .id = UCLASS_VIDEO_CONSOLE, .ops = &console_ops_2, - .probe = console_probe_2, + .probe = console_probe, };U_BOOT_DRIVER (vidconsole_3) = {
Signature · 1 line
2.30.2
Re: [PATCH v3 2/9] video console: refactoring and optimization
Quoted 18 lines · Dzmitry Sankouski
- 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]>---
Changes for v2:
- move width and pixel data size macros toconsole_simple.c
- performance: move if statement out of pixel fill loops
- document new functions
- removeconsole_probe_2function
- makefill_pixel_and_goto_nextvoid
- fix video unit tests failures
Changes for v3: none
Quoted 2 lines
drivers/video/console_simple.c | 598 ++++++++++++++------------------- 1 file changed, 258 insertions(+), 340 deletions(-)
PATCH v3 3/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
drivers/video/console_simple.c | 93 +++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 34 deletions(-)
drivers/video/console_simple.c +59 -34
@@ -13,6 +13,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
@@ -95,9 +96,9 @@ static inline void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes,static 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)
@@ -111,21 +112,32 @@ static int fill_char_horizontally(uchar *pfont, void **line, struct video_priv * 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; }
@@ -158,7 +170,7 @@ static int fill_char_horizontally(uchar *pfont, void **line, struct video_priv *static int 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);
@@ -174,23 +186,36 @@ static int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vi 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; }
@@ -249,7 +274,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 ;
@@ -358,7 +383,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 ;
@@ -429,7 +454,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 ;
@@ -504,7 +529,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 ;
Signature · 1 line
2.30.2
Re: [PATCH v3 3/9] video console: add support for fonts wider than 1 byte
Quoted 8 lines · Dzmitry Sankouski
Devices 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_WIDTHtimes, to process all width bytes, thus allowing fonts wider than 1 byte.Signed-off-by Dzmitry Sankouski <[email protected]>
Quoted 9 lines
---
Charges for v2:
- replaceTAIL_BIT_COUNTmacro with c code
- rename refactoring
Charges for v3: nonedrivers/video/console_simple.c | 93 +++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 34 deletions(-)
PATCH v3 4/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
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
Re: [PATCH v3 4/9] video console: move 8x16 font data in named header
Quoted 5 lines · Dzmitry Sankouski
Consistent font data header names needed to add new fonts.
Signed-off-by Dzmitry Sankouski <[email protected]>
Quoted 9 lines
---
Changes for v2: N/A
Changes for v3: N/Ainclude/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%)
PATCH v3 5/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
common/splash.c | 17 ++- drivers/video/Kconfig | 15 +++ drivers/video/console_simple.c | 232 ++++++++++++++++++++------------- include/video_font.h | 17 ++- include/video_font_4x6.h | 11 +- include/video_font_8x16.h | 8 +- include/video_font_data.h | 31 +++++ 7 files changed, 216 insertions(+), 115 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_simple.c +139 -93
507 lines not on this page · raw message
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
Re: [PATCH v3 5/9] video console: implement multiple fonts configuration
Quoted 11 lines · Dzmitry Sankouski
This needed for unit testing different fonts.
Configured fonts are placed in an array of fonts. First font is selected by default upon console probe.
Signed-off-by Dzmitry Sankouski <[email protected]>---
Changes for v2: N/A
Changes for v3: N/A
Quoted 10 lines
common/splash.c | 17 ++- drivers/video/Kconfig | 15 +++ drivers/video/console_simple.c | 232 ++++++++++++++++++++------------- include/video_font.h | 17 ++- include/video_font_4x6.h | 11 +- include/video_font_8x16.h | 8 +- include/video_font_data.h | 31 +++++ 7 files changed, 216 insertions(+), 115 deletions(-) create mode 100644 include/video_font_data.h
PATCH v3 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
cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 +- drivers/video/Kconfig | 1 + drivers/video/console_simple.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 40 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_simple.c +30 -0
@@ -56,6 +56,28 @@ static int console_set_font(struct udevice *dev, struct video_fontdata *fontdatareturn 0 ; } +static int console_simple_get_font (struct udevice *dev,int seq,struct vidfont_info *info) +{ + info->name = (&fonts[seq])->name; + +return 0 ; +} + +static int console_simple_select_font (struct udevice *dev,const char *name,uint size) +{ +console_set_font (dev, &fonts[1 ]); +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 ; +} +/** * Checks if bits per pixel supported. *
@@ -352,6 +374,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) = {
@@ -612,18 +636,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) = {
Signature · 1 line
2.30.2
Re: [PATCH v3 6/9] video console: allow font size configuration at runtime
Quoted 17 lines · Dzmitry Sankouski
Allow font size configuration at runtime for
console_simple.cdriver. This needed for unit testing different fonts.Configuring is done by
fontcommand, also used for font selection in true type console.Signed-off-by Dzmitry Sankouski <[email protected]>---
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
Quoted 6 lines
cmd/Kconfig | 8 ++++++++ cmd/Makefile | 2 +- drivers/video/Kconfig | 1 + drivers/video/console_simple.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-)
PATCH v3 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
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 v3 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
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
PATCH v3 9/9 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
configs/sandbox_defconfig | 3 +++ test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
configs/sandbox_defconfig +3 -0
@@ -337,3 +337,6 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_CMD_SELECT_FONT=y +CONFIG_VIDEO_FONT_8X16=y +CONFIG_VIDEO_FONT_SUN12X22=y
test/dm/video.c +41 -0
71 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v3 9/9] video console: add 12x22 console simple font test
Hi Dzmitry,
Quoted 5 lines · Dzmitry Sankouski
Tests fonts wider than a byte.
Signed-off-by Dzmitry Sankouski <[email protected]>Reviewed-by Simon Glass <[email protected]>
I found a problem with this
Quoted 13 lines
---
Changes for v2: N/A
Changes for v2: noneconfigs/sandbox_defconfig | 3 +++ test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)configs/sandbox_defconfig +0
-0
configs/sandbox_defconfig CONFIG_TEST_FDTDEC=y · line 342
Quoted 6 lines
configs/sandbox_defconfig +3
-0@@ -337,3 +337,6 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_CMD_SELECT_FONT=y +CONFIG_VIDEO_FONT_8X16=y +CONFIG_VIDEO_FONT_SUN12X22=y
I don't think you can enable this, since sandbox uses CONSOLE_TRUETYPE. Can we perhaps use sandbox_flattree to run this test?
Also, for me the tests crash with signal 8 (I think).
Quoted 81 lines
test/dm/video.c +41
-1@@ -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 */ --
Quoted 2 lines
2.30.2
Regards,
Simon
Re: [PATCH v3 9/9] video console: add 12x22 console simple font test
How does CONSOLE_TRUETYPE interfere with CONFIG_VIDEO_FONT_SUN12X22?
I've got all video tests passed:
make sandbox_defconfig && make -j4 && ./u-boot -T -c 'ut dm' (...)
Test: dm_test_video_ansi: video.c
Test: dm_test_video_base: video.c
Test: dm_test_video_base: video.c (flat tree)
Test: dm_test_video_bmp: video.c
Test: dm_test_video_bmp16: video.c
Test: dm_test_video_bmp24: video.c
Test: dm_test_video_bmp24_32: video.c
Test: dm_test_video_bmp32: video.c
Test: dm_test_video_bmp8: video.c
Test: dm_test_video_bmp_comp: video.c
Test: dm_test_video_chars: video.c
Test: dm_test_video_comp_bmp32: video.c
Test: dm_test_video_comp_bmp8: video.c
Test: dm_test_video_context: video.c
Test: dm_test_video_rotation1: video.c
Test: dm_test_video_rotation2: video.c
Test: dm_test_video_rotation3: video.c
Test: dm_test_video_text: video.c
Test: dm_test_video_text_12x22: video.c
Test: dm_test_video_truetype: video.c
Test: dm_test_video_truetype_bs: video.c
Test: dm_test_video_truetype_scroll: video.c
Test: dm_test_virtio_all_ops: virtio_device.c
Test: dm_test_virtio_all_ops: virtio_device.c (flat tree)
Test: dm_test_virtio_base: virtio_device.c
(...)
чт, 16 февр. 2023 г. в 02:50, Simon Glass <[email protected]>:
Quoted 123 lines
Hi Dzmitry,
Quoted 5 lines · Dzmitry Sankouski
Tests fonts wider than a byte.
Signed-off-by Dzmitry Sankouski <[email protected]>Reviewed-by Simon Glass <[email protected]>I found a problem with this
Quoted 13 lines
---
Changes for v2: N/A
Changes for v2: noneconfigs/sandbox_defconfig | 3 +++ test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)configs/sandbox_defconfig +0
-0configs/sandbox_defconfig CONFIG_TEST_FDTDEC=y · line 342
Quoted 6 lines
configs/sandbox_defconfig +3
-0@@ -337,3 +337,6 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_CMD_SELECT_FONT=y +CONFIG_VIDEO_FONT_8X16=y +CONFIG_VIDEO_FONT_SUN12X22=yI don't think you can enable this, since sandbox uses
CONSOLE_TRUETYPE. Can we perhaps usesandbox_flattreeto run this test?Also, for me the tests crash with signal 8 (I think).
Quoted 81 lines
test/dm/video.c +41
-1@@ -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 */ --Quoted 2 lines
2.30.2
Regards,
Simon
Re: [PATCH v3 9/9] video console: add 12x22 console simple font test
Hi Dzmitry,
Quoted 3 lines · Dzmitry Sankouski
How does
CONSOLE_TRUETYPEinterfere withCONFIG_VIDEO_FONT_SUN12X22?
I don't mean that.
I tried resyncing the sandbox defconfig, and found that the defconfig additions in this patch went away, meaning they are not used.
I think I know what is needed:
vidconsole_get_font_size()
- implement this in vidconsole-uclass.c by calling the method for the
driver. See how this is done with vidconsole_putc_xy(), for example. You can see this problem if you enable CMD_SELECT_FONT but don't enable CONSOLE_TRUETYPE
config CMD_SELECT_FONT
- the 'bool' needs to be indented with a tab. I think it is is being ignored with Kconfig which is why it doesn't work
resync configs with 'make savedefconfig'
- patches should have the CONFIG options (in defconfigs) in the correct order, and this is how you check it.
Quoted 23 lines
I've got all video tests passed:
make
sandbox_defconfig&& make -j4 && ./u-boot -T -c 'ut dm' (...)
Test:dm_test_video_ansi:video.c
Test:dm_test_video_base:video.c
Test:dm_test_video_base:video.c(flat tree)
Test:dm_test_video_bmp:video.c
Test:dm_test_video_bmp16:video.c
Test:dm_test_video_bmp24:video.c
Test:dm_test_video_bmp24_32:video.c
Test:dm_test_video_bmp32:video.c
Test:dm_test_video_bmp8:video.c
Test:dm_test_video_bmp_comp:video.c
Test:dm_test_video_chars:video.c
Test:dm_test_video_comp_bmp32:video.c
Test:dm_test_video_comp_bmp8:video.c
Test:dm_test_video_context:video.c
Test:dm_test_video_rotation1:video.c
Test:dm_test_video_rotation2:video.c
Test:dm_test_video_rotation3:video.c
Test:dm_test_video_text:video.c
Quoted 9 lines
Test:
dm_test_video_text_12x22:video.c
Test:dm_test_video_truetype:video.c
Test:dm_test_video_truetype_bs:video.c
Test:dm_test_video_truetype_scroll:video.c
Test:dm_test_virtio_all_ops:virtio_device.c
Test:dm_test_virtio_all_ops:virtio_device.c(flat tree)
Test:dm_test_virtio_base:virtio_device.c
(...)
Yes, as you say, the tests pass and look good. I think my problem was the above issues.
Regards,
Simon
Quoted 124 lines
чт, 16 февр. 2023 г. в 02:50, Simon Glass <[email protected]>:
Quoted 123 lines
Hi Dzmitry,
Quoted 5 lines · Dzmitry Sankouski
Tests fonts wider than a byte.
Signed-off-by Dzmitry Sankouski <[email protected]>Reviewed-by Simon Glass <[email protected]>I found a problem with this
Quoted 13 lines
---
Changes for v2: N/A
Changes for v2: noneconfigs/sandbox_defconfig | 3 +++ test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)configs/sandbox_defconfig +0
-0configs/sandbox_defconfig CONFIG_TEST_FDTDEC=y · line 342
Quoted 6 lines
configs/sandbox_defconfig +3
-0@@ -337,3 +337,6 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_CMD_SELECT_FONT=y +CONFIG_VIDEO_FONT_8X16=y +CONFIG_VIDEO_FONT_SUN12X22=yI don't think you can enable this, since sandbox uses
CONSOLE_TRUETYPE. Can we perhaps usesandbox_flattreeto run this test?Also, for me the tests crash with signal 8 (I think).
Quoted 81 lines
test/dm/video.c +41
-1@@ -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 */ --Quoted 2 lines
2.30.2
Regards,
Simon
Re: [PATCH v3 9/9] video console: add 12x22 console simple font test
Hi Simon,
I investigated the usage of vidconsole_get_font_size, and it turned out, it's only used for tests, and in the font size command to provide font name.
So I moved vidconsole_get_font_size from the public API to cmd/test.h. I think it'll be
better than cluttering public API and driver ops functions with test stuff. Please see patches for details.
сб, 18 февр. 2023 г. в 02:49, Simon Glass <[email protected]>:
Quoted 195 lines
Hi Dzmitry,
Quoted 3 lines · Dzmitry Sankouski
How does
CONSOLE_TRUETYPEinterfere withCONFIG_VIDEO_FONT_SUN12X22?I don't mean that.
I tried resyncing the sandbox defconfig, and found that the defconfig additions in this patch went away, meaning they are not used.
I think I know what is needed:
vidconsole_get_font_size()
- implement this invidconsole-uclass.cby calling the method for the
driver. See how this is done withvidconsole_putc_xy(), for example. You can see this problem if you enableCMD_SELECT_FONTbut don't enableCONSOLE_TRUETYPEconfig
CMD_SELECT_FONT
- the 'bool' needs to be indented with a tab. I think it is is being ignored withKconfigwhich is why it doesn't workresync configs with 'make savedefconfig'
- patches should have the CONFIG options (in defconfigs) in the correct order, and this is how you check it.Quoted 23 lines
I've got all video tests passed:
make
sandbox_defconfig&& make -j4 && ./u-boot -T -c 'ut dm' (...)
Test:dm_test_video_ansi:video.c
Test:dm_test_video_base:video.c
Test:dm_test_video_base:video.c(flat tree)
Test:dm_test_video_bmp:video.c
Test:dm_test_video_bmp16:video.c
Test:dm_test_video_bmp24:video.c
Test:dm_test_video_bmp24_32:video.c
Test:dm_test_video_bmp32:video.c
Test:dm_test_video_bmp8:video.c
Test:dm_test_video_bmp_comp:video.c
Test:dm_test_video_chars:video.c
Test:dm_test_video_comp_bmp32:video.c
Test:dm_test_video_comp_bmp8:video.c
Test:dm_test_video_context:video.c
Test:dm_test_video_rotation1:video.c
Test:dm_test_video_rotation2:video.c
Test:dm_test_video_rotation3:video.c
Test:dm_test_video_text:video.cQuoted 9 lines
Test:
dm_test_video_text_12x22:video.c
Test:dm_test_video_truetype:video.c
Test:dm_test_video_truetype_bs:video.c
Test:dm_test_video_truetype_scroll:video.c
Test:dm_test_virtio_all_ops:virtio_device.c
Test:dm_test_virtio_all_ops:virtio_device.c(flat tree)
Test:dm_test_virtio_base:virtio_device.c
(...)Yes, as you say, the tests pass and look good. I think my problem was the above issues.
Regards,
SimonQuoted 124 lines
чт, 16 февр. 2023 г. в 02:50, Simon Glass <[email protected]>:
Quoted 123 lines
Hi Dzmitry,
Quoted 5 lines · Dzmitry Sankouski
Tests fonts wider than a byte.
Signed-off-by Dzmitry Sankouski <[email protected]>Reviewed-by Simon Glass <[email protected]>I found a problem with this
Quoted 13 lines
---
Changes for v2: N/A
Changes for v2: noneconfigs/sandbox_defconfig | 3 +++ test/dm/video.c | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)configs/sandbox_defconfig +0
-0configs/sandbox_defconfig CONFIG_TEST_FDTDEC=y · line 342
Quoted 6 lines
configs/sandbox_defconfig +3
-0@@ -337,3 +337,6 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_CMD_SELECT_FONT=y +CONFIG_VIDEO_FONT_8X16=y +CONFIG_VIDEO_FONT_SUN12X22=yI don't think you can enable this, since sandbox uses
CONSOLE_TRUETYPE. Can we perhaps usesandbox_flattreeto run this test?Also, for me the tests crash with signal 8 (I think).
Quoted 81 lines
test/dm/video.c +41
-1@@ -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 */ --Quoted 2 lines
2.30.2
Regards,
Simon