Changeset 2bc137c2 in mainline for uspace/fb/fb.c
- Timestamp:
- 2006-11-22T12:36:59Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ccb0cbc
- Parents:
- 33dc0ad
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/fb/fb.c
r33dc0ad r2bc137c2 50 50 #include <ipc/services.h> 51 51 #include <kernel/errno.h> 52 #include <kernel/genarch/fb/visuals.h> 52 53 #include <async.h> 54 #include <bool.h> 53 55 54 56 #include "font-8x16.h" … … 148 150 149 151 /* Conversion routines between different color representations */ 150 static void rgb_ 4byte(void *dst, int rgb)152 static void rgb_byte0888(void *dst, int rgb) 151 153 { 152 154 *(int *)dst = rgb; 153 155 } 154 156 155 static int byte 4_rgb(void *src)157 static int byte0888_rgb(void *src) 156 158 { 157 159 return (*(int *)src) & 0xffffff; 158 160 } 159 161 160 static void rgb_ 3byte(void *dst, int rgb)162 static void rgb_byte888(void *dst, int rgb) 161 163 { 162 164 uint8_t *scr = dst; … … 172 174 } 173 175 174 static int byte 3_rgb(void *src)176 static int byte888_rgb(void *src) 175 177 { 176 178 uint8_t *scr = src; … … 182 184 } 183 185 186 /** 16-bit depth (5:5:5) */ 187 static void rgb_byte555(void *dst, int rgb) 188 { 189 /* 5-bit, 5-bits, 5-bits */ 190 *((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5); 191 } 192 193 /** 16-bit depth (5:5:5) */ 194 static int byte555_rgb(void *src) 195 { 196 int color = *(uint16_t *)(src); 197 return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); 198 } 199 184 200 /** 16-bit depth (5:6:5) */ 185 static void rgb_ 2byte(void *dst, int rgb)201 static void rgb_byte565(void *dst, int rgb) 186 202 { 187 203 /* 5-bit, 6-bits, 5-bits */ … … 190 206 191 207 /** 16-bit depth (5:6:5) */ 192 static int byte 2_rgb(void *src)208 static int byte565_rgb(void *src) 193 209 { 194 210 int color = *(uint16_t *)(src); … … 197 213 198 214 /** Put pixel - 8-bit depth (3:2:3) */ 199 static void rgb_ 1byte(void *dst, int rgb)215 static void rgb_byte8(void *dst, int rgb) 200 216 { 201 217 *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); … … 203 219 204 220 /** Return pixel color - 8-bit depth (3:2:3) */ 205 static int byte 1_rgb(void *src)221 static int byte8_rgb(void *src) 206 222 { 207 223 int color = *(uint8_t *)src; … … 453 469 /** Initialize framebuffer as a chardev output device 454 470 * 455 * @param addr Address of theframebuffer 456 * @param xres Screen width in pixels 457 * @param yres Screen height in pixels 458 * @param bpp Bits per pixel (8, 16, 24, 32) 459 * @param scan Bytes per one scanline 460 * @param align Alignment for 24bpp mode. 471 * @param addr Address of theframebuffer 472 * @param xres Screen width in pixels 473 * @param yres Screen height in pixels 474 * @param visual Bits per pixel (8, 16, 24, 32) 475 * @param scan Bytes per one scanline 461 476 * @param invert_colors Inverted colors. 462 477 * 463 478 */ 464 static void 465 screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan, 466 int align, int invert_colors) 467 { 468 switch (bpp) { 469 case 8: 470 screen.rgb2scr = rgb_1byte; 471 screen.scr2rgb = byte1_rgb; 479 static bool screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int scan, unsigned int visual, bool invert_colors) 480 { 481 switch (visual) { 482 case VISUAL_INDIRECT_8: 483 screen.rgb2scr = rgb_byte8; 484 screen.scr2rgb = byte8_rgb; 472 485 screen.pixelbytes = 1; 473 486 break; 474 case 16:475 screen.rgb2scr = rgb_ 2byte;476 screen.scr2rgb = byte 2_rgb;487 case VISUAL_RGB_5_5_5: 488 screen.rgb2scr = rgb_byte555; 489 screen.scr2rgb = byte555_rgb; 477 490 screen.pixelbytes = 2; 478 491 break; 479 case 24: 480 screen.rgb2scr = rgb_3byte; 481 screen.scr2rgb = byte3_rgb; 482 if (!align) 483 screen.pixelbytes = 3; 484 else 485 screen.pixelbytes = 4; 486 break; 487 case 32: 488 screen.rgb2scr = rgb_4byte; 489 screen.scr2rgb = byte4_rgb; 492 case VISUAL_RGB_5_6_5: 493 screen.rgb2scr = rgb_byte565; 494 screen.scr2rgb = byte565_rgb; 495 screen.pixelbytes = 2; 496 break; 497 case VISUAL_RGB_8_8_8: 498 screen.rgb2scr = rgb_byte888; 499 screen.scr2rgb = byte888_rgb; 500 screen.pixelbytes = 3; 501 break; 502 case VISUAL_RGB_8_8_8_0: 503 screen.rgb2scr = rgb_byte888; 504 screen.scr2rgb = byte888_rgb; 490 505 screen.pixelbytes = 4; 491 506 break; 507 case VISUAL_RGB_0_8_8_8: 508 screen.rgb2scr = rgb_byte0888; 509 screen.scr2rgb = byte0888_rgb; 510 screen.pixelbytes = 4; 511 break; 512 default: 513 return false; 492 514 } 493 515 … … 499 521 500 522 /* Create first viewport */ 501 viewport_create(0,0,xres,yres); 523 viewport_create(0, 0, xres, yres); 524 525 return true; 502 526 } 503 527 … … 1227 1251 unsigned int fb_width; 1228 1252 unsigned int fb_height; 1229 unsigned int fb_bpp;1230 unsigned int fb_bpp_align;1231 1253 unsigned int fb_scanline; 1232 unsigned int fb_invert_colors; 1254 unsigned int fb_visual; 1255 bool fb_invert_colors; 1233 1256 void *fb_addr; 1234 1257 size_t asz; … … 1239 1262 fb_width = sysinfo_value("fb.width"); 1240 1263 fb_height = sysinfo_value("fb.height"); 1241 fb_bpp = sysinfo_value("fb.bpp");1242 fb_bpp_align = sysinfo_value("fb.bpp-align");1243 1264 fb_scanline = sysinfo_value("fb.scanline"); 1265 fb_visual = sysinfo_value("fb.visual"); 1244 1266 fb_invert_colors = sysinfo_value("fb.invert-colors"); 1245 1267 1246 asz = fb_scanline *fb_height;1268 asz = fb_scanline * fb_height; 1247 1269 fb_addr = as_get_mappable_page(asz); 1248 1270 … … 1250 1272 AS_AREA_READ | AS_AREA_WRITE); 1251 1273 1252 screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, fb_bpp_align, fb_invert_colors); 1253 return 0; 1274 if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual, fb_invert_colors)) 1275 return 0; 1276 1277 return -1; 1254 1278 } 1255 1279
Note:
See TracChangeset
for help on using the changeset viewer.