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>
This commit is contained in:
committed by
Anatolij Gustschin
parent
db2c8ed3a5
commit
a032e4b55e
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user