[PATCH v5 06/13] vidconsole: Add damage notifications to all vidconsole drivers
Alper Nebi Yasak
alpernebiyasak at gmail.com
Mon Aug 21 15:51:03 CEST 2023
From: Alexander Graf <agraf at 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.
Signed-off-by: Alexander Graf <agraf at csgraf.de>
Reported-by: Da Xue <da at libre.computer>
[Alper: Rebase for met->baseline, fontdata->height/width, make rotated
console_putc_xy() damages pass tests, edit patch message]
Co-developed-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
Signed-off-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
---
Changes in v5:
- Use met->baseline instead of priv->baseline
- Use fontdata->height/width instead of VIDEO_FONT_HEIGHT/WIDTH
- Update console_rotate.c video_damage() calls to pass video tests
- Remove mention about not having minimal damage for console_rotate.c
Changes in v2:
- Fix ranges in truetype target
- Limit rotate to necessary damage
drivers/video/console_normal.c | 18 +++++++++++
drivers/video/console_rotate.c | 54 ++++++++++++++++++++++++++++++++
drivers/video/console_truetype.c | 21 +++++++++++++
drivers/video/video-uclass.c | 1 +
4 files changed, 94 insertions(+)
diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
index 413c7abee9e1..a19ce6a2bc11 100644
--- a/drivers/video/console_normal.c
+++ b/drivers/video/console_normal.c
@@ -39,6 +39,12 @@ static int console_set_row(struct udevice *dev, uint row, int clr)
if (ret)
return ret;
+ video_damage(dev->parent,
+ 0,
+ fontdata->height * row,
+ vid_priv->xsize,
+ fontdata->height);
+
return 0;
}
@@ -60,6 +66,12 @@ static int console_move_rows(struct udevice *dev, uint rowdst,
if (ret)
return ret;
+ video_damage(dev->parent,
+ 0,
+ fontdata->height * rowdst,
+ vid_priv->xsize,
+ fontdata->height * count);
+
return 0;
}
@@ -90,6 +102,12 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, char ch)
if (ret)
return ret;
+ video_damage(dev->parent,
+ x,
+ y,
+ fontdata->width,
+ fontdata->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 65358a1c6e74..6c3e7c1bb8dc 100644
--- a/drivers/video/console_rotate.c
+++ b/drivers/video/console_rotate.c
@@ -36,6 +36,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) * fontdata->height),
+ 0,
+ fontdata->height,
+ vid_priv->ysize);
+
return 0;
}
@@ -64,6 +70,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) * fontdata->height),
+ 0,
+ count * fontdata->height,
+ vid_priv->ysize);
+
return 0;
}
@@ -96,6 +108,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 - fontdata->height,
+ linenum - 1,
+ fontdata->height,
+ fontdata->width);
+
return VID_TO_POS(fontdata->width);
}
@@ -121,6 +139,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) * fontdata->height,
+ vid_priv->xsize,
+ fontdata->height);
+
return 0;
}
@@ -142,6 +166,12 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc,
vidconsole_memmove(dev, dst, src,
fontdata->height * vid_priv->line_length * count);
+ video_damage(dev->parent,
+ 0,
+ vid_priv->ysize - (rowdst + count) * fontdata->height,
+ vid_priv->xsize,
+ count * fontdata->height);
+
return 0;
}
@@ -174,6 +204,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 - fontdata->width + 1,
+ linenum - fontdata->height + 1,
+ fontdata->width,
+ fontdata->height);
+
return VID_TO_POS(fontdata->width);
}
@@ -198,6 +234,12 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr)
if (ret)
return ret;
+ video_damage(dev->parent,
+ row * fontdata->height,
+ 0,
+ fontdata->height,
+ vid_priv->ysize);
+
return 0;
}
@@ -224,6 +266,12 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc,
dst += vid_priv->line_length;
}
+ video_damage(dev->parent,
+ rowdst * fontdata->height,
+ 0,
+ count * fontdata->height,
+ vid_priv->ysize);
+
return 0;
}
@@ -255,6 +303,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,
+ linenum - fontdata->width + 1,
+ fontdata->height,
+ fontdata->width);
+
return VID_TO_POS(fontdata->width);
}
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 0f9bb49e44f7..0adbf9cc3d67 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -178,6 +178,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;
@@ -221,6 +222,12 @@ 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;
}
@@ -228,6 +235,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;
@@ -246,6 +254,12 @@ 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;
}
@@ -403,6 +417,13 @@ 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 + met->baseline + yoff,
+ width,
+ height);
+
ret = vidconsole_sync_copy(dev, start, line);
if (ret)
return ret;
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index ebf409d839f0..8bfcbc88dda7 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -199,6 +199,7 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend,
}
line += priv->line_length;
}
+
ret = video_sync_copy(dev, start, line);
if (ret)
return ret;
--
2.40.1
More information about the U-Boot
mailing list