]> git.sur5r.net Git - u-boot/commitdiff
dm: video: support increased intensity (bold)
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 8 Feb 2018 20:47:12 +0000 (21:47 +0100)
committerAnatolij Gustschin <agust@denx.de>
Tue, 6 Mar 2018 09:05:49 +0000 (10:05 +0100)
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>
drivers/video/vidconsole-uclass.c
drivers/video/video-uclass.c
include/video.h
include/video_console.h
test/dm/video.c

index d32b1017581dd962271c20bff97ff263cb1db5da..6f3988d49ea3370f208dbf535393ec16e30b12ac 100644 (file)
@@ -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 */
index 945b20ddfd7a686d5c6b5c26bc5d59477e8cda63..b5bb8e0efde53bb82f196f46bfd978293b7b91ee 100644 (file)
@@ -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
index 841f3dc56b138a5be8f188895019add57958f8c9..ddc2eeb5a95f2ae820fa24b774c7abe5eb4eeedb 100644 (file)
@@ -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 */
index 656a47295f62e630887edc3e01a80bcbbb40235d..7621a189d2a2855e906ef620e44142670e140641 100644 (file)
 #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
index d158f1fcb394a6345f869fbf11fc0b4f9c2814b0..caca49690274fd122ea5f29ca502dbcdf4b274de 100644 (file)
@@ -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;
 }