Rev 2927 | Rev 4338 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2927 | Rev 3674 | ||
---|---|---|---|
Line 189... | Line 189... | ||
189 | { |
189 | { |
190 | *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | |
190 | *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | |
191 | BLUE(rgb, 3); |
191 | BLUE(rgb, 3); |
192 | } |
192 | } |
193 | 193 | ||
- | 194 | static void sb1500rgb_byte8(void *dst, int rgb) |
|
- | 195 | { |
|
- | 196 | if (RED(rgb, 1) && GREEN(rgb, 1) && BLUE(rgb, 1)) |
|
- | 197 | *((uint8_t *) dst) = 255; |
|
- | 198 | else if (RED(rgb, 1) && GREEN(rgb, 1)) |
|
- | 199 | *((uint8_t *) dst) = 150; |
|
- | 200 | else if (GREEN(rgb, 1) && BLUE(rgb, 1)) |
|
- | 201 | *((uint8_t *) dst) = 47; |
|
- | 202 | else if (RED(rgb, 1) && BLUE(rgb, 1)) |
|
- | 203 | *((uint8_t *) dst) = 48; |
|
- | 204 | else if (RED(rgb, 1)) |
|
- | 205 | *((uint8_t *) dst) = 32; |
|
- | 206 | else if (GREEN(rgb, 1)) |
|
- | 207 | *((uint8_t *) dst) = 47; |
|
- | 208 | else if (BLUE(rgb, 1)) |
|
- | 209 | *((uint8_t *) dst) = 2; |
|
- | 210 | else |
|
- | 211 | *((uint8_t *) dst) = 1; |
|
- | 212 | } |
|
- | 213 | ||
194 | /** Return pixel color - 8-bit depth (color palette/3:2:3) |
214 | /** Return pixel color - 8-bit depth (color palette/3:2:3) |
195 | * |
215 | * |
196 | * See the comment for rgb_byte(). |
216 | * See the comment for rgb_byte(). |
197 | */ |
217 | */ |
198 | static int byte8_rgb(void *src) |
218 | static int byte8_rgb(void *src) |
Line 434... | Line 454... | ||
434 | }; |
454 | }; |
435 | 455 | ||
436 | 456 | ||
437 | /** Initialize framebuffer as a chardev output device |
457 | /** Initialize framebuffer as a chardev output device |
438 | * |
458 | * |
439 | * @param addr Physical address of the framebuffer |
459 | * @param props Properties of the framebuffer device. |
440 | * @param x Screen width in pixels |
- | |
441 | * @param y Screen height in pixels |
- | |
442 | * @param scan Bytes per one scanline |
- | |
443 | * @param visual Color model |
- | |
444 | * |
- | |
445 | */ |
460 | */ |
446 | void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, |
- | |
447 | unsigned int visual) |
461 | void fb_init(fb_properties_t *props) |
448 | { |
462 | { |
449 | switch (visual) { |
463 | switch (props->visual) { |
450 | case VISUAL_INDIRECT_8: |
464 | case VISUAL_INDIRECT_8: |
451 | rgb2scr = rgb_byte8; |
465 | rgb2scr = rgb_byte8; |
452 | scr2rgb = byte8_rgb; |
466 | scr2rgb = byte8_rgb; |
453 | pixelbytes = 1; |
467 | pixelbytes = 1; |
454 | break; |
468 | break; |
- | 469 | case VISUAL_SB1500_PALETTE: |
|
- | 470 | rgb2scr = sb1500rgb_byte8; |
|
- | 471 | scr2rgb = byte8_rgb; |
|
- | 472 | pixelbytes = 1; |
|
- | 473 | break; |
|
455 | case VISUAL_RGB_5_5_5: |
474 | case VISUAL_RGB_5_5_5: |
456 | rgb2scr = rgb_byte555; |
475 | rgb2scr = rgb_byte555; |
457 | scr2rgb = byte555_rgb; |
476 | scr2rgb = byte555_rgb; |
458 | pixelbytes = 2; |
477 | pixelbytes = 2; |
459 | break; |
478 | break; |
Line 484... | Line 503... | ||
484 | break; |
503 | break; |
485 | default: |
504 | default: |
486 | panic("Unsupported visual.\n"); |
505 | panic("Unsupported visual.\n"); |
487 | } |
506 | } |
488 | 507 | ||
489 | unsigned int fbsize = scan * y; |
508 | unsigned int fbsize = props->scan * props->y + props->offset; |
490 | 509 | ||
491 | /* Map the framebuffer */ |
510 | /* Map the framebuffer */ |
492 | fbaddress = (uint8_t *) hw_map((uintptr_t) addr, fbsize); |
511 | fbaddress = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize); |
- | 512 | fbaddress += props->offset; |
|
493 | 513 | ||
494 | xres = x; |
514 | xres = props->x; |
495 | yres = y; |
515 | yres = props->y; |
496 | scanline = scan; |
516 | scanline = props->scan; |
497 | 517 | ||
498 | rows = y / FONT_SCANLINES; |
518 | rows = props->y / FONT_SCANLINES; |
499 | columns = x / COL_WIDTH; |
519 | columns = props->x / COL_WIDTH; |
500 | 520 | ||
501 | fb_parea.pbase = (uintptr_t) addr; |
521 | fb_parea.pbase = (uintptr_t) props->addr; |
502 | fb_parea.vbase = (uintptr_t) fbaddress; |
522 | fb_parea.vbase = (uintptr_t) fbaddress; |
503 | fb_parea.frames = SIZE2FRAMES(fbsize); |
523 | fb_parea.frames = SIZE2FRAMES(fbsize); |
504 | fb_parea.cacheable = false; |
524 | fb_parea.cacheable = false; |
505 | ddi_parea_register(&fb_parea); |
525 | ddi_parea_register(&fb_parea); |
506 | 526 | ||
507 | sysinfo_set_item_val("fb", NULL, true); |
527 | sysinfo_set_item_val("fb", NULL, true); |
508 | sysinfo_set_item_val("fb.kind", NULL, 1); |
528 | sysinfo_set_item_val("fb.kind", NULL, 1); |
509 | sysinfo_set_item_val("fb.width", NULL, xres); |
529 | sysinfo_set_item_val("fb.width", NULL, xres); |
510 | sysinfo_set_item_val("fb.height", NULL, yres); |
530 | sysinfo_set_item_val("fb.height", NULL, yres); |
511 | sysinfo_set_item_val("fb.scanline", NULL, scan); |
531 | sysinfo_set_item_val("fb.scanline", NULL, props->scan); |
512 | sysinfo_set_item_val("fb.visual", NULL, visual); |
532 | sysinfo_set_item_val("fb.visual", NULL, props->visual); |
513 | sysinfo_set_item_val("fb.address.physical", NULL, addr); |
533 | sysinfo_set_item_val("fb.address.physical", NULL, props->addr); |
514 | sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors); |
534 | sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors); |
515 | 535 | ||
516 | /* Allocate double buffer */ |
536 | /* Allocate double buffer */ |
517 | unsigned int order = fnzb(SIZE2FRAMES(fbsize) - 1) + 1; |
537 | unsigned int order = fnzb(SIZE2FRAMES(fbsize) - 1) + 1; |
518 | dbbuffer = (uint8_t *) frame_alloc(order, FRAME_ATOMIC | FRAME_KA); |
538 | dbbuffer = (uint8_t *) frame_alloc(order, FRAME_ATOMIC | FRAME_KA); |
Line 522... | Line 542... | ||
522 | 542 | ||
523 | /* Initialized blank line */ |
543 | /* Initialized blank line */ |
524 | blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC); |
544 | blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC); |
525 | if (!blankline) |
545 | if (!blankline) |
526 | panic("Failed to allocate blank line for framebuffer."); |
546 | panic("Failed to allocate blank line for framebuffer."); |
- | 547 | unsigned int x, y; |
|
527 | for (y = 0; y < FONT_SCANLINES; y++) |
548 | for (y = 0; y < FONT_SCANLINES; y++) |
528 | for (x = 0; x < xres; x++) |
549 | for (x = 0; x < xres; x++) |
529 | (*rgb2scr)(&blankline[POINTPOS(x, y)], COLOR(BGCOLOR)); |
550 | (*rgb2scr)(&blankline[POINTPOS(x, y)], COLOR(BGCOLOR)); |
530 | 551 | ||
531 | clear_screen(); |
552 | clear_screen(); |