[PATCH 2/3] video: fbconsole: add optional damage tracking
Philipp Zabel
p.zabel at pengutronix.de
Mon Apr 3 05:18:43 PDT 2023
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 at 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
More information about the barebox
mailing list