All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anatolij Gustschin <agust@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/8] video/console: Implement reverse video ANSI sequence for DM_VIDEO
Date: Sun, 14 Apr 2019 15:05:36 +0200	[thread overview]
Message-ID: <20190414130536.26052-1-agust@denx.de> (raw)
In-Reply-To: <20190323013002.27117-3-andre.przywara@arm.com>

From: Andre Przywara <andre.przywara@arm.com>

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>
---
Changes in v2:
 - Fix to render standard bg colors (as used to be before v1 2/8 patch).
   Catched by "dm video_ansi" test.

 drivers/video/vidconsole-uclass.c | 13 +++++++++++--
 drivers/video/video-uclass.c      |  1 +
 include/video.h                   |  2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 2ca19d4049..3ff65f3232 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -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 */
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index f307cf243b..14aac88d6d 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -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);
 }
diff --git a/include/video.h b/include/video.h
index 1d57b48b17..485071d072 100644
--- a/include/video.h
+++ b/include/video.h
@@ -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 */
-- 
2.17.1

  parent reply	other threads:[~2019-04-14 13:05 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-23  1:29 [U-Boot] [PATCH 0/8] video/console: Fix various DM_VIDEO console issues Andre Przywara
2019-03-23  1:29 ` [U-Boot] [PATCH 1/8] video/console: Fix DM_VIDEO font glyph array indexing Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-04-09 21:03   ` Anatolij Gustschin
2019-03-23  1:29 ` [U-Boot] [PATCH 2/8] video/console: Implement reverse video ANSI sequence for DM_VIDEO Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-04-09 21:04   ` Anatolij Gustschin
2019-04-14 13:05   ` Anatolij Gustschin [this message]
2019-04-17 13:36     ` [U-Boot] [PATCH v2 " Anatolij Gustschin
2019-03-23  1:29 ` [U-Boot] [PATCH 3/8] video/console: Implement relative cursor movement ANSI handling Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-04-09 21:05   ` Anatolij Gustschin
2019-04-11 12:09     ` Anatolij Gustschin
2019-04-13 21:40       ` André Przywara
2019-04-14 12:54         ` Anatolij Gustschin
2019-04-14 21:49           ` André Przywara
2019-03-23  1:29 ` [U-Boot] [PATCH 4/8] video/console: Implement ANSI clear line command Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-04-09 21:05   ` Anatolij Gustschin
2019-03-23  1:29 ` [U-Boot] [PATCH 5/8] video/console: Factor out actual character output Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-04-09 21:06   ` Anatolij Gustschin
2019-03-23  1:30 ` [U-Boot] [PATCH 6/8] video/console: Convert UTF-8 codes to CP437 code points Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-03-31 18:28     ` Alexander Graf
2019-03-31 23:54       ` André Przywara
2019-03-23  1:30 ` [U-Boot] [PATCH 7/8] usb: kbd: Properly translate up/down arrow keys Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-04-01  0:04     ` André Przywara
2019-04-01  1:58       ` Simon Glass
2019-04-09 21:06   ` Anatolij Gustschin
2019-03-23  1:30 ` [U-Boot] [PATCH 8/8] sunxi: allow boards to de-select SYS_WHITE_ON_BLACK font scheme Andre Przywara
2019-03-30 21:18   ` Simon Glass
2019-04-09 21:07   ` Anatolij Gustschin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190414130536.26052-1-agust@denx.de \
    --to=agust@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.