/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratory.
*
* 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. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* from: @(#)cgthree.c 8.2 (Berkeley) 10/30/93
*/
/*
* color display (cg2) driver.
*
* Does not handle interrupts, even though they can occur.
*
* XXX should defer colormap updates to vertical retrace interrupts
*/
static int
cg2ioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
{
struct cg2_softc *sc = device_lookup_private(&cgtwo_cd, minor(dev));
return fbioctlfb(&sc->sc_fb, cmd, data);
}
/*
* Return the address that would map the given device at the given
* offset, allowing for the given protection, or return -1 for error.
*/
static paddr_t
cg2mmap(dev_t dev, off_t off, int prot)
{
struct cg2_softc *sc = device_lookup_private(&cgtwo_cd, minor(dev));
if (off & PGOFSET)
panic("%s: bad offset", __func__);
if (off >= CG2_MAPPED_SIZE)
return -1;
/*
* I turned on PMAP_NC here to disable the cache as I was
* getting horribly broken behaviour with it on.
*/
return (sc->sc_phys + off) | sc->sc_pmtype;
}
/* Copy hardware to local arrays. */
p = &sc->sc_ctlreg->redmap[start];
for (i = start; i < ecount; i++)
red[i] = *p++;
p = &sc->sc_ctlreg->greenmap[start];
for (i = start; i < ecount; i++)
green[i] = *p++;
p = &sc->sc_ctlreg->bluemap[start];
for (i = start; i < ecount; i++)
blue[i] = *p++;
/* Copy local arrays to user space. */
if ((error = copyout(red + start, cmap->red, count)) != 0)
return error;
if ((error = copyout(green + start, cmap->green, count)) != 0)
return error;
if ((error = copyout(blue + start, cmap->blue, count)) != 0)
return error;
/* Copy from user space to local arrays. */
if ((error = copyin(cmap->red, red + start, count)) != 0)
return error;
if ((error = copyin(cmap->green, green + start, count)) != 0)
return error;
if ((error = copyin(cmap->blue, blue + start, count)) != 0)
return error;
/* XXX - Wait for retrace? */
/* Copy from local arrays to hardware. */
p = &sc->sc_ctlreg->redmap[start];
for (i = start; i < ecount; i++)
*p++ = red[i];
p = &sc->sc_ctlreg->greenmap[start];
for (i = start; i < ecount; i++)
*p++ = green[i];
p = &sc->sc_ctlreg->bluemap[start];
for (i = start; i < ecount; i++)
*p++ = blue[i];
return 0;
}
static int
cg2intr(void *vsc)
{
struct cg2_softc *sc = vsc;
/* XXX - Just disable interrupts for now. */
sc->sc_ctlreg->status.reg.inten = 0;