When set apply clipping logic to destination too.

Signed-off-by: Gerd Hoffmann <kra...@redhat.com>
---
 include/drm/drm_fb_helper.h        | 2 +-
 drivers/gpu/drm/drm_fb_helper.c    | 6 ++++--
 drivers/gpu/drm/tinydrm/mipi-dbi.c | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 696017b38add..a57420f40643 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -643,6 +643,6 @@ drm_fb_helper_remove_conflicting_pci_framebuffers(struct 
pci_dev *pdev,
 }
 
 void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb,
-                  struct drm_rect *clip);
+                  struct drm_rect *clip, bool dstclip);
 
 #endif
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 22d29834bbe9..fabeb408dce6 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -3363,7 +3363,7 @@ EXPORT_SYMBOL(drm_fb_helper_modinit);
  * @dstclip: Clip destination too.
  */
 void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb,
-                  struct drm_rect *clip)
+                  struct drm_rect *clip, bool dstclip)
 {
        unsigned int cpp = drm_format_plane_cpp(fb->format->format, 0);
        unsigned int pitch = fb->pitches[0];
@@ -3371,10 +3371,12 @@ void drm_fb_memcpy(void *dst, void *vaddr, struct 
drm_framebuffer *fb,
        size_t len = (clip->x2 - clip->x1) * cpp;
        unsigned int y;
 
+       if (dstclip)
+               dst += (clip->y1 * pitch) + (clip->x1 * cpp);
        for (y = clip->y1; y < clip->y2; y++) {
                memcpy(dst, src, len);
                src += pitch;
-               dst += len;
+               dst += dstclip ? pitch : len;
        }
 }
 EXPORT_SYMBOL(drm_fb_memcpy);
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c 
b/drivers/gpu/drm/tinydrm/mipi-dbi.c
index fb7e4582e293..e26fd61360a3 100644
--- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
+++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
@@ -221,7 +221,7 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
                if (swap)
                        tinydrm_swab16(dst, src, fb, clip);
                else
-                       drm_fb_memcpy(dst, src, fb, clip);
+                       drm_fb_memcpy(dst, src, fb, clip, false);
                break;
        case DRM_FORMAT_XRGB8888:
                tinydrm_xrgb8888_to_rgb565(dst, src, fb, clip, swap);
-- 
2.18.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to