All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@csgraf.de>
To: u-boot@lists.denx.de
Cc: Matthias Brugger <mbrugger@suse.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Anatolij Gustschin <agust@denx.de>,
	Simon Glass <sjg@chromium.org>, Da Xue <da@libre.computer>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Kever Yang <kever.yang@rock-chips.com>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	uboot-stm32@st-md-mailman.stormreply.com,
	u-boot-amlogic@groups.io
Subject: [PATCH v4 3/9] vidconsole: Add damage notifications to all vidconsole drivers
Date: Tue,  3 Jan 2023 22:49:58 +0100	[thread overview]
Message-ID: <20230103215004.22646-4-agraf@csgraf.de> (raw)
In-Reply-To: <20230103215004.22646-1-agraf@csgraf.de>

Now that we have a damage tracking API, let's populate damage done by
vidconsole drivers. We try to declare as little memory as damaged as
possible, with the exception of rotated screens that I couldn't get my
head wrapped around. On those, we revert to the old behavior and mark
the full screen as damaged on every update.

Signed-off-by: Alexander Graf <agraf@csgraf.de>
Reported-by: Da Xue <da@libre.computer>

---

v1 -> v2:

  - Fix ranges in truetype target
  - Limit rotate to necessary damange
---
 drivers/video/console_normal.c   | 10 ++++++
 drivers/video/console_rotate.c   | 54 ++++++++++++++++++++++++++++++++
 drivers/video/console_truetype.c | 15 +++++++++
 3 files changed, 79 insertions(+)

diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
index 04f022491e..5b5586fd3e 100644
--- a/drivers/video/console_normal.c
+++ b/drivers/video/console_normal.c
@@ -57,6 +57,9 @@ static int console_normal_set_row(struct udevice *dev, uint row, int clr)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent, 0, VIDEO_FONT_HEIGHT * row, vid_priv->xsize,
+		     VIDEO_FONT_HEIGHT);
+
 	return 0;
 }
 
@@ -76,6 +79,9 @@ static int console_normal_move_rows(struct udevice *dev, uint rowdst,
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent, 0, VIDEO_FONT_HEIGHT * rowdst, vid_priv->xsize,
+		     VIDEO_FONT_HEIGHT * count);
+
 	return 0;
 }
 
@@ -143,6 +149,10 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y,
 		}
 		line += vid_priv->line_length;
 	}
+
+	video_damage(dev->parent, VID_TO_PIXEL(x_frac), y, VIDEO_FONT_WIDTH,
+		     VIDEO_FONT_HEIGHT);
+
 	ret = vidconsole_sync_copy(dev, start, line);
 	if (ret)
 		return ret;
diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
index 36c8d0609d..56e20bb4f3 100644
--- a/drivers/video/console_rotate.c
+++ b/drivers/video/console_rotate.c
@@ -57,6 +57,12 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent,
+		     vid_priv->xsize - ((row + 1) * VIDEO_FONT_HEIGHT),
+		     0,
+		     VIDEO_FONT_HEIGHT,
+		     vid_priv->ysize);
+
 	return 0;
 }
 
@@ -83,6 +89,12 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc,
 		dst += vid_priv->line_length;
 	}
 
+	video_damage(dev->parent,
+		     vid_priv->xsize - ((rowdst + count) * VIDEO_FONT_HEIGHT),
+		     0,
+		     count * VIDEO_FONT_HEIGHT,
+		     vid_priv->ysize);
+
 	return 0;
 }
 
@@ -150,6 +162,12 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, char ch)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent,
+		     vid_priv->xsize - y - VIDEO_FONT_HEIGHT - 1,
+		     linenum - 1,
+		     VIDEO_FONT_HEIGHT,
+		     VIDEO_FONT_WIDTH);
+
 	return VID_TO_POS(VIDEO_FONT_WIDTH);
 }
 
@@ -199,6 +217,12 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent,
+		     0,
+		     vid_priv->ysize - (row + 1) * VIDEO_FONT_HEIGHT,
+		     vid_priv->xsize,
+		     VIDEO_FONT_HEIGHT);
+
 	return 0;
 }
 
@@ -218,6 +242,12 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
 	vidconsole_memmove(dev, dst, src,
 			   VIDEO_FONT_HEIGHT * vid_priv->line_length * count);
 
+	video_damage(dev->parent,
+		     0,
+		     vid_priv->ysize - (rowdst + count) * VIDEO_FONT_HEIGHT,
+		     vid_priv->xsize,
+		     count * VIDEO_FONT_HEIGHT);
+
 	return 0;
 }
 
@@ -288,6 +318,12 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, char ch)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent,
+		     x - VIDEO_FONT_WIDTH,
+		     linenum - VIDEO_FONT_HEIGHT + 1,
+		     VIDEO_FONT_WIDTH,
+		     VIDEO_FONT_HEIGHT);
+
 	return VID_TO_POS(VIDEO_FONT_WIDTH);
 }
 
@@ -335,6 +371,12 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent,
+		     row * VIDEO_FONT_HEIGHT,
+		     0,
+		     VIDEO_FONT_HEIGHT,
+		     vid_priv->ysize);
+
 	return 0;
 }
 
@@ -359,6 +401,12 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
 		dst += vid_priv->line_length;
 	}
 
+	video_damage(dev->parent,
+		     rowdst * VIDEO_FONT_HEIGHT,
+		     0,
+		     count * VIDEO_FONT_HEIGHT,
+		     vid_priv->ysize);
+
 	return 0;
 }
 
@@ -424,6 +472,12 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, char ch)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent,
+		     y,
+		     x - VIDEO_FONT_WIDTH + 1,
+		     VIDEO_FONT_HEIGHT,
+		     VIDEO_FONT_WIDTH);
+
 	return VID_TO_POS(VIDEO_FONT_WIDTH);
 }
 
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 6859c9fa11..3fc6e24485 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -145,6 +145,7 @@ struct console_tt_priv {
 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 vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
 	struct console_tt_priv *priv = dev_get_priv(dev);
 	struct console_tt_metrics *met = priv->cur_met;
 	void *end, *line;
@@ -188,6 +189,9 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr)
 	if (ret)
 		return ret;
 
+	video_damage(dev->parent, 0, vc_priv->y_charsize * row, vid_priv->xsize,
+		     vc_priv->y_charsize);
+
 	return 0;
 }
 
@@ -195,6 +199,7 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst,
 				     uint rowsrc, uint count)
 {
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+	struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
 	struct console_tt_priv *priv = dev_get_priv(dev);
 	struct console_tt_metrics *met = priv->cur_met;
 	void *dst;
@@ -213,6 +218,9 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst,
 	for (i = 0; i < priv->pos_ptr; i++)
 		priv->pos[i].ypos -= diff;
 
+	video_damage(dev->parent, 0, vc_priv->y_charsize * rowdst, vid_priv->xsize,
+		     vc_priv->y_charsize * count);
+
 	return 0;
 }
 
@@ -370,6 +378,10 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 
 		line += vid_priv->line_length;
 	}
+
+	video_damage(dev->parent, VID_TO_PIXEL(x) + xoff,
+		     y + priv->baseline + yoff, width, height);
+
 	ret = vidconsole_sync_copy(dev, start, line);
 	if (ret)
 		return ret;
@@ -437,6 +449,9 @@ static int console_truetype_erase(struct udevice *dev, int xstart, int ystart,
 		}
 		line += vid_priv->line_length;
 	}
+
+	video_damage(dev->parent, xstart, ystart, xend - xstart, yend - ystart);
+
 	ret = vidconsole_sync_copy(dev, start, line);
 	if (ret)
 		return ret;
-- 
2.37.1 (Apple Git-137.1)


  parent reply	other threads:[~2023-01-03 21:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 21:49 [PATCH v4 0/9] Add video damage tracking Alexander Graf
2023-01-03 21:49 ` [PATCH v4 1/9] dm: video: Add damage tracking API Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:49 ` [PATCH v4 2/9] dm: video: Add damage notification on display clear Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:49 ` Alexander Graf [this message]
2023-01-07  0:13   ` [PATCH v4 3/9] vidconsole: Add damage notifications to all vidconsole drivers Simon Glass
2023-01-03 21:49 ` [PATCH v4 4/9] video: Add damage notification on bmp display Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 5/9] efi_loader: GOP: Add damage notification on BLT Alexander Graf
2023-01-04 12:50   ` Heinrich Schuchardt
2023-01-03 21:50 ` [PATCH v4 6/9] video: Only dcache flush damaged lines Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 7/9] video: Use VIDEO_DAMAGE for VIDEO_COPY Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-07 22:40     ` Heinrich Schuchardt
2023-01-08 15:48       ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 8/9] video: Always compile cache flushing code Alexander Graf
2023-01-07  0:13   ` Simon Glass
2023-01-03 21:50 ` [PATCH v4 9/9] video: Enable VIDEO_DAMAGE for drivers that need it Alexander Graf
2023-01-04 12:32   ` Neil Armstrong
2023-01-07  0:13   ` Simon Glass
2023-01-07  0:13 ` [PATCH v4 0/9] Add video damage tracking Simon Glass
2023-04-14  7:35 ` Antonio Murdaca
2023-04-19  1:45   ` 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=20230103215004.22646-4-agraf@csgraf.de \
    --to=agraf@csgraf.de \
    --cc=agust@denx.de \
    --cc=andre.przywara@arm.com \
    --cc=da@libre.computer \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jagan@amarulasolutions.com \
    --cc=kever.yang@rock-chips.com \
    --cc=mbrugger@suse.com \
    --cc=neil.armstrong@linaro.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=u-boot-amlogic@groups.io \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-stm32@st-md-mailman.stormreply.com \
    --cc=xypron.glpk@gmx.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.