All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 14/26] video: Update truetype console to support copy buffer
Date: Sun, 24 May 2020 19:48:51 -0600	[thread overview]
Message-ID: <20200524194852.v2.14.I7b2b4487cb81658022e283a2676803ae1bc173ff@changeid> (raw)
In-Reply-To: <20200525014904.115621-1-sjg@chromium.org>

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@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
---

Changes in v2: None

 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.rc0.183.gde8f92d652-goog

  parent reply	other threads:[~2020-05-25  1:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  1:48 [PATCH v2 00/26] x86: video: Speed up the framebuffer Simon Glass
2020-05-25  1:48 ` [PATCH v2 01/26] x86: fsp: Reinit the FPU after FSP meminit Simon Glass
2020-05-25  1:48 ` [PATCH v2 02/26] console: Add a way to output to serial only Simon Glass
2020-05-25  1:48 ` [PATCH v2 03/26] video: Show an error when a vidconsole function fails Simon Glass
2020-05-25  1:48 ` [PATCH v2 04/26] sandbox: video: Allow selection of rotated console Simon Glass
2020-05-25  1:48 ` [PATCH v2 05/26] video: Split out expression parts into variables Simon Glass
2020-05-25  1:48 ` [PATCH v2 06/26] video: Adjust rotated console to start at right edge Simon Glass
2020-05-25  1:48 ` [PATCH v2 07/26] video: Drop unnecessary #ifdef around vid_console_color() Simon Glass
2020-05-25  1:48 ` [PATCH v2 08/26] video: Add a comment for struct video_uc_platdata Simon Glass
2020-05-25  1:48 ` [PATCH v2 09/26] video: Add support for copying to a hardware framebuffer Simon Glass
2020-05-25  1:48 ` [PATCH v2 10/26] video: Set up the copy framebuffer when enabled Simon Glass
2020-05-25  1:48 ` [PATCH v2 11/26] video: Clear the copy framebuffer when clearing the screen Simon Glass
2020-05-25  1:48 ` [PATCH v2 12/26] video: Add helpers for vidconsole for the copy framebuffer Simon Glass
2020-05-25  1:48 ` [PATCH v2 13/26] video: Update normal console to support copy buffer Simon Glass
2020-05-25  1:48 ` Simon Glass [this message]
2020-05-25  1:48 ` [PATCH v2 15/26] video: Update rotated " Simon Glass
2020-05-25  1:48 ` [PATCH v2 16/26] video: Update the copy framebuffer when writing bitmaps Simon Glass
2020-05-25  1:48 ` [PATCH v2 17/26] video: Add comments to struct sandbox_sdl_plat Simon Glass
2020-05-25  1:48 ` [PATCH v2 18/26] video: sandbox: Add support for the copy framebuffer Simon Glass
2020-05-25  1:48 ` [PATCH v2 19/26] video: pci: Set up " Simon Glass
2020-05-25  1:48 ` [PATCH v2 20/26] x86: fsp: video: Allocate a frame buffer when needed Simon Glass
2020-05-25  1:48 ` [PATCH v2 21/26] video: Correctly handle multiple framebuffers Simon Glass
2020-05-25  1:48 ` [PATCH v2 22/26] x86: video: Support copy framebuffer with probed devices Simon Glass
2020-05-25  1:49 ` [PATCH v2 23/26] chromebook_samus: Enable the copy framebuffer Simon Glass
2020-05-25  1:49 ` [PATCH v2 24/26] chromebook_link: " Simon Glass
2020-05-25  1:49 ` [PATCH v2 25/26] minnowmax: " Simon Glass
2020-05-25  1:49 ` [PATCH v2 26/26] x86: minnowmax: Drop screen resolution to 1024x768 Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200524194852.v2.14.I7b2b4487cb81658022e283a2676803ae1bc173ff@changeid \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.