From 6deedafda44b855bfb8eb6ba4120bee600d47455 Mon Sep 17 00:00:00 2001 From: rin Date: Mon, 19 Oct 2020 01:12:14 +0000 Subject: Fix colors of 32-bpp raster console for evbarm/aarch64eb and armeb. Most boards are configured to little-endian in initial, and switched to big-endian after kernel is loaded. In this case, framebuffer seems byte-swapped to CPU. It is best to reconfigure framebuffer (as done recently for sunxi_mixer by jmcneill), but in most cases, HW is incapable, or we just don't know register bits to configure them. Therefore, override "format" FDT property for "simple-framebuffer" to let drivers know byte-order for 32-bpp framebuffer. Then, make fdt/simplefb (genfb) and arm_simplefb (early console) detect byte-swapped FB, and configure genfb(4) or rasops(4) layers accordingly. Tested on Pine A64+ (arm_simplefb) and Cubietruck (both fdt/simplefb and arm_simplefb). Discussed with jmcneill. Thanks!! --- sys/dev/fdt/simplefb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/fdt/simplefb.c b/sys/dev/fdt/simplefb.c index d766538e60a..9c4af114b29 100644 --- a/sys/dev/fdt/simplefb.c +++ b/sys/dev/fdt/simplefb.c @@ -1,4 +1,4 @@ -/* $NetBSD: simplefb.c,v 1.8 2019/07/23 14:34:12 rin Exp $ */ +/* $NetBSD: simplefb.c,v 1.9 2020/10/19 01:12:14 rin Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_wsdisplay_compat.h" #include -__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.8 2019/07/23 14:34:12 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.9 2020/10/19 01:12:14 rin Exp $"); #include #include @@ -157,6 +157,10 @@ simplefb_attach_genfb(struct simplefb_softc *sc) if (strcmp(format, "a8b8g8r8") == 0 || strcmp(format, "x8r8g8b8") == 0) { depth = 32; + } else if (strcmp(format, "r8g8b8a8") == 0 || + strcmp(format, "b8g8r8x8") == 0) { + depth = 32; + prop_dictionary_set_bool(dict, "is_swapped", true); } else if (strcmp(format, "r5g6b5") == 0) { depth = 16; } else { -- cgit