Changeset 800eaf5 in mainline
- Timestamp:
- 2006-11-21T16:17:23Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d6f270f
- Parents:
- abc9fc5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/fb/fb.c
rabc9fc5 r800eaf5 98 98 static void rgb_4byte(void *dst, int rgb) 99 99 { 100 *( int *)dst= rgb;100 *((int *) dst) = rgb; 101 101 } 102 102 103 103 static int byte4_rgb(void *src) 104 104 { 105 return (*( int *)src) & 0xffffff;105 return (*((int *) src)) & 0xffffff; 106 106 } 107 107 … … 134 134 { 135 135 /* 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); 137 137 } 138 138 … … 154 154 static void rgb_1byte(void *dst, int rgb) 155 155 { 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); 157 157 } 158 158 … … 169 169 static void putpixel(unsigned int x, unsigned int y, int color) 170 170 { 171 (*rgb2scr)(&fbaddress[POINTPOS(x, y)], COLOR(color));171 (*rgb2scr)(&fbaddress[POINTPOS(x, y)], COLOR(color)); 172 172 173 173 if (dbbuffer) { 174 174 int dline = (y + dboffset) % yres; 175 (*rgb2scr)(&dbbuffer[POINTPOS(x, dline)], COLOR(color));175 (*rgb2scr)(&dbbuffer[POINTPOS(x, dline)], COLOR(color)); 176 176 } 177 177 } … … 182 182 if (dbbuffer) { 183 183 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)])); 187 187 } 188 188 … … 194 194 195 195 for (y = 0; y < yres; y++) { 196 memcpy(&fbaddress[scanline *y], blankline, xres*pixelbytes);196 memcpy(&fbaddress[scanline * y], blankline, xres * pixelbytes); 197 197 if (dbbuffer) 198 memcpy(&dbbuffer[scanline *y], blankline, xres*pixelbytes);198 memcpy(&dbbuffer[scanline * y], blankline, xres * pixelbytes); 199 199 } 200 200 } … … 208 208 209 209 if (dbbuffer) { 210 memcpy(&dbbuffer[dboffset *scanline], blankline, FONT_SCANLINES*scanline);210 memcpy(&dbbuffer[dboffset * scanline], blankline, FONT_SCANLINES * scanline); 211 211 212 212 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); 217 217 } else { 218 218 memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES); … … 359 359 { 360 360 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; 375 382 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"); 386 386 } 387 387 … … 410 410 411 411 /* 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); 421 414 if (!dbbuffer) 422 415 printf("Failed to allocate scroll buffer.\n"); … … 427 420 if (!blankline) 428 421 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 435 426 clear_screen(); 436 427 … … 443 434 chardev_initialize("fb", &framebuffer, &fb_ops); 444 435 stdout = &framebuffer; 445 446 436 } 447 437
Note:
See TracChangeset
for help on using the changeset viewer.