Module Name:    src
Committed By:   jmcneill
Date:           Mon Aug 30 22:47:25 UTC 2021

Modified Files:
        src/sys/arch/arm/fdt: arm_simplefb.c
        src/sys/dev/fdt: simplefb.c
        src/sys/dev/wsfb: genfb.c

Log Message:
Add 10-bit pixel format support.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/arm_simplefb.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/fdt/simplefb.c
cvs rdiff -u -r1.83 -r1.84 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/arch/arm/fdt/arm_simplefb.c
diff -u src/sys/arch/arm/fdt/arm_simplefb.c:1.10 src/sys/arch/arm/fdt/arm_simplefb.c:1.11
--- src/sys/arch/arm/fdt/arm_simplefb.c:1.10	Tue Mar  2 11:51:00 2021
+++ src/sys/arch/arm/fdt/arm_simplefb.c	Mon Aug 30 22:47:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_simplefb.c,v 1.10 2021/03/02 11:51:00 jmcneill Exp $ */
+/* $NetBSD: arm_simplefb.c,v 1.11 2021/08/30 22:47:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include "opt_vcons.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.10 2021/03/02 11:51:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.11 2021/08/30 22:47:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -68,6 +68,7 @@ static struct arm_simplefb_softc {
 	uint32_t	sc_stride;
 	uint16_t	sc_depth;
 	bool		sc_swapped;
+	bool		sc_10bit;
 	void		*sc_bits;
 } arm_simplefb_softc;
 
@@ -136,6 +137,12 @@ arm_simplefb_init_screen(void *cookie, s
 		ri->ri_rpos =  8;
 		ri->ri_gpos = 16;
 		ri->ri_bpos = 24;
+	} else if (sc->sc_10bit) {
+		KASSERT(ri->ri_depth == 32);
+		ri->ri_rnum = ri->ri_gnum = ri->ri_bnum = 10;
+		ri->ri_rpos = 20;
+		ri->ri_gpos = 10;
+		ri->ri_bpos =  0;
 	}
 
 	scr->scr_flags |= VCONS_LOADFONT;
@@ -207,6 +214,7 @@ arm_simplefb_preattach(void)
 	uint16_t depth;
 	long defattr;
 	bool swapped = false;
+	bool is_10bit = false;
 
 	const int phandle = arm_simplefb_find_node();
 	if (phandle == -1)
@@ -231,6 +239,9 @@ arm_simplefb_preattach(void)
 		   strcmp(format, "b8g8r8x8") == 0) {
 		depth = 32;
 		swapped = true;
+	} else if (strcmp(format, "x2r10g10b10") == 0) {
+		depth = 32;
+		is_10bit = true;
 	} else if (strcmp(format, "r5g6b5") == 0) {
 		depth = 16;
 	} else {
@@ -259,6 +270,7 @@ arm_simplefb_preattach(void)
 	sc->sc_stride = stride;
 	sc->sc_bits = bus_space_vaddr(bst, bsh);
 	sc->sc_swapped = swapped;
+	sc->sc_10bit = is_10bit;
 
 	wsfont_init();
 

Index: src/sys/dev/fdt/simplefb.c
diff -u src/sys/dev/fdt/simplefb.c:1.14 src/sys/dev/fdt/simplefb.c:1.15
--- src/sys/dev/fdt/simplefb.c:1.14	Tue Mar  2 11:51:00 2021
+++ src/sys/dev/fdt/simplefb.c	Mon Aug 30 22:47:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: simplefb.c,v 1.14 2021/03/02 11:51:00 jmcneill Exp $ */
+/* $NetBSD: simplefb.c,v 1.15 2021/08/30 22:47:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcne...@invisible.ca>
@@ -29,7 +29,7 @@
 #include "opt_wsdisplay_compat.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.14 2021/03/02 11:51:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.15 2021/08/30 22:47:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -162,6 +162,9 @@ simplefb_attach_genfb(struct simplefb_so
 		   strcmp(format, "b8g8r8x8") == 0) {
 		depth = 32;
 		prop_dictionary_set_bool(dict, "is_swapped", true);
+	} else if (strcmp(format, "x2r10g10b10") == 0) {
+		depth = 32;
+		prop_dictionary_set_bool(dict, "is_10bit", true);
 	} else if (strcmp(format, "r5g6b5") == 0) {
 		depth = 16;
 	} else {

Index: src/sys/dev/wsfb/genfb.c
diff -u src/sys/dev/wsfb/genfb.c:1.83 src/sys/dev/wsfb/genfb.c:1.84
--- src/sys/dev/wsfb/genfb.c:1.83	Sat Aug  7 16:19:17 2021
+++ src/sys/dev/wsfb/genfb.c	Mon Aug 30 22:47:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb.c,v 1.83 2021/08/07 16:19:17 thorpej Exp $ */
+/*	$NetBSD: genfb.c,v 1.84 2021/08/30 22:47:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.83 2021/08/07 16:19:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.84 2021/08/30 22:47:25 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -558,7 +558,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, is_swapped;
+	bool is_bgr, is_swapped, is_10bit;
 
 	ri->ri_depth = sc->sc_depth;
 	ri->ri_width = sc->sc_width;
@@ -584,7 +584,6 @@ 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;
@@ -595,22 +594,29 @@ genfb_init_screen(void *cookie, struct v
 		prop_dictionary_get_bool(device_properties(sc->sc_dev),
 		    "is_swapped", &is_swapped);
 
+		is_10bit = false;
+		prop_dictionary_get_bool(device_properties(sc->sc_dev),
+		    "is_10bit", &is_10bit);
+
+		const int bits = is_10bit ? 10 : 8;
+		ri->ri_rnum = ri->ri_gnum = ri->ri_bnum = bits;
+
 		if (is_bgr) {
 			/* someone requested BGR */
-			ri->ri_rpos = 0;
-			ri->ri_gpos = 8;
-			ri->ri_bpos = 16;
+			ri->ri_rpos = bits * 0;
+			ri->ri_gpos = bits * 1;
+			ri->ri_bpos = bits * 2;
 		} else if (is_swapped) {
 			/* byte-swapped, must be 32 bpp */
-			KASSERT(ri->ri_depth == 32);
+			KASSERT(ri->ri_depth == 32 && bits == 8);
 			ri->ri_rpos = 8;
 			ri->ri_gpos = 16;
 			ri->ri_bpos = 24;
 		} else {
 			/* assume RGB */
-			ri->ri_rpos = 16;
-			ri->ri_gpos = 8;
-			ri->ri_bpos = 0;
+			ri->ri_rpos = bits * 2;
+			ri->ri_gpos = bits * 1;
+			ri->ri_bpos = bits * 0;
 		}
 		break;
 

Reply via email to