Changeset 2bc137c2 in mainline
- Timestamp:
- 2006-11-22T12:36:59Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ccb0cbc
- Parents:
- 33dc0ad
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/drivers/vesa.c
r33dc0ad r2bc137c2 38 38 39 39 #include <genarch/fb/fb.h> 40 #include <genarch/fb/visuals.h> 40 41 #include <arch/drivers/vesa.h> 41 42 #include <putchar.h> … … 68 69 void vesa_init(void) 69 70 { 70 fb_init(vesa_ph_addr, vesa_width, vesa_height, vesa_bpp, vesa_scanline, false); 71 unsigned int visual; 72 73 switch (vesa_bpp) { 74 case 8: 75 visual = VISUAL_INDIRECT_8; 76 break; 77 case 16: 78 visual = VISUAL_RGB_5_6_5; 79 break; 80 case 24: 81 visual = VISUAL_RGB_8_8_8; 82 break; 83 case 32: 84 visual = VISUAL_RGB_0_8_8_8; 85 break; 86 default: 87 panic("Unsupported bits per pixel"); 88 } 89 90 fb_init(vesa_ph_addr, vesa_width, vesa_height, vesa_scanline, visual); 71 91 } 72 92 -
kernel/arch/mips32/src/mips32.c
r33dc0ad r2bc137c2 54 54 #include <arch/debugger.h> 55 55 #include <genarch/fb/fb.h> 56 #include <genarch/fb/visuals.h> 56 57 #include <macros.h> 57 58 #include <ddi/device.h> … … 123 124 console_init(device_assign_devno()); 124 125 #ifdef CONFIG_FB 125 fb_init(0x12000000, 640, 480, 24, 1920, false); // gxemul framebuffer126 fb_init(0x12000000, 640, 480, 1920, VISUAL_RGB_8_8_8); // gxemul framebuffer 126 127 #endif 127 128 sysinfo_set_item_val("machine." STRING(MACHINE), NULL, 1); -
kernel/arch/ppc32/src/ppc32.c
r33dc0ad r2bc137c2 39 39 #include <arch/interrupt.h> 40 40 #include <genarch/fb/fb.h> 41 #include <genarch/fb/visuals.h> 41 42 #include <userspace.h> 42 43 #include <proc/uarg.h> … … 76 77 if (config.cpu_active == 1) { 77 78 /* Initialize framebuffer */ 78 fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline, false); 79 unsigned int visual; 80 81 switch (bootinfo.screen.bpp) { 82 case 8: 83 visual = VISUAL_INDIRECT_8; 84 break; 85 case 16: 86 visual = VISUAL_RGB_5_5_5; 87 break; 88 case 24: 89 visual = VISUAL_RGB_8_8_8; 90 break; 91 case 32: 92 visual = VISUAL_RGB_0_8_8_8; 93 break; 94 default: 95 panic("Unsupported bits per pixel"); 96 } 97 fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.scanline, visual); 79 98 80 99 /* Initialize IRQ routing */ -
kernel/arch/ppc64/src/ppc64.c
r33dc0ad r2bc137c2 38 38 #include <arch/interrupt.h> 39 39 #include <genarch/fb/fb.h> 40 #include <genarch/fb/visuals.h> 40 41 #include <userspace.h> 41 42 #include <proc/uarg.h> … … 69 70 { 70 71 if (config.cpu_active == 1) { 71 fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline, false); 72 /* Initialize framebuffer */ 73 unsigned int visual; 74 75 switch (bootinfo.screen.bpp) { 76 case 8: 77 visual = VISUAL_INDIRECT_8; 78 break; 79 case 16: 80 visual = VISUAL_RGB_5_5_5; 81 break; 82 case 24: 83 visual = VISUAL_RGB_8_8_8; 84 break; 85 case 32: 86 visual = VISUAL_RGB_0_8_8_8; 87 break; 88 default: 89 panic("Unsupported bits per pixel"); 90 } 91 fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.scanline, visual); 92 72 93 73 94 /* Merge all zones to 1 big zone */ -
kernel/arch/sparc64/src/drivers/scr.c
r33dc0ad r2bc137c2 36 36 #include <genarch/ofw/ofw_tree.h> 37 37 #include <genarch/fb/fb.h> 38 #include <genarch/fb/visuals.h> 38 39 #include <arch/types.h> 39 40 #include <typedefs.h> … … 76 77 uint32_t fb_linebytes = 0; 77 78 uint32_t fb_scanline = 0; 79 unsigned int visual; 78 80 79 81 prop = ofw_tree_getprop(node, "width"); … … 116 118 return; 117 119 } 118 119 if (fb_depth == 24) 120 121 switch (fb_depth) { 122 case 8: 123 fb_scanline = fb_linebytes * (fb_depth >> 3); 124 visual = VISUAL_INDIRECT_8; 125 break; 126 case 16: 127 fb_scanline = fb_linebytes * (fb_depth >> 3); 128 visual = VISUAL_RGB_5_6_5; 129 break; 130 case 24: 120 131 fb_scanline = fb_linebytes * 4; 121 else 132 visual = VISUAL_RGB_8_8_8_0; 133 break; 134 case 32: 122 135 fb_scanline = fb_linebytes * (fb_depth >> 3); 136 visual = VISUAL_RGB_0_8_8_8; 137 break; 138 default: 139 printf("Unsupported bits per pixel.\n"); 140 return; 141 } 123 142 124 143 break; 125 144 case SCR_FFB: 126 fb_depth = 32;127 145 fb_scanline = 8192; 146 visual = VISUAL_RGB_0_8_8_8; 128 147 129 148 ofw_upa_reg_t *reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP]; … … 138 157 } 139 158 140 fb_init(fb_addr, fb_width, fb_height, fb_ depth, fb_scanline, true);159 fb_init(fb_addr, fb_width, fb_height, fb_scanline, visual); 141 160 } 142 161 -
kernel/genarch/include/fb/fb.h
r33dc0ad r2bc137c2 40 40 41 41 extern spinlock_t fb_lock; 42 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, bool align);42 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual); 43 43 44 44 #endif -
kernel/genarch/src/fb/fb.c
r33dc0ad r2bc137c2 34 34 35 35 #include <genarch/fb/font-8x16.h> 36 #include <genarch/fb/visuals.h> 36 37 #include <genarch/fb/fb.h> 37 38 #include <console/chardev.h> … … 59 60 static unsigned int yres = 0; 60 61 static unsigned int scanline = 0; 61 static unsigned int bitspp = 0;62 62 static unsigned int pixelbytes = 0; 63 63 #ifdef FB_INVERT_COLORS … … 96 96 97 97 /* Conversion routines between different color representations */ 98 static void rgb_ 4byte(void *dst, int rgb)98 static void rgb_byte0888(void *dst, int rgb) 99 99 { 100 100 *((int *) dst) = rgb; 101 101 } 102 102 103 static int byte 4_rgb(void *src)103 static int byte0888_rgb(void *src) 104 104 { 105 105 return (*((int *) src)) & 0xffffff; 106 106 } 107 107 108 static void rgb_ 3byte(void *dst, int rgb)108 static void rgb_byte888(void *dst, int rgb) 109 109 { 110 110 uint8_t *scr = dst; … … 120 120 } 121 121 122 static int byte 3_rgb(void *src)122 static int byte888_rgb(void *src) 123 123 { 124 124 uint8_t *scr = src; … … 130 130 } 131 131 132 /** 16-bit depth (5:5:5) */ 133 static void rgb_byte555(void *dst, int rgb) 134 { 135 /* 5-bit, 5-bits, 5-bits */ 136 *((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5); 137 } 138 139 /** 16-bit depth (5:5:5) */ 140 static int byte555_rgb(void *src) 141 { 142 int color = *(uint16_t *)(src); 143 return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); 144 } 145 132 146 /** 16-bit depth (5:6:5) */ 133 static void rgb_ 2byte(void *dst, int rgb)147 static void rgb_byte565(void *dst, int rgb) 134 148 { 135 149 /* 5-bit, 6-bits, 5-bits */ … … 138 152 139 153 /** 16-bit depth (5:6:5) */ 140 static int byte 2_rgb(void *src)154 static int byte565_rgb(void *src) 141 155 { 142 156 int color = *(uint16_t *)(src); … … 152 166 * and setting it to simulate the 8-bit truecolor. 153 167 */ 154 static void rgb_ 1byte(void *dst, int rgb)168 static void rgb_byte8(void *dst, int rgb) 155 169 { 156 170 *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); … … 159 173 /** Return pixel color - 8-bit depth (color palette/3:2:3) 160 174 * 161 * See the comment for rgb_ 1byte().162 */ 163 static int byte 1_rgb(void *src)175 * See the comment for rgb_byte(). 176 */ 177 static int byte8_rgb(void *src) 164 178 { 165 179 int color = *(uint8_t *)src; … … 208 222 209 223 if (dbbuffer) { 210 memcpy(&dbbuffer[dboffset * scanline], blankline, FONT_SCANLINES * scanline);224 memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES); 211 225 212 226 dboffset = (dboffset + FONT_SCANLINES) % yres; … … 349 363 /** Initialize framebuffer as a chardev output device 350 364 * 351 * @param addr 352 * @param x 353 * @param y 354 * @param bpp Bits per pixel (8, 16, 24, 32)355 * @param scan Bytes per one scanline356 * @param align Request alignment for 24bpp mode.357 */ 358 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, bool align)359 { 360 switch ( bpp) {361 case 8:362 rgb2scr = rgb_ 1byte;363 scr2rgb = byte 1_rgb;365 * @param addr Physical address of the framebuffer 366 * @param x Screen width in pixels 367 * @param y Screen height in pixels 368 * @param scan Bytes per one scanline 369 * @param visual Color model 370 * 371 */ 372 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual) 373 { 374 switch (visual) { 375 case VISUAL_INDIRECT_8: 376 rgb2scr = rgb_byte8; 377 scr2rgb = byte8_rgb; 364 378 pixelbytes = 1; 365 379 break; 366 case 16:367 rgb2scr = rgb_ 2byte;368 scr2rgb = byte 2_rgb;380 case VISUAL_RGB_5_5_5: 381 rgb2scr = rgb_byte555; 382 scr2rgb = byte555_rgb; 369 383 pixelbytes = 2; 370 384 break; 371 case 24: 372 rgb2scr = rgb_3byte; 373 scr2rgb = byte3_rgb; 374 if (align) 375 pixelbytes = 4; 376 else 377 pixelbytes = 3; 378 break; 379 case 32: 380 rgb2scr = rgb_4byte; 381 scr2rgb = byte4_rgb; 385 case VISUAL_RGB_5_6_5: 386 rgb2scr = rgb_byte565; 387 scr2rgb = byte565_rgb; 388 pixelbytes = 2; 389 break; 390 case VISUAL_RGB_8_8_8: 391 rgb2scr = rgb_byte888; 392 scr2rgb = byte888_rgb; 393 pixelbytes = 3; 394 break; 395 case VISUAL_RGB_8_8_8_0: 396 rgb2scr = rgb_byte888; 397 scr2rgb = byte888_rgb; 382 398 pixelbytes = 4; 383 399 break; 400 case VISUAL_RGB_0_8_8_8: 401 rgb2scr = rgb_byte0888; 402 scr2rgb = byte0888_rgb; 403 pixelbytes = 4; 404 break; 384 405 default: 385 panic("Unsupported bpp.\n");406 panic("Unsupported visual.\n"); 386 407 } 387 408 … … 393 414 xres = x; 394 415 yres = y; 395 bitspp = bpp;396 416 scanline = scan; 397 417 … … 403 423 sysinfo_set_item_val("fb.width", NULL, xres); 404 424 sysinfo_set_item_val("fb.height", NULL, yres); 405 sysinfo_set_item_val("fb.bpp", NULL, bpp);406 sysinfo_set_item_val("fb.bpp-align", NULL, align);407 425 sysinfo_set_item_val("fb.scanline", NULL, scan); 426 sysinfo_set_item_val("fb.visual", NULL, visual); 408 427 sysinfo_set_item_val("fb.address.physical", NULL, addr); 409 428 sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors); -
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.