Commit e9c05b42e33e60a18e443d6526e9400ea2714444

Authored by balrog
1 parent 4d043a09

Implement PL110 byte order config bit (original patch by Richard Purdie).


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3330 c046a42c-6fe2-441c-8c8c-71466251a162
hw/pl110.c
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 #include "vl.h" 10 #include "vl.h"
11 11
12 #define PL110_CR_EN 0x001 12 #define PL110_CR_EN 0x001
  13 +#define PL110_CR_BGR 0x100
13 #define PL110_CR_BEBO 0x200 14 #define PL110_CR_BEBO 0x200
14 #define PL110_CR_BEPO 0x400 15 #define PL110_CR_BEPO 0x400
15 #define PL110_CR_PWR 0x800 16 #define PL110_CR_PWR 0x800
@@ -114,6 +115,7 @@ static void pl110_update_display(void *opaque) @@ -114,6 +115,7 @@ static void pl110_update_display(void *opaque)
114 int first, last = 0; 115 int first, last = 0;
115 int dirty, new_dirty; 116 int dirty, new_dirty;
116 int i; 117 int i;
  118 + int bpp_offset;
117 119
118 if (!pl110_enabled(s)) 120 if (!pl110_enabled(s))
119 return; 121 return;
@@ -145,12 +147,17 @@ static void pl110_update_display(void *opaque) @@ -145,12 +147,17 @@ static void pl110_update_display(void *opaque)
145 fprintf(stderr, "pl110: Bad color depth\n"); 147 fprintf(stderr, "pl110: Bad color depth\n");
146 exit(1); 148 exit(1);
147 } 149 }
  150 + if (s->cr & PL110_CR_BGR)
  151 + bpp_offset = 0;
  152 + else
  153 + bpp_offset = 18;
  154 +
148 if (s->cr & PL110_CR_BEBO) 155 if (s->cr & PL110_CR_BEBO)
149 - fn = fntable[s->bpp + 6]; 156 + fn = fntable[s->bpp + 6 + bpp_offset];
150 else if (s->cr & PL110_CR_BEPO) 157 else if (s->cr & PL110_CR_BEPO)
151 - fn = fntable[s->bpp + 12]; 158 + fn = fntable[s->bpp + 12 + bpp_offset];
152 else 159 else
153 - fn = fntable[s->bpp]; 160 + fn = fntable[s->bpp + bpp_offset];
154 161
155 src_width = s->cols; 162 src_width = s->cols;
156 switch (s->bpp) { 163 switch (s->bpp) {
hw/pl110_template.h
@@ -24,35 +24,68 @@ @@ -24,35 +24,68 @@
24 #error unknown bit depth 24 #error unknown bit depth
25 #endif 25 #endif
26 26
  27 +#undef RGB
  28 +#define BORDER bgr
27 #define ORDER 0 29 #define ORDER 0
28 #include "pl110_template.h" 30 #include "pl110_template.h"
29 #define ORDER 1 31 #define ORDER 1
30 #include "pl110_template.h" 32 #include "pl110_template.h"
31 #define ORDER 2 33 #define ORDER 2
32 #include "pl110_template.h" 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 #undef BITS 91 #undef BITS
@@ -61,18 +94,18 @@ static drawfn glue(pl110_draw_fn_,BITS)[18] = @@ -61,18 +94,18 @@ static drawfn glue(pl110_draw_fn_,BITS)[18] =
61 #else 94 #else
62 95
63 #if ORDER == 0 96 #if ORDER == 0
64 -#define NAME glue(lblp, BITS) 97 +#define NAME glue(glue(lblp_, BORDER), BITS)
65 #ifdef WORDS_BIGENDIAN 98 #ifdef WORDS_BIGENDIAN
66 #define SWAP_WORDS 1 99 #define SWAP_WORDS 1
67 #endif 100 #endif
68 #elif ORDER == 1 101 #elif ORDER == 1
69 -#define NAME glue(bbbp, BITS) 102 +#define NAME glue(glue(bbbp_, BORDER), BITS)
70 #ifndef WORDS_BIGENDIAN 103 #ifndef WORDS_BIGENDIAN
71 #define SWAP_WORDS 1 104 #define SWAP_WORDS 1
72 #endif 105 #endif
73 #else 106 #else
74 #define SWAP_PIXELS 1 107 #define SWAP_PIXELS 1
75 -#define NAME glue(lbbp, BITS) 108 +#define NAME glue(glue(lbbp_, BORDER), BITS)
76 #ifdef WORDS_BIGENDIAN 109 #ifdef WORDS_BIGENDIAN
77 #define SWAP_WORDS 1 110 #define SWAP_WORDS 1
78 #endif 111 #endif
@@ -195,29 +228,38 @@ static void glue(pl110_draw_line16_,NAME)(uint32_t *pallette, uint8_t *d, const @@ -195,29 +228,38 @@ static void glue(pl110_draw_line16_,NAME)(uint32_t *pallette, uint8_t *d, const
195 #ifdef SWAP_WORDS 228 #ifdef SWAP_WORDS
196 data = bswap32(data); 229 data = bswap32(data);
197 #endif 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 #if 0 238 #if 0
199 - r = data & 0x1f; 239 + LSB = data & 0x1f;
200 data >>= 5; 240 data >>= 5;
201 g = data & 0x3f; 241 g = data & 0x3f;
202 data >>= 6; 242 data >>= 6;
203 - b = data & 0x1f; 243 + MSB = data & 0x1f;
204 data >>= 5; 244 data >>= 5;
205 #else 245 #else
206 - r = (data & 0x1f) << 3; 246 + LSB = (data & 0x1f) << 3;
207 data >>= 5; 247 data >>= 5;
208 g = (data & 0x3f) << 2; 248 g = (data & 0x3f) << 2;
209 data >>= 6; 249 data >>= 6;
210 - b = (data & 0x1f) << 3; 250 + MSB = (data & 0x1f) << 3;
211 data >>= 5; 251 data >>= 5;
212 #endif 252 #endif
213 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); 253 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
214 - r = (data & 0x1f) << 3; 254 + LSB = (data & 0x1f) << 3;
215 data >>= 5; 255 data >>= 5;
216 g = (data & 0x3f) << 2; 256 g = (data & 0x3f) << 2;
217 data >>= 6; 257 data >>= 6;
218 - b = (data & 0x1f) << 3; 258 + MSB = (data & 0x1f) << 3;
219 data >>= 5; 259 data >>= 5;
220 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); 260 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
  261 +#undef MSB
  262 +#undef LSB
221 width -= 2; 263 width -= 2;
222 src += 4; 264 src += 4;
223 } 265 }
@@ -229,16 +271,25 @@ static void glue(pl110_draw_line32_,NAME)(uint32_t *pallette, uint8_t *d, const @@ -229,16 +271,25 @@ static void glue(pl110_draw_line32_,NAME)(uint32_t *pallette, uint8_t *d, const
229 unsigned int r, g, b; 271 unsigned int r, g, b;
230 while (width > 0) { 272 while (width > 0) {
231 data = *(uint32_t *)src; 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 #ifdef SWAP_WORDS 281 #ifdef SWAP_WORDS
233 - r = data & 0xff; 282 + LSB = data & 0xff;
234 g = (data >> 8) & 0xff; 283 g = (data >> 8) & 0xff;
235 - b = (data >> 16) & 0xff; 284 + MSB = (data >> 16) & 0xff;
236 #else 285 #else
237 - r = (data >> 24) & 0xff; 286 + LSB = (data >> 24) & 0xff;
238 g = (data >> 16) & 0xff; 287 g = (data >> 16) & 0xff;
239 - b = (data >> 8) & 0xff; 288 + MSB = (data >> 8) & 0xff;
240 #endif 289 #endif
241 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b)); 290 COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
  291 +#undef MSB
  292 +#undef LSB
242 width--; 293 width--;
243 src += 4; 294 src += 4;
244 } 295 }