/* $NetBSD: grf_obio.c,v 1.59 2019/07/26 10:48:44 rin Exp $ */
/*
* Copyright (C) 1998 Scott Reynolds
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Allen Briggs.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Graphics display driver for the Macintosh internal video for machines
* that don't map it into a fake nubus card.
*/
bus_space_unmap(oa->oa_tag, bsh, 0x40);
break;
}
/*
* Note: the only system in this class that does not have
* the Valkyrie chip -- at least, that we know of -- is
* the Performa/LC 57x series. This system has a version
* of the DAFB controller, instead.
*
* If this assumption proves false, we'll have to be more
* intelligent here.
*/
/*FALLTHROUGH*/
case MACH_CLASSQ:
/*
* Assume DAFB for all of these, unless we can't
* access the memory.
*/
base = DAFB_CONTROL_BASE;
if (bus_space_map(oa->oa_tag, base, 0x20, 0, &bsh))
return 0;
/* Compute the current frame buffer offset */
vbase1 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x0) & 0xfff;
#if 1
/*
* XXX The following exists because the DAFB v7 in these
* systems doesn't return reasonable values to use for fbofs.
* Ken'ichi Ishizaka gets credit for this hack. (sar 19990426)
* (Does this get us the correct result for _all_ DAFB-
* equipped systems and monitor combinations? It seems
* possible, if not likely...)
*/
switch (current_mac_model->machineid) {
case MACH_MACLC475:
case MACH_MACLC475_33:
case MACH_MACLC575:
case MACH_MACQ605:
case MACH_MACQ605_33:
vbase1 &= 0x3f;
break;
}
#endif
vbase2 = bus_space_read_4(sc->sc_tag, sc->sc_regh, 0x4) & 0xf;
sc->sc_fbofs = (vbase1 << 9) | (vbase2 << 5);
/* Perform common video attachment. */
grf_establish(sc, NULL, grfiv_mode);
}
static int
grfiv_mode(struct grf_softc *sc, int cmd, void *arg)
{
switch (cmd) {
case GM_GRFON:
case GM_GRFOFF:
return 0;
case GM_CURRMODE:
break;
case GM_NEWMODE:
break;
case GM_LISTMODES:
break;
}
return EINVAL;
}
static void
dafb_set_mapreg(void *cookie, int index, int r, int g, int b)
{
struct grfbus_softc *sc = (struct grfbus_softc *)cookie;
static int last = -2;
static void
civic_set_mapreg(void *cookie, int index, int r, int g, int b)
{
struct grfbus_softc *sc = (struct grfbus_softc *)cookie;
uint8_t status, junk = 0;