2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-01-19 02:52:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Google, Inc
|
|
|
|
* (C) Copyright 2001-2015
|
|
|
|
* DENX Software Engineering -- wd@denx.de
|
|
|
|
* Compulab Ltd - http://compulab.co.il/
|
|
|
|
* Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <video.h>
|
|
|
|
#include <video_console.h>
|
|
|
|
#include <video_font.h> /* Get font data, width and height */
|
|
|
|
|
|
|
|
static int console_normal_set_row(struct udevice *dev, uint row, int clr)
|
|
|
|
{
|
|
|
|
struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
|
2020-07-03 03:12:24 +00:00
|
|
|
void *line, *end;
|
2019-12-21 01:10:34 +00:00
|
|
|
int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
|
2020-07-03 03:12:24 +00:00
|
|
|
int ret;
|
2019-12-21 01:10:34 +00:00
|
|
|
int i;
|
2016-01-19 02:52:18 +00:00
|
|
|
|
|
|
|
line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
|
|
|
|
switch (vid_priv->bpix) {
|
2019-12-21 01:10:34 +00:00
|
|
|
case VIDEO_BPP8:
|
|
|
|
if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
|
|
|
|
uint8_t *dst = line;
|
2016-01-19 02:52:18 +00:00
|
|
|
|
2019-12-21 01:10:34 +00:00
|
|
|
for (i = 0; i < pixels; i++)
|
|
|
|
*dst++ = clr;
|
2020-07-03 03:12:24 +00:00
|
|
|
end = dst;
|
2019-12-21 01:10:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIDEO_BPP16:
|
|
|
|
if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
|
|
|
|
uint16_t *dst = line;
|
|
|
|
|
|
|
|
for (i = 0; i < pixels; i++)
|
|
|
|
*dst++ = clr;
|
2020-07-03 03:12:24 +00:00
|
|
|
end = dst;
|
2019-12-21 01:10:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIDEO_BPP32:
|
|
|
|
if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
|
|
|
|
uint32_t *dst = line;
|
|
|
|
|
|
|
|
for (i = 0; i < pixels; i++)
|
|
|
|
*dst++ = clr;
|
2020-07-03 03:12:24 +00:00
|
|
|
end = dst;
|
2019-12-21 01:10:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-01-19 02:52:18 +00:00
|
|
|
default:
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
2020-07-03 03:12:24 +00:00
|
|
|
ret = vidconsole_sync_copy(dev, line, end);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2016-01-19 02:52:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int console_normal_move_rows(struct udevice *dev, uint rowdst,
|
|
|
|
uint rowsrc, uint count)
|
|
|
|
{
|
|
|
|
struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
|
|
|
|
void *dst;
|
|
|
|
void *src;
|
2020-07-03 03:12:24 +00:00
|
|
|
int size;
|
|
|
|
int ret;
|
2016-01-19 02:52:18 +00:00
|
|
|
|
|
|
|
dst = vid_priv->fb + rowdst * VIDEO_FONT_HEIGHT * vid_priv->line_length;
|
|
|
|
src = vid_priv->fb + rowsrc * VIDEO_FONT_HEIGHT * vid_priv->line_length;
|
2020-07-03 03:12:24 +00:00
|
|
|
size = VIDEO_FONT_HEIGHT * vid_priv->line_length * count;
|
|
|
|
ret = vidconsole_memmove(dev, dst, src, size);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2016-01-19 02:52:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-01-15 01:10:37 +00:00
|
|
|
static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
|
|
|
|
char ch)
|
2016-01-19 02:52:18 +00:00
|
|
|
{
|
2016-01-15 01:10:37 +00:00
|
|
|
struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
|
2016-01-19 02:52:18 +00:00
|
|
|
struct udevice *vid = dev->parent;
|
|
|
|
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
|
2019-12-21 01:10:34 +00:00
|
|
|
int i, row;
|
2020-07-03 03:12:24 +00:00
|
|
|
void *start;
|
|
|
|
void *line;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
start = vid_priv->fb + y * vid_priv->line_length +
|
2016-01-15 01:10:37 +00:00
|
|
|
VID_TO_PIXEL(x_frac) * VNBYTES(vid_priv->bpix);
|
2020-07-03 03:12:24 +00:00
|
|
|
line = start;
|
2016-01-15 01:10:37 +00:00
|
|
|
|
|
|
|
if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac)
|
|
|
|
return -EAGAIN;
|
2016-01-19 02:52:18 +00:00
|
|
|
|
|
|
|
for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
|
2019-03-23 01:29:55 +00:00
|
|
|
unsigned int idx = (u8)ch * VIDEO_FONT_HEIGHT + row;
|
2019-12-21 01:10:34 +00:00
|
|
|
uchar bits = video_fontdata[idx];
|
2016-01-19 02:52:18 +00:00
|
|
|
|
|
|
|
switch (vid_priv->bpix) {
|
2019-12-21 01:10:34 +00:00
|
|
|
case VIDEO_BPP8:
|
|
|
|
if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
|
|
|
|
uint8_t *dst = line;
|
|
|
|
|
|
|
|
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
|
|
|
*dst++ = (bits & 0x80) ?
|
|
|
|
vid_priv->colour_fg :
|
|
|
|
vid_priv->colour_bg;
|
|
|
|
bits <<= 1;
|
|
|
|
}
|
|
|
|
break;
|
2016-01-19 02:52:18 +00:00
|
|
|
}
|
2019-12-21 01:10:34 +00:00
|
|
|
case VIDEO_BPP16:
|
|
|
|
if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
|
|
|
|
uint16_t *dst = line;
|
|
|
|
|
|
|
|
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
|
|
|
*dst++ = (bits & 0x80) ?
|
|
|
|
vid_priv->colour_fg :
|
|
|
|
vid_priv->colour_bg;
|
|
|
|
bits <<= 1;
|
|
|
|
}
|
|
|
|
break;
|
2016-01-19 02:52:18 +00:00
|
|
|
}
|
2019-12-21 01:10:34 +00:00
|
|
|
case VIDEO_BPP32:
|
|
|
|
if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
|
|
|
|
uint32_t *dst = line;
|
|
|
|
|
|
|
|
for (i = 0; i < VIDEO_FONT_WIDTH; i++) {
|
|
|
|
*dst++ = (bits & 0x80) ?
|
|
|
|
vid_priv->colour_fg :
|
|
|
|
vid_priv->colour_bg;
|
|
|
|
bits <<= 1;
|
|
|
|
}
|
|
|
|
break;
|
2016-01-19 02:52:18 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
line += vid_priv->line_length;
|
|
|
|
}
|
2020-07-03 03:12:24 +00:00
|
|
|
ret = vidconsole_sync_copy(dev, start, line);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2016-01-19 02:52:18 +00:00
|
|
|
|
2016-01-15 01:10:37 +00:00
|
|
|
return VID_TO_POS(VIDEO_FONT_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int console_normal_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
|
|
|
|
struct udevice *vid_dev = dev->parent;
|
|
|
|
struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
|
|
|
|
|
|
|
|
vc_priv->x_charsize = VIDEO_FONT_WIDTH;
|
|
|
|
vc_priv->y_charsize = VIDEO_FONT_HEIGHT;
|
|
|
|
vc_priv->cols = vid_priv->xsize / VIDEO_FONT_WIDTH;
|
|
|
|
vc_priv->rows = vid_priv->ysize / VIDEO_FONT_HEIGHT;
|
|
|
|
|
2016-01-19 02:52:18 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct vidconsole_ops console_normal_ops = {
|
|
|
|
.putc_xy = console_normal_putc_xy,
|
|
|
|
.move_rows = console_normal_move_rows,
|
|
|
|
.set_row = console_normal_set_row,
|
|
|
|
};
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(vidconsole_normal) = {
|
|
|
|
.name = "vidconsole0",
|
|
|
|
.id = UCLASS_VIDEO_CONSOLE,
|
|
|
|
.ops = &console_normal_ops,
|
2016-01-15 01:10:37 +00:00
|
|
|
.probe = console_normal_probe,
|
2016-01-19 02:52:18 +00:00
|
|
|
};
|