root / hw / pxa2xx_template.h @ aba35a6c
History | View | Annotate | Download (11.2 kB)
1 | a171fe39 | balrog | /*
|
---|---|---|---|
2 | a171fe39 | balrog | * Intel XScale PXA255/270 LCDC emulation.
|
3 | a171fe39 | balrog | *
|
4 | a171fe39 | balrog | * Copyright (c) 2006 Openedhand Ltd.
|
5 | a171fe39 | balrog | * Written by Andrzej Zaborowski <balrog@zabor.org>
|
6 | a171fe39 | balrog | *
|
7 | a171fe39 | balrog | * This code is licensed under the GPLv2.
|
8 | a171fe39 | balrog | *
|
9 | a171fe39 | balrog | * Framebuffer format conversion routines.
|
10 | a171fe39 | balrog | */
|
11 | a171fe39 | balrog | |
12 | a171fe39 | balrog | # define SKIP_PIXEL(to) to += deststep
|
13 | a171fe39 | balrog | #if BITS == 8 |
14 | a171fe39 | balrog | # define COPY_PIXEL(to, from) *to = from; SKIP_PIXEL(to)
|
15 | a171fe39 | balrog | #elif BITS == 15 || BITS == 16 |
16 | a171fe39 | balrog | # define COPY_PIXEL(to, from) *(uint16_t *) to = from; SKIP_PIXEL(to)
|
17 | 5fafdf24 | ths | #elif BITS == 24 |
18 | a171fe39 | balrog | # define COPY_PIXEL(to, from) \
|
19 | a171fe39 | balrog | *(uint16_t *) to = from; *(to + 2) = (from) >> 16; SKIP_PIXEL(to) |
20 | a171fe39 | balrog | #elif BITS == 32 |
21 | a171fe39 | balrog | # define COPY_PIXEL(to, from) *(uint32_t *) to = from; SKIP_PIXEL(to)
|
22 | a171fe39 | balrog | #else
|
23 | a171fe39 | balrog | # error unknown bit depth
|
24 | a171fe39 | balrog | #endif
|
25 | a171fe39 | balrog | |
26 | a171fe39 | balrog | #ifdef WORDS_BIGENDIAN
|
27 | a171fe39 | balrog | # define SWAP_WORDS 1 |
28 | a171fe39 | balrog | #endif
|
29 | a171fe39 | balrog | |
30 | a171fe39 | balrog | #define FN_2(x) FN(x + 1) FN(x) |
31 | a171fe39 | balrog | #define FN_4(x) FN_2(x + 2) FN_2(x) |
32 | a171fe39 | balrog | |
33 | a171fe39 | balrog | static void glue(pxa2xx_draw_line2_, BITS)(uint32_t *palette, |
34 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
35 | a171fe39 | balrog | { |
36 | a171fe39 | balrog | uint32_t data; |
37 | a171fe39 | balrog | while (width > 0) { |
38 | a171fe39 | balrog | data = *(uint32_t *) src; |
39 | a171fe39 | balrog | #define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]); |
40 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
41 | a171fe39 | balrog | FN_4(12)
|
42 | a171fe39 | balrog | FN_4(8)
|
43 | a171fe39 | balrog | FN_4(4)
|
44 | a171fe39 | balrog | FN_4(0)
|
45 | a171fe39 | balrog | #else
|
46 | a171fe39 | balrog | FN_4(0)
|
47 | a171fe39 | balrog | FN_4(4)
|
48 | a171fe39 | balrog | FN_4(8)
|
49 | a171fe39 | balrog | FN_4(12)
|
50 | a171fe39 | balrog | #endif
|
51 | a171fe39 | balrog | #undef FN
|
52 | a171fe39 | balrog | width -= 16;
|
53 | a171fe39 | balrog | src += 4;
|
54 | a171fe39 | balrog | } |
55 | a171fe39 | balrog | } |
56 | a171fe39 | balrog | |
57 | a171fe39 | balrog | static void glue(pxa2xx_draw_line4_, BITS)(uint32_t *palette, |
58 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
59 | a171fe39 | balrog | { |
60 | a171fe39 | balrog | uint32_t data; |
61 | a171fe39 | balrog | while (width > 0) { |
62 | a171fe39 | balrog | data = *(uint32_t *) src; |
63 | a171fe39 | balrog | #define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]); |
64 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
65 | a171fe39 | balrog | FN_2(6)
|
66 | a171fe39 | balrog | FN_2(4)
|
67 | a171fe39 | balrog | FN_2(2)
|
68 | a171fe39 | balrog | FN_2(0)
|
69 | a171fe39 | balrog | #else
|
70 | a171fe39 | balrog | FN_2(0)
|
71 | a171fe39 | balrog | FN_2(2)
|
72 | a171fe39 | balrog | FN_2(4)
|
73 | a171fe39 | balrog | FN_2(6)
|
74 | a171fe39 | balrog | #endif
|
75 | a171fe39 | balrog | #undef FN
|
76 | a171fe39 | balrog | width -= 8;
|
77 | a171fe39 | balrog | src += 4;
|
78 | a171fe39 | balrog | } |
79 | a171fe39 | balrog | } |
80 | a171fe39 | balrog | |
81 | a171fe39 | balrog | static void glue(pxa2xx_draw_line8_, BITS)(uint32_t *palette, |
82 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
83 | a171fe39 | balrog | { |
84 | a171fe39 | balrog | uint32_t data; |
85 | a171fe39 | balrog | while (width > 0) { |
86 | a171fe39 | balrog | data = *(uint32_t *) src; |
87 | a171fe39 | balrog | #define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]); |
88 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
89 | a171fe39 | balrog | FN(24)
|
90 | a171fe39 | balrog | FN(16)
|
91 | a171fe39 | balrog | FN(8)
|
92 | a171fe39 | balrog | FN(0)
|
93 | a171fe39 | balrog | #else
|
94 | a171fe39 | balrog | FN(0)
|
95 | a171fe39 | balrog | FN(8)
|
96 | a171fe39 | balrog | FN(16)
|
97 | a171fe39 | balrog | FN(24)
|
98 | a171fe39 | balrog | #endif
|
99 | a171fe39 | balrog | #undef FN
|
100 | a171fe39 | balrog | width -= 4;
|
101 | a171fe39 | balrog | src += 4;
|
102 | a171fe39 | balrog | } |
103 | a171fe39 | balrog | } |
104 | a171fe39 | balrog | |
105 | a171fe39 | balrog | static void glue(pxa2xx_draw_line16_, BITS)(uint32_t *palette, |
106 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
107 | a171fe39 | balrog | { |
108 | a171fe39 | balrog | uint32_t data; |
109 | a171fe39 | balrog | unsigned int r, g, b; |
110 | a171fe39 | balrog | while (width > 0) { |
111 | a171fe39 | balrog | data = *(uint32_t *) src; |
112 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
113 | a171fe39 | balrog | data = bswap32(data); |
114 | a171fe39 | balrog | #endif
|
115 | a171fe39 | balrog | b = (data & 0x1f) << 3; |
116 | a171fe39 | balrog | data >>= 5;
|
117 | a171fe39 | balrog | g = (data & 0x3f) << 2; |
118 | a171fe39 | balrog | data >>= 6;
|
119 | a171fe39 | balrog | r = (data & 0x1f) << 3; |
120 | a171fe39 | balrog | data >>= 5;
|
121 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
122 | a171fe39 | balrog | b = (data & 0x1f) << 3; |
123 | a171fe39 | balrog | data >>= 5;
|
124 | a171fe39 | balrog | g = (data & 0x3f) << 2; |
125 | a171fe39 | balrog | data >>= 6;
|
126 | a171fe39 | balrog | r = (data & 0x1f) << 3; |
127 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
128 | a171fe39 | balrog | width -= 2;
|
129 | a171fe39 | balrog | src += 4;
|
130 | a171fe39 | balrog | } |
131 | a171fe39 | balrog | } |
132 | a171fe39 | balrog | |
133 | a171fe39 | balrog | static void glue(pxa2xx_draw_line16t_, BITS)(uint32_t *palette, |
134 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
135 | a171fe39 | balrog | { |
136 | a171fe39 | balrog | uint32_t data; |
137 | a171fe39 | balrog | unsigned int r, g, b; |
138 | a171fe39 | balrog | while (width > 0) { |
139 | a171fe39 | balrog | data = *(uint32_t *) src; |
140 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
141 | a171fe39 | balrog | data = bswap32(data); |
142 | a171fe39 | balrog | #endif
|
143 | a171fe39 | balrog | b = (data & 0x1f) << 3; |
144 | a171fe39 | balrog | data >>= 5;
|
145 | a171fe39 | balrog | g = (data & 0x1f) << 3; |
146 | a171fe39 | balrog | data >>= 5;
|
147 | a171fe39 | balrog | r = (data & 0x1f) << 3; |
148 | a171fe39 | balrog | data >>= 5;
|
149 | a171fe39 | balrog | if (data & 1) |
150 | a171fe39 | balrog | SKIP_PIXEL(dest); |
151 | a171fe39 | balrog | else
|
152 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
153 | a171fe39 | balrog | data >>= 1;
|
154 | a171fe39 | balrog | b = (data & 0x1f) << 3; |
155 | a171fe39 | balrog | data >>= 5;
|
156 | a171fe39 | balrog | g = (data & 0x1f) << 3; |
157 | a171fe39 | balrog | data >>= 5;
|
158 | a171fe39 | balrog | r = (data & 0x1f) << 3; |
159 | abbaab5c | balrog | data >>= 5;
|
160 | a171fe39 | balrog | if (data & 1) |
161 | a171fe39 | balrog | SKIP_PIXEL(dest); |
162 | a171fe39 | balrog | else
|
163 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
164 | a171fe39 | balrog | width -= 2;
|
165 | a171fe39 | balrog | src += 4;
|
166 | a171fe39 | balrog | } |
167 | a171fe39 | balrog | } |
168 | a171fe39 | balrog | |
169 | a171fe39 | balrog | static void glue(pxa2xx_draw_line18_, BITS)(uint32_t *palette, |
170 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
171 | a171fe39 | balrog | { |
172 | a171fe39 | balrog | uint32_t data; |
173 | a171fe39 | balrog | unsigned int r, g, b; |
174 | a171fe39 | balrog | while (width > 0) { |
175 | a171fe39 | balrog | data = *(uint32_t *) src; |
176 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
177 | a171fe39 | balrog | data = bswap32(data); |
178 | a171fe39 | balrog | #endif
|
179 | a171fe39 | balrog | b = (data & 0x3f) << 2; |
180 | a171fe39 | balrog | data >>= 6;
|
181 | a171fe39 | balrog | g = (data & 0x3f) << 2; |
182 | a171fe39 | balrog | data >>= 6;
|
183 | a171fe39 | balrog | r = (data & 0x3f) << 2; |
184 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
185 | a171fe39 | balrog | width -= 1;
|
186 | a171fe39 | balrog | src += 4;
|
187 | a171fe39 | balrog | } |
188 | a171fe39 | balrog | } |
189 | a171fe39 | balrog | |
190 | a171fe39 | balrog | /* The wicked packed format */
|
191 | a171fe39 | balrog | static void glue(pxa2xx_draw_line18p_, BITS)(uint32_t *palette, |
192 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
193 | a171fe39 | balrog | { |
194 | a171fe39 | balrog | uint32_t data[3];
|
195 | a171fe39 | balrog | unsigned int r, g, b; |
196 | a171fe39 | balrog | while (width > 0) { |
197 | a171fe39 | balrog | data[0] = *(uint32_t *) src;
|
198 | a171fe39 | balrog | src += 4;
|
199 | a171fe39 | balrog | data[1] = *(uint32_t *) src;
|
200 | a171fe39 | balrog | src += 4;
|
201 | a171fe39 | balrog | data[2] = *(uint32_t *) src;
|
202 | a171fe39 | balrog | src += 4;
|
203 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
204 | a171fe39 | balrog | data[0] = bswap32(data[0]); |
205 | a171fe39 | balrog | data[1] = bswap32(data[1]); |
206 | a171fe39 | balrog | data[2] = bswap32(data[2]); |
207 | a171fe39 | balrog | #endif
|
208 | a171fe39 | balrog | b = (data[0] & 0x3f) << 2; |
209 | a171fe39 | balrog | data[0] >>= 6; |
210 | a171fe39 | balrog | g = (data[0] & 0x3f) << 2; |
211 | a171fe39 | balrog | data[0] >>= 6; |
212 | a171fe39 | balrog | r = (data[0] & 0x3f) << 2; |
213 | a171fe39 | balrog | data[0] >>= 12; |
214 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
215 | a171fe39 | balrog | b = (data[0] & 0x3f) << 2; |
216 | a171fe39 | balrog | data[0] >>= 6; |
217 | a171fe39 | balrog | g = ((data[1] & 0xf) << 4) | (data[0] << 2); |
218 | a171fe39 | balrog | data[1] >>= 4; |
219 | a171fe39 | balrog | r = (data[1] & 0x3f) << 2; |
220 | a171fe39 | balrog | data[1] >>= 12; |
221 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
222 | a171fe39 | balrog | b = (data[1] & 0x3f) << 2; |
223 | a171fe39 | balrog | data[1] >>= 6; |
224 | a171fe39 | balrog | g = (data[1] & 0x3f) << 2; |
225 | a171fe39 | balrog | data[1] >>= 6; |
226 | a171fe39 | balrog | r = ((data[2] & 0x3) << 6) | (data[1] << 2); |
227 | a171fe39 | balrog | data[2] >>= 8; |
228 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
229 | a171fe39 | balrog | b = (data[2] & 0x3f) << 2; |
230 | a171fe39 | balrog | data[2] >>= 6; |
231 | a171fe39 | balrog | g = (data[2] & 0x3f) << 2; |
232 | a171fe39 | balrog | data[2] >>= 6; |
233 | a171fe39 | balrog | r = data[2] << 2; |
234 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
235 | a171fe39 | balrog | width -= 4;
|
236 | a171fe39 | balrog | } |
237 | a171fe39 | balrog | } |
238 | a171fe39 | balrog | |
239 | a171fe39 | balrog | static void glue(pxa2xx_draw_line19_, BITS)(uint32_t *palette, |
240 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
241 | a171fe39 | balrog | { |
242 | a171fe39 | balrog | uint32_t data; |
243 | a171fe39 | balrog | unsigned int r, g, b; |
244 | a171fe39 | balrog | while (width > 0) { |
245 | a171fe39 | balrog | data = *(uint32_t *) src; |
246 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
247 | a171fe39 | balrog | data = bswap32(data); |
248 | a171fe39 | balrog | #endif
|
249 | a171fe39 | balrog | b = (data & 0x3f) << 2; |
250 | a171fe39 | balrog | data >>= 6;
|
251 | a171fe39 | balrog | g = (data & 0x3f) << 2; |
252 | a171fe39 | balrog | data >>= 6;
|
253 | a171fe39 | balrog | r = (data & 0x3f) << 2; |
254 | a171fe39 | balrog | data >>= 6;
|
255 | a171fe39 | balrog | if (data & 1) |
256 | a171fe39 | balrog | SKIP_PIXEL(dest); |
257 | a171fe39 | balrog | else
|
258 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
259 | a171fe39 | balrog | width -= 1;
|
260 | a171fe39 | balrog | src += 4;
|
261 | a171fe39 | balrog | } |
262 | a171fe39 | balrog | } |
263 | a171fe39 | balrog | |
264 | a171fe39 | balrog | /* The wicked packed format */
|
265 | a171fe39 | balrog | static void glue(pxa2xx_draw_line19p_, BITS)(uint32_t *palette, |
266 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
267 | a171fe39 | balrog | { |
268 | a171fe39 | balrog | uint32_t data[3];
|
269 | a171fe39 | balrog | unsigned int r, g, b; |
270 | a171fe39 | balrog | while (width > 0) { |
271 | a171fe39 | balrog | data[0] = *(uint32_t *) src;
|
272 | a171fe39 | balrog | src += 4;
|
273 | a171fe39 | balrog | data[1] = *(uint32_t *) src;
|
274 | a171fe39 | balrog | src += 4;
|
275 | a171fe39 | balrog | data[2] = *(uint32_t *) src;
|
276 | a171fe39 | balrog | src += 4;
|
277 | a171fe39 | balrog | # ifdef SWAP_WORDS
|
278 | a171fe39 | balrog | data[0] = bswap32(data[0]); |
279 | a171fe39 | balrog | data[1] = bswap32(data[1]); |
280 | a171fe39 | balrog | data[2] = bswap32(data[2]); |
281 | a171fe39 | balrog | # endif
|
282 | a171fe39 | balrog | b = (data[0] & 0x3f) << 2; |
283 | a171fe39 | balrog | data[0] >>= 6; |
284 | a171fe39 | balrog | g = (data[0] & 0x3f) << 2; |
285 | a171fe39 | balrog | data[0] >>= 6; |
286 | a171fe39 | balrog | r = (data[0] & 0x3f) << 2; |
287 | a171fe39 | balrog | data[0] >>= 6; |
288 | a171fe39 | balrog | if (data[0] & 1) |
289 | a171fe39 | balrog | SKIP_PIXEL(dest); |
290 | a171fe39 | balrog | else
|
291 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
292 | a171fe39 | balrog | data[0] >>= 6; |
293 | a171fe39 | balrog | b = (data[0] & 0x3f) << 2; |
294 | a171fe39 | balrog | data[0] >>= 6; |
295 | a171fe39 | balrog | g = ((data[1] & 0xf) << 4) | (data[0] << 2); |
296 | a171fe39 | balrog | data[1] >>= 4; |
297 | a171fe39 | balrog | r = (data[1] & 0x3f) << 2; |
298 | a171fe39 | balrog | data[1] >>= 6; |
299 | a171fe39 | balrog | if (data[1] & 1) |
300 | a171fe39 | balrog | SKIP_PIXEL(dest); |
301 | a171fe39 | balrog | else
|
302 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
303 | a171fe39 | balrog | data[1] >>= 6; |
304 | a171fe39 | balrog | b = (data[1] & 0x3f) << 2; |
305 | a171fe39 | balrog | data[1] >>= 6; |
306 | a171fe39 | balrog | g = (data[1] & 0x3f) << 2; |
307 | a171fe39 | balrog | data[1] >>= 6; |
308 | a171fe39 | balrog | r = ((data[2] & 0x3) << 6) | (data[1] << 2); |
309 | a171fe39 | balrog | data[2] >>= 2; |
310 | a171fe39 | balrog | if (data[2] & 1) |
311 | a171fe39 | balrog | SKIP_PIXEL(dest); |
312 | a171fe39 | balrog | else
|
313 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
314 | a171fe39 | balrog | data[2] >>= 6; |
315 | a171fe39 | balrog | b = (data[2] & 0x3f) << 2; |
316 | a171fe39 | balrog | data[2] >>= 6; |
317 | a171fe39 | balrog | g = (data[2] & 0x3f) << 2; |
318 | a171fe39 | balrog | data[2] >>= 6; |
319 | a171fe39 | balrog | r = data[2] << 2; |
320 | a171fe39 | balrog | data[2] >>= 6; |
321 | a171fe39 | balrog | if (data[2] & 1) |
322 | a171fe39 | balrog | SKIP_PIXEL(dest); |
323 | a171fe39 | balrog | else
|
324 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
325 | a171fe39 | balrog | width -= 4;
|
326 | a171fe39 | balrog | } |
327 | a171fe39 | balrog | } |
328 | a171fe39 | balrog | |
329 | a171fe39 | balrog | static void glue(pxa2xx_draw_line24_, BITS)(uint32_t *palette, |
330 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
331 | a171fe39 | balrog | { |
332 | a171fe39 | balrog | uint32_t data; |
333 | a171fe39 | balrog | unsigned int r, g, b; |
334 | a171fe39 | balrog | while (width > 0) { |
335 | a171fe39 | balrog | data = *(uint32_t *) src; |
336 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
337 | a171fe39 | balrog | data = bswap32(data); |
338 | a171fe39 | balrog | #endif
|
339 | a171fe39 | balrog | b = data & 0xff;
|
340 | a171fe39 | balrog | data >>= 8;
|
341 | a171fe39 | balrog | g = data & 0xff;
|
342 | a171fe39 | balrog | data >>= 8;
|
343 | a171fe39 | balrog | r = data & 0xff;
|
344 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
345 | a171fe39 | balrog | width -= 1;
|
346 | a171fe39 | balrog | src += 4;
|
347 | a171fe39 | balrog | } |
348 | a171fe39 | balrog | } |
349 | a171fe39 | balrog | |
350 | a171fe39 | balrog | static void glue(pxa2xx_draw_line24t_, BITS)(uint32_t *palette, |
351 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
352 | a171fe39 | balrog | { |
353 | a171fe39 | balrog | uint32_t data; |
354 | a171fe39 | balrog | unsigned int r, g, b; |
355 | a171fe39 | balrog | while (width > 0) { |
356 | a171fe39 | balrog | data = *(uint32_t *) src; |
357 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
358 | a171fe39 | balrog | data = bswap32(data); |
359 | a171fe39 | balrog | #endif
|
360 | a171fe39 | balrog | b = (data & 0x7f) << 1; |
361 | a171fe39 | balrog | data >>= 7;
|
362 | a171fe39 | balrog | g = data & 0xff;
|
363 | a171fe39 | balrog | data >>= 8;
|
364 | a171fe39 | balrog | r = data & 0xff;
|
365 | a171fe39 | balrog | data >>= 8;
|
366 | a171fe39 | balrog | if (data & 1) |
367 | a171fe39 | balrog | SKIP_PIXEL(dest); |
368 | a171fe39 | balrog | else
|
369 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
370 | a171fe39 | balrog | width -= 1;
|
371 | a171fe39 | balrog | src += 4;
|
372 | a171fe39 | balrog | } |
373 | a171fe39 | balrog | } |
374 | a171fe39 | balrog | |
375 | a171fe39 | balrog | static void glue(pxa2xx_draw_line25_, BITS)(uint32_t *palette, |
376 | a171fe39 | balrog | uint8_t *dest, const uint8_t *src, int width, int deststep) |
377 | a171fe39 | balrog | { |
378 | a171fe39 | balrog | uint32_t data; |
379 | a171fe39 | balrog | unsigned int r, g, b; |
380 | a171fe39 | balrog | while (width > 0) { |
381 | a171fe39 | balrog | data = *(uint32_t *) src; |
382 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
383 | a171fe39 | balrog | data = bswap32(data); |
384 | a171fe39 | balrog | #endif
|
385 | a171fe39 | balrog | b = data & 0xff;
|
386 | a171fe39 | balrog | data >>= 8;
|
387 | a171fe39 | balrog | g = data & 0xff;
|
388 | a171fe39 | balrog | data >>= 8;
|
389 | a171fe39 | balrog | r = data & 0xff;
|
390 | a171fe39 | balrog | data >>= 8;
|
391 | a171fe39 | balrog | if (data & 1) |
392 | a171fe39 | balrog | SKIP_PIXEL(dest); |
393 | a171fe39 | balrog | else
|
394 | a171fe39 | balrog | COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b)); |
395 | a171fe39 | balrog | width -= 1;
|
396 | a171fe39 | balrog | src += 4;
|
397 | a171fe39 | balrog | } |
398 | a171fe39 | balrog | } |
399 | a171fe39 | balrog | |
400 | a171fe39 | balrog | /* Overlay planes disabled, no transparency */
|
401 | a171fe39 | balrog | static drawfn glue(pxa2xx_draw_fn_, BITS)[16] = |
402 | a171fe39 | balrog | { |
403 | a171fe39 | balrog | [0 ... 0xf] = 0, |
404 | a171fe39 | balrog | [pxa_lcdc_2bpp] = glue(pxa2xx_draw_line2_, BITS), |
405 | a171fe39 | balrog | [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS), |
406 | a171fe39 | balrog | [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS), |
407 | a171fe39 | balrog | [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16_, BITS), |
408 | a171fe39 | balrog | [pxa_lcdc_18bpp] = glue(pxa2xx_draw_line18_, BITS), |
409 | a171fe39 | balrog | [pxa_lcdc_18pbpp] = glue(pxa2xx_draw_line18p_, BITS), |
410 | a171fe39 | balrog | [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24_, BITS), |
411 | a171fe39 | balrog | }; |
412 | a171fe39 | balrog | |
413 | a171fe39 | balrog | /* Overlay planes enabled, transparency used */
|
414 | a171fe39 | balrog | static drawfn glue(glue(pxa2xx_draw_fn_, BITS), t)[16] = |
415 | a171fe39 | balrog | { |
416 | a171fe39 | balrog | [0 ... 0xf] = 0, |
417 | a171fe39 | balrog | [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS), |
418 | a171fe39 | balrog | [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS), |
419 | a171fe39 | balrog | [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16t_, BITS), |
420 | a171fe39 | balrog | [pxa_lcdc_19bpp] = glue(pxa2xx_draw_line19_, BITS), |
421 | a171fe39 | balrog | [pxa_lcdc_19pbpp] = glue(pxa2xx_draw_line19p_, BITS), |
422 | a171fe39 | balrog | [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24t_, BITS), |
423 | a171fe39 | balrog | [pxa_lcdc_25bpp] = glue(pxa2xx_draw_line25_, BITS), |
424 | a171fe39 | balrog | }; |
425 | a171fe39 | balrog | |
426 | a171fe39 | balrog | #undef BITS
|
427 | a171fe39 | balrog | #undef COPY_PIXEL
|
428 | a171fe39 | balrog | #undef SKIP_PIXEL
|
429 | a171fe39 | balrog | |
430 | a171fe39 | balrog | #ifdef SWAP_WORDS
|
431 | a171fe39 | balrog | # undef SWAP_WORDS
|
432 | a171fe39 | balrog | #endif |