diff options
author | Simon Glass <sjg@chromium.org> | 2016-01-15 01:10:37 (GMT) |
---|---|---|
committer | Anatolij Gustschin <agust@denx.de> | 2016-01-30 09:53:26 (GMT) |
commit | f266178698307608ee23741e69b9626196e66481 (patch) | |
tree | cee098f37679faf65c38592bb1e8f212fa78885f /drivers/video/console_normal.c | |
parent | 6e42e251964d79117f4b3d16a2352083037a251c (diff) | |
download | u-boot-f266178698307608ee23741e69b9626196e66481.tar.xz |
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_normal.c')
-rw-r--r-- | drivers/video/console_normal.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index d1031c8..89a55dd 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -71,13 +71,18 @@ static int console_normal_move_rows(struct udevice *dev, uint rowdst, return 0; } -static int console_normal_putc_xy(struct udevice *dev, uint x, uint y, char ch) +static int console_normal_putc_xy(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 = vid_priv->fb + y * vid_priv->line_length + - x * VNBYTES(vid_priv->bpix); + VID_TO_PIXEL(x_frac) * VNBYTES(vid_priv->bpix); + + if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac) + return -EAGAIN; for (row = 0; row < VIDEO_FONT_HEIGHT; row++) { uchar bits = video_fontdata[ch * VIDEO_FONT_HEIGHT + row]; @@ -125,6 +130,20 @@ static int console_normal_putc_xy(struct udevice *dev, uint x, uint y, char ch) line += vid_priv->line_length; } + 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; + return 0; } @@ -138,4 +157,5 @@ U_BOOT_DRIVER(vidconsole_normal) = { .name = "vidconsole0", .id = UCLASS_VIDEO_CONSOLE, .ops = &console_normal_ops, + .probe = console_normal_probe, }; |