From bc55fab413e4a543149ca618f7ef2b6ec1e30b18 Mon Sep 17 00:00:00 2001 From: rin Date: Mon, 19 Oct 2020 01:08:06 +0000 Subject: Add "is_swapped" property which indicates 32-bpp framebuffer is byte-swapped. --- sys/dev/wsfb/genfb.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/wsfb/genfb.c b/sys/dev/wsfb/genfb.c index 48986db284b..ffc29cfc522 100644 --- a/sys/dev/wsfb/genfb.c +++ b/sys/dev/wsfb/genfb.c @@ -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 -__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 #include @@ -539,7 +539,7 @@ genfb_init_screen(void *cookie, struct vcons_screen *scr, 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 vcons_screen *scr, 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; -- cgit