Commit 2a81dba4 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Dave Airlie

fbdev: Fix cfb_imageblit() for arbitrary image widths

Commit 0d030118 ("fbdev: Improve performance of cfb_imageblit()")
broke cfb_imageblit() for image widths that are not aligned to 8-bit
boundaries. Fix this by handling the trailing pixels on each line
separately. The performance improvements in the original commit do not
regress by this change.
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Fixes: 0d030118 ("fbdev: Improve performance of cfb_imageblit()")
Reported-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220313192952.12058-3-tzimmermann@suse.de
parent 40faaf80
...@@ -218,7 +218,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info * ...@@ -218,7 +218,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
{ {
u32 fgx = fgcolor, bgx = bgcolor, bpp = p->var.bits_per_pixel; u32 fgx = fgcolor, bgx = bgcolor, bpp = p->var.bits_per_pixel;
u32 ppw = 32/bpp, spitch = (image->width + 7)/8; u32 ppw = 32/bpp, spitch = (image->width + 7)/8;
u32 bit_mask, eorx; u32 bit_mask, eorx, shift;
const char *s = image->data, *src; const char *s = image->data, *src;
u32 __iomem *dst; u32 __iomem *dst;
const u32 *tab = NULL; const u32 *tab = NULL;
...@@ -259,17 +259,23 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info * ...@@ -259,17 +259,23 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
for (i = image->height; i--; ) { for (i = image->height; i--; ) {
dst = (u32 __iomem *)dst1; dst = (u32 __iomem *)dst1;
shift = 8;
src = s; src = s;
/*
* Manually unroll the per-line copying loop for better
* performance. This works until we processed the last
* completely filled source byte (inclusive).
*/
switch (ppw) { switch (ppw) {
case 4: /* 8 bpp */ case 4: /* 8 bpp */
for (j = k; j; j -= 2, ++src) { for (j = k; j >= 2; j -= 2, ++src) {
FB_WRITEL(colortab[(*src >> 4) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 4) & bit_mask], dst++);
FB_WRITEL(colortab[(*src >> 0) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 0) & bit_mask], dst++);
} }
break; break;
case 2: /* 16 bpp */ case 2: /* 16 bpp */
for (j = k; j; j -= 4, ++src) { for (j = k; j >= 4; j -= 4, ++src) {
FB_WRITEL(colortab[(*src >> 6) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 6) & bit_mask], dst++);
FB_WRITEL(colortab[(*src >> 4) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 4) & bit_mask], dst++);
FB_WRITEL(colortab[(*src >> 2) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 2) & bit_mask], dst++);
...@@ -277,7 +283,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info * ...@@ -277,7 +283,7 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
} }
break; break;
case 1: /* 32 bpp */ case 1: /* 32 bpp */
for (j = k; j; j -= 8, ++src) { for (j = k; j >= 8; j -= 8, ++src) {
FB_WRITEL(colortab[(*src >> 7) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 7) & bit_mask], dst++);
FB_WRITEL(colortab[(*src >> 6) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 6) & bit_mask], dst++);
FB_WRITEL(colortab[(*src >> 5) & bit_mask], dst++); FB_WRITEL(colortab[(*src >> 5) & bit_mask], dst++);
...@@ -290,6 +296,20 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info * ...@@ -290,6 +296,20 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
break; break;
} }
/*
* For image widths that are not a multiple of 8, there
* are trailing pixels left on the current line. Print
* them as well.
*/
for (; j--; ) {
shift -= ppw;
FB_WRITEL(colortab[(*src >> shift) & bit_mask], dst++);
if (!shift) {
shift = 8;
++src;
}
}
dst1 += p->fix.line_length; dst1 += p->fix.line_length;
s += spitch; s += spitch;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment