diff options
Diffstat (limited to 'drivers/video/video-uclass.c')
-rw-r--r-- | drivers/video/video-uclass.c | 102 |
1 files changed, 96 insertions, 6 deletions
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 01e8af5..0ce376c 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -64,6 +64,13 @@ struct video_uc_priv { ulong video_ptr; }; +/** struct vid_rgb - Describes a video colour */ +struct vid_rgb { + u32 r; + u32 g; + u32 b; +}; + void video_set_flush_dcache(struct udevice *dev, bool flush) { struct video_priv *priv = dev_get_uclass_priv(dev); @@ -119,7 +126,7 @@ int video_reserve(ulong *addrp) return 0; } -int video_clear(struct udevice *dev) +int video_fill(struct udevice *dev, u32 colour) { struct video_priv *priv = dev_get_uclass_priv(dev); int ret; @@ -131,7 +138,7 @@ int video_clear(struct udevice *dev) u16 *end = priv->fb + priv->fb_size; while (ppix < end) - *ppix++ = priv->colour_bg; + *ppix++ = colour; break; } case VIDEO_BPP32: @@ -140,11 +147,11 @@ int video_clear(struct udevice *dev) u32 *end = priv->fb + priv->fb_size; while (ppix < end) - *ppix++ = priv->colour_bg; + *ppix++ = colour; break; } default: - memset(priv->fb, priv->colour_bg, priv->fb_size); + memset(priv->fb, colour, priv->fb_size); break; } ret = video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size); @@ -154,6 +161,73 @@ int video_clear(struct udevice *dev) return video_sync(dev, false); } +int video_clear(struct udevice *dev) +{ + struct video_priv *priv = dev_get_uclass_priv(dev); + int ret; + + ret = video_fill(dev, priv->colour_bg); + if (ret) + return ret; + + return 0; +} + +static const struct vid_rgb colours[VID_COLOUR_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 video_index_to_colour(struct video_priv *priv, unsigned int idx) +{ + switch (priv->bpix) { + case VIDEO_BPP16: + if (CONFIG_IS_ENABLED(VIDEO_BPP16)) { + return ((colours[idx].r >> 3) << 11) | + ((colours[idx].g >> 2) << 5) | + ((colours[idx].b >> 3) << 0); + } + break; + case VIDEO_BPP32: + if (CONFIG_IS_ENABLED(VIDEO_BPP32)) { + if (priv->format == VIDEO_X2R10G10B10) + return (colours[idx].r << 22) | + (colours[idx].g << 12) | + (colours[idx].b << 2); + else + return (colours[idx].r << 16) | + (colours[idx].g << 8) | + (colours[idx].b << 0); + } + break; + default: + break; + } + + /* + * For unknown bit arrangements just support + * black and white. + */ + if (idx) + return 0xffffff; /* white */ + + return 0x000000; /* black */ +} + void video_set_default_colors(struct udevice *dev, bool invert) { struct video_priv *priv = dev_get_uclass_priv(dev); @@ -176,8 +250,8 @@ void video_set_default_colors(struct udevice *dev, bool invert) } 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); + priv->colour_fg = video_index_to_colour(priv, fore); + priv->colour_bg = video_index_to_colour(priv, back); } /* Flush video activity to the caches */ @@ -332,6 +406,11 @@ int video_sync_copy_all(struct udevice *dev) SPLASH_DECL(u_boot_logo); +void *video_get_u_boot_logo(void) +{ + return SPLASH_START(u_boot_logo); +} + static int show_splash(struct udevice *dev) { u8 *data = SPLASH_START(u_boot_logo); @@ -342,6 +421,17 @@ static int show_splash(struct udevice *dev) return 0; } +int video_default_font_height(struct udevice *dev) +{ + struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); + + if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE)) + return IF_ENABLED_INT(CONFIG_CONSOLE_TRUETYPE, + CONFIG_CONSOLE_TRUETYPE_SIZE); + + return vc_priv->y_charsize; +} + /* Set up the display ready for use */ static int video_post_probe(struct udevice *dev) { |