aboutsummaryrefslogtreecommitdiff
path: root/drivers/video/vidconsole-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-10-06 08:36:03 -0600
committerAnatolij Gustschin <agust@denx.de>2022-10-30 08:43:24 +0100
commita032e4b55ea717fb931dd0d4754cf72b9bafe2f4 (patch)
tree503fc51df906b9bb0920be7d241af3495fc1883b /drivers/video/vidconsole-uclass.c
parentdb2c8ed3a5850e64fcf612d099ce7b22c480a752 (diff)
downloadu-boot-a032e4b55ea717fb931dd0d4754cf72b9bafe2f4.zip
u-boot-a032e4b55ea717fb931dd0d4754cf72b9bafe2f4.tar.gz
u-boot-a032e4b55ea717fb931dd0d4754cf72b9bafe2f4.tar.bz2
video: Move console colours to the video uclass
At present these are attached to vidconsole which means that the video uclass requires that a console is enabled. This is not the intention. The colours are a reasonable way of indexing common colours in any case, so move them to the video uclass instead. Rename vid_console_color() to video_index_to_colour() now that it is more generic. Also fix the inconsistent spelling in these functions. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/video/vidconsole-uclass.c')
-rw-r--r--drivers/video/vidconsole-uclass.c74
1 files changed, 5 insertions, 69 deletions
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index f42db40..f67027c 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -19,15 +19,6 @@
#include <video_font.h> /* Bitmap font for code page 437 */
#include <linux/ctype.h>
-/*
- * Structure to describe a console color
- */
-struct vid_rgb {
- u32 r;
- u32 g;
- u32 b;
-};
-
/* By default we scroll by a single line */
#ifndef CONFIG_CONSOLE_SCROLL_LINES
#define CONFIG_CONSOLE_SCROLL_LINES 1
@@ -124,61 +115,6 @@ static void vidconsole_newline(struct udevice *dev)
}
}
-static const struct vid_rgb colors[VID_COLOR_COUNT] = {
- { 0x00, 0x00, 0x00 }, /* black */
- { 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 }, /* bright blue */
- { 0xff, 0x00, 0xff }, /* bright magenta */
- { 0x00, 0xff, 0xff }, /* bright cyan */
- { 0xff, 0xff, 0xff }, /* white */
-};
-
-u32 vid_console_color(struct video_priv *priv, unsigned int idx)
-{
- switch (priv->bpix) {
- case VIDEO_BPP16:
- if (CONFIG_IS_ENABLED(VIDEO_BPP16)) {
- return ((colors[idx].r >> 3) << 11) |
- ((colors[idx].g >> 2) << 5) |
- ((colors[idx].b >> 3) << 0);
- }
- break;
- case VIDEO_BPP32:
- if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
- if (priv->format == VIDEO_X2R10G10B10)
- return (colors[idx].r << 22) |
- (colors[idx].g << 12) |
- (colors[idx].b << 2);
- else
- return (colors[idx].r << 16) |
- (colors[idx].g << 8) |
- (colors[idx].b << 0);
- }
- break;
- default:
- break;
- }
-
- /*
- * For unknown bit arrangements just support
- * black and white.
- */
- if (idx)
- return 0xffffff; /* white */
-
- return 0x000000; /* black */
-}
-
static char *parsenum(char *s, int *num)
{
char *end;
@@ -441,28 +377,28 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
case 1:
/* bold */
vid_priv->fg_col_idx |= 8;
- vid_priv->colour_fg = vid_console_color(
+ vid_priv->colour_fg = video_index_to_colour(
vid_priv, vid_priv->fg_col_idx);
break;
case 7:
/* reverse video */
- vid_priv->colour_fg = vid_console_color(
+ vid_priv->colour_fg = video_index_to_colour(
vid_priv, vid_priv->bg_col_idx);
- vid_priv->colour_bg = vid_console_color(
+ vid_priv->colour_bg = video_index_to_colour(
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->colour_fg = video_index_to_colour(
vid_priv, vid_priv->fg_col_idx);
break;
case 40 ... 47:
/* 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->colour_bg = video_index_to_colour(
vid_priv, vid_priv->bg_col_idx);
break;
default: