Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/format-helper: Pass destination pitch to drm_fb_memcpy_dstclip()

The memcpy's destination buffer might have a different pitch than the
source. Support different pitches as function argument.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: nerdopolis <bluescreen_avenger@verizon.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20210430105840.30515-2-tzimmermann@suse.de

+8 -7
+5 -4
drivers/gpu/drm/drm_format_helper.c
··· 52 52 /** 53 53 * drm_fb_memcpy_dstclip - Copy clip buffer 54 54 * @dst: Destination buffer (iomem) 55 + * @dst_pitch: Number of bytes between two consecutive scanlines within dst 55 56 * @vaddr: Source buffer 56 57 * @fb: DRM framebuffer 57 58 * @clip: Clip rectangle area to copy ··· 60 59 * This function applies clipping on dst, i.e. the destination is a 61 60 * full (iomem) framebuffer but only the clip rect content is copied over. 62 61 */ 63 - void drm_fb_memcpy_dstclip(void __iomem *dst, void *vaddr, 64 - struct drm_framebuffer *fb, 62 + void drm_fb_memcpy_dstclip(void __iomem *dst, unsigned int dst_pitch, 63 + void *vaddr, struct drm_framebuffer *fb, 65 64 struct drm_rect *clip) 66 65 { 67 66 unsigned int cpp = fb->format->cpp[0]; 68 - unsigned int offset = clip_offset(clip, fb->pitches[0], cpp); 67 + unsigned int offset = clip_offset(clip, dst_pitch, cpp); 69 68 size_t len = (clip->x2 - clip->x1) * cpp; 70 69 unsigned int y, lines = clip->y2 - clip->y1; 71 70 ··· 74 73 for (y = 0; y < lines; y++) { 75 74 memcpy_toio(dst, vaddr, len); 76 75 vaddr += fb->pitches[0]; 77 - dst += fb->pitches[0]; 76 + dst += dst_pitch; 78 77 } 79 78 } 80 79 EXPORT_SYMBOL(drm_fb_memcpy_dstclip);
+1 -1
drivers/gpu/drm/mgag200/mgag200_mode.c
··· 1554 1554 { 1555 1555 void *vmap = map->vaddr; /* TODO: Use mapping abstraction properly */ 1556 1556 1557 - drm_fb_memcpy_dstclip(mdev->vram, vmap, fb, clip); 1557 + drm_fb_memcpy_dstclip(mdev->vram, fb->pitches[0], vmap, fb, clip); 1558 1558 1559 1559 /* Always scanout image at VRAM offset 0 */ 1560 1560 mgag200_set_startadd(mdev, (u32)0);
+1 -1
drivers/gpu/drm/tiny/cirrus.c
··· 324 324 return -ENODEV; 325 325 326 326 if (cirrus->cpp == fb->format->cpp[0]) 327 - drm_fb_memcpy_dstclip(cirrus->vram, 327 + drm_fb_memcpy_dstclip(cirrus->vram, fb->pitches[0], 328 328 vmap, fb, rect); 329 329 330 330 else if (fb->format->cpp[0] == 4 && cirrus->cpp == 2)
+1 -1
include/drm/drm_format_helper.h
··· 11 11 12 12 void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, 13 13 struct drm_rect *clip); 14 - void drm_fb_memcpy_dstclip(void __iomem *dst, void *vaddr, 14 + void drm_fb_memcpy_dstclip(void __iomem *dst, unsigned int dst_pitch, void *vaddr, 15 15 struct drm_framebuffer *fb, 16 16 struct drm_rect *clip); 17 17 void drm_fb_swab(void *dst, void *src, struct drm_framebuffer *fb,