Re: [PATCH v2] fbdev: fix fillrect for 24bpp modes

Andrew Morton
2009-04-20T23:19:56Z

On Sat, 18 Apr 2009 20:52:34 +0200
Michal Januszewski <spock@gentoo.org> wrote:

> while (height--) {
> - dst += dst_idx >> (ffs(bits) - 1);
> + dst += dst_idx / bits;
> dst_idx &= (bits - 1);
> - fill_op(p, dst, dst_idx, pat, left, right,
> + r = dst_idx % bpp;
> + /* rotate pattern to the correct start position */
> +#ifdef __LITTLE_ENDIAN
> + pat2 = pat << r | pat >> (bpp-r);
> +#else
> + pat2 = pat << (bpp-r) | pat >> r;
> +#endif
> + fill_op(p, dst, dst_idx, pat2, left, right,
> width*bpp, bits);
> - r = (p->fix.line_length*8) % bpp;
> - pat = pat << (bpp-r) | pat >> r;
> dst_idx += p->fix.line_length*8;

hm, that's fairly eye-popping.

Could we do something like

pat2 = le32_to_cpu(rol32(cpu_to_le32(pat), r));

(might be wrong, but you see what I mean...)