2 * Arm PrimeCell PL110 Color LCD Controller
4 * Copyright (c) 2005 CodeSourcery, LLC.
5 * Written by Paul Brook
7 * This code is licenced under the GNU LGPL
9 * Framebuffer format conversion routines.
15 #define COPY_PIXEL(to, from) *(to++) = from
16 #elif BITS == 15 || BITS == 16
17 #define COPY_PIXEL(to, from) *(uint16_t *)to = from; to += 2;
19 #define COPY_PIXEL(to, from) \
20 *(to++) = from; *(to++) = (from) >> 8; *(to++) = (from) >> 16
22 #define COPY_PIXEL(to, from) *(uint32_t *)to = from; to += 4;
24 #error unknown bit depth
28 #include "pl110_template.h"
30 #include "pl110_template.h"
32 #include "pl110_template.h"
34 static drawfn glue(pl110_draw_fn_,BITS)[18] =
36 glue(pl110_draw_line1_lblp,BITS),
37 glue(pl110_draw_line2_lblp,BITS),
38 glue(pl110_draw_line4_lblp,BITS),
39 glue(pl110_draw_line8_lblp,BITS),
40 glue(pl110_draw_line16_lblp,BITS),
41 glue(pl110_draw_line32_lblp,BITS),
43 glue(pl110_draw_line1_bbbp,BITS),
44 glue(pl110_draw_line2_bbbp,BITS),
45 glue(pl110_draw_line4_bbbp,BITS),
46 glue(pl110_draw_line8_bbbp,BITS),
47 glue(pl110_draw_line16_bbbp,BITS),
48 glue(pl110_draw_line32_bbbp,BITS),
50 glue(pl110_draw_line1_lbbp,BITS),
51 glue(pl110_draw_line2_lbbp,BITS),
52 glue(pl110_draw_line4_lbbp,BITS),
53 glue(pl110_draw_line8_lbbp,BITS),
54 glue(pl110_draw_line16_lbbp,BITS),
55 glue(pl110_draw_line32_lbbp,BITS)
64 #define NAME glue(lblp, BITS)
65 #ifdef WORDS_BIGENDIAN
69 #define NAME glue(bbbp, BITS)
70 #ifndef WORDS_BIGENDIAN
75 #define NAME glue(lbbp, BITS)
76 #ifdef WORDS_BIGENDIAN
81 #define FN_2(x, y) FN(x, y) FN(x+1, y)
82 #define FN_4(x, y) FN_2(x, y) FN_2(x+2, y)
83 #define FN_8(y) FN_4(0, y) FN_4(4, y)
85 static void glue(pl110_draw_line1_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
89 data = *(uint32_t *)src;
91 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 7 - (x))) & 1]);
93 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x) + y)) & 1]);
112 static void glue(pl110_draw_line2_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
116 data = *(uint32_t *)src;
118 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 6 - (x)*2)) & 3]);
120 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x)*2 + y)) & 3]);
139 static void glue(pl110_draw_line4_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
143 data = *(uint32_t *)src;
145 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 4 - (x)*4)) & 0xf]);
147 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x)*4 + y)) & 0xf]);
166 static void glue(pl110_draw_line8_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
170 data = *(uint32_t *)src;
171 #define FN(x) COPY_PIXEL(d, pallette[(data >> (x)) & 0xff]);
189 static void glue(pl110_draw_line16_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
192 unsigned int r, g, b;
194 data = *(uint32_t *)src;
196 data = bswap32(data);
206 r = (data & 0x1f) << 3;
208 g = (data & 0x3f) << 2;
210 b = (data & 0x1f) << 3;
213 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
214 r = (data & 0x1f) << 3;
216 g = (data & 0x3f) << 2;
218 b = (data & 0x1f) << 3;
220 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
226 static void glue(pl110_draw_line32_,NAME)(uint32_t *pallette, uint8_t *d, const uint8_t *src, int width)
229 unsigned int r, g, b;
231 data = *(uint32_t *)src;
234 g = (data >> 8) & 0xff;
235 b = (data >> 16) & 0xff;
237 r = (data >> 24) & 0xff;
238 g = (data >> 16) & 0xff;
239 b = (data >> 8) & 0xff;
241 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));