13 #include <linux/module.h>
14 #include <linux/string.h>
16 #include <asm/types.h>
21 #define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__func__,## args)
23 #define DPRINTK(fmt, args...)
26 static const u32 cfb_tab8_be[] = {
27 0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
28 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
29 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,
30 0xffff0000,0xffff00ff,0xffffff00,0xffffffff
33 static const u32 cfb_tab8_le[] = {
34 0x00000000,0xff000000,0x00ff0000,0xffff0000,
35 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,
36 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,
37 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff
40 static const u32 cfb_tab16_be[] = {
41 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
44 static const u32 cfb_tab16_le[] = {
45 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
48 static const u32 cfb_tab32[] = {
49 0x00000000, 0xffffffff
53 void *dst1,
u32 start_index,
u32 pitch_index)
58 int i,
n,
bpp = p->
var.bits_per_pixel;
73 val = *dst & start_mask;
79 color = palette[*
src];
84 if (shift >= null_bits) {
87 val = (shift == null_bits) ? 0 :
100 dst1 += p->
fix.line_length;
102 dst2 += p->
fix.line_length;
103 dst1 = (
u8 *)((
long)dst2 & ~(
sizeof(
u32) - 1));
105 start_index += pitch_index;
106 start_index &= 32 - 1;
111 static void slow_imageblit(
const struct fb_image *image,
struct fb_info *p,
112 void *dst1,
u32 fgcolor,
u32 bgcolor,
113 u32 start_index,
u32 pitch_index)
115 u32 shift, color = 0, bpp = p->
var.bits_per_pixel;
127 for (i = image->
height; i--; ) {
138 val = *dst & start_mask;
144 color = (*
s & (1 <<
l)) ? fgcolor : bgcolor;
148 if (shift >= null_bits) {
150 val = (shift == null_bits) ? 0 :
155 if (!l) { l = 8;
s++; };
170 dst1 = (
u8 *)((
long)dst2 & ~(
sizeof(
u32) - 1));
171 start_index += pitch_index;
172 start_index &= 32 - 1;
186 static void fast_imageblit(
const struct fb_image *image,
struct fb_info *p,
187 void *dst1,
u32 fgcolor,
u32 bgcolor)
189 u32 fgx = fgcolor, bgx = bgcolor, bpp = p->
var.bits_per_pixel;
191 u32 bit_mask, end_mask, eorx, shift;
199 tab = fb_be_math(p) ? cfb_tab8_be : cfb_tab8_le;
202 tab = fb_be_math(p) ? cfb_tab16_be : cfb_tab16_le;
210 for (i = ppw-1; i--; ) {
217 bit_mask = (1 << ppw) - 1;
219 k = image->
width/ppw;
221 for (i = image->
height; i--; ) {
228 end_mask = tab[(*src >> shift) & bit_mask];
229 *dst++ = (end_mask & eorx) ^ bgx;
235 dst1 += p->
fix.line_length;
242 u32 fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
243 u32 bpl =
sizeof(
u32), bpp = p->
var.bits_per_pixel;
245 u32 dx = image->
dx, dy = image->
dy;
251 bitstart = (dy * p->
fix.line_length * 8) + (dx * bpp);
252 start_index = bitstart & (32 - 1);
253 pitch_index = (p->
fix.line_length & (bpl - 1)) * 8;
256 bitstart &= ~(bpl - 1);
260 p->
fbops->fb_sync(p);
262 if (image->
depth == 1) {
272 if (32 % bpp == 0 && !start_index && !pitch_index &&
273 ((
width & (32/bpp-1)) == 0) &&
274 bpp >= 8 && bpp <= 32)
275 fast_imageblit(image, p, dst1, fgcolor, bgcolor);
277 slow_imageblit(image, p, dst1, fgcolor, bgcolor,
278 start_index, pitch_index);
280 color_imageblit(image, p, dst1, start_index, pitch_index);