Instead of marking the entire display as dirty, calculate the start
and end rows based on the damage offset and length and only mark the
affected rows dirty. This reduces unnecessary full framebuffer updates
for partial writes.

Signed-off-by: ChanSoo Shin <[email protected]>
---
 drivers/staging/fbtft/fbtft-core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-core.c 
b/drivers/staging/fbtft/fbtft-core.c
index 8a5ccc8ae0a1..1d5cb45199d0 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -415,8 +415,12 @@ static void fbtft_ops_damage_range(struct fb_info *info, 
off_t off, size_t len)
 {
        struct fbtft_par *par = info->par;
 
-       /* TODO: only mark changed area update all for now */
-       par->fbtftops.mkdirty(info, -1, 0);
+       __u32 width = info->var.xres;
+       __u32 start_row = off / width;
+       __u32 end_row = (off + len - 1) / width;
+       __u32 height = end_row - start_row + 1;
+
+       par->fbtftops.mkdirty(info, start_row, height);
 }
 
 static void fbtft_ops_damage_area(struct fb_info *info, u32 x, u32 y, u32 
width, u32 height)
-- 
2.52.0

Reply via email to