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 15/26] video: Update rotated console to support copy buffer
Date: Sun, 24 May 2020 19:48:52 -0600	[thread overview]
Message-ID: <20200524194852.v2.15.Ieb8fa645754166cb903055967c544f29fc2cfd2c@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_rotate.c | 83 ++++++++++++++++++++++++----------
 1 file changed, 60 insertions(+), 23 deletions(-)

diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
index da0ce7b9ce..36c8d0609d 100644
--- a/drivers/video/console_rotate.c
+++ b/drivers/video/console_rotate.c
@@ -15,11 +15,13 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
 {
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 	int pbytes = VNBYTES(vid_priv->bpix);
-	void *line;
+	void *start, *line;
 	int i, j;
+	int ret;
 
-	line = vid_priv->fb + vid_priv->line_length -
+	start = vid_priv->fb + vid_priv->line_length -
 		(row + 1) * VIDEO_FONT_HEIGHT * pbytes;
+	line = start;
 	for (j = 0; j < vid_priv->ysize; j++) {
 		switch (vid_priv->bpix) {
 		case VIDEO_BPP8:
@@ -51,6 +53,9 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
 		}
 		line += vid_priv->line_length;
 	}
+	ret = vidconsole_sync_copy(dev, start, line);
+	if (ret)
+		return ret;
 
 	return 0;
 }
@@ -62,7 +67,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
 	int pbytes = VNBYTES(vid_priv->bpix);
 	void *dst;
 	void *src;
-	int j;
+	int j, ret;
 
 	dst = vid_priv->fb + vid_priv->line_length -
 		(rowdst + count) * VIDEO_FONT_HEIGHT * pbytes;
@@ -70,7 +75,10 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
 		(rowsrc + count) * VIDEO_FONT_HEIGHT * pbytes;
 
 	for (j = 0; j < vid_priv->ysize; j++) {
-		memmove(dst, src, VIDEO_FONT_HEIGHT * pbytes * count);
+		ret = vidconsole_memmove(dev, dst, src,
+					 VIDEO_FONT_HEIGHT * pbytes * count);
+		if (ret)
+			return ret;
 		src += vid_priv->line_length;
 		dst += vid_priv->line_length;
 	}
@@ -85,13 +93,14 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
 	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
 	uchar *pfont = video_fontdata + (u8)ch * VIDEO_FONT_HEIGHT;
 	int pbytes = VNBYTES(vid_priv->bpix);
-	int i, col, x, linenum;
+	int i, col, x, linenum, ret;
 	int mask = 0x80;
-	void *line;
+	void *start, *line;
 
 	linenum = VID_TO_PIXEL(x_frac) + 1;
 	x = y + 1;
-	line = vid_priv->fb + linenum * vid_priv->line_length - x * pbytes;
+	start = vid_priv->fb + linenum * vid_priv->line_length - x * pbytes;
+	line = start;
 	if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac)
 		return -EAGAIN;
 
@@ -136,6 +145,10 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
 		line += vid_priv->line_length;
 		mask >>= 1;
 	}
+	/* We draw backwards from 'start, so account for the first line */
+	ret = vidconsole_sync_copy(dev, start - vid_priv->line_length, line);
+	if (ret)
+		return ret;
 
 	return VID_TO_POS(VIDEO_FONT_WIDTH);
 }
@@ -144,12 +157,13 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
 static int console_set_row_2(struct udevice *dev, uint row, int clr)
 {
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
-	void *line;
+	void *start, *line, *end;
 	int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
-	int i;
+	int i, ret;
 
-	line = vid_priv->fb + vid_priv->ysize * vid_priv->line_length -
+	start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length -
 		(row + 1) * VIDEO_FONT_HEIGHT * vid_priv->line_length;
+	line = start;
 	switch (vid_priv->bpix) {
 	case VIDEO_BPP8:
 		if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
@@ -157,6 +171,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
 
 			for (i = 0; i < pixels; i++)
 				*dst++ = clr;
+			end = dst;
 			break;
 		}
 	case VIDEO_BPP16:
@@ -165,6 +180,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
 
 			for (i = 0; i < pixels; i++)
 				*dst++ = clr;
+			end = dst;
 			break;
 		}
 	case VIDEO_BPP32:
@@ -173,11 +189,15 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
 
 			for (i = 0; i < pixels; i++)
 				*dst++ = clr;
+			end = dst;
 			break;
 		}
 	default:
 		return -ENOSYS;
 	}
+	ret = vidconsole_sync_copy(dev, start, end);
+	if (ret)
+		return ret;
 
 	return 0;
 }
@@ -195,7 +215,8 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
 		vid_priv->line_length;
 	src = end - (rowsrc + count) * VIDEO_FONT_HEIGHT *
 		vid_priv->line_length;
-	memmove(dst, src, VIDEO_FONT_HEIGHT * vid_priv->line_length * count);
+	vidconsole_memmove(dev, dst, src,
+			   VIDEO_FONT_HEIGHT * vid_priv->line_length * count);
 
 	return 0;
 }
@@ -206,14 +227,15 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
 	struct udevice *vid = dev->parent;
 	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
 	int pbytes = VNBYTES(vid_priv->bpix);
-	int i, row, x, linenum;
-	void *line;
+	int i, row, x, linenum, ret;
+	void *start, *line;
 
 	if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac)
 		return -EAGAIN;
 	linenum = vid_priv->ysize - y - 1;
 	x = vid_priv->xsize - VID_TO_PIXEL(x_frac) - 1;
-	line = vid_priv->fb + linenum * vid_priv->line_length + x * pbytes;
+	start = vid_priv->fb + linenum * vid_priv->line_length + x * pbytes;
+	line = start;
 
 	for (row = 0; row < VIDEO_FONT_HEIGHT; row++) {
 		unsigned int idx = (u8)ch * VIDEO_FONT_HEIGHT + row;
@@ -261,6 +283,10 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
 		}
 		line -= vid_priv->line_length;
 	}
+	/* Add 4 bytes to allow for the first pixel writen */
+	ret = vidconsole_sync_copy(dev, start + 4, line);
+	if (ret)
+		return ret;
 
 	return VID_TO_POS(VIDEO_FONT_WIDTH);
 }
@@ -269,10 +295,11 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
 {
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
 	int pbytes = VNBYTES(vid_priv->bpix);
-	void *line;
-	int i, j;
+	void *start, *line;
+	int i, j, ret;
 
-	line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * pbytes;
+	start = vid_priv->fb + row * VIDEO_FONT_HEIGHT * pbytes;
+	line = start;
 	for (j = 0; j < vid_priv->ysize; j++) {
 		switch (vid_priv->bpix) {
 		case VIDEO_BPP8:
@@ -304,6 +331,9 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
 		}
 		line += vid_priv->line_length;
 	}
+	ret = vidconsole_sync_copy(dev, start, line);
+	if (ret)
+		return ret;
 
 	return 0;
 }
@@ -315,13 +345,16 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
 	int pbytes = VNBYTES(vid_priv->bpix);
 	void *dst;
 	void *src;
-	int j;
+	int j, ret;
 
 	dst = vid_priv->fb + rowdst * VIDEO_FONT_HEIGHT * pbytes;
 	src = vid_priv->fb + rowsrc * VIDEO_FONT_HEIGHT * pbytes;
 
 	for (j = 0; j < vid_priv->ysize; j++) {
-		memmove(dst, src, VIDEO_FONT_HEIGHT * pbytes * count);
+		ret = vidconsole_memmove(dev, dst, src,
+					 VIDEO_FONT_HEIGHT * pbytes * count);
+		if (ret)
+			return ret;
 		src += vid_priv->line_length;
 		dst += vid_priv->line_length;
 	}
@@ -336,15 +369,15 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
 	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
 	uchar *pfont = video_fontdata + (u8)ch * VIDEO_FONT_HEIGHT;
 	int pbytes = VNBYTES(vid_priv->bpix);
-	int i, col, x;
+	int i, col, x, ret;
 	int mask = 0x80;
-	void *line;
+	void *start, *line;
 
 	if (x_frac + VID_TO_POS(vc_priv->x_charsize) > vc_priv->xsize_frac)
 		return -EAGAIN;
 	x = vid_priv->ysize - VID_TO_PIXEL(x_frac) - 1;
-	line = vid_priv->fb + x * vid_priv->line_length + y * pbytes;
-
+	start = vid_priv->fb + x * vid_priv->line_length + y * pbytes;
+	line = start;
 	for (col = 0; col < VIDEO_FONT_HEIGHT; col++) {
 		switch (vid_priv->bpix) {
 		case VIDEO_BPP8:
@@ -386,6 +419,10 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
 		line -= vid_priv->line_length;
 		mask >>= 1;
 	}
+	/* Add a line to allow for the first pixels writen */
+	ret = vidconsole_sync_copy(dev, start + vid_priv->line_length, line);
+	if (ret)
+		return ret;
 
 	return VID_TO_POS(VIDEO_FONT_WIDTH);
 }
-- 
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 ` [PATCH v2 14/26] video: Update truetype " Simon Glass
2020-05-25  1:48 ` Simon Glass [this message]
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.15.Ieb8fa645754166cb903055967c544f29fc2cfd2c@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.