Changeset 965dc18 in mainline for kernel/genarch/src/fb/fb.c


Ignore:
Timestamp:
2008-12-05T19:59:03Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
49093a4
Parents:
0258e67
Message:

Merge sparc branch to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/fb/fb.c

    r0258e67 r965dc18  
    190190        *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 |
    191191            BLUE(rgb, 3);
     192}
     193
     194static 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;
    192212}
    193213
     
    437457/** Initialize framebuffer as a chardev output device
    438458 *
    439  * @param addr   Physical address of the framebuffer
    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  */
    446 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan,
    447     unsigned int visual)
    448 {
    449         switch (visual) {
     459 * @param props         Properties of the framebuffer device.
     460 */
     461void fb_init(fb_properties_t *props)
     462{
     463        switch (props->visual) {
    450464        case VISUAL_INDIRECT_8:
    451465                rgb2scr = rgb_byte8;
     
    453467                pixelbytes = 1;
    454468                break;
     469        case VISUAL_SB1500_PALETTE:
     470                rgb2scr = sb1500rgb_byte8;
     471                scr2rgb = byte8_rgb;
     472                pixelbytes = 1;
     473                break;
    455474        case VISUAL_RGB_5_5_5:
    456475                rgb2scr = rgb_byte555;
     
    487506        }
    488507       
    489         unsigned int fbsize = scan * y;
     508        unsigned int fbsize = props->scan * props->y + props->offset;
    490509       
    491510        /* Map the framebuffer */
    492         fbaddress = (uint8_t *) hw_map((uintptr_t) addr, fbsize);
    493        
    494         xres = x;
    495         yres = y;
    496         scanline = scan;
    497        
    498         rows = y / FONT_SCANLINES;
    499         columns = x / COL_WIDTH;
    500 
    501         fb_parea.pbase = (uintptr_t) addr;
     511        fbaddress = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize);
     512        fbaddress += props->offset;
     513       
     514        xres = props->x;
     515        yres = props->y;
     516        scanline = props->scan;
     517       
     518        rows = props->y / FONT_SCANLINES;
     519        columns = props->x / COL_WIDTH;
     520
     521        fb_parea.pbase = (uintptr_t) props->addr;
    502522        fb_parea.vbase = (uintptr_t) fbaddress;
    503523        fb_parea.frames = SIZE2FRAMES(fbsize);
     
    509529        sysinfo_set_item_val("fb.width", NULL, xres);
    510530        sysinfo_set_item_val("fb.height", NULL, yres);
    511         sysinfo_set_item_val("fb.scanline", NULL, scan);
    512         sysinfo_set_item_val("fb.visual", NULL, visual);
    513         sysinfo_set_item_val("fb.address.physical", NULL, addr);
     531        sysinfo_set_item_val("fb.scanline", NULL, props->scan);
     532        sysinfo_set_item_val("fb.visual", NULL, props->visual);
     533        sysinfo_set_item_val("fb.address.physical", NULL, props->addr);
    514534        sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
    515535
     
    525545        if (!blankline)
    526546                panic("Failed to allocate blank line for framebuffer.");
     547        unsigned int x, y;
    527548        for (y = 0; y < FONT_SCANLINES; y++)
    528549                for (x = 0; x < xres; x++)
Note: See TracChangeset for help on using the changeset viewer.