Module Name:    src
Committed By:   rin
Date:           Mon Oct 19 01:08:06 UTC 2020

Modified Files:
        src/sys/dev/wsfb: genfb.c

Log Message:
Add "is_swapped" property which indicates 32-bpp framebuffer is
byte-swapped.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/wsfb/genfb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/wsfb/genfb.c
diff -u src/sys/dev/wsfb/genfb.c:1.77 src/sys/dev/wsfb/genfb.c:1.78
--- src/sys/dev/wsfb/genfb.c:1.77	Sun Oct 18 12:47:37 2020
+++ src/sys/dev/wsfb/genfb.c	Mon Oct 19 01:08:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb.c,v 1.77 2020/10/18 12:47:37 rin Exp $ */
+/*	$NetBSD: genfb.c,v 1.78 2020/10/19 01:08:06 rin Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.77 2020/10/18 12:47:37 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.78 2020/10/19 01:08:06 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -539,7 +539,7 @@ genfb_init_screen(void *cookie, struct v
 	struct genfb_softc *sc = cookie;
 	struct rasops_info *ri = &scr->scr_ri;
 	int wantcols;
-	bool is_bgr;
+	bool is_bgr, is_swapped;
 
 	ri->ri_depth = sc->sc_depth;
 	ri->ri_width = sc->sc_width;
@@ -565,24 +565,30 @@ genfb_init_screen(void *cookie, struct v
 	switch (ri->ri_depth) {
 	case 32:
 	case 24:
+		ri->ri_rnum = ri->ri_gnum = ri->ri_bnum = 8;
 		ri->ri_flg |= RI_ENABLE_ALPHA;
 
 		is_bgr = false;
 		prop_dictionary_get_bool(device_properties(sc->sc_dev),
 		    "is_bgr", &is_bgr);
+
+		is_swapped = false;
+		prop_dictionary_get_bool(device_properties(sc->sc_dev),
+		    "is_swapped", &is_swapped);
+
 		if (is_bgr) {
 			/* someone requested BGR */
-			ri->ri_rnum = 8;
-			ri->ri_gnum = 8;
-			ri->ri_bnum = 8;
 			ri->ri_rpos = 0;
 			ri->ri_gpos = 8;
 			ri->ri_bpos = 16;
+		} else if (is_swapped) {
+			/* byte-swapped, must be 32 bpp */
+			KASSERT(ri->ri_depth == 32);
+			ri->ri_rpos = 8;
+			ri->ri_gpos = 16;
+			ri->ri_bpos = 24;
 		} else {
 			/* assume RGB */
-			ri->ri_rnum = 8;
-			ri->ri_gnum = 8;
-			ri->ri_bnum = 8;
 			ri->ri_rpos = 16;
 			ri->ri_gpos = 8;
 			ri->ri_bpos = 0;

Reply via email to