video: Make white-on-black a video-device property
The CONFIG_WHITE_ON_BLACK setting is hard-coded at build-time. It is useful to be able to control this when showing menus. Create a property to hold this information, using the CONFIG as the initial value. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -194,7 +194,7 @@ int expo_render(struct expo *exp)
|
|||||||
u32 colour;
|
u32 colour;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
back = CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK) ? VID_BLACK : VID_WHITE;
|
back = vid_priv->white_on_black ? VID_BLACK : VID_WHITE;
|
||||||
colour = video_index_to_colour(vid_priv, back);
|
colour = video_index_to_colour(vid_priv, back);
|
||||||
ret = video_fill(dev, colour);
|
ret = video_fill(dev, colour);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@@ -330,8 +330,9 @@ static void scene_render_background(struct scene_obj *obj, bool box_only)
|
|||||||
enum colour_idx fore, back;
|
enum colour_idx fore, back;
|
||||||
uint inset = theme->menu_inset;
|
uint inset = theme->menu_inset;
|
||||||
|
|
||||||
|
vid_priv = dev_get_uclass_priv(dev);
|
||||||
/* draw a background for the object */
|
/* draw a background for the object */
|
||||||
if (CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK)) {
|
if (vid_priv->white_on_black) {
|
||||||
fore = VID_DARK_GREY;
|
fore = VID_DARK_GREY;
|
||||||
back = VID_WHITE;
|
back = VID_WHITE;
|
||||||
} else {
|
} else {
|
||||||
@@ -344,7 +345,6 @@ static void scene_render_background(struct scene_obj *obj, bool box_only)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
vidconsole_push_colour(cons, fore, back, &old);
|
vidconsole_push_colour(cons, fore, back, &old);
|
||||||
vid_priv = dev_get_uclass_priv(dev);
|
|
||||||
video_fill_part(dev, label_bbox.x0 - inset, label_bbox.y0 - inset,
|
video_fill_part(dev, label_bbox.x0 - inset, label_bbox.y0 - inset,
|
||||||
label_bbox.x1 + inset, label_bbox.y1 + inset,
|
label_bbox.x1 + inset, label_bbox.y1 + inset,
|
||||||
vid_priv->colour_fg);
|
vid_priv->colour_fg);
|
||||||
@@ -408,7 +408,8 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode)
|
|||||||
struct vidconsole_colour old;
|
struct vidconsole_colour old;
|
||||||
enum colour_idx fore, back;
|
enum colour_idx fore, back;
|
||||||
|
|
||||||
if (CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK)) {
|
vid_priv = dev_get_uclass_priv(dev);
|
||||||
|
if (vid_priv->white_on_black) {
|
||||||
fore = VID_BLACK;
|
fore = VID_BLACK;
|
||||||
back = VID_WHITE;
|
back = VID_WHITE;
|
||||||
} else {
|
} else {
|
||||||
@@ -416,7 +417,6 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode)
|
|||||||
back = VID_BLACK;
|
back = VID_BLACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
vid_priv = dev_get_uclass_priv(dev);
|
|
||||||
if (obj->flags & SCENEOF_POINT) {
|
if (obj->flags & SCENEOF_POINT) {
|
||||||
vidconsole_push_colour(cons, fore, back, &old);
|
vidconsole_push_colour(cons, fore, back, &old);
|
||||||
video_fill_part(dev, x - theme->menu_inset, y,
|
video_fill_part(dev, x - theme->menu_inset, y,
|
||||||
|
@@ -345,7 +345,7 @@ void video_set_default_colors(struct udevice *dev, bool invert)
|
|||||||
struct video_priv *priv = dev_get_uclass_priv(dev);
|
struct video_priv *priv = dev_get_uclass_priv(dev);
|
||||||
int fore, back;
|
int fore, back;
|
||||||
|
|
||||||
if (CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK)) {
|
if (priv->white_on_black) {
|
||||||
/* White is used when switching to bold, use light gray here */
|
/* White is used when switching to bold, use light gray here */
|
||||||
fore = VID_LIGHT_GRAY;
|
fore = VID_LIGHT_GRAY;
|
||||||
back = VID_BLACK;
|
back = VID_BLACK;
|
||||||
@@ -582,6 +582,18 @@ static void video_idle(struct cyclic_info *cyc)
|
|||||||
video_sync_all();
|
video_sync_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void video_set_white_on_black(struct udevice *dev, bool white_on_black)
|
||||||
|
{
|
||||||
|
struct video_priv *priv = dev_get_uclass_priv(dev);
|
||||||
|
|
||||||
|
if (priv->white_on_black != white_on_black) {
|
||||||
|
priv->white_on_black = white_on_black;
|
||||||
|
video_set_default_colors(dev, false);
|
||||||
|
|
||||||
|
video_clear(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Set up the display ready for use */
|
/* Set up the display ready for use */
|
||||||
static int video_post_probe(struct udevice *dev)
|
static int video_post_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
@@ -624,6 +636,8 @@ static int video_post_probe(struct udevice *dev)
|
|||||||
if (IS_ENABLED(CONFIG_VIDEO_COPY) && plat->copy_base)
|
if (IS_ENABLED(CONFIG_VIDEO_COPY) && plat->copy_base)
|
||||||
priv->copy_fb = map_sysmem(plat->copy_base, plat->size);
|
priv->copy_fb = map_sysmem(plat->copy_base, plat->size);
|
||||||
|
|
||||||
|
priv->white_on_black = CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK);
|
||||||
|
|
||||||
/* Set up colors */
|
/* Set up colors */
|
||||||
video_set_default_colors(dev, false);
|
video_set_default_colors(dev, false);
|
||||||
|
|
||||||
|
@@ -100,6 +100,7 @@ enum video_format {
|
|||||||
* @fg_col_idx: Foreground color code (bit 3 = bold, bit 0-2 = color)
|
* @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)
|
* @bg_col_idx: Background color code (bit 3 = bold, bit 0-2 = color)
|
||||||
* @last_sync: Monotonic time of last video sync
|
* @last_sync: Monotonic time of last video sync
|
||||||
|
* @white_on_black: Use a black background
|
||||||
*/
|
*/
|
||||||
struct video_priv {
|
struct video_priv {
|
||||||
/* Things set up by the driver: */
|
/* Things set up by the driver: */
|
||||||
@@ -131,6 +132,7 @@ struct video_priv {
|
|||||||
u8 fg_col_idx;
|
u8 fg_col_idx;
|
||||||
u8 bg_col_idx;
|
u8 bg_col_idx;
|
||||||
ulong last_sync;
|
ulong last_sync;
|
||||||
|
bool white_on_black;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -346,6 +348,16 @@ void video_set_flush_dcache(struct udevice *dev, bool flush);
|
|||||||
*/
|
*/
|
||||||
void video_set_default_colors(struct udevice *dev, bool invert);
|
void video_set_default_colors(struct udevice *dev, bool invert);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* video_set_white_on_black() - Change the setting for white-on-black
|
||||||
|
*
|
||||||
|
* This does nothing if the setting is already the same.
|
||||||
|
*
|
||||||
|
* @dev: video device
|
||||||
|
* @white_on_black: true to use white-on-black, false for black-on-white
|
||||||
|
*/
|
||||||
|
void video_set_white_on_black(struct udevice *dev, bool white_on_black);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video_default_font_height() - Get the default font height
|
* video_default_font_height() - Get the default font height
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user