xref: /netbsd-src/sys/arch/sun3/dev/btvar.h (revision 95e1ffb15694e54f29f8baaa4232152b703c2a5a)
1*95e1ffb1Schristos /*	$NetBSD: btvar.h,v 1.4 2005/12/11 12:19:20 christos Exp $ */
263c3c68dSgwr 
363c3c68dSgwr /*
463c3c68dSgwr  * Copyright (c) 1993
563c3c68dSgwr  *	The Regents of the University of California.  All rights reserved.
663c3c68dSgwr  *
763c3c68dSgwr  * This software was developed by the Computer Systems Engineering group
863c3c68dSgwr  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
963c3c68dSgwr  * contributed to Berkeley.
1063c3c68dSgwr  *
1163c3c68dSgwr  * All advertising materials mentioning features or use of this software
1263c3c68dSgwr  * must display the following acknowledgement:
1363c3c68dSgwr  *	This product includes software developed by the University of
1463c3c68dSgwr  *	California, Lawrence Berkeley Laboratory.
1563c3c68dSgwr  *
1663c3c68dSgwr  * Redistribution and use in source and binary forms, with or without
1763c3c68dSgwr  * modification, are permitted provided that the following conditions
1863c3c68dSgwr  * are met:
1963c3c68dSgwr  * 1. Redistributions of source code must retain the above copyright
2063c3c68dSgwr  *    notice, this list of conditions and the following disclaimer.
2163c3c68dSgwr  * 2. Redistributions in binary form must reproduce the above copyright
2263c3c68dSgwr  *    notice, this list of conditions and the following disclaimer in the
2363c3c68dSgwr  *    documentation and/or other materials provided with the distribution.
24aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
2563c3c68dSgwr  *    may be used to endorse or promote products derived from this software
2663c3c68dSgwr  *    without specific prior written permission.
2763c3c68dSgwr  *
2863c3c68dSgwr  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2963c3c68dSgwr  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3063c3c68dSgwr  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3163c3c68dSgwr  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3263c3c68dSgwr  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3363c3c68dSgwr  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3463c3c68dSgwr  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3563c3c68dSgwr  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3663c3c68dSgwr  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3763c3c68dSgwr  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3863c3c68dSgwr  * SUCH DAMAGE.
3963c3c68dSgwr  *
4063c3c68dSgwr  *	@(#)btvar.h	8.2 (Berkeley) 1/21/94
4163c3c68dSgwr  */
4263c3c68dSgwr 
4363c3c68dSgwr /*
4463c3c68dSgwr  * Brooktree color frame buffer state variables (see btreg.h).
4563c3c68dSgwr  *
4663c3c68dSgwr  * Unfortunately, remarkably little code can be shared between the
4763c3c68dSgwr  * cg3 and cg6 drivers here, as the cg3 registers do longword-ops
4863c3c68dSgwr  * `as expected', but the cg6 ones use only the upper byte.
4963c3c68dSgwr  *
5063c3c68dSgwr  * Still, the software color map manipulation is not completely trivial.
5163c3c68dSgwr  */
5263c3c68dSgwr union bt_cmap {
5363c3c68dSgwr 	u_char  cm_map[256][3];		/* 256 R/G/B entries */
5463c3c68dSgwr 	u_int   cm_chip[256 * 3 / 4];	/* the way the chip gets loaded */
5563c3c68dSgwr };
5663c3c68dSgwr 
5763c3c68dSgwr /*
5863c3c68dSgwr  * Routines in bt_subr.c.
5963c3c68dSgwr  */
6010b1a7beSchs int	bt_getcmap(struct fbcmap *, union bt_cmap *, int);
6110b1a7beSchs int	bt_putcmap(struct fbcmap *, union bt_cmap *, int);
6263c3c68dSgwr 
6363c3c68dSgwr /*
6463c3c68dSgwr  * Compute (x / 4) * 3 and (x / 4) * 4.  These are used in turning
6563c3c68dSgwr  * RGB indices (which are in multiples of three) into `chip RGB' values
6663c3c68dSgwr  * (which are in multiples of four).
6763c3c68dSgwr  */
6863c3c68dSgwr #define	BT_D4M3(x) ((((x) >> 2) << 1) + ((x) >> 2))	/* (x / 4) * 3 */
6963c3c68dSgwr #define	BT_D4M4(x) ((x) & ~3)				/* (x / 4) * 4 */
70