2 * Arm PrimeCell PL110 Color LCD Controller
4 * Copyright (c) 2005 CodeSourcery, LLC.
5 * Written by Paul Brook
7 * This code is licensed 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
30 #include "pl110_template.h"
32 #include "pl110_template.h"
34 #include "pl110_template.h"
39 #include "pl110_template.h"
41 #include "pl110_template.h"
43 #include "pl110_template.h"
46 static drawfn glue(pl110_draw_fn_,BITS)[36] =
48 glue(pl110_draw_line1_lblp_bgr,BITS),
49 glue(pl110_draw_line2_lblp_bgr,BITS),
50 glue(pl110_draw_line4_lblp_bgr,BITS),
51 glue(pl110_draw_line8_lblp_bgr,BITS),
52 glue(pl110_draw_line16_lblp_bgr,BITS),
53 glue(pl110_draw_line32_lblp_bgr,BITS),
55 glue(pl110_draw_line1_bbbp_bgr,BITS),
56 glue(pl110_draw_line2_bbbp_bgr,BITS),
57 glue(pl110_draw_line4_bbbp_bgr,BITS),
58 glue(pl110_draw_line8_bbbp_bgr,BITS),
59 glue(pl110_draw_line16_bbbp_bgr,BITS),
60 glue(pl110_draw_line32_bbbp_bgr,BITS),
62 glue(pl110_draw_line1_lbbp_bgr,BITS),
63 glue(pl110_draw_line2_lbbp_bgr,BITS),
64 glue(pl110_draw_line4_lbbp_bgr,BITS),
65 glue(pl110_draw_line8_lbbp_bgr,BITS),
66 glue(pl110_draw_line16_lbbp_bgr,BITS),
67 glue(pl110_draw_line32_lbbp_bgr,BITS),
69 glue(pl110_draw_line1_lblp_rgb,BITS),
70 glue(pl110_draw_line2_lblp_rgb,BITS),
71 glue(pl110_draw_line4_lblp_rgb,BITS),
72 glue(pl110_draw_line8_lblp_rgb,BITS),
73 glue(pl110_draw_line16_lblp_rgb,BITS),
74 glue(pl110_draw_line32_lblp_rgb,BITS),
76 glue(pl110_draw_line1_bbbp_rgb,BITS),
77 glue(pl110_draw_line2_bbbp_rgb,BITS),
78 glue(pl110_draw_line4_bbbp_rgb,BITS),
79 glue(pl110_draw_line8_bbbp_rgb,BITS),
80 glue(pl110_draw_line16_bbbp_rgb,BITS),
81 glue(pl110_draw_line32_bbbp_rgb,BITS),
83 glue(pl110_draw_line1_lbbp_rgb,BITS),
84 glue(pl110_draw_line2_lbbp_rgb,BITS),
85 glue(pl110_draw_line4_lbbp_rgb,BITS),
86 glue(pl110_draw_line8_lbbp_rgb,BITS),
87 glue(pl110_draw_line16_lbbp_rgb,BITS),
88 glue(pl110_draw_line32_lbbp_rgb,BITS),
97 #define NAME glue(glue(lblp_, BORDER), BITS)
98 #ifdef HOST_WORDS_BIGENDIAN
102 #define NAME glue(glue(bbbp_, BORDER), BITS)
103 #ifndef HOST_WORDS_BIGENDIAN
107 #define SWAP_PIXELS 1
108 #define NAME glue(glue(lbbp_, BORDER), BITS)
109 #ifdef HOST_WORDS_BIGENDIAN
114 #define FN_2(x, y) FN(x, y) FN(x+1, y)
115 #define FN_4(x, y) FN_2(x, y) FN_2(x+2, y)
116 #define FN_8(y) FN_4(0, y) FN_4(4, y)
118 static void glue(pl110_draw_line1_,NAME)(void *opaque, uint8_t *d, const uint8_t *src, int width, int deststep)
120 uint32_t *pallette = opaque;
123 data = *(uint32_t *)src;
125 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 7 - (x))) & 1]);
127 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x) + y)) & 1]);
146 static void glue(pl110_draw_line2_,NAME)(void *opaque, uint8_t *d, const uint8_t *src, int width, int deststep)
148 uint32_t *pallette = opaque;
151 data = *(uint32_t *)src;
153 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 6 - (x)*2)) & 3]);
155 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x)*2 + y)) & 3]);
174 static void glue(pl110_draw_line4_,NAME)(void *opaque, uint8_t *d, const uint8_t *src, int width, int deststep)
176 uint32_t *pallette = opaque;
179 data = *(uint32_t *)src;
181 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> (y + 4 - (x)*4)) & 0xf]);
183 #define FN(x, y) COPY_PIXEL(d, pallette[(data >> ((x)*4 + y)) & 0xf]);
202 static void glue(pl110_draw_line8_,NAME)(void *opaque, uint8_t *d, const uint8_t *src, int width, int deststep)
204 uint32_t *pallette = opaque;
207 data = *(uint32_t *)src;
208 #define FN(x) COPY_PIXEL(d, pallette[(data >> (x)) & 0xff]);
226 static void glue(pl110_draw_line16_,NAME)(void *opaque, uint8_t *d, const uint8_t *src, int width, int deststep)
229 unsigned int r, g, b;
231 data = *(uint32_t *)src;
233 data = bswap32(data);
250 LSB = (data & 0x1f) << 3;
252 g = (data & 0x3f) << 2;
254 MSB = (data & 0x1f) << 3;
257 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
258 LSB = (data & 0x1f) << 3;
260 g = (data & 0x3f) << 2;
262 MSB = (data & 0x1f) << 3;
264 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
272 static void glue(pl110_draw_line32_,NAME)(void *opaque, uint8_t *d, const uint8_t *src, int width, int deststep)
275 unsigned int r, g, b;
277 data = *(uint32_t *)src;
287 g = (data >> 8) & 0xff;
288 MSB = (data >> 16) & 0xff;
290 LSB = (data >> 24) & 0xff;
291 g = (data >> 16) & 0xff;
292 MSB = (data >> 8) & 0xff;
294 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));