diff options
author | Antonino A. Daplas <adaplas@gmail.com> | 2007-05-08 03:39:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:30 -0400 |
commit | dc0e6e0544f1cb2af44e5d7a7e68acda05dec6fa (patch) | |
tree | 7f5d28d54c333c5ba84bb4b4afe3821246696818 /drivers/video/fb_draw.h | |
parent | 52102c07a68a26fe6f8926e6a8497b577655f18a (diff) |
fbdev: consolidate common drawing functions into a header file
Consolidate common drawing functions into a single header file.
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/fb_draw.h')
-rw-r--r-- | drivers/video/fb_draw.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/drivers/video/fb_draw.h b/drivers/video/fb_draw.h new file mode 100644 index 000000000000..c5c45203833b --- /dev/null +++ b/drivers/video/fb_draw.h | |||
@@ -0,0 +1,72 @@ | |||
1 | #ifndef _FB_DRAW_H | ||
2 | #define _FB_DRAW_H | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | /* | ||
7 | * Compose two values, using a bitmask as decision value | ||
8 | * This is equivalent to (a & mask) | (b & ~mask) | ||
9 | */ | ||
10 | |||
11 | static inline unsigned long | ||
12 | comp(unsigned long a, unsigned long b, unsigned long mask) | ||
13 | { | ||
14 | return ((a ^ b) & mask) ^ b; | ||
15 | } | ||
16 | |||
17 | /* | ||
18 | * Create a pattern with the given pixel's color | ||
19 | */ | ||
20 | |||
21 | #if BITS_PER_LONG == 64 | ||
22 | static inline unsigned long | ||
23 | pixel_to_pat( u32 bpp, u32 pixel) | ||
24 | { | ||
25 | switch (bpp) { | ||
26 | case 1: | ||
27 | return 0xfffffffffffffffful*pixel; | ||
28 | case 2: | ||
29 | return 0x5555555555555555ul*pixel; | ||
30 | case 4: | ||
31 | return 0x1111111111111111ul*pixel; | ||
32 | case 8: | ||
33 | return 0x0101010101010101ul*pixel; | ||
34 | case 12: | ||
35 | return 0x0001001001001001ul*pixel; | ||
36 | case 16: | ||
37 | return 0x0001000100010001ul*pixel; | ||
38 | case 24: | ||
39 | return 0x0000000001000001ul*pixel; | ||
40 | case 32: | ||
41 | return 0x0000000100000001ul*pixel; | ||
42 | default: | ||
43 | panic("pixel_to_pat(): unsupported pixelformat\n"); | ||
44 | } | ||
45 | } | ||
46 | #else | ||
47 | static inline unsigned long | ||
48 | pixel_to_pat( u32 bpp, u32 pixel) | ||
49 | { | ||
50 | switch (bpp) { | ||
51 | case 1: | ||
52 | return 0xfffffffful*pixel; | ||
53 | case 2: | ||
54 | return 0x55555555ul*pixel; | ||
55 | case 4: | ||
56 | return 0x11111111ul*pixel; | ||
57 | case 8: | ||
58 | return 0x01010101ul*pixel; | ||
59 | case 12: | ||
60 | return 0x00001001ul*pixel; | ||
61 | case 16: | ||
62 | return 0x00010001ul*pixel; | ||
63 | case 24: | ||
64 | return 0x00000001ul*pixel; | ||
65 | case 32: | ||
66 | return 0x00000001ul*pixel; | ||
67 | default: | ||
68 | panic("pixel_to_pat(): unsupported pixelformat\n"); | ||
69 | } | ||
70 | } | ||
71 | #endif | ||
72 | #endif /* FB_DRAW_H */ | ||