diff options
| author | macallan <macallan@NetBSD.org> | 2007-04-14 19:56:05 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2007-04-14 19:56:05 +0000 |
| commit | aa2949fa772d3166457f9a706dd4e78ae4072cd3 (patch) | |
| tree | 6aeb3b15b84f74a801dd579496a5d8584c39d462 /sys | |
| parent | dd9aa16186d99a98573121c2e3aed47ae54cd946 (diff) | |
add a callback to change the colour map
so now X with wsfb on top of genfb should look right
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/arch/macppc/macppc/autoconf.c | 24 | ||||
| -rw-r--r-- | sys/dev/wsfb/genfb.c | 25 | ||||
| -rw-r--r-- | sys/dev/wsfb/genfbvar.h | 10 |
3 files changed, 51 insertions, 8 deletions
diff --git a/sys/arch/macppc/macppc/autoconf.c b/sys/arch/macppc/macppc/autoconf.c index 815f06cb996..318e7a9490b 100644 --- a/sys/arch/macppc/macppc/autoconf.c +++ b/sys/arch/macppc/macppc/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.56 2007/02/28 04:21:51 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.57 2007/04/14 19:56:05 macallan Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2007/02/28 04:21:51 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2007/04/14 19:56:05 macallan Exp $"); #include <sys/param.h> #include <sys/conf.h> @@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2007/02/28 04:21:51 thorpej Exp $" #include <dev/scsipi/scsiconf.h> #include <dev/ata/atavar.h> #include <dev/ic/wdcvar.h> +#include <dev/wsfb/genfbvar.h> void canonicalize_bootpath __P((void)); void ofw_stack __P((void)); @@ -64,6 +65,9 @@ int console_node = 0, console_instance = 0; u_int *heathrow_FCR = NULL; +struct genfb_colormap_callback gfb_cb; +static void of_set_palette(void *, int, int, int, int); + static void add_model_specifics(prop_dictionary_t); static void copyprops(int, prop_dictionary_t); @@ -285,10 +289,17 @@ device_register(dev, aux) } if (console) { + uint64_t cmap_cb; prop_dictionary_set_uint32(dict, "instance_handle", console_instance); copyprops(console_node, dict); + + gfb_cb.gcc_cookie = (void *)console_instance; + gfb_cb.gcc_set_mapreg = of_set_palette; + cmap_cb = (uint64_t)&gfb_cb; + prop_dictionary_set_uint64(dict, "cmap_callback", + cmap_cb); } } @@ -553,3 +564,12 @@ copyprops(int node, prop_dictionary_t dict) OF_to_dataprop(dict, console_node, "EDID", "EDID"); add_model_specifics(dict); } + +static void +of_set_palette(void *cookie, int index, int r, int g, int b) +{ + int ih = (int)cookie; + + OF_call_method_1("color!", ih, 4, r, g, b, index); +} + diff --git a/sys/dev/wsfb/genfb.c b/sys/dev/wsfb/genfb.c index 634a0b3db66..415c3b9787e 100644 --- a/sys/dev/wsfb/genfb.c +++ b/sys/dev/wsfb/genfb.c @@ -1,4 +1,4 @@ -/* $NetBSD: genfb.c,v 1.3 2007/04/11 04:47:09 macallan Exp $ */ +/* $NetBSD: genfb.c,v 1.4 2007/04/14 19:56:05 macallan Exp $ */ /*- * Copyright (c) 2007 Michael Lorenz @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.3 2007/04/11 04:47:09 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.4 2007/04/14 19:56:05 macallan Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -81,6 +81,7 @@ void genfb_init(struct genfb_softc *sc) { prop_dictionary_t dict; + uint64_t cmap_cb; uint32_t fboffset; dict = device_properties(&sc->sc_dev); @@ -102,6 +103,13 @@ genfb_init(struct genfb_softc *sc) if (!prop_dictionary_get_uint32(dict, "linebytes", &sc->sc_stride)) sc->sc_stride = (sc->sc_width * sc->sc_depth) >> 3; sc->sc_fbsize = sc->sc_width * sc->sc_stride; + + /* optional colour map callback */ + sc->sc_cmcb = NULL; + if (prop_dictionary_get_uint64(dict, "cmap_callback", &cmap_cb)) { + if (cmap_cb != 0) + sc->sc_cmcb = (void *)(vaddr_t)cmap_cb; + } } int @@ -155,7 +163,11 @@ genfb_attach(struct genfb_softc *sc, struct genfb_ops *ops) } j = 0; - for (i = 0; i < 256; i++) { + for (i = 0; i < (1 << (sc->sc_depth - 1)); i++) { + + sc->sc_cmap_red[i] = rasops_cmap[j]; + sc->sc_cmap_green[i] = rasops_cmap[j + 1]; + sc->sc_cmap_blue[i] = rasops_cmap[j + 2]; genfb_putpalreg(sc, i, rasops_cmap[j], rasops_cmap[j + 1], rasops_cmap[j + 2]); j += 3; @@ -331,7 +343,7 @@ genfb_restore_palette(struct genfb_softc *sc) { int i; - for (i = 0; i < 256; i++) { + for (i = 0; i < (1 << (sc->sc_depth - 1)); i++) { genfb_putpalreg(sc, i, sc->sc_cmap_red[i], sc->sc_cmap_green[i], sc->sc_cmap_blue[i]); } @@ -342,6 +354,11 @@ genfb_putpalreg(struct genfb_softc *sc, uint8_t idx, uint8_t r, uint8_t g, uint8_t b) { + if (sc->sc_cmcb) { + + sc->sc_cmcb->gcc_set_mapreg(sc->sc_cmcb->gcc_cookie, + idx, r, g, b); + } return 0; } diff --git a/sys/dev/wsfb/genfbvar.h b/sys/dev/wsfb/genfbvar.h index ac0b3a2c550..6644c0b5d21 100644 --- a/sys/dev/wsfb/genfbvar.h +++ b/sys/dev/wsfb/genfbvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: genfbvar.h,v 1.2 2007/04/10 00:14:42 macallan Exp $ */ +/* $NetBSD: genfbvar.h,v 1.3 2007/04/14 19:56:05 macallan Exp $ */ /*- * Copyright (c) 2007 Michael Lorenz @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: genfbvar.h,v 1.2 2007/04/10 00:14:42 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfbvar.h,v 1.3 2007/04/14 19:56:05 macallan Exp $"); #ifndef GENFBVAR_H #define GENFBVAR_H @@ -53,6 +53,11 @@ struct genfb_ops { paddr_t (*genfb_mmap)(void *, void *, off_t, int); }; +struct genfb_colormap_callback { + void *gcc_cookie; + void (*gcc_set_mapreg)(void *, int, int, int, int); +}; + struct genfb_softc { struct device sc_dev; struct vcons_data vd; @@ -61,6 +66,7 @@ struct genfb_softc { struct wsscreen_descr sc_defaultscreen_descr; const struct wsscreen_descr *sc_screens[1]; struct wsscreen_list sc_screenlist; + struct genfb_colormap_callback *sc_cmcb; void * sc_fbaddr; /* kva */ bus_addr_t sc_fboffset; /* bus address */ int sc_width, sc_height, sc_stride, sc_depth; |
