summaryrefslogtreecommitdiff
path: root/drivers/video/console_rotate.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-01-14 18:10:37 -0700
committerAnatolij Gustschin <agust@denx.de>2016-01-30 10:53:26 +0100
commitf266178698307608ee23741e69b9626196e66481 (patch)
treecee098f37679faf65c38592bb1e8f212fa78885f /drivers/video/console_rotate.c
parent6e42e251964d79117f4b3d16a2352083037a251c (diff)
downloadu-boot-imx-f266178698307608ee23741e69b9626196e66481.zip
u-boot-imx-f266178698307608ee23741e69b9626196e66481.tar.gz
u-boot-imx-f266178698307608ee23741e69b9626196e66481.tar.bz2
video: Use fractional units for X coordinates
With anti-aliased fonts we need a more fine-grained horizontal position than a single pixel. Characters can be positioned to start part-way through a pixel, with anti-aliasing (greyscale edges) taking care of the visual effect. To cope with this, use fractional units (1/256 pixel) for horizontal positions in the text console. Signed-off-by: Simon Glass <sjg@chromium.org> [agust: rebased] Signed-off-by: Anatolij Gustschin <agust@denx.de>
Diffstat (limited to 'drivers/video/console_rotate.c')
-rw-r--r--drivers/video/console_rotate.c65
1 files changed, 49 insertions, 16 deletions
diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
index ebb31d8..227141d 100644
--- a/drivers/video/console_rotate.c
+++ b/drivers/video/console_rotate.c
@@ -82,17 +82,22 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
return 0;
}
-static int console_putc_xy_1(struct udevice *dev, uint x, uint y, char ch)
+static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
{
+ struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
struct udevice *vid = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
int pbytes = VNBYTES(vid_priv->bpix);
int i, col;
int mask = 0x80;
- void *line = vid_priv->fb + (x + 1) * vid_priv->line_length -
- (y + 1) * pbytes;
+ void *line;
uchar *pfont = video_fontdata + ch * VIDEO_FONT_HEIGHT;
+ line = vid_priv->fb + (VID_TO_PIXEL(x_frac) + 1) *
+ vid_priv->line_length - (y + 1) * pbytes;
+ if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac)
+ return -EAGAIN;
+
for (col = 0; col < VIDEO_FONT_HEIGHT; col++) {
switch (vid_priv->bpix) {
#ifdef CONFIG_VIDEO_BPP8
@@ -135,7 +140,7 @@ static int console_putc_xy_1(struct udevice *dev, uint x, uint y, char ch)
mask >>= 1;
}
- return 0;
+ return VID_TO_POS(VIDEO_FONT_WIDTH);
}
@@ -201,17 +206,21 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
return 0;
}
-static int console_putc_xy_2(struct udevice *dev, uint x, uint y, char ch)
+static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
{
+ struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
struct udevice *vid = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
int i, row;
void *line;
+ if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac)
+ return -EAGAIN;
+
line = vid_priv->fb + (vid_priv->ysize - y - 1) *
- vid_priv->line_length +
- (vid_priv->xsize - x - VIDEO_FONT_WIDTH - 1) *
- VNBYTES(vid_priv->bpix);
+ vid_priv->line_length +
+ (vid_priv->xsize - VID_TO_PIXEL(x_frac) -
+ VIDEO_FONT_WIDTH - 1) * VNBYTES(vid_priv->bpix);
for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
uchar bits = video_fontdata[ch * VIDEO_FONT_HEIGHT + row];
@@ -259,7 +268,7 @@ static int console_putc_xy_2(struct udevice *dev, uint x, uint y, char ch)
line -= vid_priv->line_length;
}
- return 0;
+ return VID_TO_POS(VIDEO_FONT_WIDTH);
}
static int console_set_row_3(struct udevice *dev, uint row, int clr)
@@ -329,17 +338,22 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
return 0;
}
-static int console_putc_xy_3(struct udevice *dev, uint x, uint y, char ch)
+static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
{
+ struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
struct udevice *vid = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
int pbytes = VNBYTES(vid_priv->bpix);
int i, col;
int mask = 0x80;
- void *line = vid_priv->fb + (vid_priv->ysize - x - 1) *
+ void *line = vid_priv->fb +
+ (vid_priv->ysize - VID_TO_PIXEL(x_frac) - 1) *
vid_priv->line_length + y * pbytes;
uchar *pfont = video_fontdata + ch * VIDEO_FONT_HEIGHT;
+ if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac)
+ return -EAGAIN;
+
for (col = 0; col < VIDEO_FONT_HEIGHT; col++) {
switch (vid_priv->bpix) {
#ifdef CONFIG_VIDEO_BPP8
@@ -382,17 +396,35 @@ static int console_putc_xy_3(struct udevice *dev, uint x, uint y, char ch)
mask >>= 1;
}
- return 0;
+ return VID_TO_POS(VIDEO_FONT_WIDTH);
}
+static int console_probe_2(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;
+
+ return 0;
+}
+
static int console_probe_1_3(struct udevice *dev)
{
- struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
- struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+ 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);
- priv->cols = vid_priv->ysize / VIDEO_FONT_WIDTH;
- priv->rows = vid_priv->xsize / VIDEO_FONT_HEIGHT;
+ vc_priv->x_charsize = VIDEO_FONT_WIDTH;
+ vc_priv->y_charsize = VIDEO_FONT_HEIGHT;
+ vc_priv->cols = vid_priv->ysize / VIDEO_FONT_WIDTH;
+ vc_priv->rows = vid_priv->xsize / VIDEO_FONT_HEIGHT;
+ vc_priv->xsize_frac = VID_TO_POS(vid_priv->ysize);
return 0;
}
@@ -426,6 +458,7 @@ U_BOOT_DRIVER(vidconsole_2) = {
.name = "vidconsole2",
.id = UCLASS_VIDEO_CONSOLE,
.ops = &console_ops_2,
+ .probe = console_probe_2,
};
U_BOOT_DRIVER(vidconsole_3) = {