Commit 2eab7ff843d2cb8c9b2ace869774bd85b2316090
1 parent
96f47d6105
Exists in
master
and in
39 other branches
fbdev: c2p - Rename c2p to c2p_planar
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Showing 5 changed files with 163 additions and 162 deletions Side-by-side Diff
drivers/video/Makefile
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o |
29 | 29 | |
30 | 30 | # Hardware specific drivers go first |
31 | -obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o | |
31 | +obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o | |
32 | 32 | obj-$(CONFIG_FB_ARC) += arcfb.o |
33 | 33 | obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o |
34 | 34 | obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o |
drivers/video/amifb.c
... | ... | @@ -2159,9 +2159,9 @@ |
2159 | 2159 | src += pitch; |
2160 | 2160 | } |
2161 | 2161 | } else { |
2162 | - c2p(info->screen_base, image->data, dx, dy, width, height, | |
2163 | - par->next_line, par->next_plane, image->width, | |
2164 | - info->var.bits_per_pixel); | |
2162 | + c2p_planar(info->screen_base, image->data, dx, dy, width, | |
2163 | + height, par->next_line, par->next_plane, | |
2164 | + image->width, info->var.bits_per_pixel); | |
2165 | 2165 | } |
2166 | 2166 | } |
2167 | 2167 |
drivers/video/c2p.c
1 | -/* | |
2 | - * Fast C2P (Chunky-to-Planar) Conversion | |
3 | - * | |
4 | - * Copyright (C) 2003-2008 Geert Uytterhoeven | |
5 | - * | |
6 | - * This file is subject to the terms and conditions of the GNU General Public | |
7 | - * License. See the file COPYING in the main directory of this archive | |
8 | - * for more details. | |
9 | - */ | |
10 | - | |
11 | -#include <linux/module.h> | |
12 | -#include <linux/string.h> | |
13 | - | |
14 | -#include <asm/unaligned.h> | |
15 | - | |
16 | -#include "c2p.h" | |
17 | -#include "c2p_core.h" | |
18 | - | |
19 | - | |
20 | - /* | |
21 | - * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words | |
22 | - * containing | |
23 | - * - 32 8-bit chunky pixels on input | |
24 | - * - permutated planar data (1 plane per 32-bit word) on output | |
25 | - */ | |
26 | - | |
27 | -static void c2p_32x8(u32 d[8]) | |
28 | -{ | |
29 | - transp8(d, 16, 4); | |
30 | - transp8(d, 8, 2); | |
31 | - transp8(d, 4, 1); | |
32 | - transp8(d, 2, 4); | |
33 | - transp8(d, 1, 2); | |
34 | -} | |
35 | - | |
36 | - | |
37 | - /* | |
38 | - * Array containing the permutation indices of the planar data after c2p | |
39 | - */ | |
40 | - | |
41 | -static const int perm_c2p_32x8[8] = { 7, 5, 3, 1, 6, 4, 2, 0 }; | |
42 | - | |
43 | - | |
44 | - /* | |
45 | - * Store a full block of planar data after c2p conversion | |
46 | - */ | |
47 | - | |
48 | -static inline void store_planar(void *dst, u32 dst_inc, u32 bpp, u32 d[8]) | |
49 | -{ | |
50 | - int i; | |
51 | - | |
52 | - for (i = 0; i < bpp; i++, dst += dst_inc) | |
53 | - put_unaligned_be32(d[perm_c2p_32x8[i]], dst); | |
54 | -} | |
55 | - | |
56 | - | |
57 | - /* | |
58 | - * Store a partial block of planar data after c2p conversion | |
59 | - */ | |
60 | - | |
61 | -static inline void store_planar_masked(void *dst, u32 dst_inc, u32 bpp, | |
62 | - u32 d[8], u32 mask) | |
63 | -{ | |
64 | - int i; | |
65 | - | |
66 | - for (i = 0; i < bpp; i++, dst += dst_inc) | |
67 | - put_unaligned_be32(comp(d[perm_c2p_32x8[i]], | |
68 | - get_unaligned_be32(dst), mask), | |
69 | - dst); | |
70 | -} | |
71 | - | |
72 | - | |
73 | - /* | |
74 | - * c2p - Copy 8-bit chunky image data to a planar frame buffer | |
75 | - * @dst: Starting address of the planar frame buffer | |
76 | - * @dx: Horizontal destination offset (in pixels) | |
77 | - * @dy: Vertical destination offset (in pixels) | |
78 | - * @width: Image width (in pixels) | |
79 | - * @height: Image height (in pixels) | |
80 | - * @dst_nextline: Frame buffer offset to the next line (in bytes) | |
81 | - * @dst_nextplane: Frame buffer offset to the next plane (in bytes) | |
82 | - * @src_nextline: Image offset to the next line (in bytes) | |
83 | - * @bpp: Bits per pixel of the planar frame buffer (1-8) | |
84 | - */ | |
85 | - | |
86 | -void c2p(void *dst, const void *src, u32 dx, u32 dy, u32 width, u32 height, | |
87 | - u32 dst_nextline, u32 dst_nextplane, u32 src_nextline, u32 bpp) | |
88 | -{ | |
89 | - union { | |
90 | - u8 pixels[32]; | |
91 | - u32 words[8]; | |
92 | - } d; | |
93 | - u32 dst_idx, first, last, w; | |
94 | - const u8 *c; | |
95 | - void *p; | |
96 | - | |
97 | - dst += dy*dst_nextline+(dx & ~31); | |
98 | - dst_idx = dx % 32; | |
99 | - first = 0xffffffffU >> dst_idx; | |
100 | - last = ~(0xffffffffU >> ((dst_idx+width) % 32)); | |
101 | - while (height--) { | |
102 | - c = src; | |
103 | - p = dst; | |
104 | - w = width; | |
105 | - if (dst_idx+width <= 32) { | |
106 | - /* Single destination word */ | |
107 | - first &= last; | |
108 | - memset(d.pixels, 0, sizeof(d)); | |
109 | - memcpy(d.pixels+dst_idx, c, width); | |
110 | - c += width; | |
111 | - c2p_32x8(d.words); | |
112 | - store_planar_masked(p, dst_nextplane, bpp, d.words, | |
113 | - first); | |
114 | - p += 4; | |
115 | - } else { | |
116 | - /* Multiple destination words */ | |
117 | - w = width; | |
118 | - /* Leading bits */ | |
119 | - if (dst_idx) { | |
120 | - w = 32 - dst_idx; | |
121 | - memset(d.pixels, 0, dst_idx); | |
122 | - memcpy(d.pixels+dst_idx, c, w); | |
123 | - c += w; | |
124 | - c2p_32x8(d.words); | |
125 | - store_planar_masked(p, dst_nextplane, bpp, | |
126 | - d.words, first); | |
127 | - p += 4; | |
128 | - w = width-w; | |
129 | - } | |
130 | - /* Main chunk */ | |
131 | - while (w >= 32) { | |
132 | - memcpy(d.pixels, c, 32); | |
133 | - c += 32; | |
134 | - c2p_32x8(d.words); | |
135 | - store_planar(p, dst_nextplane, bpp, d.words); | |
136 | - p += 4; | |
137 | - w -= 32; | |
138 | - } | |
139 | - /* Trailing bits */ | |
140 | - w %= 32; | |
141 | - if (w > 0) { | |
142 | - memcpy(d.pixels, c, w); | |
143 | - memset(d.pixels+w, 0, 32-w); | |
144 | - c2p_32x8(d.words); | |
145 | - store_planar_masked(p, dst_nextplane, bpp, | |
146 | - d.words, last); | |
147 | - } | |
148 | - } | |
149 | - src += src_nextline; | |
150 | - dst += dst_nextline; | |
151 | - } | |
152 | -} | |
153 | -EXPORT_SYMBOL_GPL(c2p); | |
154 | - | |
155 | -MODULE_LICENSE("GPL"); |
drivers/video/c2p.h
... | ... | @@ -10,9 +10,9 @@ |
10 | 10 | |
11 | 11 | #include <linux/types.h> |
12 | 12 | |
13 | -extern void c2p(void *dst, const void *src, u32 dx, u32 dy, u32 width, | |
14 | - u32 height, u32 dst_nextline, u32 dst_nextplane, | |
15 | - u32 src_nextline, u32 bpp); | |
13 | +extern void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width, | |
14 | + u32 height, u32 dst_nextline, u32 dst_nextplane, | |
15 | + u32 src_nextline, u32 bpp); | |
16 | 16 | |
17 | 17 | extern void c2p_iplan2(void *dst, const void *src, u32 dx, u32 dy, u32 width, |
18 | 18 | u32 height, u32 dst_nextline, u32 src_nextline, |
drivers/video/c2p_planar.c
1 | +/* | |
2 | + * Fast C2P (Chunky-to-Planar) Conversion | |
3 | + * | |
4 | + * Copyright (C) 2003-2008 Geert Uytterhoeven | |
5 | + * | |
6 | + * This file is subject to the terms and conditions of the GNU General Public | |
7 | + * License. See the file COPYING in the main directory of this archive | |
8 | + * for more details. | |
9 | + */ | |
10 | + | |
11 | +#include <linux/module.h> | |
12 | +#include <linux/string.h> | |
13 | + | |
14 | +#include <asm/unaligned.h> | |
15 | + | |
16 | +#include "c2p.h" | |
17 | +#include "c2p_core.h" | |
18 | + | |
19 | + | |
20 | + /* | |
21 | + * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words | |
22 | + * containing | |
23 | + * - 32 8-bit chunky pixels on input | |
24 | + * - permutated planar data (1 plane per 32-bit word) on output | |
25 | + */ | |
26 | + | |
27 | +static void c2p_32x8(u32 d[8]) | |
28 | +{ | |
29 | + transp8(d, 16, 4); | |
30 | + transp8(d, 8, 2); | |
31 | + transp8(d, 4, 1); | |
32 | + transp8(d, 2, 4); | |
33 | + transp8(d, 1, 2); | |
34 | +} | |
35 | + | |
36 | + | |
37 | + /* | |
38 | + * Array containing the permutation indices of the planar data after c2p | |
39 | + */ | |
40 | + | |
41 | +static const int perm_c2p_32x8[8] = { 7, 5, 3, 1, 6, 4, 2, 0 }; | |
42 | + | |
43 | + | |
44 | + /* | |
45 | + * Store a full block of planar data after c2p conversion | |
46 | + */ | |
47 | + | |
48 | +static inline void store_planar(void *dst, u32 dst_inc, u32 bpp, u32 d[8]) | |
49 | +{ | |
50 | + int i; | |
51 | + | |
52 | + for (i = 0; i < bpp; i++, dst += dst_inc) | |
53 | + put_unaligned_be32(d[perm_c2p_32x8[i]], dst); | |
54 | +} | |
55 | + | |
56 | + | |
57 | + /* | |
58 | + * Store a partial block of planar data after c2p conversion | |
59 | + */ | |
60 | + | |
61 | +static inline void store_planar_masked(void *dst, u32 dst_inc, u32 bpp, | |
62 | + u32 d[8], u32 mask) | |
63 | +{ | |
64 | + int i; | |
65 | + | |
66 | + for (i = 0; i < bpp; i++, dst += dst_inc) | |
67 | + put_unaligned_be32(comp(d[perm_c2p_32x8[i]], | |
68 | + get_unaligned_be32(dst), mask), | |
69 | + dst); | |
70 | +} | |
71 | + | |
72 | + | |
73 | + /* | |
74 | + * c2p_planar - Copy 8-bit chunky image data to a planar frame buffer | |
75 | + * @dst: Starting address of the planar frame buffer | |
76 | + * @dx: Horizontal destination offset (in pixels) | |
77 | + * @dy: Vertical destination offset (in pixels) | |
78 | + * @width: Image width (in pixels) | |
79 | + * @height: Image height (in pixels) | |
80 | + * @dst_nextline: Frame buffer offset to the next line (in bytes) | |
81 | + * @dst_nextplane: Frame buffer offset to the next plane (in bytes) | |
82 | + * @src_nextline: Image offset to the next line (in bytes) | |
83 | + * @bpp: Bits per pixel of the planar frame buffer (1-8) | |
84 | + */ | |
85 | + | |
86 | +void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width, | |
87 | + u32 height, u32 dst_nextline, u32 dst_nextplane, | |
88 | + u32 src_nextline, u32 bpp) | |
89 | +{ | |
90 | + union { | |
91 | + u8 pixels[32]; | |
92 | + u32 words[8]; | |
93 | + } d; | |
94 | + u32 dst_idx, first, last, w; | |
95 | + const u8 *c; | |
96 | + void *p; | |
97 | + | |
98 | + dst += dy*dst_nextline+(dx & ~31); | |
99 | + dst_idx = dx % 32; | |
100 | + first = 0xffffffffU >> dst_idx; | |
101 | + last = ~(0xffffffffU >> ((dst_idx+width) % 32)); | |
102 | + while (height--) { | |
103 | + c = src; | |
104 | + p = dst; | |
105 | + w = width; | |
106 | + if (dst_idx+width <= 32) { | |
107 | + /* Single destination word */ | |
108 | + first &= last; | |
109 | + memset(d.pixels, 0, sizeof(d)); | |
110 | + memcpy(d.pixels+dst_idx, c, width); | |
111 | + c += width; | |
112 | + c2p_32x8(d.words); | |
113 | + store_planar_masked(p, dst_nextplane, bpp, d.words, | |
114 | + first); | |
115 | + p += 4; | |
116 | + } else { | |
117 | + /* Multiple destination words */ | |
118 | + w = width; | |
119 | + /* Leading bits */ | |
120 | + if (dst_idx) { | |
121 | + w = 32 - dst_idx; | |
122 | + memset(d.pixels, 0, dst_idx); | |
123 | + memcpy(d.pixels+dst_idx, c, w); | |
124 | + c += w; | |
125 | + c2p_32x8(d.words); | |
126 | + store_planar_masked(p, dst_nextplane, bpp, | |
127 | + d.words, first); | |
128 | + p += 4; | |
129 | + w = width-w; | |
130 | + } | |
131 | + /* Main chunk */ | |
132 | + while (w >= 32) { | |
133 | + memcpy(d.pixels, c, 32); | |
134 | + c += 32; | |
135 | + c2p_32x8(d.words); | |
136 | + store_planar(p, dst_nextplane, bpp, d.words); | |
137 | + p += 4; | |
138 | + w -= 32; | |
139 | + } | |
140 | + /* Trailing bits */ | |
141 | + w %= 32; | |
142 | + if (w > 0) { | |
143 | + memcpy(d.pixels, c, w); | |
144 | + memset(d.pixels+w, 0, 32-w); | |
145 | + c2p_32x8(d.words); | |
146 | + store_planar_masked(p, dst_nextplane, bpp, | |
147 | + d.words, last); | |
148 | + } | |
149 | + } | |
150 | + src += src_nextline; | |
151 | + dst += dst_nextline; | |
152 | + } | |
153 | +} | |
154 | +EXPORT_SYMBOL_GPL(c2p_planar); | |
155 | + | |
156 | +MODULE_LICENSE("GPL"); |