Changeset 51baa8a in mainline
- Timestamp:
- 2007-01-26T17:04:42Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6f4495f5
- Parents:
- e71a61d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/fb/fb.c
re71a61d r51baa8a 82 82 #define LOGOCOLOR 0x2020b0 83 83 84 #define RED(x, bits) ((x >> ( 16+ 8 - bits)) & ((1 << bits) - 1))84 #define RED(x, bits) ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1)) 85 85 #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) 86 86 #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) … … 112 112 static void bgr_byte0888(void *dst, int rgb) 113 113 { 114 *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb,115 114 *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | 115 RED(rgb, 8); 116 116 } 117 117 … … 119 119 { 120 120 int color = *(uint32_t *)(src); 121 return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color122 121 return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | 122 ((color >> 16) & 0xff); 123 123 } 124 124 … … 151 151 { 152 152 /* 5-bit, 5-bits, 5-bits */ 153 *((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb,154 153 *((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | 154 BLUE(rgb, 5); 155 155 } 156 156 … … 159 159 { 160 160 int color = *(uint16_t *)(src); 161 return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) <<162 161 return (((color >> 10) & 0x1f) << (16 + 3)) | 162 (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); 163 163 } 164 164 … … 167 167 { 168 168 /* 5-bit, 6-bits, 5-bits */ 169 *((uint16_t *) dst) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5); 169 *((uint16_t *) dst) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | 170 BLUE(rgb, 5); 170 171 } 171 172 … … 174 175 { 175 176 int color = *(uint16_t *)(src); 176 return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) <<177 177 return (((color >> 11) & 0x1f) << (16 + 3)) | 178 (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); 178 179 } 179 180 … … 188 189 static void rgb_byte8(void *dst, int rgb) 189 190 { 190 *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb,191 191 *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | 192 BLUE(rgb, 3); 192 193 } 193 194 … … 199 200 { 200 201 int color = *(uint8_t *)src; 201 return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8202 202 return (((color >> 5) & 0x7) << (16 + 5)) | 203 (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); 203 204 } 204 205 … … 232 233 memcpy(&fbaddress[scanline * y], blankline, xres * pixelbytes); 233 234 if (dbbuffer) 234 memcpy(&dbbuffer[scanline * y], blankline, xres *235 235 memcpy(&dbbuffer[scanline * y], blankline, 236 xres * pixelbytes); 236 237 } 237 238 } … … 244 245 count_t first; 245 246 247 /* Clear the last row */ 246 248 memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES); 247 249 248 250 dboffset = (dboffset + FONT_SCANLINES) % yres; 249 251 first = yres - dboffset; 250 251 memcpy(fbaddress, &dbbuffer[scanline * dboffset], first * 252 scanline); 253 memcpy(&fbaddress[first * scanline], dbbuffer, dboffset * 254 scanline); 252 253 /* Move all rows one row up */ 254 if (xres * pixelbytes == scanline) { 255 memcpy(fbaddress, &dbbuffer[dboffset * scanline], 256 first * scanline); 257 memcpy(&fbaddress[first * scanline], dbbuffer, 258 dboffset * scanline); 259 } else { 260 /* 261 * When the scanline is bigger than number of bytes 262 * in the X-resolution, chances are that the 263 * frame buffer memory past the X-resolution is special 264 * in some way. For example, the SUNW,ffb framebuffer 265 * wraps this area around the beginning of the same 266 * line. To avoid troubles, copy only memory as 267 * specified by the resolution. 268 */ 269 int i; 270 271 for (i = 0; i < first; i++) 272 memcpy(&fbaddress[i * scanline], 273 &dbbuffer[(dboffset + i) * scanline], 274 xres * pixelbytes); 275 for (i = 0; i < dboffset; i++) 276 memcpy(&fbaddress[(first + i) * scanline], 277 &dbbuffer[i * scanline], xres * pixelbytes); 278 } 255 279 } else { 256 280 uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES]; 257 281 258 memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], 259 scanline * yres - ROW_BYTES); 260 /* Clear last row */ 261 memcpy((void *) lastline, (void *) blankline, ROW_BYTES); 282 if (xres * pixelbytes == scanline) { 283 /* Move all rows one row up */ 284 memcpy((void *) fbaddress, 285 (void *) &fbaddress[ROW_BYTES], 286 scanline * yres - ROW_BYTES); 287 /* Clear the last row */ 288 memcpy((void *) lastline, (void *) blankline, 289 ROW_BYTES); 290 } else { 291 /* 292 * See the comment in the dbbuffer case. 293 */ 294 int i; 295 296 /* Move all rows one row up */ 297 for (i = 0; i < yres - FONT_SCANLINES; i++) 298 memcpy(&fbaddress[i * scanline], 299 &fbaddress[(i + FONT_SCANLINES) * scanline], 300 xres * pixelbytes); 301 /* Clear the last row */ 302 for (i = 0; i < FONT_SCANLINES; i++) 303 memcpy(&lastline[i * scanline], 304 &blankline[i * scanline], 305 xres * pixelbytes); 306 } 262 307 } 263 308 } … … 291 336 292 337 for (y = 0; y < FONT_SCANLINES; y++) 293 draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col *294 338 draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], 339 col * COL_WIDTH, row * FONT_SCANLINES + y); 295 340 } 296 341 … … 303 348 for (x = 0; x < COL_WIDTH; x++) 304 349 for (y = 0; y < FONT_SCANLINES; y++) 305 invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES +306 350 invert_pixel(col * COL_WIDTH + x, 351 row * FONT_SCANLINES + y); 307 352 } 308 353 … … 328 373 if (byte & 1) 329 374 putpixel(startx + x, starty + y, 330 375 COLOR(LOGOCOLOR)); 331 376 } 332 377 } … … 401 446 */ 402 447 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, 403 448 unsigned int visual) 404 449 { 405 450 switch (visual) { … … 468 513 sysinfo_set_item_val("fb.visual", NULL, visual); 469 514 sysinfo_set_item_val("fb.address.physical", NULL, addr); 470 sysinfo_set_item_val("fb.address.color", NULL, PAGE_COLOR((uintptr_t)471 515 sysinfo_set_item_val("fb.address.color", NULL, 516 PAGE_COLOR((uintptr_t) fbaddress)); 472 517 sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors); 473 518
Note:
See TracChangeset
for help on using the changeset viewer.