Index: kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
===================================================================
--- kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/arch/arm32/src/mach/integratorcp/integratorcp.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -137,5 +137,5 @@
 		.y = 480,
 		.scan = 2560,
-		.visual = VISUAL_RGB_8_8_8_0,
+		.visual = VISUAL_BGR_0_8_8_8,
 	};
 	prop.addr = icp_get_fb_address();
Index: kernel/arch/arm32/src/mach/testarm/testarm.c
===================================================================
--- kernel/arch/arm32/src/mach/testarm/testarm.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/arch/arm32/src/mach/testarm/testarm.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -86,5 +86,5 @@
 		.y = 480,
 		.scan = 1920,
-		.visual = VISUAL_BGR_8_8_8,
+		.visual = VISUAL_RGB_8_8_8,
 	};
 	fb_init(&prop);
Index: kernel/arch/ia32/src/drivers/vesa.c
===================================================================
--- kernel/arch/ia32/src/drivers/vesa.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/arch/ia32/src/drivers/vesa.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -86,13 +86,13 @@
 		    && (vesa_green_mask == 5) && (vesa_green_pos == 5)
 		    && (vesa_blue_mask == 5) && (vesa_blue_pos == 0))
-			visual = VISUAL_RGB_5_5_5;
+			visual = VISUAL_BGR_5_5_5;
 		else
-			visual = VISUAL_RGB_5_6_5;
+			visual = VISUAL_BGR_5_6_5;
 		break;
 	case 24:
-		visual = VISUAL_RGB_8_8_8;
+		visual = VISUAL_BGR_8_8_8;
 		break;
 	case 32:
-		visual = VISUAL_RGB_0_8_8_8;
+		visual = VISUAL_BGR_8_8_8_0;
 		break;
 	default:
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/arch/mips32/src/mips32.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -142,5 +142,5 @@
 		.y = 480,
 		.scan = 1920,
-		.visual = VISUAL_BGR_8_8_8,
+		.visual = VISUAL_RGB_8_8_8,
 	};
 	fb_init(&gxemul_prop);
Index: kernel/arch/ppc32/src/ppc32.c
===================================================================
--- kernel/arch/ppc32/src/ppc32.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/arch/ppc32/src/ppc32.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -93,8 +93,8 @@
 				break;
 			case 16:
-				visual = VISUAL_RGB_5_5_5;
+				visual = VISUAL_BGR_5_5_5;
 				break;
 			case 24:
-				visual = VISUAL_RGB_8_8_8;
+				visual = VISUAL_BGR_8_8_8;
 				break;
 			case 32:
Index: kernel/arch/sparc64/src/drivers/scr.c
===================================================================
--- kernel/arch/sparc64/src/drivers/scr.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/arch/sparc64/src/drivers/scr.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -134,9 +134,9 @@
 		case 16:
 			fb_scanline = fb_linebytes * (fb_depth >> 3);
-			visual = VISUAL_RGB_5_6_5;
+			visual = VISUAL_BGR_5_6_5;
 			break;
 		case 24:
 			fb_scanline = fb_linebytes * 4;
-			visual = VISUAL_RGB_8_8_8_0;
+			visual = VISUAL_BGR_8_8_8_0;
 			break;
 		case 32:
@@ -178,9 +178,9 @@
 		case 16:
 			fb_scanline = fb_linebytes * (fb_depth >> 3);
-			visual = VISUAL_RGB_5_6_5;
+			visual = VISUAL_BGR_5_6_5;
 			break;
 		case 24:
 			fb_scanline = fb_linebytes * 4;
-			visual = VISUAL_RGB_8_8_8_0;
+			visual = VISUAL_BGR_8_8_8_0;
 			break;
 		case 32:
Index: kernel/genarch/include/fb/visuals.h
===================================================================
--- kernel/genarch/include/fb/visuals.h	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/genarch/include/fb/visuals.h	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -36,14 +36,15 @@
 #define KERN_VISUALS_H_
 
-#define VISUAL_INDIRECT_8   0
-
-#define VISUAL_RGB_5_5_5    1
-#define VISUAL_RGB_5_6_5    2
-#define VISUAL_RGB_8_8_8    3
-#define VISUAL_RGB_8_8_8_0  4
-#define VISUAL_RGB_0_8_8_8  5
-
-#define VISUAL_BGR_0_8_8_8  6
-#define VISUAL_BGR_8_8_8    7
+typedef enum {
+	VISUAL_INDIRECT_8,
+	VISUAL_BGR_5_5_5,
+	VISUAL_BGR_5_6_5,
+	VISUAL_BGR_8_8_8,
+	VISUAL_BGR_0_8_8_8,
+	VISUAL_BGR_8_8_8_0,
+	VISUAL_RGB_8_8_8,
+	VISUAL_RGB_0_8_8_8,
+	VISUAL_RGB_8_8_8_0
+} visual_t;
 
 #endif
Index: kernel/genarch/src/fb/fb.c
===================================================================
--- kernel/genarch/src/fb/fb.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ kernel/genarch/src/fb/fb.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -51,4 +51,5 @@
 #include <ddi/ddi.h>
 #include <arch/types.h>
+#include <byteorder.h>
 
 SPINLOCK_INITIALIZE(fb_lock);
@@ -81,7 +82,7 @@
 #define INV_COLOR    0xaaaaaa
 
-#define RED(x, bits)         ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1))
-#define GREEN(x, bits)       ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
-#define BLUE(x, bits)        ((x >> (8 - bits)) & ((1 << bits) - 1))
+#define RED(x, bits)         (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1))
+#define GREEN(x, bits)       (((x) >> (8 + 8 - (bits))) & ((1 << (bits)) - 1))
+#define BLUE(x, bits)        (((x) >> (8 - (bits))) & ((1 << (bits)) - 1))
 
 #define COL2X(col)           ((col) * FONT_WIDTH)
@@ -98,35 +99,45 @@
 static void (*rgb_conv)(void *, uint32_t);
 
-
-/** ARGB 8:8:8:8 conversion
- *
- */
+/*
+ * RGB conversion functions.
+ *
+ * These functions write an RGB value to some memory in some predefined format.
+ * The naming convention corresponds to the format created by these functions.
+ * The functions use the so called network order (i.e. big endian) with respect
+ * to their names.
+ */
+
 static void rgb_0888(void *dst, uint32_t rgb)
 {
-	*((uint32_t *) dst) = rgb & 0xffffff;
-}
-
-
-/** ABGR 8:8:8:8 conversion
- *
- */
+	*((uint32_t *) dst) = host2uint32_t_be((0 << 24) |
+	    (RED(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (BLUE(rgb, 8)));
+}
+
 static void bgr_0888(void *dst, uint32_t rgb)
 {
-	*((uint32_t *) dst)
-	    = (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | RED(rgb, 8);
+	*((uint32_t *) dst) = host2uint32_t_be((0 << 24) |
+	    (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (RED(rgb, 8)));
 }
 
 static void rgb_8880(void *dst, uint32_t rgb)
 {
-	*((uint32_t *) dst)
-	   = (RED(rgb, 8) << 24) | (GREEN(rgb, 8) << 16) | (BLUE(rgb, 8) << 8);
-
-}
-
-
-/** RGB 8:8:8 conversion
- *
- */
+	*((uint32_t *) dst) = host2uint32_t_be((RED(rgb, 8) << 24) |
+	    (GREEN(rgb,	8) << 16) | (BLUE(rgb, 8) << 8) | 0);
+}
+
+static void bgr_8880(void *dst, uint32_t rgb)
+{
+	*((uint32_t *) dst) = host2uint32_t_be((BLUE(rgb, 8) << 24) |
+	    (GREEN(rgb,	8) << 16) | (RED(rgb, 8) << 8) | 0);
+}
+
 static void rgb_888(void *dst, uint32_t rgb)
+{
+	((uint8_t *) dst)[0] = RED(rgb, 8);
+	((uint8_t *) dst)[1] = GREEN(rgb, 8);
+	((uint8_t *) dst)[2] = BLUE(rgb, 8);
+}
+
+static void bgr_888(void *dst, uint32_t rgb)
 {
 	((uint8_t *) dst)[0] = BLUE(rgb, 8);
@@ -135,37 +146,20 @@
 }
 
-
-/** BGR 8:8:8 conversion
- *
- */
-static void bgr_888(void *dst, uint32_t rgb)
-{
-	((uint8_t *) dst)[0] = RED(rgb, 8);
-	((uint8_t *) dst)[1] = GREEN(rgb, 8);
-	((uint8_t *) dst)[2] = BLUE(rgb, 8);
-}
-
-
-/** RGB 5:5:5 conversion
- *
- */
-static void rgb_555(void *dst, uint32_t rgb)
-{
-	*((uint16_t *) dst)
-	    = (RED(rgb, 5) << 10) | (GREEN(rgb, 5) << 5) | BLUE(rgb, 5);
-}
-
-
-/** RGB 5:6:5 conversion
- *
- */
-static void rgb_565(void *dst, uint32_t rgb)
-{
-	*((uint16_t *) dst)
-	    = (RED(rgb, 5) << 11) | (GREEN(rgb, 6) << 5) | BLUE(rgb, 5);
-}
-
-
-/** RGB 3:2:3
+static void bgr_555(void *dst, uint32_t rgb)
+{
+	uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 5) << 5)) & 0xff;
+	uint8_t lo = (GREEN(rgb, 5) >> 3) | (RED(rgb, 5) << 2);
+	*((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo);
+}
+
+static void bgr_565(void *dst, uint32_t rgb)
+{
+	uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 6) << 5)) & 0xff;
+	uint8_t lo = (GREEN(rgb, 6) >> 3) | (RED(rgb, 5) << 3);
+	*((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo);
+}
+
+
+/** BGR 3:2:3
  *
  * Even though we try 3:2:3 color scheme here, an 8-bit framebuffer
@@ -184,5 +178,5 @@
  *
  */
-static void rgb_323(void *dst, uint32_t rgb)
+static void bgr_323(void *dst, uint32_t rgb)
 {
 	*((uint8_t *) dst)
@@ -458,13 +452,13 @@
 	switch (props->visual) {
 	case VISUAL_INDIRECT_8:
-		rgb_conv = rgb_323;
+		rgb_conv = bgr_323;
 		pixelbytes = 1;
 		break;
-	case VISUAL_RGB_5_5_5:
-		rgb_conv = rgb_555;
+	case VISUAL_BGR_5_5_5:
+		rgb_conv = bgr_555;
 		pixelbytes = 2;
 		break;
-	case VISUAL_RGB_5_6_5:
-		rgb_conv = rgb_565;
+	case VISUAL_BGR_5_6_5:
+		rgb_conv = bgr_565;
 		pixelbytes = 2;
 		break;
@@ -487,4 +481,8 @@
 	case VISUAL_BGR_0_8_8_8:
 		rgb_conv = bgr_0888;
+		pixelbytes = 4;
+		break;
+	case VISUAL_BGR_8_8_8_0:
+		rgb_conv = bgr_8880;
 		pixelbytes = 4;
 		break;
Index: uspace/srv/fb/fb.c
===================================================================
--- uspace/srv/fb/fb.c	(revision 646b9960f45edec2b83f4adb3bc5a501c2b28e9b)
+++ uspace/srv/fb/fb.c	(revision 30885b92b99d4bae510111a9b90bc2b5bf34fe14)
@@ -58,4 +58,5 @@
 #include <bool.h>
 #include <stdio.h>
+#include <byteorder.h>
 
 #include "font-8x16.h"
@@ -213,7 +214,7 @@
 
 
-#define RED(x, bits)                 ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1))
-#define GREEN(x, bits)               ((x >> (8 + 8 - bits)) & ((1 << bits) - 1))
-#define BLUE(x, bits)                ((x >> (8 - bits)) & ((1 << bits) - 1))
+#define RED(x, bits)                 (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1))
+#define GREEN(x, bits)               (((x) >> (8 + 8 - (bits))) & ((1 << (bits)) - 1))
+#define BLUE(x, bits)                (((x) >> (8 - (bits))) & ((1 << (bits)) - 1))
 
 #define COL2X(col)                   ((col) * FONT_WIDTH)
@@ -227,43 +228,55 @@
 #define GLYPH_POS(glyph, y, cursor)  (((glyph) + (cursor) * FONT_GLYPHS) * screen.glyphbytes + (y) * screen.glyphscanline)
 
-
-/** ARGB 8:8:8:8 conversion
- *
- */
+/*
+ * RGB conversion and mask functions.
+ *
+ * These functions write an RGB value to some memory in some predefined format.
+ * The naming convention corresponds to the format created by these functions.
+ * The functions use the so called network order (i.e. big endian) with respect
+ * to their names.
+ */
+
 static void rgb_0888(void *dst, uint32_t rgb)
 {
-	*((uint32_t *) dst) = rgb & 0x00ffffff;
+	*((uint32_t *) dst) = host2uint32_t_be((0 << 24) |
+	    (RED(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (BLUE(rgb, 8)));
+}
+
+static void bgr_0888(void *dst, uint32_t rgb)
+{
+	*((uint32_t *) dst) = host2uint32_t_be((0 << 24) |
+	    (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | (RED(rgb, 8)));
 }
 
 static void mask_0888(void *dst, bool mask)
 {
-	*((uint32_t *) dst) = (mask ? 0x00ffffff : 0);
-}
-
-
-/** ABGR 8:8:8:8 conversion
- *
- */
-static void bgr_0888(void *dst, uint32_t rgb)
-{
-	*((uint32_t *) dst)
-	    = (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | RED(rgb, 8);
+	bgr_0888(dst, mask ? 0xffffff : 0);
 }
 
 static void rgb_8880(void *dst, uint32_t rgb)
 {
-	*((uint32_t *) dst)
-	    = (RED(rgb, 8) << 24) | (GREEN(rgb, 8) << 16) | BLUE(rgb, 8) << 8;
+	*((uint32_t *) dst) = host2uint32_t_be((RED(rgb, 8) << 24) |
+	    (GREEN(rgb,	8) << 16) | (BLUE(rgb, 8) << 8) | 0);
+}
+
+static void bgr_8880(void *dst, uint32_t rgb)
+{
+	*((uint32_t *) dst) = host2uint32_t_be((BLUE(rgb, 8) << 24) |
+	    (GREEN(rgb,	8) << 16) | (RED(rgb, 8) << 8) | 0);
 }
 
 static void mask_8880(void *dst, bool mask)
 {
-	*((uint32_t *) dst) = (mask ? 0xffffff00 : 0);
-}
-
-/** RGB 8:8:8 conversion
- *
- */
+	bgr_8880(dst, mask ? 0xffffff : 0);
+}
+
 static void rgb_888(void *dst, uint32_t rgb)
+{
+	((uint8_t *) dst)[0] = RED(rgb, 8);
+	((uint8_t *) dst)[1] = GREEN(rgb, 8);
+	((uint8_t *) dst)[2] = BLUE(rgb, 8);
+}
+
+static void bgr_888(void *dst, uint32_t rgb)
 {
 	((uint8_t *) dst)[0] = BLUE(rgb, 8);
@@ -274,61 +287,32 @@
 static void mask_888(void *dst, bool mask)
 {
-	if (mask) {
-		((uint8_t *) dst)[0] = 0xff;
-		((uint8_t *) dst)[1] = 0xff;
-		((uint8_t *) dst)[2] = 0xff;
-	} else {
-		((uint8_t *) dst)[0] = 0;
-		((uint8_t *) dst)[1] = 0;
-		((uint8_t *) dst)[2] = 0;
-	}
-}
-
-
-/** BGR 8:8:8 conversion
- *
- */
-static void bgr_888(void *dst, uint32_t rgb)
-{
-	((uint8_t *) dst)[0] = RED(rgb, 8);
-	((uint8_t *) dst)[1] = GREEN(rgb, 8);
-	((uint8_t *) dst)[2] = BLUE(rgb, 8);
-}
-
-
-/** RGB 5:5:5 conversion
- *
- */
-static void rgb_555(void *dst, uint32_t rgb)
-{
-	*((uint16_t *) dst)
-	    = (RED(rgb, 5) << 10) | (GREEN(rgb, 5) << 5) | BLUE(rgb, 5);
+	bgr_888(dst, mask ? 0xffffff : 0);
+}
+
+static void bgr_555(void *dst, uint32_t rgb)
+{
+	uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 5) << 5)) & 0xff;
+	uint8_t lo = (GREEN(rgb, 5) >> 3) | (RED(rgb, 5) << 2);
+	*((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo);
 }
 
 static void mask_555(void *dst, bool mask)
 {
-	*((uint16_t *) dst) = (mask ? 0x7fff : 0);
-}
-
-
-/** RGB 5:6:5 conversion
- *
- */
-static void rgb_565(void *dst, uint32_t rgb)
-{
-	*((uint16_t *) dst)
-	    = (RED(rgb, 5) << 11) | (GREEN(rgb, 6) << 5) | BLUE(rgb, 5);
+	bgr_555(dst, mask ? 0xffffff : 0);
+}
+
+static void bgr_565(void *dst, uint32_t rgb)
+{
+	uint8_t hi = (BLUE(rgb, 5) | (GREEN(rgb, 6) << 5)) & 0xff;
+	uint8_t lo = (GREEN(rgb, 6) >> 3) | (RED(rgb, 5) << 3);
+	*((uint16_t *) dst) = host2uint16_t_be((hi << 8) | lo);
 }
 
 static void mask_565(void *dst, bool mask)
 {
-	*((uint16_t *) dst) = (mask ? 0xffff : 0);
-}
-
-
-/** RGB 3:2:3
- *
- */
-static void rgb_323(void *dst, uint32_t rgb)
+	bgr_565(dst, mask ? 0xffffff : 0);
+}
+
+static void bgr_323(void *dst, uint32_t rgb)
 {
 	*((uint8_t *) dst)
@@ -338,5 +322,5 @@
 static void mask_323(void *dst, bool mask)
 {
-	*((uint8_t *) dst) = (mask ? 0xff : 0);
+	bgr_323(dst, mask ? 0x0 : ~0x0);
 }
 
@@ -632,19 +616,17 @@
     unsigned int scan, unsigned int visual)
 {
-	
-	
 	switch (visual) {
 	case VISUAL_INDIRECT_8:
-		screen.rgb_conv = rgb_323;
+		screen.rgb_conv = bgr_323;
 		screen.mask_conv = mask_323;
 		screen.pixelbytes = 1;
 		break;
-	case VISUAL_RGB_5_5_5:
-		screen.rgb_conv = rgb_555;
+	case VISUAL_BGR_5_5_5:
+		screen.rgb_conv = bgr_555;
 		screen.mask_conv = mask_555;
 		screen.pixelbytes = 2;
 		break;
-	case VISUAL_RGB_5_6_5:
-		screen.rgb_conv = rgb_565;
+	case VISUAL_BGR_5_6_5:
+		screen.rgb_conv = bgr_565;
 		screen.mask_conv = mask_565;
 		screen.pixelbytes = 2;
@@ -673,4 +655,9 @@
 		screen.rgb_conv = bgr_0888;
 		screen.mask_conv = mask_0888;
+		screen.pixelbytes = 4;
+		break;
+	case VISUAL_BGR_8_8_8_0:
+		screen.rgb_conv = bgr_8880;
+		screen.mask_conv = mask_8880;
 		screen.pixelbytes = 4;
 		break;
