32 #include <linux/module.h>
33 #include <linux/string.h>
35 #include <asm/types.h>
41 #define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__func__,## args)
43 #define DPRINTK(fmt, args...)
46 static const u32 cfb_tab8_be[] = {
47 0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
48 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
49 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,
50 0xffff0000,0xffff00ff,0xffffff00,0xffffffff
53 static const u32 cfb_tab8_le[] = {
54 0x00000000,0xff000000,0x00ff0000,0xffff0000,
55 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,
56 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,
57 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff
60 static const u32 cfb_tab16_be[] = {
61 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
64 static const u32 cfb_tab16_le[] = {
65 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
68 static const u32 cfb_tab32[] = {
69 0x00000000, 0xffffffff
72 #define FB_WRITEL fb_writel
73 #define FB_READL fb_readl
75 static inline void color_imageblit(
const struct fb_image *
image,
83 int i,
n,
bpp = p->
var.bits_per_pixel;
90 for (i = image->
height; i--; ) {
98 start_index, bswapmask);
105 color = palette[*
src];
110 if (shift >= null_bits) {
113 val = (shift == null_bits) ? 0 :
126 dst1 += p->
fix.line_length;
128 dst2 += p->
fix.line_length;
131 start_index += pitch_index;
132 start_index &= 32 - 1;
156 for (i = image->
height; i--; ) {
166 start_index, bswapmask);
173 color = (*
s & (1 <<
l)) ? fgcolor : bgcolor;
177 if (shift >= null_bits) {
179 val = (shift == null_bits) ? 0 :
184 if (!l) { l = 8;
s++; };
200 start_index += pitch_index;
201 start_index &= 32 - 1;
215 static inline void fast_imageblit(
const struct fb_image *image,
struct fb_info *p,
219 u32 fgx = fgcolor, bgx = bgcolor,
bpp = p->
var.bits_per_pixel;
221 u32 bit_mask, end_mask, eorx, shift;
229 tab = fb_be_math(p) ? cfb_tab8_be : cfb_tab8_le;
232 tab = fb_be_math(p) ? cfb_tab16_be : cfb_tab16_le;
240 for (i = ppw-1; i--; ) {
247 bit_mask = (1 << ppw) - 1;
249 k = image->
width/ppw;
251 for (i = image->
height; i--; ) {
256 end_mask = tab[(*src >> shift) & bit_mask];
258 if (!shift) { shift = 8; src++; }
260 dst1 += p->
fix.line_length;
267 u32 fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
268 u32 bpl =
sizeof(
u32), bpp = p->
var.bits_per_pixel;
270 u32 dx = image->
dx, dy = image->
dy;
276 bitstart = (dy * p->
fix.line_length * 8) + (dx * bpp);
277 start_index = bitstart & (32 - 1);
278 pitch_index = (p->
fix.line_length & (bpl - 1)) * 8;
281 bitstart &= ~(bpl - 1);
284 if (p->
fbops->fb_sync)
285 p->
fbops->fb_sync(p);
287 if (image->
depth == 1) {
297 if (32 % bpp == 0 && !start_index && !pitch_index &&
298 ((
width & (32/bpp-1)) == 0) &&
299 bpp >= 8 && bpp <= 32)
300 fast_imageblit(image, p, dst1, fgcolor, bgcolor);
302 slow_imageblit(image, p, dst1, fgcolor, bgcolor,
303 start_index, pitch_index);
305 color_imageblit(image, p, dst1, start_index, pitch_index);