aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/c2p_core.h
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2009-01-04 05:58:20 -0500
committerGeert Uytterhoeven <geert@linux-m68k.org>2009-01-12 14:56:31 -0500
commit2cd1de0a0ff1d3da08ff1f1437cf4a44deae6a00 (patch)
treed384dea3a349ee2f2f897e242882cbbb7e56a705 /drivers/video/c2p_core.h
parent1f034456c140a8677d0ff3a9bdb3c4b620aae2cb (diff)
fbdev: c2p - Extract common c2p core to c2p_core.h
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'drivers/video/c2p_core.h')
-rw-r--r--drivers/video/c2p_core.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/drivers/video/c2p_core.h b/drivers/video/c2p_core.h
new file mode 100644
index 000000000000..3573cf723e43
--- /dev/null
+++ b/drivers/video/c2p_core.h
@@ -0,0 +1,106 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * NOTES:
7 * - This code was inspired by Scout's C2P tutorial
8 * - It assumes to run on a big endian system
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15
16 /*
17 * Basic transpose step
18 */
19
20static inline void _transp(u32 d[], unsigned int i1, unsigned int i2,
21 unsigned int shift, u32 mask)
22{
23 u32 t = (d[i1] ^ (d[i2] >> shift)) & mask;
24
25 d[i1] ^= t;
26 d[i2] ^= t << shift;
27}
28
29
30extern void c2p_unsupported(void);
31
32static inline u32 get_mask(unsigned int n)
33{
34 switch (n) {
35 case 1:
36 return 0x55555555;
37
38 case 2:
39 return 0x33333333;
40
41 case 4:
42 return 0x0f0f0f0f;
43
44 case 8:
45 return 0x00ff00ff;
46
47 case 16:
48 return 0x0000ffff;
49 }
50
51 c2p_unsupported();
52 return 0;
53}
54
55
56 /*
57 * Transpose operations on 8 32-bit words
58 */
59
60static inline void transp8(u32 d[], unsigned int n, unsigned int m)
61{
62 u32 mask = get_mask(n);
63
64 switch (m) {
65 case 1:
66 /* First n x 1 block */
67 _transp(d, 0, 1, n, mask);
68 /* Second n x 1 block */
69 _transp(d, 2, 3, n, mask);
70 /* Third n x 1 block */
71 _transp(d, 4, 5, n, mask);
72 /* Fourth n x 1 block */
73 _transp(d, 6, 7, n, mask);
74 return;
75
76 case 2:
77 /* First n x 2 block */
78 _transp(d, 0, 2, n, mask);
79 _transp(d, 1, 3, n, mask);
80 /* Second n x 2 block */
81 _transp(d, 4, 6, n, mask);
82 _transp(d, 5, 7, n, mask);
83 return;
84
85 case 4:
86 /* Single n x 4 block */
87 _transp(d, 0, 4, n, mask);
88 _transp(d, 1, 5, n, mask);
89 _transp(d, 2, 6, n, mask);
90 _transp(d, 3, 7, n, mask);
91 return;
92 }
93
94 c2p_unsupported();
95}
96
97
98 /*
99 * Compose two values, using a bitmask as decision value
100 * This is equivalent to (a & mask) | (b & ~mask)
101 */
102
103static inline u32 comp(u32 a, u32 b, u32 mask)
104{
105 return ((a ^ b) & mask) ^ b;
106}