Revision e9c05b42

b/hw/pl110.c
10 10
#include "vl.h"
11 11

  
12 12
#define PL110_CR_EN   0x001
13
#define PL110_CR_BGR  0x100
13 14
#define PL110_CR_BEBO 0x200
14 15
#define PL110_CR_BEPO 0x400
15 16
#define PL110_CR_PWR  0x800
......
114 115
    int first, last = 0;
115 116
    int dirty, new_dirty;
116 117
    int i;
118
    int bpp_offset;
117 119

  
118 120
    if (!pl110_enabled(s))
119 121
        return;
......
145 147
        fprintf(stderr, "pl110: Bad color depth\n");
146 148
        exit(1);
147 149
    }
150
    if (s->cr & PL110_CR_BGR)
151
        bpp_offset = 0;
152
    else
153
        bpp_offset = 18;
154

  
148 155
    if (s->cr & PL110_CR_BEBO)
149
      fn = fntable[s->bpp + 6];
156
        fn = fntable[s->bpp + 6 + bpp_offset];
150 157
    else if (s->cr & PL110_CR_BEPO)
151
      fn = fntable[s->bpp + 12];
158
        fn = fntable[s->bpp + 12 + bpp_offset];
152 159
    else
153
      fn = fntable[s->bpp];
160
        fn = fntable[s->bpp + bpp_offset];
154 161

  
155 162
    src_width = s->cols;
156 163
    switch (s->bpp) {
b/hw/pl110_template.h
24 24
#error unknown bit depth
25 25
#endif
26 26

  
27
#undef RGB
28
#define BORDER bgr
27 29
#define ORDER 0
28 30
#include "pl110_template.h"
29 31
#define ORDER 1
30 32
#include "pl110_template.h"
31 33
#define ORDER 2
32 34
#include "pl110_template.h"
35
#undef BORDER
36
#define RGB
37
#define BORDER rgb
38
#define ORDER 0
39
#include "pl110_template.h"
40
#define ORDER 1
41
#include "pl110_template.h"
42
#define ORDER 2
43
#include "pl110_template.h"
44
#undef BORDER
33 45

  
34
static drawfn glue(pl110_draw_fn_,BITS)[18] =
46
static drawfn glue(pl110_draw_fn_,BITS)[36] =
35 47
{
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),
42

  
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),
49

  
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)
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),
54

  
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),
61

  
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),
68

  
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),
75

  
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),
82

  
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),
56 89
};
57 90

  
58 91
#undef BITS
......
61 94
#else
62 95

  
63 96
#if ORDER == 0
64
#define NAME glue(lblp, BITS)
97
#define NAME glue(glue(lblp_, BORDER), BITS)
65 98
#ifdef WORDS_BIGENDIAN
66 99
#define SWAP_WORDS 1
67 100
#endif
68 101
#elif ORDER == 1
69
#define NAME glue(bbbp, BITS)
102
#define NAME glue(glue(bbbp_, BORDER), BITS)
70 103
#ifndef WORDS_BIGENDIAN
71 104
#define SWAP_WORDS 1
72 105
#endif
73 106
#else
74 107
#define SWAP_PIXELS 1
75
#define NAME glue(lbbp, BITS)
108
#define NAME glue(glue(lbbp_, BORDER), BITS)
76 109
#ifdef WORDS_BIGENDIAN
77 110
#define SWAP_WORDS 1
78 111
#endif
......
195 228
#ifdef SWAP_WORDS
196 229
        data = bswap32(data);
197 230
#endif
231
#ifdef RGB
232
#define LSB r
233
#define MSB b
234
#else
235
#define LSB b
236
#define MSB r
237
#endif
198 238
#if 0
199
        r = data & 0x1f;
239
        LSB = data & 0x1f;
200 240
        data >>= 5;
201 241
        g = data & 0x3f;
202 242
        data >>= 6;
203
        b = data & 0x1f;
243
        MSB = data & 0x1f;
204 244
        data >>= 5;
205 245
#else
206
        r = (data & 0x1f) << 3;
246
        LSB = (data & 0x1f) << 3;
207 247
        data >>= 5;
208 248
        g = (data & 0x3f) << 2;
209 249
        data >>= 6;
210
        b = (data & 0x1f) << 3;
250
        MSB = (data & 0x1f) << 3;
211 251
        data >>= 5;
212 252
#endif
213 253
        COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
214
        r = (data & 0x1f) << 3;
254
        LSB = (data & 0x1f) << 3;
215 255
        data >>= 5;
216 256
        g = (data & 0x3f) << 2;
217 257
        data >>= 6;
218
        b = (data & 0x1f) << 3;
258
        MSB = (data & 0x1f) << 3;
219 259
        data >>= 5;
220 260
        COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
261
#undef MSB
262
#undef LSB
221 263
        width -= 2;
222 264
        src += 4;
223 265
    }
......
229 271
    unsigned int r, g, b;
230 272
    while (width > 0) {
231 273
        data = *(uint32_t *)src;
274
#ifdef RGB
275
#define LSB r
276
#define MSB b
277
#else
278
#define LSB b
279
#define MSB r
280
#endif
232 281
#ifdef SWAP_WORDS
233
        r = data & 0xff;
282
        LSB = data & 0xff;
234 283
        g = (data >> 8) & 0xff;
235
        b = (data >> 16) & 0xff;
284
        MSB = (data >> 16) & 0xff;
236 285
#else
237
        r = (data >> 24) & 0xff;
286
        LSB = (data >> 24) & 0xff;
238 287
        g = (data >> 16) & 0xff;
239
        b = (data >> 8) & 0xff;
288
        MSB = (data >> 8) & 0xff;
240 289
#endif
241 290
        COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
291
#undef MSB
292
#undef LSB
242 293
        width--;
243 294
        src += 4;
244 295
    }

Also available in: Unified diff