Changeset 30885b9 in mainline for kernel/genarch/src/fb/fb.c
- Timestamp:
- 2009-07-31T19:11:54Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a405563
- Parents:
- 646b996
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/fb/fb.c
r646b996 r30885b9 51 51 #include <ddi/ddi.h> 52 52 #include <arch/types.h> 53 #include <byteorder.h> 53 54 54 55 SPINLOCK_INITIALIZE(fb_lock); … … 81 82 #define INV_COLOR 0xaaaaaa 82 83 83 #define RED(x, bits) (( x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1))84 #define GREEN(x, bits) (( x >> (8 + 8 - bits)) & ((1 << bits) - 1))85 #define BLUE(x, bits) (( x >> (8 - bits)) & ((1 << bits) - 1))84 #define RED(x, bits) (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1)) 85 #define GREEN(x, bits) (((x) >> (8 + 8 - (bits))) & ((1 << (bits)) - 1)) 86 #define BLUE(x, bits) (((x) >> (8 - (bits))) & ((1 << (bits)) - 1)) 86 87 87 88 #define COL2X(col) ((col) * FONT_WIDTH) … … 98 99 static void (*rgb_conv)(void *, uint32_t); 99 100 100 101 /** ARGB 8:8:8:8 conversion 102 * 103 */ 101 /* 102 * RGB conversion functions. 103 * 104 * These functions write an RGB value to some memory in some predefined format. 105 * The naming convention corresponds to the format created by these functions. 106 * The functions use the so called network order (i.e. big endian) with respect 107 * to their names. 108 */ 109 104 110 static void rgb_0888(void *dst, uint32_t rgb) 105 111 { 106 *((uint32_t *) dst) = rgb & 0xffffff; 107 } 108 109 110 /** ABGR 8:8:8:8 conversion 111 * 112 */ 112 *((uint32_t *) dst) = host2uint32_t_be((0 << 24) | 113 (RED(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (BLUE(rgb, 8))); 114 } 115 113 116 static void bgr_0888(void *dst, uint32_t rgb) 114 117 { 115 *((uint32_t *) dst) 116 = (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | RED(rgb, 8);118 *((uint32_t *) dst) = host2uint32_t_be((0 << 24) | 119 (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (RED(rgb, 8))); 117 120 } 118 121 119 122 static void rgb_8880(void *dst, uint32_t rgb) 120 123 { 121 *((uint32_t *) dst) 122 = (RED(rgb, 8) << 24) | (GREEN(rgb, 8) << 16) | (BLUE(rgb, 8) << 8); 123 124 } 125 126 127 /** RGB 8:8:8 conversion 128 * 129 */ 124 *((uint32_t *) dst) = host2uint32_t_be((RED(rgb, 8) << 24) | 125 (GREEN(rgb, 8) << 16) | (BLUE(rgb, 8) << 8) | 0); 126 } 127 128 static void bgr_8880(void *dst, uint32_t rgb) 129 { 130 *((uint32_t *) dst) = host2uint32_t_be((BLUE(rgb, 8) << 24) | 131 (GREEN(rgb, 8) << 16) | (RED(rgb, 8) << 8) | 0); 132 } 133 130 134 static void rgb_888(void *dst, uint32_t rgb) 135 { 136 ((uint8_t *) dst)[0] = RED(rgb, 8); 137 ((uint8_t *) dst)[1] = GREEN(rgb, 8); 138 ((uint8_t *) dst)[2] = BLUE(rgb, 8); 139 } 140 141 static void bgr_888(void *dst, uint32_t rgb) 131 142 { 132 143 ((uint8_t *) dst)[0] = BLUE(rgb, 8); … … 135 146 } 136 147 137 138 /** BGR 8:8:8 conversion 139 * 140 */ 141 static void bgr_888(void *dst, uint32_t rgb) 142 { 143 ((uint8_t *) dst)[0] = RED(rgb, 8); 144 ((uint8_t *) dst)[1] = GREEN(rgb, 8); 145 ((uint8_t *) dst)[2] = BLUE(rgb, 8); 146 } 147 148 149 /** RGB 5:5:5 conversion 150 * 151 */ 152 static void rgb_555(void *dst, uint32_t rgb) 153 { 154 *((uint16_t *) dst) 155 = (RED(rgb, 5) << 10) | (GREEN(rgb, 5) << 5) | BLUE(rgb, 5); 156 } 157 158 159 /** RGB 5:6:5 conversion 160 * 161 */ 162 static void rgb_565(void *dst, uint32_t rgb) 163 { 164 *((uint16_t *) dst) 165 = (RED(rgb, 5) << 11) | (GREEN(rgb, 6) << 5) | BLUE(rgb, 5); 166 } 167 168 169 /** RGB 3:2:3 148 static void bgr_555(void *dst, uint32_t rgb) 149 { 150 uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 5) << 5)) & 0xff; 151 uint8_t lo = (GREEN(rgb, 5) >> 3) | (RED(rgb, 5) << 2); 152 *((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo); 153 } 154 155 static void bgr_565(void *dst, uint32_t rgb) 156 { 157 uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 6) << 5)) & 0xff; 158 uint8_t lo = (GREEN(rgb, 6) >> 3) | (RED(rgb, 5) << 3); 159 *((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo); 160 } 161 162 163 /** BGR 3:2:3 170 164 * 171 165 * Even though we try 3:2:3 color scheme here, an 8-bit framebuffer … … 184 178 * 185 179 */ 186 static void rgb_323(void *dst, uint32_t rgb)180 static void bgr_323(void *dst, uint32_t rgb) 187 181 { 188 182 *((uint8_t *) dst) … … 458 452 switch (props->visual) { 459 453 case VISUAL_INDIRECT_8: 460 rgb_conv = rgb_323;454 rgb_conv = bgr_323; 461 455 pixelbytes = 1; 462 456 break; 463 case VISUAL_ RGB_5_5_5:464 rgb_conv = rgb_555;457 case VISUAL_BGR_5_5_5: 458 rgb_conv = bgr_555; 465 459 pixelbytes = 2; 466 460 break; 467 case VISUAL_ RGB_5_6_5:468 rgb_conv = rgb_565;461 case VISUAL_BGR_5_6_5: 462 rgb_conv = bgr_565; 469 463 pixelbytes = 2; 470 464 break; … … 487 481 case VISUAL_BGR_0_8_8_8: 488 482 rgb_conv = bgr_0888; 483 pixelbytes = 4; 484 break; 485 case VISUAL_BGR_8_8_8_0: 486 rgb_conv = bgr_8880; 489 487 pixelbytes = 4; 490 488 break;
Note:
See TracChangeset
for help on using the changeset viewer.