diff mbox series

[U-Boot,2/8] video/console: Implement reverse video ANSI sequence for DM_VIDEO

Message ID 20190323013002.27117-3-andre.przywara@arm.com
State Superseded
Delegated to: Anatolij Gustschin
Headers show
Series video/console: Fix various DM_VIDEO console issues | expand

Commit Message

Andre Przywara March 23, 2019, 1:29 a.m. UTC
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>
---
 drivers/video/vidconsole-uclass.c | 11 ++++++++++-
 drivers/video/video-uclass.c      |  1 +
 include/video.h                   |  2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

Comments

Simon Glass March 30, 2019, 9:18 p.m. UTC | #1
On Fri, 22 Mar 2019 at 19:32, Andre Przywara <andre.przywara@arm.com> wrote:
>
> 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>
> ---
>  drivers/video/vidconsole-uclass.c | 11 ++++++++++-
>  drivers/video/video-uclass.c      |  1 +
>  include/video.h                   |  2 ++
>  3 files changed, 13 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Anatolij Gustschin April 9, 2019, 9:04 p.m. UTC | #2
On Sat, 23 Mar 2019 01:29:56 +0000
Andre Przywara andre.przywara@arm.com wrote:

> 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>
> ---
>  drivers/video/vidconsole-uclass.c | 11 ++++++++++-
>  drivers/video/video-uclass.c      |  1 +
>  include/video.h                   |  2 ++
>  3 files changed, 13 insertions(+), 1 deletion(-)

Applied to u-boot-video/master, thanks!

--
Anatolij
diff mbox series

Patch

diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 2ca19d4049..87f43c2030 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;
@@ -369,8 +376,10 @@  static void vidconsole_escape_char(struct udevice *dev, char ch)
 				break;
 			case 40 ... 47:
 				/* background color */
+				vid_priv->bg_col_idx &= ~7;
+				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 */