Message ID | 20190404152430.8263-5-kraxel@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/cirrus: rewrite and modernize driver. | expand |
On Thu, Apr 04, 2019 at 05:24:28PM +0200, Gerd Hoffmann wrote: > When set apply clipping logic to destination too. > > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > include/drm/drm_fb_helper.h | 3 ++- > drivers/gpu/drm/drm_fb_helper.c | 8 +++++++- > drivers/gpu/drm/tinydrm/mipi-dbi.c | 2 +- > 3 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h > index 0350c7e9d6ba..1406057e1a93 100644 > --- a/include/drm/drm_fb_helper.h > +++ b/include/drm/drm_fb_helper.h > @@ -646,6 +646,7 @@ void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, > struct drm_rect *clip, bool dstclip); > void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, > struct drm_framebuffer *fb, > - struct drm_rect *clip, bool swap); > + struct drm_rect *clip, > + bool swap, bool dstclip); > > #endif > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > index 087e49741094..2c9286702c3f 100644 > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -3388,13 +3388,15 @@ EXPORT_SYMBOL(drm_fb_memcpy); > * @fb: DRM framebuffer > * @clip: Clip rectangle area to copy > * @swap: Swap bytes > + * @dstclip: Clip destination too. > * > * Drivers can use this function for RGB565 devices that don't natively > * support XRGB8888. > */ > void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, > struct drm_framebuffer *fb, > - struct drm_rect *clip, bool swap) > + struct drm_rect *clip, > + bool swap, bool dstclip) > { > size_t len = (clip->x2 - clip->x1) * sizeof(u32); > unsigned int x, y; > @@ -3405,6 +3407,8 @@ void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, > if (!buf) > return; > > + if (dstclip) > + dst += clip->y1 * fb->width + clip->x1; > for (y = clip->y1; y < clip->y2; y++) { > src = vaddr + (y * fb->pitches[0]); > src += clip->x1; > @@ -3420,6 +3424,8 @@ void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, > else > *dst++ = val16; > } > + if (dstclip) > + dst += fb->width - (clip->x2 - clip->x1); > } Same story as before with dstclip and boolean parameters to functions. A small helper and you had two functions with and without clip. Sam
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 0350c7e9d6ba..1406057e1a93 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -646,6 +646,7 @@ void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip, bool dstclip); void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, struct drm_framebuffer *fb, - struct drm_rect *clip, bool swap); + struct drm_rect *clip, + bool swap, bool dstclip); #endif diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 087e49741094..2c9286702c3f 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -3388,13 +3388,15 @@ EXPORT_SYMBOL(drm_fb_memcpy); * @fb: DRM framebuffer * @clip: Clip rectangle area to copy * @swap: Swap bytes + * @dstclip: Clip destination too. * * Drivers can use this function for RGB565 devices that don't natively * support XRGB8888. */ void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, struct drm_framebuffer *fb, - struct drm_rect *clip, bool swap) + struct drm_rect *clip, + bool swap, bool dstclip) { size_t len = (clip->x2 - clip->x1) * sizeof(u32); unsigned int x, y; @@ -3405,6 +3407,8 @@ void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, if (!buf) return; + if (dstclip) + dst += clip->y1 * fb->width + clip->x1; for (y = clip->y1; y < clip->y2; y++) { src = vaddr + (y * fb->pitches[0]); src += clip->x1; @@ -3420,6 +3424,8 @@ void drm_fb_xrgb8888_to_rgb565(u16 *dst, void *vaddr, else *dst++ = val16; } + if (dstclip) + dst += fb->width - (clip->x2 - clip->x1); } kfree(buf); diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c index cf8df5fb7494..b2d74f8707db 100644 --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c @@ -224,7 +224,7 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, drm_fb_memcpy(dst, src, fb, clip, false); break; case DRM_FORMAT_XRGB8888: - drm_fb_xrgb8888_to_rgb565(dst, src, fb, clip, swap); + drm_fb_xrgb8888_to_rgb565(dst, src, fb, clip, swap, false); break; default: dev_err_once(fb->dev->dev, "Format is not supported: %s\n",
When set apply clipping logic to destination too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> --- include/drm/drm_fb_helper.h | 3 ++- drivers/gpu/drm/drm_fb_helper.c | 8 +++++++- drivers/gpu/drm/tinydrm/mipi-dbi.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-)