Rev 1790 | Rev 1869 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1790 | Rev 1837 | ||
|---|---|---|---|
| Line 132... | Line 132... | ||
| 132 | { |
132 | { |
| 133 | int color = *(uint16_t *)(src); |
133 | int color = *(uint16_t *)(src); |
| 134 | return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
134 | return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
| 135 | } |
135 | } |
| 136 | 136 | ||
| 137 | /** Put pixel - 8-bit depth (3:2:3) */ |
137 | /** Put pixel - 8-bit depth (color palette/3:2:3) |
| - | 138 | * |
|
| - | 139 | * Even though we try 3:2:3 color scheme here, an 8-bit framebuffer |
|
| - | 140 | * will most likely use a color palette. The color appearance |
|
| - | 141 | * will be pretty random and depend on the default installed |
|
| - | 142 | * palette. This could be fixed by supporting custom palette |
|
| - | 143 | * and setting it to simulate the 8-bit truecolor. |
|
| - | 144 | */ |
|
| 138 | static void rgb_1byte(void *dst, int rgb) |
145 | static void rgb_1byte(void *dst, int rgb) |
| 139 | { |
146 | { |
| 140 | *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); |
147 | *(uint8_t *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); |
| 141 | } |
148 | } |
| 142 | 149 | ||
| 143 | /** Return pixel color - 8-bit depth (3:2:3) */ |
150 | /** Return pixel color - 8-bit depth (color palette/3:2:3) |
| - | 151 | * |
|
| - | 152 | * See the comment for rgb_1byte(). |
|
| - | 153 | */ |
|
| 144 | static int byte1_rgb(void *src) |
154 | static int byte1_rgb(void *src) |
| 145 | { |
155 | { |
| 146 | int color = *(uint8_t *)src; |
156 | int color = *(uint8_t *)src; |
| 147 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
157 | return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
| 148 | } |
158 | } |
| Line 327... | Line 337... | ||
| 327 | }; |
337 | }; |
| 328 | 338 | ||
| 329 | 339 | ||
| 330 | /** Initialize framebuffer as a chardev output device |
340 | /** Initialize framebuffer as a chardev output device |
| 331 | * |
341 | * |
| 332 | * @param addr Physical address of the framebuffer |
342 | * @param addr Physical address of the framebuffer |
| 333 | * @param x Screen width in pixels |
343 | * @param x Screen width in pixels |
| 334 | * @param y Screen height in pixels |
344 | * @param y Screen height in pixels |
| 335 | * @param bpp Bits per pixel (8, 16, 24, 32) |
345 | * @param bpp Bits per pixel (8, 16, 24, 32) |
| 336 | * @param scan Bytes per one scanline |
346 | * @param scan Bytes per one scanline |
| 337 | * |
- | |
| - | 347 | * @param align Request alignment for 24bpp mode. |
|
| 338 | */ |
348 | */ |
| 339 | void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan) |
349 | void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int bpp, unsigned int scan, bool align) |
| 340 | { |
350 | { |
| 341 | switch (bpp) { |
351 | switch (bpp) { |
| 342 | case 8: |
352 | case 8: |
| 343 | rgb2scr = rgb_1byte; |
353 | rgb2scr = rgb_1byte; |
| 344 | scr2rgb = byte1_rgb; |
354 | scr2rgb = byte1_rgb; |
| Line 350... | Line 360... | ||
| 350 | pixelbytes = 2; |
360 | pixelbytes = 2; |
| 351 | break; |
361 | break; |
| 352 | case 24: |
362 | case 24: |
| 353 | rgb2scr = rgb_3byte; |
363 | rgb2scr = rgb_3byte; |
| 354 | scr2rgb = byte3_rgb; |
364 | scr2rgb = byte3_rgb; |
| - | 365 | if (align) |
|
| - | 366 | pixelbytes = 4; |
|
| - | 367 | else |
|
| 355 | pixelbytes = 3; |
368 | pixelbytes = 3; |
| 356 | break; |
369 | break; |
| 357 | case 32: |
370 | case 32: |
| 358 | rgb2scr = rgb_4byte; |
371 | rgb2scr = rgb_4byte; |
| 359 | scr2rgb = byte4_rgb; |
372 | scr2rgb = byte4_rgb; |
| 360 | pixelbytes = 4; |
373 | pixelbytes = 4; |