Changeset 800eaf5 in mainline


Ignore:
Timestamp:
2006-11-21T16:17:23Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d6f270f
Parents:
abc9fc5
Message:

framebuffer cleanup

File:
1 edited

Legend:

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

    rabc9fc5 r800eaf5  
    9898static void rgb_4byte(void *dst, int rgb)
    9999{
    100         *(int *)dst = rgb;
     100        *((int *) dst) = rgb;
    101101}
    102102
    103103static int byte4_rgb(void *src)
    104104{
    105         return (*(int *)src) & 0xffffff;
     105        return (*((int *) src)) & 0xffffff;
    106106}
    107107
     
    134134{
    135135        /* 5-bit, 6-bits, 5-bits */
    136         *((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
     136        *((uint16_t *) dst) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5);
    137137}
    138138
     
    154154static void rgb_1byte(void *dst, int rgb)
    155155{
    156         *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
     156        *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3);
    157157}
    158158
     
    169169static void putpixel(unsigned int x, unsigned int y, int color)
    170170{
    171         (*rgb2scr)(&fbaddress[POINTPOS(x,y)], COLOR(color));
     171        (*rgb2scr)(&fbaddress[POINTPOS(x, y)], COLOR(color));
    172172
    173173        if (dbbuffer) {
    174174                int dline = (y + dboffset) % yres;
    175                 (*rgb2scr)(&dbbuffer[POINTPOS(x,dline)], COLOR(color));
     175                (*rgb2scr)(&dbbuffer[POINTPOS(x, dline)], COLOR(color));
    176176        }
    177177}
     
    182182        if (dbbuffer) {
    183183                int dline = (y + dboffset) % yres;
    184                 return COLOR((*scr2rgb)(&dbbuffer[POINTPOS(x,dline)]));
    185         }
    186         return COLOR((*scr2rgb)(&fbaddress[POINTPOS(x,y)]));
     184                return COLOR((*scr2rgb)(&dbbuffer[POINTPOS(x, dline)]));
     185        }
     186        return COLOR((*scr2rgb)(&fbaddress[POINTPOS(x, y)]));
    187187}
    188188
     
    194194
    195195        for (y = 0; y < yres; y++) {
    196                 memcpy(&fbaddress[scanline*y], blankline, xres*pixelbytes);
     196                memcpy(&fbaddress[scanline * y], blankline, xres * pixelbytes);
    197197                if (dbbuffer)
    198                         memcpy(&dbbuffer[scanline*y], blankline, xres*pixelbytes);
     198                        memcpy(&dbbuffer[scanline * y], blankline, xres * pixelbytes);
    199199        }
    200200}
     
    208208
    209209        if (dbbuffer) {
    210                 memcpy(&dbbuffer[dboffset*scanline], blankline, FONT_SCANLINES*scanline);
     210                memcpy(&dbbuffer[dboffset * scanline], blankline, FONT_SCANLINES * scanline);
    211211               
    212212                dboffset = (dboffset + FONT_SCANLINES) % yres;
    213                 firstsz = yres-dboffset;
    214 
    215                 memcpy(fbaddress, &dbbuffer[scanline*dboffset], firstsz*scanline);
    216                 memcpy(&fbaddress[firstsz*scanline], dbbuffer, dboffset*scanline);
     213                firstsz = yres - dboffset;
     214
     215                memcpy(fbaddress, &dbbuffer[scanline * dboffset], firstsz * scanline);
     216                memcpy(&fbaddress[firstsz * scanline], dbbuffer, dboffset * scanline);
    217217        } else {
    218218                memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES);
     
    359359{
    360360        switch (bpp) {
    361         case 8:
    362                 rgb2scr = rgb_1byte;
    363                 scr2rgb = byte1_rgb;
    364                 pixelbytes = 1;
    365                 break;
    366         case 16:
    367                 rgb2scr = rgb_2byte;
    368                 scr2rgb = byte2_rgb;
    369                 pixelbytes = 2;
    370                 break;
    371         case 24:
    372                 rgb2scr = rgb_3byte;
    373                 scr2rgb = byte3_rgb;
    374                 if (align)
     361                case 8:
     362                        rgb2scr = rgb_1byte;
     363                        scr2rgb = byte1_rgb;
     364                        pixelbytes = 1;
     365                        break;
     366                case 16:
     367                        rgb2scr = rgb_2byte;
     368                        scr2rgb = byte2_rgb;
     369                        pixelbytes = 2;
     370                        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;
    375382                        pixelbytes = 4;
    376                 else
    377                         pixelbytes = 3;
    378                 break;
    379         case 32:
    380                 rgb2scr = rgb_4byte;
    381                 scr2rgb = byte4_rgb;
    382                 pixelbytes = 4;
    383                 break;
    384         default:
    385                 panic("Unsupported bpp.\n");
     383                        break;
     384                default:
     385                        panic("Unsupported bpp.\n");
    386386        }
    387387       
     
    410410
    411411        /* Allocate double buffer */
    412         int totsize = scanline * yres;
    413         int pages = SIZE2FRAMES(totsize);
    414         int order;
    415         if (pages == 1)
    416                 order = 0;
    417         else
    418                 order = fnzb(pages - 1) + 1;
    419 
    420         dbbuffer = frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
     412        unsigned int order = fnzb(SIZE2FRAMES(ALIGN_UP(fbsize, FRAME_SIZE))) + 1;
     413        dbbuffer = (uint8_t * ) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
    421414        if (!dbbuffer)
    422415                printf("Failed to allocate scroll buffer.\n");
     
    427420        if (!blankline)
    428421                panic("Failed to allocate blank line for framebuffer.");
    429         for (y=0; y < FONT_SCANLINES; y++) {
    430                 for (x=0; x < xres; x++) {
    431                         (*rgb2scr)(&blankline[POINTPOS(x,y)], COLOR(BGCOLOR));
    432                 }
    433         }
    434 
     422        for (y = 0; y < FONT_SCANLINES; y++)
     423                for (x = 0; x < xres; x++)
     424                        (*rgb2scr)(&blankline[POINTPOS(x, y)], COLOR(BGCOLOR));
     425       
    435426        clear_screen();
    436427
     
    443434        chardev_initialize("fb", &framebuffer, &fb_ops);
    444435        stdout = &framebuffer;
    445        
    446436}
    447437
Note: See TracChangeset for help on using the changeset viewer.