board/csky: fixup gdb instructions in readme.txt
[buildroot-gz.git] / package / fbv / 0004-fix-bgr555.patch
blob8f185f0a37a61a80871f1cd38334e4bc1d1fde2f
1 [PATCH] fbv: support bgr555 format
3 Signed-off-by: Josh.Wu <josh.wu@atmel.com>
4 diff -Naur fbv-1.0b-ori/fb_display.c fbv-1.0b/fb_display.c
5 --- fbv-1.0b-ori/fb_display.c 2010-04-02 09:38:15.000000000 +0800
6 +++ fbv-1.0b/fb_display.c 2010-04-01 18:54:15.000000000 +0800
7 @@ -297,6 +297,14 @@
8 ((b >> 3) & 31) );
11 +inline static unsigned short make15color_bgr(unsigned char r, unsigned char g, unsigned char b)
13 + return (
14 + (((b >> 3) & 31) << 10) |
15 + (((g >> 3) & 31) << 5) |
16 + ((r >> 3) & 31) );
19 inline static unsigned short make16color(unsigned char r, unsigned char g, unsigned char b)
21 return (
22 @@ -313,6 +321,14 @@
23 u_int16_t *s_fbbuff;
24 u_int32_t *i_fbbuff;
26 + int is_bgr555 = 0;
27 + struct fb_var_screeninfo var;
28 + getVarScreenInfo(fh, &var);
29 + if(var.red.offset == 0 &&
30 + var.green.offset == 5 &&
31 + var.blue.offset == 10)
32 + is_bgr555 = 1;
34 switch(bpp)
36 case 8:
37 @@ -325,15 +341,23 @@
38 case 15:
39 *cpp = 2;
40 s_fbbuff = (unsigned short *) malloc(count * sizeof(unsigned short));
41 - for(i = 0; i < count ; i++)
42 - s_fbbuff[i] = make15color(rgbbuff[i*3], rgbbuff[i*3+1], rgbbuff[i*3+2]);
43 + if(is_bgr555)
44 + for(i = 0; i < count ; i++)
45 + s_fbbuff[i] = make15color_bgr(rgbbuff[i*3], rgbbuff[i*3+1], rgbbuff[i*3+2]);
46 + else
47 + for(i = 0; i < count ; i++)
48 + s_fbbuff[i] = make15color(rgbbuff[i*3], rgbbuff[i*3+1], rgbbuff[i*3+2]);
49 fbbuff = (void *) s_fbbuff;
50 break;
51 case 16:
52 *cpp = 2;
53 s_fbbuff = (unsigned short *) malloc(count * sizeof(unsigned short));
54 - for(i = 0; i < count ; i++)
55 - s_fbbuff[i] = make16color(rgbbuff[i*3], rgbbuff[i*3+1], rgbbuff[i*3+2]);
56 + if(is_bgr555)
57 + for(i = 0; i < count ; i++)
58 + s_fbbuff[i] = make15color_bgr(rgbbuff[i*3], rgbbuff[i*3+1], rgbbuff[i*3+2]);
59 + else
60 + for(i = 0; i < count ; i++)
61 + s_fbbuff[i] = make16color(rgbbuff[i*3], rgbbuff[i*3+1], rgbbuff[i*3+2]);
62 fbbuff = (void *) s_fbbuff;
63 break;
64 case 24: