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