mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] video: fbconsole: add optional damage tracking
Date: Mon,  3 Apr 2023 14:18:43 +0200	[thread overview]
Message-ID: <20230403121844.3447836-2-p.zabel@pengutronix.de> (raw)
In-Reply-To: <20230403121844.3447836-1-p.zabel@pengutronix.de>

Annotate framebuffer updates with damage rectangles so drivers may
implement partial updates for displays with an integrated framebuffer.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/video/fbconsole.c | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
index 070378aa2352..25d7ea685ff6 100644
--- a/drivers/video/fbconsole.c
+++ b/drivers/video/fbconsole.c
@@ -18,6 +18,7 @@ enum state_t {
 struct fbc_priv {
 	struct console_device cdev;
 	struct fb_info *fb;
+	struct fb_rect rect;
 
 	struct screen *sc;
 
@@ -60,9 +61,11 @@ static int fbc_tstc(struct console_device *cdev)
 static void cls(struct fbc_priv *priv)
 {
 	void *buf = gui_screen_render_buffer(priv->sc);
+	struct fb_info *fb = priv->fb;
 
 	memset(buf, 0, priv->fb->line_length * priv->fb->yres);
 	gu_screen_blit(priv->sc);
+	fb_damage(fb, &priv->rect);
 }
 
 struct rgb {
@@ -139,13 +142,20 @@ static void drawchar(struct fbc_priv *priv, int x, int y, int c)
 static void video_invertchar(struct fbc_priv *priv, int x, int y)
 {
 	void *buf;
+	struct fb_rect rect;
+
+	rect.x1 = x * priv->font->width;
+	rect.y1 = y * priv->font->height;
+	rect.x2 = rect.x1 + priv->font->width;
+	rect.y2 = rect.y1 + priv->font->height;
 
 	buf = gui_screen_render_buffer(priv->sc);
 
-	gu_invert_area(priv->fb, buf, x * priv->font->width, y * priv->font->height,
+	gu_invert_area(priv->fb, buf, rect.x1, rect.y1,
 			priv->font->width, priv->font->height);
-	gu_screen_blit_area(priv->sc, x * priv->font->width, y * priv->font->height,
+	gu_screen_blit_area(priv->sc, rect.x1, rect.y1,
 			priv->font->width, priv->font->height);
+	fb_damage(priv->fb, &rect);
 }
 
 static void show_cursor(struct fbc_priv *priv, int x, int y)
@@ -156,6 +166,9 @@ static void show_cursor(struct fbc_priv *priv, int x, int y)
 
 static void printchar(struct fbc_priv *priv, int c)
 {
+	struct fb_info *fb = priv->fb;
+	struct fb_rect rect;
+
 	video_invertchar(priv, priv->x, priv->y);
 
 	switch (c) {
@@ -185,9 +198,14 @@ static void printchar(struct fbc_priv *priv, int c)
 	default:
 		drawchar(priv, priv->x, priv->y, c);
 
-		gu_screen_blit_area(priv->sc, priv->x * priv->font->width,
-				priv->y * priv->font->height,
+		rect.x1 = priv->x * priv->font->width;
+		rect.y1 = priv->y * priv->font->height;
+		rect.x2 =  rect.x1 + priv->font->width;
+		rect.y2 =  rect.y1 + priv->font->height;
+
+		gu_screen_blit_area(priv->sc, rect.x1, rect.y1,
 				priv->font->width, priv->font->height);
+		fb_damage(fb, &rect);
 
 		priv->x++;
 		if (priv->x > priv->cols) {
@@ -207,6 +225,7 @@ static void printchar(struct fbc_priv *priv, int c)
 		memset(buf + line_height * priv->rows, 0, line_height);
 
 		gu_screen_blit(priv->sc);
+		fb_damage(fb, &priv->rect);
 		priv->y = priv->rows;
 	}
 
@@ -508,6 +527,11 @@ int register_fbconsole(struct fb_info *fb)
 			set_font, NULL,
 			&priv->par_font_val, priv);
 
+	priv->rect.x1 = 0;
+	priv->rect.y1 = 0;
+	priv->rect.x2 = fb->xres;
+	priv->rect.y2 = fb->yres;
+
 	pr_info("registered as %s%d\n", cdev->class_dev.name, cdev->class_dev.id);
 
 	return 0;
-- 
2.39.2




  reply	other threads:[~2023-04-03 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 12:18 [PATCH 1/3] video: fb: " Philipp Zabel
2023-04-03 12:18 ` Philipp Zabel [this message]
2023-04-05 11:13   ` [PATCH 2/3] video: fbconsole: " Sascha Hauer
2023-04-05 12:27     ` Philipp Zabel
2023-04-03 12:18 ` [PATCH 3/3] video: mipi_dbi: add damage tracking and partial updates Philipp Zabel
2023-04-04 12:24 ` [PATCH 1/3] video: fb: add optional damage tracking Ahmad Fatoum
2023-04-05 12:26   ` Philipp Zabel

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=20230403121844.3447836-2-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox