Changeset fcbca14f in mainline
- Timestamp:
- 2006-02-14T15:41:13Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 23230aa
- Parents:
- 95c7526
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
genarch/src/fb/fb.c
r95c7526 rfcbca14f 31 31 #include <console/chardev.h> 32 32 #include <console/console.h> 33 #include <p rint.h>33 #include <panic.h> 34 34 35 35 SPINLOCK_INITIALIZE(fb_lock); … … 58 58 /* Pixel specific fuctions */ 59 59 60 /** Draw pixel of given color on screen */ 61 static inline void putpixel(int x,int y,int color) 62 { 63 int startbyte = POINTPOS(x,y); 64 65 if (pixelbytes == 3) { 66 fbaddress[startbyte] = RED(color,8); 67 fbaddress[startbyte+1] = GREEN(color,8); 68 fbaddress[startbyte+2] = BLUE(color,8); 69 } else if (pixelbytes == 4) { 70 *((__u32 *)(fbaddress+startbyte)) = color; 71 } else { 72 int compcolor; 73 /* 5-bit, 5-bits, 5-bits */ 74 compcolor = RED(color,5) << 10 \ 75 | GREEN(color,5) << 5 \ 76 | BLUE(color,5); 77 *((__u16 *)(fbaddress+startbyte)) = compcolor; 78 } 60 static void (*putpixel)(int x,int y,int color); 61 static int (*getpixel)(int x,int y); 62 63 /** Put pixel - 24-bit depth, 1 free byte */ 64 static void putpixel_4byte(int x,int y,int color) 65 { 66 int startbyte = POINTPOS(x,y); 67 68 *((__u32 *)(fbaddress+startbyte)) = color; 79 69 } 80 70 81 71 /** Return pixel color */ 82 static inline int getpixel(int x,int y) 72 static int getpixel_4byte(int x,int y) 73 { 74 int startbyte = POINTPOS(x,y); 75 76 return *((__u32 *)(fbaddress+startbyte)) & 0xffffff; 77 } 78 79 /** Draw pixel of given color on screen - 24-bit depth */ 80 static void putpixel_3byte(int x,int y,int color) 81 { 82 int startbyte = POINTPOS(x,y); 83 84 fbaddress[startbyte] = RED(color,8); 85 fbaddress[startbyte+1] = GREEN(color,8); 86 fbaddress[startbyte+2] = BLUE(color,8); 87 } 88 89 static int getpixel_3byte(int x,int y) 90 { 91 int startbyte = POINTPOS(x,y); 92 int result; 93 94 result = fbaddress[startbyte] << 16 \ 95 | fbaddress[startbyte+1] << 8 \ 96 | fbaddress[startbyte+2]; 97 return result; 98 } 99 100 /** Put pixel - 16-bit depth (5:6:6) */ 101 static void putpixel_2byte(int x,int y,int color) 102 { 103 int startbyte = POINTPOS(x,y); 104 int compcolor; 105 106 /* 5-bit, 5-bits, 5-bits */ 107 compcolor = RED(color,5) << 11 \ 108 | GREEN(color,6) << 5 \ 109 | BLUE(color,5); 110 *((__u16 *)(fbaddress+startbyte)) = compcolor; 111 } 112 113 static int getpixel_2byte(int x,int y) 83 114 { 84 115 int startbyte = POINTPOS(x,y); 85 116 int color; 86 int result; 87 88 if (pixelbytes == 3) { 89 result = fbaddress[startbyte] << 16 \ 90 | fbaddress[startbyte+1] << 8 \ 91 | fbaddress[startbyte+2]; 92 } else if (pixelbytes == 4) { 93 result = *((__u32 *)(fbaddress+startbyte)) & 0xffffff; 94 } else { 95 int red,green,blue; 96 color = *((__u16 *)(fbaddress+startbyte)); 97 red = (color >> 10) & 0x1f; 98 green = (color >> 5) & 0x1f; 99 blue = color & 0x1f; 100 result = (red << 16) | (green << 8) | blue; 101 } 102 return result; 117 int red,green,blue; 118 119 color = *((__u16 *)(fbaddress+startbyte)); 120 red = (color >> 11) & 0x1f; 121 green = (color >> 5) & 0x3f; 122 blue = color & 0x1f; 123 return (red << (16+3)) | (green << (8+2)) | (blue << 3); 124 } 125 126 /** Put pixel - 8-bit depth (3:3:2) */ 127 static void putpixel_1byte(int x,int y,int color) 128 { 129 int compcolor; 130 131 /* 3-bit, 3-bits, 2-bits */ 132 compcolor = RED(color,3) << 5 \ 133 | GREEN(color,3) << 2 \ 134 | BLUE(color,2); 135 fbaddress[POINTPOS(x,y)] = compcolor; 136 } 137 138 139 static int getpixel_1byte(int x,int y) 140 { 141 int color; 142 int red,green,blue; 143 144 color = fbaddress[POINTPOS(x,y)]; 145 red = (color >> 5) & 0x7; 146 green = (color >> 5) & 0x7; 147 blue = color & 0x3; 148 return (red << (16+5)) | (green << (8+5)) | blue << 6; 103 149 } 104 150 … … 127 173 int x; 128 174 for (x=0; x<xres;x++) 129 putpixel(x,y,BGCOLOR);175 (*putpixel)(x,y,BGCOLOR); 130 176 } 131 177 … … 141 187 static void invert_pixel(int x, int y) 142 188 { 143 putpixel(x,y, ~getpixel(x,y));189 (*putpixel)(x,y, ~(*getpixel)(x,y)); 144 190 } 145 191 … … 152 198 for (i=0; i < 8; i++) 153 199 if (glline & (1 << (7-i))) { 154 putpixel(x+i,y,FGCOLOR);200 (*putpixel)(x+i,y,FGCOLOR); 155 201 } else 156 putpixel(x+i,y,BGCOLOR);202 (*putpixel)(x+i,y,BGCOLOR); 157 203 } 158 204 … … 247 293 { 248 294 fbaddress = (unsigned char *)addr; 295 296 switch (bytes) { 297 case 1: 298 putpixel = putpixel_1byte; 299 getpixel = getpixel_1byte; 300 break; 301 case 2: 302 putpixel = putpixel_2byte; 303 getpixel = getpixel_2byte; 304 break; 305 case 3: 306 putpixel = putpixel_3byte; 307 getpixel = getpixel_3byte; 308 break; 309 case 4: 310 putpixel = putpixel_4byte; 311 getpixel = getpixel_4byte; 312 break; 313 default: 314 panic("Unsupported color depth"); 315 } 249 316 250 317 xres = x;
Note:
See TracChangeset
for help on using the changeset viewer.