Changeset 2bc137c2 in mainline for kernel/genarch
- Timestamp:
- 2006-11-22T12:36:59Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ccb0cbc
- Parents:
- 33dc0ad
- Location:
- kernel/genarch
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/include/fb/fb.h
r33dc0ad r2bc137c2 40 40 41 41 extern 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);42 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual); 43 43 44 44 #endif -
kernel/genarch/src/fb/fb.c
r33dc0ad r2bc137c2 34 34 35 35 #include <genarch/fb/font-8x16.h> 36 #include <genarch/fb/visuals.h> 36 37 #include <genarch/fb/fb.h> 37 38 #include <console/chardev.h> … … 59 60 static unsigned int yres = 0; 60 61 static unsigned int scanline = 0; 61 static unsigned int bitspp = 0;62 62 static unsigned int pixelbytes = 0; 63 63 #ifdef FB_INVERT_COLORS … … 96 96 97 97 /* Conversion routines between different color representations */ 98 static void rgb_ 4byte(void *dst, int rgb)98 static void rgb_byte0888(void *dst, int rgb) 99 99 { 100 100 *((int *) dst) = rgb; 101 101 } 102 102 103 static int byte 4_rgb(void *src)103 static int byte0888_rgb(void *src) 104 104 { 105 105 return (*((int *) src)) & 0xffffff; 106 106 } 107 107 108 static void rgb_ 3byte(void *dst, int rgb)108 static void rgb_byte888(void *dst, int rgb) 109 109 { 110 110 uint8_t *scr = dst; … … 120 120 } 121 121 122 static int byte 3_rgb(void *src)122 static int byte888_rgb(void *src) 123 123 { 124 124 uint8_t *scr = src; … … 130 130 } 131 131 132 /** 16-bit depth (5:5:5) */ 133 static 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) */ 140 static 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 132 146 /** 16-bit depth (5:6:5) */ 133 static void rgb_ 2byte(void *dst, int rgb)147 static void rgb_byte565(void *dst, int rgb) 134 148 { 135 149 /* 5-bit, 6-bits, 5-bits */ … … 138 152 139 153 /** 16-bit depth (5:6:5) */ 140 static int byte 2_rgb(void *src)154 static int byte565_rgb(void *src) 141 155 { 142 156 int color = *(uint16_t *)(src); … … 152 166 * and setting it to simulate the 8-bit truecolor. 153 167 */ 154 static void rgb_ 1byte(void *dst, int rgb)168 static void rgb_byte8(void *dst, int rgb) 155 169 { 156 170 *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); … … 159 173 /** Return pixel color - 8-bit depth (color palette/3:2:3) 160 174 * 161 * See the comment for rgb_ 1byte().162 */ 163 static int byte 1_rgb(void *src)175 * See the comment for rgb_byte(). 176 */ 177 static int byte8_rgb(void *src) 164 178 { 165 179 int color = *(uint8_t *)src; … … 208 222 209 223 if (dbbuffer) { 210 memcpy(&dbbuffer[dboffset * scanline], blankline, FONT_SCANLINES * scanline);224 memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES); 211 225 212 226 dboffset = (dboffset + FONT_SCANLINES) % yres; … … 349 363 /** Initialize framebuffer as a chardev output device 350 364 * 351 * @param addr 352 * @param x 353 * @param y 354 * @param bpp Bits per pixel (8, 16, 24, 32)355 * @param scan Bytes per one scanline356 * @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 = byte 1_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 */ 372 void 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; 364 378 pixelbytes = 1; 365 379 break; 366 case 16:367 rgb2scr = rgb_ 2byte;368 scr2rgb = byte 2_rgb;380 case VISUAL_RGB_5_5_5: 381 rgb2scr = rgb_byte555; 382 scr2rgb = byte555_rgb; 369 383 pixelbytes = 2; 370 384 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; 382 398 pixelbytes = 4; 383 399 break; 400 case VISUAL_RGB_0_8_8_8: 401 rgb2scr = rgb_byte0888; 402 scr2rgb = byte0888_rgb; 403 pixelbytes = 4; 404 break; 384 405 default: 385 panic("Unsupported bpp.\n");406 panic("Unsupported visual.\n"); 386 407 } 387 408 … … 393 414 xres = x; 394 415 yres = y; 395 bitspp = bpp;396 416 scanline = scan; 397 417 … … 403 423 sysinfo_set_item_val("fb.width", NULL, xres); 404 424 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);407 425 sysinfo_set_item_val("fb.scanline", NULL, scan); 426 sysinfo_set_item_val("fb.visual", NULL, visual); 408 427 sysinfo_set_item_val("fb.address.physical", NULL, addr); 409 428 sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
Note:
See TracChangeset
for help on using the changeset viewer.