dm: video: enhancements for Shell.efi
cover dm: video: enhancements for Shell.efi
Split out of earlier efi_loader patchset, and updated with some comments, use of simple_strtol[1], and added kconfig option to enable ANSI escape sequence support.
[1] not a hard dependency, but to ensure correct behavior in all cases, depends on "lib: strto: fix incorrect handling of specified base"
Rob Clark (3):
dm: video: Fix cache flushes
dm: video: Add basic ANSI escape sequence support
dm: video: Add color ANSI escape sequence support
drivers/video/Kconfig | 8 ++ drivers/video/vidconsole-uclass.c | 206 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 ++ include/video_console.h | 11 ++ 5 files changed, 233 insertions(+), 3 deletions(-)
Signature · 1 line
2.13.5
PATCH 1/3 dm: video: Fix cache flushes
Content can come to screen via putc() and we cannot always rely on updates ending with a puts(). This is the case with efi_console output to vidconsole. Fixes corruption with Shell.efi.
--- drivers/video/vidconsole-uclass.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/vidconsole-uclass.c +3 -0
@@ -163,6 +163,7 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch)struct udevice *dev = sdev->priv;vidconsole_put_char (dev, ch); +video_sync (dev->parent); }static void vidconsole_puts (struct stdio_dev *sdev,const char *s)
@@ -260,6 +261,8 @@ static int do_video_puts(cmd_tbl_t *cmdtp, int flag, int argc,for (s = argv[1 ]; *s; s++)vidconsole_put_char (dev, *s); +video_sync (dev->parent); +return 0 ; }
Signature · 1 line
2.13.5
PATCH 2/3 dm: video: Add basic ANSI escape sequence support
In reply to Rob ClarkReally just the subset that is needed by efi_console. Perhaps more will be added later, for example color support would be useful to implement efi_cout_set_attribute().
--- drivers/video/Kconfig | 8 +++ drivers/video/vidconsole-uclass.c | 109 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 +++ include/video_console.h | 11 ++++ 5 files changed, 136 insertions(+), 3 deletions(-)
drivers/video/Kconfig +8 -0
@@ -44,6 +44,14 @@ config VIDEO_BPP32 this option, such displays will not be supported and console output will be empty. +config VIDEO_ANSI + bool "Support ANSI escape sequences in video console" + depends on DM_VIDEO + default y if DM_VIDEO + help + Enable ANSI escape sequence decoding for a more fully functional + console. + config CONSOLE_NORMAL bool "Support a simple text console" depends on DM_VIDEO
drivers/video/vidconsole-uclass.c +109 -0
127 lines not on this page · raw message
drivers/video/video-uclass.c +1 -3
@@ -87,7 +87,7 @@ int video_reserve(ulong *addrp)return 0 ; } -static int video_clear (struct udevice *dev) +void video_clear (struct udevice *dev) {struct video_priv *priv =dev_get_uclass_priv (dev);
@@ -100,8 +100,6 @@ static int video_clear(struct udevice *dev) }else {memset (priv->fb, priv->colour_bg, priv->fb_size); } - -return 0 ; }/* Flush video activity to the caches */
include/video.h +7 -0
@@ -115,6 +115,13 @@ struct video_ops {int video_reserve (ulong *addrp);/** +* video_clear() - Clear a device's frame buffer to background color. +* +* @dev: Device to clear +*/ +void video_clear (struct udevice *dev); + +/** * video_sync() - Sync a device's frame buffer with its hardware * * Some frame buffers are cached or have a secondary frame buffer. This
include/video_console.h +11 -0
@@ -29,6 +29,9 @@* @xsize_frac: Width of the display in fractional units * @xstart_frac: Left margin for the text console in fractional units * @last_ch: Last character written to the text console on this line +* @escape: TRUE if currently accumulating an ANSI escape sequence +* @escape_len: Length of accumulated escape sequence so far +* @escape_buf: Buffer to accumulate escape sequence */ struct vidconsole_priv {struct stdio_dev sdev;
@@ -42,6 +45,14 @@ struct vidconsole_priv {int xsize_frac;int xstart_frac;int last_ch; +/* +* ANSI escape sequences are accumulated character by character, +* starting after the ESC char (0x1b) until the entire sequence +* is consumed at which point it is acted upon. +*/ +int escape; +int escape_len; +char escape_buf[32 ]; };/**
Signature · 1 line
2.13.5
PATCH 2/3 dm: video: Add basic ANSI escape sequence support
Quoted 4 lines · Rob Clark
Really just the subset that is needed by
efi_console. Perhaps more will be added later, for example color support would be useful to implementefi_cout_set_attribute().
Quoted 8 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/video/Kconfig | 8 +++ drivers/video/vidconsole-uclass.c | 109 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 +++ include/video_console.h | 11 ++++ 5 files changed, 136 insertions(+), 3 deletions(-)
I don't see the test though - is that in another patch?
PATCH 2/3 dm: video: Add basic ANSI escape sequence support
Quoted 14 lines · Simon Glass
Quoted 4 lines · Rob Clark
Really just the subset that is needed by
efi_console. Perhaps more will be added later, for example color support would be useful to implementefi_cout_set_attribute().Quoted 8 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/video/Kconfig | 8 +++ drivers/video/vidconsole-uclass.c | 109 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 +++ include/video_console.h | 11 ++++ 5 files changed, 136 insertions(+), 3 deletions(-)
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>I don't see the test though - is that in another patch?
well, at this point test is load/bootefi Shell.efi and does it look messed up on screen. If you have better ideas, let me know.
BR,
-R
PATCH 2/3 dm: video: Add basic ANSI escape sequence support
Hi Rob,
Quoted 15 lines · Rob Clark
Quoted 14 lines · Simon Glass
Quoted 12 lines · Rob Clark
Really just the subset that is needed by
efi_console. Perhaps more will be added later, for example color support would be useful to implementefi_cout_set_attribute().Signed-off-by Rob Clark <[email protected]>--- drivers/video/Kconfig | 8 +++ drivers/video/vidconsole-uclass.c | 109 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 +++ include/video_console.h | 11 ++++ 5 files changed, 136 insertions(+), 3 deletions(-)
Quoted 6 lines
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>I don't see the test though - is that in another patch?
well, at this point test is load/bootefi Shell.efi and does it look messed up on screen. If you have better ideas, let me know.
It should be easy enough to update test/dm/video.o to use the new feature in a new test. This code has nothing to do with EFI really.
The tests are fairly slow in that they gzip the display to check that it is correctly, but they work.
Regards,
Simon
PATCH 2/3 dm: video: Add basic ANSI escape sequence support
Quoted 22 lines · Simon Glass
Hi Rob,
Quoted 19 lines · Rob Clark
Quoted 17 lines · Simon Glass
Quoted 4 lines · Rob Clark
Really just the subset that is needed by
efi_console. Perhaps more will be added later, for example color support would be useful to implementefi_cout_set_attribute().Quoted 8 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/video/Kconfig | 8 +++ drivers/video/vidconsole-uclass.c | 109 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 +++ include/video_console.h | 11 ++++ 5 files changed, 136 insertions(+), 3 deletions(-)Reviewed-by Simon Glass <[email protected]>I don't see the test though - is that in another patch?
Quoted 9 lines
Quoted 2 lines
well, at this point test is load/bootefi Shell.efi and does it look messed up on screen. If you have better ideas, let me know.
It should be easy enough to update
test/dm/video.oto use the new feature in a new test. This code has nothing to do with EFI really.The tests are fairly slow in that they gzip the display to check that it is correctly, but they work.
ok, I guess snapshotting fb and comparing to a reference is a way.. where do I look to figure out how to build/run these tests (and presumable update reference screenshots?)
I'd be inclined to add any test as a patch on top of the following patch to cover color escape sequences at the same time..
BR,
-R
PATCH 2/3 dm: video: Add basic ANSI escape sequence support
Hi Rob,
Quoted 29 lines · Rob Clark
Quoted 28 lines · Simon Glass
Hi Rob,
Quoted 15 lines · Rob Clark
Quoted 14 lines · Simon Glass
Quoted 12 lines · Rob Clark
Really just the subset that is needed by
efi_console. Perhaps more will be added later, for example color support would be useful to implementefi_cout_set_attribute().Signed-off-by Rob Clark <[email protected]>--- drivers/video/Kconfig | 8 +++ drivers/video/vidconsole-uclass.c | 109 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 +++ include/video_console.h | 11 ++++ 5 files changed, 136 insertions(+), 3 deletions(-)Quoted 6 lines
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>I don't see the test though - is that in another patch?
well, at this point test is load/bootefi Shell.efi and does it look messed up on screen. If you have better ideas, let me know.
It should be easy enough to update
test/dm/video.oto use the new feature in a new test. This code has nothing to do with EFI really.
Quoted 8 lines
Quoted 3 lines
The tests are fairly slow in that they gzip the display to check that it is correctly, but they work.
ok, I guess snapshotting fb and comparing to a reference is a way.. where do I look to figure out how to build/run these tests (and presumable update reference screenshots?)
make tests
will run the tests.
To run the video tests, something like:
./test/py/test.py -k video --build-dir sandbox/
BTW there are no real reference screenshots. Just run the test once to get the value, check that the display looks good (run sandbox with -l) and then update your test with that value.
Quoted 4 lines
I'd be inclined to add any test as a patch on top of the following patch to cover color escape sequences at the same time..
Yes that sounds good.
- Simon
PATCH 3/3 dm: video: Add color ANSI escape sequence support
In reply to Rob ClarkNote that this doesn't differentiate (due to lack of information in video_priv) between different possible component orders for 32bpp. But the main user at this point is efi_loader, and GOP expects xBGR so any video drivers that this is incorrect for already have problems. (Also, conveniently, this matches what simple-framebuffer bindings expect for kernels that use the simple-framebuffer DT binding to take over the bootloader display.)
--- drivers/video/vidconsole-uclass.c | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+)
drivers/video/vidconsole-uclass.c +94 -0
@@ -108,6 +108,41 @@ static void vidconsole_newline(struct udevice *dev)video_sync (dev->parent); } +static const struct { +unsigned r; +unsigned g; +unsigned b; +} colors[] = { + {0x00 ,0x00 ,0x00 },/* black */ + {0xff ,0x00 ,0x00 },/* red */ + {0x00 ,0xff ,0x00 },/* green */ + {0xff ,0xff ,0x00 },/* yellow */ + {0x00 ,0x00 ,0xff },/* blue */ + {0xff ,0x00 ,0xff },/* magenta */ + {0x00 ,0xff ,0xff },/* cyan */ + {0xff ,0xff ,0xff },/* white */ +}; + +static void set_color (struct video_priv *priv,unsigned idx,unsigned *c) +{ +switch (priv->bpix) { +case VIDEO_BPP16 : + *c = ((colors[idx].r >>3 ) <<0 ) | + ((colors[idx].g >>2 ) <<5 ) | + ((colors[idx].b >>3 ) <<11 ); +break ; +case VIDEO_BPP32 : + *c =0xff000000 | + (colors[idx].r <<0 ) | + (colors[idx].g <<8 ) | + (colors[idx].b <<16 ); +break ; +default : +/* unsupported, leave current color in place */ +break ; + } +} +static char *parsenum (char *s,int *num) {char *end;
@@ -194,6 +229,65 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) }break ; } +case 'm' : { +struct video_priv *vid_priv =dev_get_uclass_priv (dev->parent); +char *s = priv->escape_buf; +char *end = &priv->escape_buf[priv->escape_len]; + +/* +* Set graphics mode: [%d;...;%dm +* +* Currently only supports the color attributes: +* +* Foreground Colors: +* +* 30 Black +* 31 Red +* 32 Green +* 33 Yellow +* 34 Blue +* 35 Magenta +* 36 Cyan +* 37 White +* +* Background Colors: +* +* 40 Black +* 41 Red +* 42 Green +* 43 Yellow +* 44 Blue +* 45 Magenta +* 46 Cyan +* 47 White +*/ + + s++;/* [ */ +while (s < end) { +int val; + + s =parsenum (s, &val); + s++; + +switch (val) { + case 30 ... 37: +/* fg color */ +set_color (vid_priv, val -30 , + (unsigned *)&vid_priv->colour_fg); +break ; + case 40 ... 47: +/* bg color */ +set_color (vid_priv, val -40 , + (unsigned *)&vid_priv->colour_bg); +break ; +default : +/* unknown/unsupported */ +break ; + } + } + +break ; + }default :debug ("unrecognized escape sequence: %*s\n" , priv->escape_len, priv->escape_buf);
Signature · 1 line
2.13.5
cover dm: video: enhancements for Shell.efi
In reply to Rob ClarkHi Rob,
Quoted 13 lines · Rob Clark
Split out of earlier
efi_loaderpatchset, and updated with some comments, use of simple_strtol[1], and added kconfig option to enable ANSI escape sequence support.[1] not a hard dependency, but to ensure correct behavior in all cases, depends on "lib: strto: fix incorrect handling of specified base"
Rob Clark (3):
dm: video: Fix cache flushes
dm: video: Add basic ANSI escape sequence support
dm: video: Add color ANSI escape sequence support
Quoted 6 lines
drivers/video/Kconfig | 8 ++ drivers/video/vidconsole-uclass.c | 206 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 ++ include/video_console.h | 11 ++ 5 files changed, 233 insertions(+), 3 deletions(-)
I'd like to apply this series but am waiting for the test update. Did you get my email about this?
Regards,
Simon
cover dm: video: enhancements for Shell.efi
Quoted 23 lines · Simon Glass
Hi Rob,
Quoted 13 lines · Rob Clark
Split out of earlier
efi_loaderpatchset, and updated with some comments, use of simple_strtol[1], and added kconfig option to enable ANSI escape sequence support.[1] not a hard dependency, but to ensure correct behavior in all cases, depends on "lib: strto: fix incorrect handling of specified base"
Rob Clark (3):
dm: video: Fix cache flushes
dm: video: Add basic ANSI escape sequence support
dm: video: Add color ANSI escape sequence supportQuoted 6 lines
drivers/video/Kconfig | 8 ++ drivers/video/vidconsole-uclass.c | 206 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 ++ include/video_console.h | 11 ++ 5 files changed, 233 insertions(+), 3 deletions(-)
Quoted 3 lines
I'd like to apply this series but am waiting for the test update. Did you get my email about this?
yes, I guess you missed:
https://patchwork.ozlabs.org/project/uboot/list/?series=5009
BR,
-R
cover dm: video: enhancements for Shell.efi
In reply to Rob ClarkHi Rob,
Quoted 12 lines · On Wed, 13 Sep 2017 18:12:19 -0400 Rob Clark robdclark at gmail.com wrote:
Split out of earlier
efi_loaderpatchset, and updated with some comments, use of simple_strtol[1], and added kconfig option to enable ANSI escape sequence support.[1] not a hard dependency, but to ensure correct behavior in all cases, depends on "lib: strto: fix incorrect handling of specified base"
Rob Clark (3):
dm: video: Fix cache flushes
dm: video: Add basic ANSI escape sequence support
dm: video: Add color ANSI escape sequence support
Quoted 6 lines
drivers/video/Kconfig | 8 ++ drivers/video/vidconsole-uclass.c | 206 ++++++++++++++++++++++++++++++++++++++ drivers/video/video-uclass.c | 4 +- include/video.h | 7 ++ include/video_console.h | 11 ++ 5 files changed, 233 insertions(+), 3 deletions(-)
Series applied to u-boot-video/master, thanks!
--
Anatolij