]> git.sur5r.net Git - u-boot/blobdiff - drivers/video/console_normal.c
lpi2c: Fix bus stop problem in xfer
[u-boot] / drivers / video / console_normal.c
index d1031c8ed1752118e27c1c2cb6aecc4d761c2037..2cfa510d5f7d7a0c2830986a21df1dc84d9eeab8 100644 (file)
@@ -1,11 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * 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
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -18,7 +17,7 @@ static int console_normal_set_row(struct udevice *dev, uint row, int clr)
 {
        struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
        void *line;
-       int pixels = VIDEO_FONT_HEIGHT * vid_priv->line_length;
+       int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
        int i;
 
        line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
@@ -71,13 +70,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 +129,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 +156,5 @@ U_BOOT_DRIVER(vidconsole_normal) = {
        .name   = "vidconsole0",
        .id     = UCLASS_VIDEO_CONSOLE,
        .ops    = &console_normal_ops,
+       .probe  = console_normal_probe,
 };