]> git.baikalelectronics.ru Git - uboot.git/commitdiff
video/console: Implement reverse video ANSI sequence for DM_VIDEO
authorAndre Przywara <andre.przywara@arm.com>
Sat, 23 Mar 2019 01:29:56 +0000 (01:29 +0000)
committerAnatolij Gustschin <agust@denx.de>
Sun, 14 Apr 2019 12:18:47 +0000 (14:18 +0200)
The video console for DM_VIDEO compliant drivers only understands a very
small number of ANSI sequences. First and foremost it misses the "reverse
video" command, which is used by our own bootmenu command to highlight
the selected entry.

To avoid forcing people to use their imagination when using the
bootmenu, let's just implement the rather simple reverse effect. We need
to store the background colour index for that, so that we can
recalculate both the foreground and background colour pixel values.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[agust: merged BG color escape seq change to fix "ut dm video_ansi" test]
Signed-off-by: Anatolij Gustschin <agust@denx.de>
drivers/video/vidconsole-uclass.c
drivers/video/video-uclass.c
include/video.h

index 2ca19d40491cedffec50f76e908a1f4905214eba..3ff65f3232958bbe364b21dd226e7c03b1cf1c27 100644 (file)
@@ -360,6 +360,13 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                                vid_priv->colour_fg = vid_console_color(
                                                vid_priv, vid_priv->fg_col_idx);
                                break;
+                       case 7:
+                               /* reverse video */
+                               vid_priv->colour_fg = vid_console_color(
+                                               vid_priv, vid_priv->bg_col_idx);
+                               vid_priv->colour_bg = vid_console_color(
+                                               vid_priv, vid_priv->fg_col_idx);
+                               break;
                        case 30 ... 37:
                                /* foreground color */
                                vid_priv->fg_col_idx &= ~7;
@@ -368,9 +375,11 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                                                vid_priv, vid_priv->fg_col_idx);
                                break;
                        case 40 ... 47:
-                               /* background color */
+                               /* background color, also mask the bold bit */
+                               vid_priv->bg_col_idx &= ~0xf;
+                               vid_priv->bg_col_idx |= val - 40;
                                vid_priv->colour_bg = vid_console_color(
-                                                       vid_priv, val - 40);
+                                               vid_priv, vid_priv->bg_col_idx);
                                break;
                        default:
                                /* ignore unsupported SGR parameter */
index f307cf243bdcb876b355b2e9c30990fbaf1bd318..14aac88d6d277576758ee3369bb4e76a179b8635 100644 (file)
@@ -136,6 +136,7 @@ void video_set_default_colors(struct udevice *dev, bool invert)
                back = temp;
        }
        priv->fg_col_idx = fore;
+       priv->bg_col_idx = back;
        priv->colour_fg = vid_console_color(priv, fore);
        priv->colour_bg = vid_console_color(priv, back);
 }
index 1d57b48b173807dfb9914793e7ff283ab5962425..485071d0723356abe07ab48d31f0738333eea4f6 100644 (file)
@@ -70,6 +70,7 @@ enum video_log2_bpp {
  *             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)
+ * @bg_col_idx:        Background color code (bit 3 = bold, bit 0-2 = color)
  */
 struct video_priv {
        /* Things set up by the driver: */
@@ -92,6 +93,7 @@ struct video_priv {
        bool flush_dcache;
        ushort *cmap;
        u8 fg_col_idx;
+       u8 bg_col_idx;
 };
 
 /* Placeholder - there are no video operations at present */