dm: video: support increased intensity (bold)
Support special rendition code 0 - reset attributes. Support special rendition code 1 - increased intensity (bold). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
5c30fbb8ec
commit
9ffa4d12a8
@ -119,12 +119,20 @@ static void vidconsole_newline(struct udevice *dev)
|
||||
|
||||
static const struct vid_rgb colors[VID_COLOR_COUNT] = {
|
||||
{ 0x00, 0x00, 0x00 }, /* black */
|
||||
{ 0xff, 0x00, 0x00 }, /* red */
|
||||
{ 0x00, 0xff, 0x00 }, /* green */
|
||||
{ 0xc0, 0x00, 0x00 }, /* red */
|
||||
{ 0x00, 0xc0, 0x00 }, /* green */
|
||||
{ 0xc0, 0x60, 0x00 }, /* brown */
|
||||
{ 0x00, 0x00, 0xc0 }, /* blue */
|
||||
{ 0xc0, 0x00, 0xc0 }, /* magenta */
|
||||
{ 0x00, 0xc0, 0xc0 }, /* cyan */
|
||||
{ 0xc0, 0xc0, 0xc0 }, /* light gray */
|
||||
{ 0x80, 0x80, 0x80 }, /* gray */
|
||||
{ 0xff, 0x00, 0x00 }, /* bright red */
|
||||
{ 0x00, 0xff, 0x00 }, /* bright green */
|
||||
{ 0xff, 0xff, 0x00 }, /* yellow */
|
||||
{ 0x00, 0x00, 0xff }, /* blue */
|
||||
{ 0xff, 0x00, 0xff }, /* magenta */
|
||||
{ 0x00, 0xff, 0xff }, /* cyan */
|
||||
{ 0x00, 0x00, 0xff }, /* bright blue */
|
||||
{ 0xff, 0x00, 0xff }, /* bright magenta */
|
||||
{ 0x00, 0xff, 0xff }, /* bright cyan */
|
||||
{ 0xff, 0xff, 0xff }, /* white */
|
||||
};
|
||||
|
||||
@ -278,10 +286,22 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
|
||||
s++;
|
||||
|
||||
switch (val) {
|
||||
case 0:
|
||||
/* all attributes off */
|
||||
video_set_default_colors(vid_priv);
|
||||
break;
|
||||
case 1:
|
||||
/* bold */
|
||||
vid_priv->fg_col_idx |= 8;
|
||||
vid_priv->colour_fg = vid_console_color(
|
||||
vid_priv, vid_priv->fg_col_idx);
|
||||
break;
|
||||
case 30 ... 37:
|
||||
/* foreground color */
|
||||
vid_priv->fg_col_idx &= ~7;
|
||||
vid_priv->fg_col_idx |= val - 30;
|
||||
vid_priv->colour_fg = vid_console_color(
|
||||
vid_priv, val - 30);
|
||||
vid_priv, vid_priv->fg_col_idx);
|
||||
break;
|
||||
case 40 ... 47:
|
||||
/* background color */
|
||||
|
@ -117,9 +117,12 @@ void video_clear(struct udevice *dev)
|
||||
void video_set_default_colors(struct video_priv *priv)
|
||||
{
|
||||
#ifdef CONFIG_SYS_WHITE_ON_BLACK
|
||||
priv->colour_fg = vid_console_color(priv, VID_WHITE);
|
||||
/* White is used when switching to bold, use light gray here */
|
||||
priv->fg_col_idx = VID_LIGHT_GRAY;
|
||||
priv->colour_fg = vid_console_color(priv, VID_LIGHT_GRAY);
|
||||
priv->colour_bg = vid_console_color(priv, VID_BLACK);
|
||||
#else
|
||||
priv->fg_col_idx = VID_BLACK;
|
||||
priv->colour_fg = vid_console_color(priv, VID_BLACK);
|
||||
priv->colour_bg = vid_console_color(priv, VID_WHITE);
|
||||
#endif
|
||||
|
@ -67,6 +67,7 @@ enum video_log2_bpp {
|
||||
* @flush_dcache: true to enable flushing of the data cache after
|
||||
* the LCD is updated
|
||||
* @cmap: Colour map for 8-bit-per-pixel displays
|
||||
* @fg_col_idx: Foreground color code (bit 3 = bold, bit 0-2 = color)
|
||||
*/
|
||||
struct video_priv {
|
||||
/* Things set up by the driver: */
|
||||
@ -88,6 +89,7 @@ struct video_priv {
|
||||
u32 colour_bg;
|
||||
bool flush_dcache;
|
||||
ushort *cmap;
|
||||
u8 fg_col_idx;
|
||||
};
|
||||
|
||||
/* Placeholder - there are no video operations at present */
|
||||
|
@ -15,16 +15,24 @@
|
||||
#define VID_TO_POS(x) ((x) * VID_FRAC_DIV)
|
||||
|
||||
/*
|
||||
* The 8 colors supported by the console
|
||||
* The 16 colors supported by the console
|
||||
*/
|
||||
enum color_idx {
|
||||
VID_BLACK = 0,
|
||||
VID_RED,
|
||||
VID_GREEN,
|
||||
VID_YELLOW,
|
||||
VID_BROWN,
|
||||
VID_BLUE,
|
||||
VID_MAGENTA,
|
||||
VID_CYAN,
|
||||
VID_LIGHT_GRAY,
|
||||
VID_GRAY,
|
||||
VID_LIGHT_RED,
|
||||
VID_LIGTH_GREEN,
|
||||
VID_YELLOW,
|
||||
VID_LIGHT_BLUE,
|
||||
VID_LIGHT_MAGENTA,
|
||||
VID_LIGHT_CYAN,
|
||||
VID_WHITE,
|
||||
|
||||
VID_COLOR_COUNT
|
||||
|
@ -186,7 +186,7 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
|
||||
/* test colors (30-37 fg color, 40-47 bg color) */
|
||||
vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */
|
||||
vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */
|
||||
ut_asserteq(267, compress_frame_buffer(dev));
|
||||
ut_asserteq(265, compress_frame_buffer(dev));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user