Module Name:    src
Committed By:   jmcneill
Date:           Sat Jan 20 00:24:58 UTC 2024

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

Log Message:
wsfb: add support for optional "devcmap" property

A hardware driver can supply a pointer to a 16x 32-bit array to override
the default rasops device colour map in the "devcmap" property.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 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.90 src/sys/dev/wsfb/genfb.c:1.91
--- src/sys/dev/wsfb/genfb.c:1.90	Mon Aug  1 23:30:10 2022
+++ src/sys/dev/wsfb/genfb.c	Sat Jan 20 00:24:58 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb.c,v 1.90 2022/08/01 23:30:10 riastradh Exp $ */
+/*	$NetBSD: genfb.c,v 1.91 2024/01/20 00:24:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.90 2022/08/01 23:30:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.91 2024/01/20 00:24:58 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -85,6 +85,7 @@ struct genfb_private {
 	struct genfb_parameter_callback *sc_backlight;
 	struct genfb_parameter_callback *sc_brightness;
 	struct genfb_mode_callback *sc_modecb;
+	uint32_t *sc_devcmap;
 	int sc_backlight_level, sc_backlight_on;
 	void *sc_shadowfb;
 	bool sc_enable_shadowfb;
@@ -167,7 +168,7 @@ genfb_init(struct genfb_softc *sc)
 {
 	struct genfb_private *scp;
 	prop_dictionary_t dict;
-	uint64_t cmap_cb, pmf_cb, mode_cb, bl_cb, br_cb, fbaddr;
+	uint64_t cmap_cb, pmf_cb, mode_cb, bl_cb, br_cb, devcmap, fbaddr;
 	uint64_t fboffset;
 	bool console;
 
@@ -225,6 +226,13 @@ genfb_init(struct genfb_softc *sc)
 
 	sc->sc_fbsize = sc->sc_height * sc->sc_stride;
 
+	/* optional device colour map */
+	scp->sc_devcmap = NULL;
+	if (prop_dictionary_get_uint64(dict, "devcmap", &devcmap)) {
+		if (devcmap != 0)
+			scp->sc_devcmap = (uint32_t *)(uintptr_t)devcmap;
+	}
+
 	/* optional colour map callback */
 	scp->sc_cmcb = NULL;
 	if (prop_dictionary_get_uint64(dict, "cmap_callback", &cmap_cb)) {
@@ -721,6 +729,10 @@ genfb_init_screen(void *cookie, struct v
 	rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
 	    sc->sc_width / ri->ri_font->fontwidth);
 
+	if (scp->sc_devcmap != NULL) {
+		memcpy(ri->ri_devcmap, scp->sc_devcmap, sizeof(ri->ri_devcmap));
+	}
+
 	ri->ri_hw = scr;
 #if GENFB_GLYPHCACHE > 0
 	scp->sc_putchar = ri->ri_ops.putchar;

Reply via email to