[U-Boot] [PATCH v3 4/4] dm: video: support increased intensity (bold)

Heinrich Schuchardt xypron.glpk at gmx.de
Mon Jan 29 07:19:48 UTC 2018


Support special rendition code 0 - reset attributes.
Support special rendition code 1 - increased intensity (bold).

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
v3
	Add color constants.
v2
	SGR 0 should reset the colors and the attributes.
---
 drivers/video/vidconsole-uclass.c | 32 ++++++++++++++++++++++++++------
 drivers/video/video-uclass.c      |  5 ++++-
 include/video.h                   |  2 ++
 include/video_console.h           | 12 ++++++++++--
 test/dm/video.c                   |  2 +-
 5 files changed, 43 insertions(+), 10 deletions(-)

diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 44f557c46a..a878eb402a 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 |= 8;
+				vid_priv->colour_fg = vid_console_color(
+							vid_priv, vid_priv->fg);
+				break;
 			case 30 ... 37:
 				/* foreground color */
+				vid_priv->fg &= ~7;
+				vid_priv->fg |= val - 30;
 				vid_priv->colour_fg = vid_console_color(
-							vid_priv, val - 30);
+							vid_priv, vid_priv->fg);
 				break;
 			case 40 ... 47:
 				/* background color */
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 945b20ddfd..43ab6f6b32 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 = 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 = 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..3101459d2a 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:		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;
 };
 
 /* Placeholder - there are no video operations at present */
diff --git a/include/video_console.h b/include/video_console.h
index 9505db1dc3..a3ff176269 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;
 }
-- 
2.14.2



More information about the U-Boot mailing list