From: Heinrich Schuchardt Date: Thu, 8 Feb 2018 20:47:12 +0000 (+0100) Subject: dm: video: support increased intensity (bold) X-Git-Tag: v2018.05-rc1~137^2~3 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9ffa4d12a850c6fb8b9b8f7d5fc31ac28633fcdb;p=oweals%2Fu-boot.git 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 Reviewed-by: Simon Glass --- diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index d32b101758..6f3988d49e 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -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 */ diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 945b20ddfd..b5bb8e0efd 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -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 diff --git a/include/video.h b/include/video.h index 841f3dc56b..ddc2eeb5a9 100644 --- a/include/video.h +++ b/include/video.h @@ -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 */ diff --git a/include/video_console.h b/include/video_console.h index 656a47295f..7621a189d2 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -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 diff --git a/test/dm/video.c b/test/dm/video.c index d158f1fcb3..caca496902 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -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; }