Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/wsfb Add "is_swapped" property which indicates 32-bp...



details:   https://anonhg.NetBSD.org/src/rev/26caa979352e
branches:  trunk
changeset: 941116:26caa979352e
user:      rin <rin%NetBSD.org@localhost>
date:      Mon Oct 19 01:08:06 2020 +0000

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

diffstat:

 sys/dev/wsfb/genfb.c |  24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diffs (64 lines):

diff -r 4f1100a6291c -r 26caa979352e sys/dev/wsfb/genfb.c
--- a/sys/dev/wsfb/genfb.c      Sun Oct 18 22:55:52 2020 +0000
+++ b/sys/dev/wsfb/genfb.c      Mon Oct 19 01:08:06 2020 +0000
@@ -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 @@
        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 @@
        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;



Home | Main Index | Thread Index | Old Index