[RESEND PATCH v3 14/26] video: Update truetype console to support copy buffer

Simon Glass sjg at chromium.org
Fri Jul 3 05:12:25 CEST 2020


Update the implementation to keep a track of what it changes in the frame
buffer and then tell the copy buffer about it. Use the special
vidconsole_memmove() helper so that memmove() operations are also
reflected in the copy buffer.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Anatolij Gustschin <agust at denx.de>
---

(no changes since v1)

 drivers/video/console_truetype.c | 43 +++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 5f7f03904b..22b2ea7191 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -127,9 +127,9 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 {
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 	struct console_tt_priv *priv = dev_get_priv(dev);
-	void *line;
+	void *end, *line;
 	int pixels = priv->font_size * vid_priv->line_length;
-	int i;
+	int i, ret;
 
 	line = vid_priv->fb + row * priv->font_size * vid_priv->line_length;
 	switch (vid_priv->bpix) {
@@ -139,6 +139,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 
 		for (i = 0; i < pixels; i++)
 			*dst++ = clr;
+		end = dst;
 		break;
 	}
 #endif
@@ -148,6 +149,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 
 		for (i = 0; i < pixels; i++)
 			*dst++ = clr;
+		end = dst;
 		break;
 	}
 #endif
@@ -157,12 +159,16 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 
 		for (i = 0; i < pixels; i++)
 			*dst++ = clr;
+		end = dst;
 		break;
 	}
 #endif
 	default:
 		return -ENOSYS;
 	}
+	ret = vidconsole_sync_copy(dev, line, end);
+	if (ret)
+		return ret;
 
 	return 0;
 }
@@ -174,11 +180,14 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst,
 	struct console_tt_priv *priv = dev_get_priv(dev);
 	void *dst;
 	void *src;
-	int i, diff;
+	int i, diff, ret;
 
 	dst = vid_priv->fb + rowdst * priv->font_size * vid_priv->line_length;
 	src = vid_priv->fb + rowsrc * priv->font_size * vid_priv->line_length;
-	memmove(dst, src, priv->font_size * vid_priv->line_length * count);
+	ret = vidconsole_memmove(dev, dst, src, priv->font_size *
+				 vid_priv->line_length * count);
+	if (ret)
+		return ret;
 
 	/* Scroll up our position history */
 	diff = (rowsrc - rowdst) * priv->font_size;
@@ -203,8 +212,8 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 	struct pos_info *pos;
 	u8 *bits, *data;
 	int advance;
-	void *line;
-	int row;
+	void *start, *end, *line;
+	int row, ret;
 
 	/* First get some basic metrics about this character */
 	stbtt_GetCodepointHMetrics(font, ch, &advance, &lsb);
@@ -253,11 +262,12 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 
 	/* Figure out where to write the character in the frame buffer */
 	bits = data;
-	line = vid_priv->fb + y * vid_priv->line_length +
+	start = vid_priv->fb + y * vid_priv->line_length +
 		VID_TO_PIXEL(x) * VNBYTES(vid_priv->bpix);
 	linenum = priv->baseline + yoff;
 	if (linenum > 0)
-		line += linenum * vid_priv->line_length;
+		start += linenum * vid_priv->line_length;
+	line = start;
 
 	/*
 	 * Write a row at a time, converting the 8bpp image into the colour
@@ -286,6 +296,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 					*dst++ &= out;
 				bits++;
 			}
+			end = dst;
 			break;
 		}
 #endif
@@ -307,6 +318,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 					*dst++ &= out;
 				bits++;
 			}
+			end = dst;
 			break;
 		}
 #endif
@@ -317,6 +329,9 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 
 		line += vid_priv->line_length;
 	}
+	ret = vidconsole_sync_copy(dev, start, line);
+	if (ret)
+		return ret;
 	free(data);
 
 	return width_frac;
@@ -340,12 +355,13 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
 				  int xend, int yend, int clr)
 {
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
-	void *line;
+	void *start, *line;
 	int pixels = xend - xstart;
-	int row, i;
+	int row, i, ret;
 
-	line = vid_priv->fb + ystart * vid_priv->line_length;
-	line += xstart * VNBYTES(vid_priv->bpix);
+	start = vid_priv->fb + ystart * vid_priv->line_length;
+	start += xstart * VNBYTES(vid_priv->bpix);
+	line = start;
 	for (row = ystart; row < yend; row++) {
 		switch (vid_priv->bpix) {
 #ifdef CONFIG_VIDEO_BPP8
@@ -380,6 +396,9 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
 		}
 		line += vid_priv->line_length;
 	}
+	ret = vidconsole_sync_copy(dev, start, line);
+	if (ret)
+		return ret;
 
 	return 0;
 }
-- 
2.27.0.212.ge8ba1cc988-goog



More information about the U-Boot mailing list