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.
13 #error "pl110_template.h is only for inclusion by pl110.c"
17 #define NAME glue(lblp_, BORDER)
22 #define NAME glue(bbbp_, BORDER)
28 #define NAME glue(lbbp_, BORDER)
34 #define FN_2(x, y) FN(x, y) FN(x+1, y)
35 #define FN_4(x, y) FN_2(x, y) FN_2(x+2, y)
36 #define FN_8(y) FN_4(0, y) FN_4(4, y)
38 static void glue(pl110_draw_line1_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
40 uint32_t *palette
= opaque
;
43 data
= *(uint32_t *)src
;
45 #define FN(x, y) COPY_PIXEL(d, palette[(data >> (y + 7 - (x))) & 1]);
47 #define FN(x, y) COPY_PIXEL(d, palette[(data >> ((x) + y)) & 1]);
66 static void glue(pl110_draw_line2_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
68 uint32_t *palette
= opaque
;
71 data
= *(uint32_t *)src
;
73 #define FN(x, y) COPY_PIXEL(d, palette[(data >> (y + 6 - (x)*2)) & 3]);
75 #define FN(x, y) COPY_PIXEL(d, palette[(data >> ((x)*2 + y)) & 3]);
94 static void glue(pl110_draw_line4_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
96 uint32_t *palette
= opaque
;
99 data
= *(uint32_t *)src
;
101 #define FN(x, y) COPY_PIXEL(d, palette[(data >> (y + 4 - (x)*4)) & 0xf]);
103 #define FN(x, y) COPY_PIXEL(d, palette[(data >> ((x)*4 + y)) & 0xf]);
122 static void glue(pl110_draw_line8_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
124 uint32_t *palette
= opaque
;
127 data
= *(uint32_t *)src
;
128 #define FN(x) COPY_PIXEL(d, palette[(data >> (x)) & 0xff]);
146 static void glue(pl110_draw_line16_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
149 unsigned int r
, g
, b
;
151 data
= *(uint32_t *)src
;
153 data
= bswap32(data
);
170 LSB
= (data
& 0x1f) << 3;
172 g
= (data
& 0x3f) << 2;
174 MSB
= (data
& 0x1f) << 3;
177 COPY_PIXEL(d
, rgb_to_pixel32(r
, g
, b
));
178 LSB
= (data
& 0x1f) << 3;
180 g
= (data
& 0x3f) << 2;
182 MSB
= (data
& 0x1f) << 3;
184 COPY_PIXEL(d
, rgb_to_pixel32(r
, g
, b
));
192 static void glue(pl110_draw_line32_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
195 unsigned int r
, g
, b
;
197 data
= *(uint32_t *)src
;
207 g
= (data
>> 8) & 0xff;
208 MSB
= (data
>> 16) & 0xff;
210 LSB
= (data
>> 24) & 0xff;
211 g
= (data
>> 16) & 0xff;
212 MSB
= (data
>> 8) & 0xff;
214 COPY_PIXEL(d
, rgb_to_pixel32(r
, g
, b
));
222 static void glue(pl110_draw_line16_555_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
224 /* RGB 555 plus an intensity bit (which we ignore) */
226 unsigned int r
, g
, b
;
228 data
= *(uint32_t *)src
;
230 data
= bswap32(data
);
239 LSB
= (data
& 0x1f) << 3;
241 g
= (data
& 0x1f) << 3;
243 MSB
= (data
& 0x1f) << 3;
245 COPY_PIXEL(d
, rgb_to_pixel32(r
, g
, b
));
246 LSB
= (data
& 0x1f) << 3;
248 g
= (data
& 0x1f) << 3;
250 MSB
= (data
& 0x1f) << 3;
252 COPY_PIXEL(d
, rgb_to_pixel32(r
, g
, b
));
260 static void glue(pl110_draw_line12_
,NAME
)(void *opaque
, uint8_t *d
, const uint8_t *src
, int width
, int deststep
)
262 /* RGB 444 with 4 bits of zeroes at the top of each halfword */
264 unsigned int r
, g
, b
;
266 data
= *(uint32_t *)src
;
268 data
= bswap32(data
);
277 LSB
= (data
& 0xf) << 4;
279 g
= (data
& 0xf) << 4;
281 MSB
= (data
& 0xf) << 4;
283 COPY_PIXEL(d
, rgb_to_pixel32(r
, g
, b
));
284 LSB
= (data
& 0xf) << 4;
286 g
= (data
& 0xf) << 4;
288 MSB
= (data
& 0xf) << 4;
290 COPY_PIXEL(d
, rgb_to_pixel32(r
, g
, b
));