aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/cfbfillrect.c36
-rw-r--r--drivers/video/fb_draw.h21
-rw-r--r--drivers/video/sysfillrect.c30
3 files changed, 48 insertions, 39 deletions
diff --git a/drivers/video/cfbfillrect.c b/drivers/video/cfbfillrect.c
index 64b35766b2a2..ba9f58b2a5e8 100644
--- a/drivers/video/cfbfillrect.c
+++ b/drivers/video/cfbfillrect.c
@@ -9,10 +9,6 @@
9 * 9 *
10 * NOTES: 10 * NOTES:
11 * 11 *
12 * The code for depths like 24 that don't have integer number of pixels per
13 * long is broken and needs to be fixed. For now I turned these types of
14 * mode off.
15 *
16 * Also need to add code to deal with cards endians that are different than 12 * Also need to add code to deal with cards endians that are different than
17 * the native cpu endians. I also need to deal with MSB position in the word. 13 * the native cpu endians. I also need to deal with MSB position in the word.
18 * 14 *
@@ -139,7 +135,7 @@ bitfill_unaligned(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
139 135
140 // Trailing bits 136 // Trailing bits
141 if (last) 137 if (last)
142 FB_WRITEL(comp(pat, FB_READL(dst), first), dst); 138 FB_WRITEL(comp(pat, FB_READL(dst), last), dst);
143 } 139 }
144} 140}
145 141
@@ -281,7 +277,7 @@ bitfill_unaligned_rev(struct fb_info *p, unsigned long __iomem *dst,
281 277
282void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect) 278void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
283{ 279{
284 unsigned long pat, fg; 280 unsigned long pat, pat2, fg;
285 unsigned long width = rect->width, height = rect->height; 281 unsigned long width = rect->width, height = rect->height;
286 int bits = BITS_PER_LONG, bytes = bits >> 3; 282 int bits = BITS_PER_LONG, bytes = bits >> 3;
287 u32 bpp = p->var.bits_per_pixel; 283 u32 bpp = p->var.bits_per_pixel;
@@ -297,7 +293,7 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
297 else 293 else
298 fg = rect->color; 294 fg = rect->color;
299 295
300 pat = pixel_to_pat( bpp, fg); 296 pat = pixel_to_pat(bpp, fg);
301 297
302 dst = (unsigned long __iomem *)((unsigned long)p->screen_base & ~(bytes-1)); 298 dst = (unsigned long __iomem *)((unsigned long)p->screen_base & ~(bytes-1));
303 dst_idx = ((unsigned long)p->screen_base & (bytes - 1))*8; 299 dst_idx = ((unsigned long)p->screen_base & (bytes - 1))*8;
@@ -333,17 +329,16 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
333 dst_idx += p->fix.line_length*8; 329 dst_idx += p->fix.line_length*8;
334 } 330 }
335 } else { 331 } else {
336 int right; 332 int right, r;
337 int r;
338 int rot = (left-dst_idx) % bpp;
339 void (*fill_op)(struct fb_info *p, unsigned long __iomem *dst, 333 void (*fill_op)(struct fb_info *p, unsigned long __iomem *dst,
340 int dst_idx, unsigned long pat, int left, 334 int dst_idx, unsigned long pat, int left,
341 int right, unsigned n, int bits) = NULL; 335 int right, unsigned n, int bits) = NULL;
342 336#ifdef __LITTLE_ENDIAN
343 /* rotate pattern to correct start position */ 337 right = left;
344 pat = pat << rot | pat >> (bpp-rot); 338 left = bpp - right;
345 339#else
346 right = bpp-left; 340 right = bpp - left;
341#endif
347 switch (rect->rop) { 342 switch (rect->rop) {
348 case ROP_XOR: 343 case ROP_XOR:
349 fill_op = bitfill_unaligned_rev; 344 fill_op = bitfill_unaligned_rev;
@@ -352,17 +347,18 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
352 fill_op = bitfill_unaligned; 347 fill_op = bitfill_unaligned;
353 break; 348 break;
354 default: 349 default:
355 printk( KERN_ERR "cfb_fillrect(): unknown rop, defaulting to ROP_COPY\n"); 350 printk(KERN_ERR "cfb_fillrect(): unknown rop, defaulting to ROP_COPY\n");
356 fill_op = bitfill_unaligned; 351 fill_op = bitfill_unaligned;
357 break; 352 break;
358 } 353 }
359 while (height--) { 354 while (height--) {
360 dst += dst_idx >> (ffs(bits) - 1); 355 dst += dst_idx / bits;
361 dst_idx &= (bits - 1); 356 dst_idx &= (bits - 1);
362 fill_op(p, dst, dst_idx, pat, left, right, 357 r = dst_idx % bpp;
358 /* rotate pattern to the correct start position */
359 pat2 = le_long_to_cpu(rolx(cpu_to_le_long(pat), r, bpp));
360 fill_op(p, dst, dst_idx, pat2, left, right,
363 width*bpp, bits); 361 width*bpp, bits);
364 r = (p->fix.line_length*8) % bpp;
365 pat = pat << (bpp-r) | pat >> r;
366 dst_idx += p->fix.line_length*8; 362 dst_idx += p->fix.line_length*8;
367 } 363 }
368 } 364 }
diff --git a/drivers/video/fb_draw.h b/drivers/video/fb_draw.h
index 1db622192bde..04c01faaf772 100644
--- a/drivers/video/fb_draw.h
+++ b/drivers/video/fb_draw.h
@@ -33,11 +33,11 @@ pixel_to_pat( u32 bpp, u32 pixel)
33 case 8: 33 case 8:
34 return 0x0101010101010101ul*pixel; 34 return 0x0101010101010101ul*pixel;
35 case 12: 35 case 12:
36 return 0x0001001001001001ul*pixel; 36 return 0x1001001001001001ul*pixel;
37 case 16: 37 case 16:
38 return 0x0001000100010001ul*pixel; 38 return 0x0001000100010001ul*pixel;
39 case 24: 39 case 24:
40 return 0x0000000001000001ul*pixel; 40 return 0x0001000001000001ul*pixel;
41 case 32: 41 case 32:
42 return 0x0000000100000001ul*pixel; 42 return 0x0000000100000001ul*pixel;
43 default: 43 default:
@@ -58,11 +58,11 @@ pixel_to_pat( u32 bpp, u32 pixel)
58 case 8: 58 case 8:
59 return 0x01010101ul*pixel; 59 return 0x01010101ul*pixel;
60 case 12: 60 case 12:
61 return 0x00001001ul*pixel; 61 return 0x01001001ul*pixel;
62 case 16: 62 case 16:
63 return 0x00010001ul*pixel; 63 return 0x00010001ul*pixel;
64 case 24: 64 case 24:
65 return 0x00000001ul*pixel; 65 return 0x01000001ul*pixel;
66 case 32: 66 case 32:
67 return 0x00000001ul*pixel; 67 return 0x00000001ul*pixel;
68 default: 68 default:
@@ -167,4 +167,17 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val,
167 167
168#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */ 168#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */
169 169
170#define cpu_to_le_long _cpu_to_le_long(BITS_PER_LONG)
171#define _cpu_to_le_long(x) __cpu_to_le_long(x)
172#define __cpu_to_le_long(x) cpu_to_le##x
173
174#define le_long_to_cpu _le_long_to_cpu(BITS_PER_LONG)
175#define _le_long_to_cpu(x) __le_long_to_cpu(x)
176#define __le_long_to_cpu(x) le##x##_to_cpu
177
178static inline unsigned long rolx(unsigned long word, unsigned int shift, unsigned int x)
179{
180 return (word << shift) | (word >> (x - shift));
181}
182
170#endif /* FB_DRAW_H */ 183#endif /* FB_DRAW_H */
diff --git a/drivers/video/sysfillrect.c b/drivers/video/sysfillrect.c
index f94d6b6e29ee..33ee3d34f9d2 100644
--- a/drivers/video/sysfillrect.c
+++ b/drivers/video/sysfillrect.c
@@ -124,7 +124,7 @@ bitfill_unaligned(struct fb_info *p, unsigned long *dst, int dst_idx,
124 124
125 /* Trailing bits */ 125 /* Trailing bits */
126 if (last) 126 if (last)
127 *dst = comp(pat, *dst, first); 127 *dst = comp(pat, *dst, last);
128 } 128 }
129} 129}
130 130
@@ -242,7 +242,7 @@ bitfill_unaligned_rev(struct fb_info *p, unsigned long *dst, int dst_idx,
242 242
243void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect) 243void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
244{ 244{
245 unsigned long pat, fg; 245 unsigned long pat, pat2, fg;
246 unsigned long width = rect->width, height = rect->height; 246 unsigned long width = rect->width, height = rect->height;
247 int bits = BITS_PER_LONG, bytes = bits >> 3; 247 int bits = BITS_PER_LONG, bytes = bits >> 3;
248 u32 bpp = p->var.bits_per_pixel; 248 u32 bpp = p->var.bits_per_pixel;
@@ -292,17 +292,16 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
292 dst_idx += p->fix.line_length*8; 292 dst_idx += p->fix.line_length*8;
293 } 293 }
294 } else { 294 } else {
295 int right; 295 int right, r;
296 int r;
297 int rot = (left-dst_idx) % bpp;
298 void (*fill_op)(struct fb_info *p, unsigned long *dst, 296 void (*fill_op)(struct fb_info *p, unsigned long *dst,
299 int dst_idx, unsigned long pat, int left, 297 int dst_idx, unsigned long pat, int left,
300 int right, unsigned n, int bits) = NULL; 298 int right, unsigned n, int bits) = NULL;
301 299#ifdef __LITTLE_ENDIAN
302 /* rotate pattern to correct start position */ 300 right = left;
303 pat = pat << rot | pat >> (bpp-rot); 301 left = bpp - right;
304 302#else
305 right = bpp-left; 303 right = bpp - left;
304#endif
306 switch (rect->rop) { 305 switch (rect->rop) {
307 case ROP_XOR: 306 case ROP_XOR:
308 fill_op = bitfill_unaligned_rev; 307 fill_op = bitfill_unaligned_rev;
@@ -311,18 +310,19 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
311 fill_op = bitfill_unaligned; 310 fill_op = bitfill_unaligned;
312 break; 311 break;
313 default: 312 default:
314 printk(KERN_ERR "cfb_fillrect(): unknown rop, " 313 printk(KERN_ERR "sys_fillrect(): unknown rop, "
315 "defaulting to ROP_COPY\n"); 314 "defaulting to ROP_COPY\n");
316 fill_op = bitfill_unaligned; 315 fill_op = bitfill_unaligned;
317 break; 316 break;
318 } 317 }
319 while (height--) { 318 while (height--) {
320 dst += dst_idx >> (ffs(bits) - 1); 319 dst += dst_idx / bits;
321 dst_idx &= (bits - 1); 320 dst_idx &= (bits - 1);
322 fill_op(p, dst, dst_idx, pat, left, right, 321 r = dst_idx % bpp;
322 /* rotate pattern to the correct start position */
323 pat2 = le_long_to_cpu(rolx(cpu_to_le_long(pat), r, bpp));
324 fill_op(p, dst, dst_idx, pat2, left, right,
323 width*bpp, bits); 325 width*bpp, bits);
324 r = (p->fix.line_length*8) % bpp;
325 pat = pat << (bpp-r) | pat >> r;
326 dst_idx += p->fix.line_length*8; 326 dst_idx += p->fix.line_length*8;
327 } 327 }
328 } 328 }