Changeset 2bc137c2 in mainline for kernel/genarch


Ignore:
Timestamp:
2006-11-22T12:36:59Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ccb0cbc
Parents:
33dc0ad
Message:

make framebuffer code more generic

Location:
kernel/genarch
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/include/fb/fb.h

    r33dc0ad r2bc137c2  
    4040
    4141extern 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);
     42void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual);
    4343
    4444#endif
  • kernel/genarch/src/fb/fb.c

    r33dc0ad r2bc137c2  
    3434
    3535#include <genarch/fb/font-8x16.h>
     36#include <genarch/fb/visuals.h>
    3637#include <genarch/fb/fb.h>
    3738#include <console/chardev.h>
     
    5960static unsigned int yres = 0;
    6061static unsigned int scanline = 0;
    61 static unsigned int bitspp = 0;
    6262static unsigned int pixelbytes = 0;
    6363#ifdef FB_INVERT_COLORS
     
    9696
    9797/* Conversion routines between different color representations */
    98 static void rgb_4byte(void *dst, int rgb)
     98static void rgb_byte0888(void *dst, int rgb)
    9999{
    100100        *((int *) dst) = rgb;
    101101}
    102102
    103 static int byte4_rgb(void *src)
     103static int byte0888_rgb(void *src)
    104104{
    105105        return (*((int *) src)) & 0xffffff;
    106106}
    107107
    108 static void rgb_3byte(void *dst, int rgb)
     108static void rgb_byte888(void *dst, int rgb)
    109109{
    110110        uint8_t *scr = dst;
     
    120120}
    121121
    122 static int byte3_rgb(void *src)
     122static int byte888_rgb(void *src)
    123123{
    124124        uint8_t *scr = src;
     
    130130}
    131131
     132/**  16-bit depth (5:5:5) */
     133static 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) */
     140static 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
    132146/**  16-bit depth (5:6:5) */
    133 static void rgb_2byte(void *dst, int rgb)
     147static void rgb_byte565(void *dst, int rgb)
    134148{
    135149        /* 5-bit, 6-bits, 5-bits */
     
    138152
    139153/** 16-bit depth (5:6:5) */
    140 static int byte2_rgb(void *src)
     154static int byte565_rgb(void *src)
    141155{
    142156        int color = *(uint16_t *)(src);
     
    152166 * and setting it to simulate the 8-bit truecolor.
    153167 */
    154 static void rgb_1byte(void *dst, int rgb)
     168static void rgb_byte8(void *dst, int rgb)
    155169{
    156170        *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
     
    159173/** Return pixel color - 8-bit depth (color palette/3:2:3)
    160174 *
    161  * See the comment for rgb_1byte().
    162  */
    163 static int byte1_rgb(void *src)
     175 * See the comment for rgb_byte().
     176 */
     177static int byte8_rgb(void *src)
    164178{
    165179        int color = *(uint8_t *)src;
     
    208222
    209223        if (dbbuffer) {
    210                 memcpy(&dbbuffer[dboffset * scanline], blankline, FONT_SCANLINES * scanline);
     224                memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES);
    211225               
    212226                dboffset = (dboffset + FONT_SCANLINES) % yres;
     
    349363/** Initialize framebuffer as a chardev output device
    350364 *
    351  * @param addr  Physical address of the framebuffer
    352  * @param x     Screen width in pixels
    353  * @param y     Screen height in pixels
    354  * @param bpp   Bits per pixel (8, 16, 24, 32)
    355  * @param scan  Bytes per one scanline
    356  * @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 = byte1_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 */
     372void 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;
    364378                pixelbytes = 1;
    365379                break;
    366         case 16:
    367                 rgb2scr = rgb_2byte;
    368                 scr2rgb = byte2_rgb;
     380        case VISUAL_RGB_5_5_5:
     381                rgb2scr = rgb_byte555;
     382                scr2rgb = byte555_rgb;
    369383                pixelbytes = 2;
    370384                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;
    382398                pixelbytes = 4;
    383399                break;
     400        case VISUAL_RGB_0_8_8_8:
     401                rgb2scr = rgb_byte0888;
     402                scr2rgb = byte0888_rgb;
     403                pixelbytes = 4;
     404                break;
    384405        default:
    385                 panic("Unsupported bpp.\n");
     406                panic("Unsupported visual.\n");
    386407        }
    387408       
     
    393414        xres = x;
    394415        yres = y;
    395         bitspp = bpp;
    396416        scanline = scan;
    397417       
     
    403423        sysinfo_set_item_val("fb.width", NULL, xres);
    404424        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);
    407425        sysinfo_set_item_val("fb.scanline", NULL, scan);
     426        sysinfo_set_item_val("fb.visual", NULL, visual);
    408427        sysinfo_set_item_val("fb.address.physical", NULL, addr);
    409428        sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
Note: See TracChangeset for help on using the changeset viewer.