summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/drm_fb_helper.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2022-02-09 17:16:17 +0100
committerThomas Zimmermann <tzimmermann@suse.de>2022-02-10 14:49:31 +0100
commitded74cafeea9311c1eaf6fccce963de2516145f7 (patch)
treef67989ea4114dfcd02ce2aaf14631f7910fb2299 /drivers/gpu/drm/drm_fb_helper.c
parentfe23b56f56532dcc5e49e83e20333b97919dec53 (diff)
downloadlinux-ded74cafeea9311c1eaf6fccce963de2516145f7.tar.gz
linux-ded74cafeea9311c1eaf6fccce963de2516145f7.tar.bz2
linux-ded74cafeea9311c1eaf6fccce963de2516145f7.zip
drm/fb-helper: Clip damage area horizontally
Clip the damage area horizontally if only a single scanline has been changed. This is helpful to reduce the memcpy overhead for small writes. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220209161617.3553-6-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/drm_fb_helper.c')
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 4d5410dd96c5..e05a7bd6fb12 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -690,6 +690,18 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off,
u32 x2 = info->var.xres;
u32 y2 = DIV_ROUND_UP(end, info->fix.line_length);
+ if ((y2 - y1) == 1) {
+ /*
+ * We've only written to a single scanline. Try to reduce
+ * the number of horizontal pixels that need an update.
+ */
+ off_t bit_off = (off % info->fix.line_length) * 8;
+ off_t bit_end = (end % info->fix.line_length) * 8;
+
+ x1 = bit_off / info->var.bits_per_pixel;
+ x2 = DIV_ROUND_UP(bit_end, info->var.bits_per_pixel);
+ }
+
drm_rect_init(clip, x1, y1, x2 - x1, y2 - y1);
}