1996-10-13 17:13:50 +04:00
|
|
|
/* $NetBSD: mfb.c,v 1.20 1996/10/13 13:13:59 jonathan Exp $ */
|
1994-10-27 00:08:38 +03:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*-
|
1994-05-27 12:39:00 +04:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-10-12 06:22:19 +03:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Ralph Campbell and Rick Macklem.
|
|
|
|
*
|
|
|
|
* 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 the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. 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.
|
|
|
|
*
|
1994-10-27 00:08:38 +03:00
|
|
|
* @(#)mfb.c 8.1 (Berkeley) 6/10/93
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mach Operating System
|
|
|
|
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
|
|
|
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* devGraphics.c --
|
|
|
|
*
|
|
|
|
* This file contains machine-dependent routines for the graphics device.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1989 Digital Equipment Corporation.
|
|
|
|
* Permission to use, copy, modify, and distribute this software and
|
|
|
|
* its documentation for any purpose and without fee is hereby granted,
|
|
|
|
* provided that the above copyright notice appears in all copies.
|
|
|
|
* Digital Equipment Corporation makes no representations about the
|
|
|
|
* suitability of this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*
|
1994-05-27 12:39:00 +04:00
|
|
|
* from: Header: /sprite/src/kernel/dev/ds3100.md/RCS/devGraphics.c,
|
|
|
|
* v 9.2 90/02/13 22:16:24 shirriff Exp SPRITE (DECWRL)";
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
1996-02-02 21:05:36 +03:00
|
|
|
#include "fb.h"
|
|
|
|
#include "mfb.h"
|
1993-10-12 06:22:19 +03:00
|
|
|
#if NMFB > 0
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
1995-09-11 11:45:36 +04:00
|
|
|
#include <sys/fcntl.h>
|
1996-08-27 06:32:48 +04:00
|
|
|
#include <sys/malloc.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <sys/errno.h>
|
1995-09-11 11:45:36 +04:00
|
|
|
#include <sys/device.h>
|
1996-05-19 05:18:57 +04:00
|
|
|
#include <sys/systm.h>
|
|
|
|
|
1996-01-30 01:52:15 +03:00
|
|
|
#include <dev/tc/tcvar.h>
|
1996-09-21 07:25:15 +04:00
|
|
|
#include <machine/autoconf.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-10-13 17:13:50 +04:00
|
|
|
#include <mips/cpuregs.h> /* mips cached->uncached */
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <machine/pmioctl.h>
|
1995-09-11 11:45:36 +04:00
|
|
|
#include <machine/fbio.h>
|
|
|
|
#include <machine/fbvar.h>
|
1996-09-21 07:25:15 +04:00
|
|
|
#include <pmax/dev/cfbvar.h> /* XXX dev/tc ? */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
#include <pmax/pmax/pmaxtype.h>
|
|
|
|
|
|
|
|
#include <pmax/dev/mfbreg.h>
|
|
|
|
#include <pmax/dev/fbreg.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These need to be mapped into user space.
|
|
|
|
*/
|
|
|
|
struct fbuaccess mfbu;
|
1995-09-11 11:45:36 +04:00
|
|
|
struct pmax_fbtty mfbfb;
|
|
|
|
struct fbinfo mfbfi; /*XXX*/
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1996-08-27 06:32:48 +04:00
|
|
|
extern int pmax_boardtype;
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Forward references.
|
|
|
|
*/
|
1996-08-27 06:32:48 +04:00
|
|
|
#define CMAP_BITS (3 * 256) /* 256 entries, 3 bytes per. */
|
|
|
|
static u_char cmap_bits [CMAP_BITS]; /* colormap for console... */
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
|
|
|
|
void mfbPosCursor __P((struct fbinfo *fi, int x, int y));
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-08-27 06:32:48 +04:00
|
|
|
int mfbinit __P((struct fbinfo *fi, caddr_t mfbaddr, int unit, int silent));
|
1996-05-19 05:18:57 +04:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
#if 1 /* these go away when we use the abstracted-out chip drivers */
|
|
|
|
static void mfbLoadCursor __P((struct fbinfo *fi, u_short *ptr));
|
|
|
|
static void mfbRestoreCursorColor __P((struct fbinfo *fi));
|
|
|
|
static void mfbCursorColor __P((struct fbinfo *fi, u_int *color));
|
|
|
|
|
|
|
|
static void mfbInitColorMapBlack __P((struct fbinfo *fi, int blackpix));
|
|
|
|
static void mfbInitColorMap __P((struct fbinfo *fi));
|
|
|
|
static int mfbLoadColorMap __P((struct fbinfo *fi, caddr_t mapbits,
|
|
|
|
int index, int count));
|
|
|
|
static int mfbLoadColorMapNoop __P((struct fbinfo *fi, caddr_t mapbits,
|
|
|
|
int index, int count));
|
|
|
|
#endif /* 0 */
|
|
|
|
|
|
|
|
/* new-style raster-cons "driver" methods */
|
|
|
|
|
|
|
|
int mfbGetColorMap __P((struct fbinfo *fi, caddr_t, int, int));
|
|
|
|
|
|
|
|
|
|
|
|
static int bt455_video_on __P((struct fbinfo *));
|
|
|
|
static int bt455_video_off __P((struct fbinfo *));
|
1996-05-19 05:18:57 +04:00
|
|
|
|
|
|
|
static void bt431_init __P((bt431_regmap_t *regs));
|
|
|
|
static void bt431_select_reg __P((bt431_regmap_t *regs, int regno));
|
|
|
|
static void bt431_write_reg __P((bt431_regmap_t *regs, int regno, int val));
|
|
|
|
|
|
|
|
#ifdef notused
|
|
|
|
static u_char bt431_read_reg __P((bt431_regmap_t *regs, int regno));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* old pmax-framebuffer hackery
|
|
|
|
*/
|
1993-10-12 06:22:19 +03:00
|
|
|
extern u_short defCursor[32];
|
|
|
|
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* "driver" (member functions) for the raster-console (rcons) pseudo-device.
|
|
|
|
*/
|
|
|
|
struct fbdriver mfb_driver = {
|
|
|
|
bt455_video_on,
|
|
|
|
bt455_video_off,
|
|
|
|
mfbInitColorMap,
|
|
|
|
mfbGetColorMap,
|
|
|
|
mfbLoadColorMapNoop, /*LoadColorMap,*/
|
|
|
|
mfbPosCursor,
|
|
|
|
mfbLoadCursor,
|
|
|
|
mfbCursorColor
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register offsets
|
|
|
|
*/
|
1993-10-12 06:22:19 +03:00
|
|
|
#define MFB_OFFSET_VRAM 0x200000 /* from module's base */
|
|
|
|
#define MFB_OFFSET_BT431 0x180000 /* Bt431 registers */
|
|
|
|
#define MFB_OFFSET_BT455 0x100000 /* Bt455 registers */
|
|
|
|
#define MFB_OFFSET_IREQ 0x080000 /* Interrupt req. control */
|
|
|
|
#define MFB_OFFSET_ROM 0x0 /* Diagnostic ROM */
|
1994-05-27 12:39:00 +04:00
|
|
|
#define MFB_FB_SIZE 0x200000 /* frame buffer size */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
1995-08-10 08:21:35 +04:00
|
|
|
* Autoconfiguration data for config.new.
|
|
|
|
* Use static-sized softc until config.old and old autoconfig
|
|
|
|
* code is completely gone.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
1995-08-10 08:21:35 +04:00
|
|
|
|
|
|
|
int mfbmatch __P((struct device *, void *, void *));
|
|
|
|
void mfbattach __P((struct device *, struct device *, void *));
|
1996-08-27 06:32:48 +04:00
|
|
|
int mfb_intr __P((void *sc));
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1996-03-17 04:38:52 +03:00
|
|
|
struct cfattach mfb_ca = {
|
|
|
|
sizeof(struct device), mfbmatch, mfbattach
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver mfb_cd = {
|
|
|
|
NULL, "mfb", DV_DULL
|
1995-08-10 08:21:35 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
mfbmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
void *match;
|
|
|
|
void *aux;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1996-05-29 10:15:40 +04:00
|
|
|
struct tc_attach_args *ta = aux;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
#ifdef FBDRIVER_DOES_ATTACH
|
|
|
|
/* leave configuration to the fb driver */
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
|
1995-08-10 08:21:35 +04:00
|
|
|
/* make sure that we're looking for this type of device. */
|
1996-05-29 10:15:40 +04:00
|
|
|
if (!TC_BUS_MATCHNAME(ta, "PMAG-AA "))
|
1993-10-12 06:22:19 +03:00
|
|
|
return (0);
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
1995-08-10 08:21:35 +04:00
|
|
|
void
|
|
|
|
mfbattach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
1996-05-29 10:15:40 +04:00
|
|
|
struct tc_attach_args *ta = aux;
|
|
|
|
caddr_t mfbaddr = (caddr_t) ta->ta_addr;
|
1995-09-11 11:45:36 +04:00
|
|
|
int unit = self->dv_unit;
|
1996-08-27 06:32:48 +04:00
|
|
|
struct fbinfo *fi = (struct fbinfo *) self;
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
#ifdef notyet
|
1996-05-19 05:18:57 +04:00
|
|
|
struct fbinfo *fi = &mfbfi;
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* if this is the console, it's already configured. */
|
1996-05-29 10:15:40 +04:00
|
|
|
if (ta->ta_cookie == cons_slot)
|
1995-09-11 11:45:36 +04:00
|
|
|
return; /* XXX patch up f softc pointer */
|
|
|
|
#endif
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1996-08-27 06:32:48 +04:00
|
|
|
if (!mfbinit(fi, mfbaddr, unit, 0))
|
1995-09-11 11:45:36 +04:00
|
|
|
return;
|
1995-08-10 08:21:35 +04:00
|
|
|
|
1996-08-27 06:32:48 +04:00
|
|
|
/*
|
|
|
|
* 3MIN does not mask un-established TC option interrupts,
|
|
|
|
* so establish a handler.
|
|
|
|
* XXX Should store cmap updates in softc and apply in the
|
|
|
|
* interrupt handler, which interrupts during vertical-retrace.
|
|
|
|
*/
|
|
|
|
if (pmax_boardtype == DS_3MIN) {
|
|
|
|
tc_intr_establish(parent, (void*)ta->ta_cookie, TC_IPL_NONE,
|
|
|
|
mfb_intr, fi);
|
|
|
|
}
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("\n");
|
1995-08-10 08:21:35 +04:00
|
|
|
}
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* Initialization
|
|
|
|
*/
|
|
|
|
int
|
1996-08-27 06:32:48 +04:00
|
|
|
mfbinit(fi, mfbaddr, unit, silent)
|
|
|
|
struct fbinfo *fi;
|
1995-09-11 11:45:36 +04:00
|
|
|
caddr_t mfbaddr;
|
|
|
|
int unit;
|
|
|
|
int silent;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1996-09-06 11:01:06 +04:00
|
|
|
|
|
|
|
register int isconsole = 0;
|
|
|
|
|
1996-08-27 06:32:48 +04:00
|
|
|
/*
|
|
|
|
* If this device is being intialized as the console, malloc()
|
|
|
|
* is not yet up and we must use statically-allocated space.
|
|
|
|
*/
|
|
|
|
if (fi == NULL) {
|
|
|
|
fi = &mfbfi; /* XXX */
|
|
|
|
fi->fi_cmap_bits = (caddr_t)cmap_bits;
|
1996-09-06 11:01:06 +04:00
|
|
|
isconsole = 1;
|
1996-08-27 06:32:48 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
fi->fi_cmap_bits = malloc(CMAP_BITS, M_DEVBUF, M_NOWAIT);
|
|
|
|
if (fi->fi_cmap_bits == NULL) {
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("mfb%d: no memory for cmap\n", unit);
|
1996-08-27 06:32:48 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* check for no frame buffer */
|
1996-08-27 06:32:48 +04:00
|
|
|
if (badaddr(mfbaddr, 4)) {
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("mfb: bad address 0x%p\n", mfbaddr);
|
1995-09-11 11:45:36 +04:00
|
|
|
return (0);
|
1996-08-27 06:32:48 +04:00
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* Fill in main frame buffer info struct. */
|
|
|
|
fi->fi_unit = unit;
|
|
|
|
fi->fi_pixels = (caddr_t)(mfbaddr + MFB_OFFSET_VRAM);
|
|
|
|
fi->fi_pixelsize = 2048 * 1024;
|
|
|
|
fi->fi_base = (caddr_t)(mfbaddr + MFB_OFFSET_BT431);
|
|
|
|
fi->fi_vdac = (caddr_t)(mfbaddr + MFB_OFFSET_BT455);
|
|
|
|
fi->fi_size = (fi->fi_pixels + MFB_FB_SIZE) - fi->fi_base;
|
|
|
|
fi->fi_linebytes = 1280;
|
|
|
|
fi->fi_driver = &mfb_driver;
|
|
|
|
fi->fi_blanked = 0;
|
|
|
|
|
|
|
|
/* Fill in Frame Buffer Type struct. */
|
|
|
|
fi->fi_type.fb_boardtype = PMAX_FBTYPE_MFB;
|
|
|
|
fi->fi_type.fb_width = 1280;
|
|
|
|
fi->fi_type.fb_height = 1024;
|
|
|
|
fi->fi_type.fb_depth = 8;
|
|
|
|
fi->fi_type.fb_cmsize = 0;
|
|
|
|
fi->fi_type.fb_size = MFB_FB_SIZE;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* Reset the video chip.
|
|
|
|
*/
|
|
|
|
bt431_init ((bt431_regmap_t *) fi->fi_base);
|
|
|
|
mfbLoadCursor(fi, defCursor); /*XXX*/ /* Is this necessary? */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* qvss/pm-style mmap()ed event queue compatibility glue
|
|
|
|
*/
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* Must be in Uncached space since the fbuaccess structure is
|
|
|
|
* mapped into the user's address space uncached.
|
|
|
|
*/
|
|
|
|
fi->fi_fbu = (struct fbuaccess *)
|
|
|
|
MACH_PHYS_TO_UNCACHED(MACH_CACHED_TO_PHYS(&mfbu));
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* This is glass-tty state but it's in the shared structure. Ick. */
|
|
|
|
fi->fi_fbu->scrInfo.max_row = 67;
|
|
|
|
fi->fi_fbu->scrInfo.max_col = 80;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
init_pmaxfbu(fi);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* Initialize old-style pmax glass-tty screen info.
|
|
|
|
*/
|
|
|
|
fi->fi_glasstty = &mfbfb;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* Initialize the color map, the screen, and the mouse.
|
|
|
|
*/
|
|
|
|
if (tb_kbdmouseconfig(fi))
|
|
|
|
return (0);
|
1994-05-27 12:39:00 +04:00
|
|
|
|
1996-09-06 11:01:06 +04:00
|
|
|
/* white-on-black if console, black-on-black otherwise. */
|
|
|
|
mfbInitColorMapBlack(fi, isconsole);
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/*
|
|
|
|
* Connect to the raster-console pseudo-driver.
|
|
|
|
*/
|
|
|
|
fbconnect("PMAG-AA", fi, silent);
|
|
|
|
|
|
|
|
#ifdef fpinitialized
|
|
|
|
fp->initialized = 1;
|
|
|
|
#endif
|
|
|
|
return (1);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char cursor_RGB[6]; /* cursor color 2 & 3 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There are actually 2 Bt431 cursor sprite chips that each generate 1 bit
|
|
|
|
* of each cursor pixel for a 2bit 64x64 cursor sprite. The corresponding
|
|
|
|
* registers for these two chips live in adjacent bytes of the shorts that
|
|
|
|
* are defined in bt431_regmap_t.
|
|
|
|
*/
|
|
|
|
static void
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbLoadCursor(fi, cursor)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
u_short *cursor;
|
|
|
|
{
|
|
|
|
register int i, j, k, pos;
|
|
|
|
register u_short ap, bp, out;
|
|
|
|
register bt431_regmap_t *regs;
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
regs = (bt431_regmap_t *)(fi -> fi_base);
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/*
|
|
|
|
* Fill in the cursor sprite using the A and B planes, as provided
|
|
|
|
* for the pmax.
|
|
|
|
* XXX This will have to change when the X server knows that this
|
|
|
|
* is not a pmax display. (ie. Not the Xcfbpmax server.)
|
|
|
|
*/
|
|
|
|
pos = 0;
|
|
|
|
bt431_select_reg(regs, BT431_REG_CRAM_BASE);
|
|
|
|
for (k = 0; k < 16; k++) {
|
|
|
|
ap = *cursor;
|
|
|
|
bp = *(cursor + 16);
|
|
|
|
j = 0;
|
|
|
|
while (j < 2) {
|
|
|
|
out = 0;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
out = (out << 1) | ((bp & 0x1) << 8) |
|
|
|
|
(ap & 0x1);
|
|
|
|
ap >>= 1;
|
|
|
|
bp >>= 1;
|
|
|
|
}
|
|
|
|
BT431_WRITE_CMAP_AUTOI(regs, out);
|
|
|
|
pos++;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
while (j < 8) {
|
|
|
|
BT431_WRITE_CMAP_AUTOI(regs, 0);
|
|
|
|
pos++;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
cursor++;
|
|
|
|
}
|
|
|
|
while (pos < 512) {
|
|
|
|
BT431_WRITE_CMAP_AUTOI(regs, 0);
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* Restore the color of the cursor. */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
void
|
|
|
|
mfbRestoreCursorColor (fi)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1995-09-11 11:45:36 +04:00
|
|
|
bt455_regmap_t *regs = (bt455_regmap_t *)(fi -> fi_vdac);
|
|
|
|
u_char cm [3];
|
1993-10-12 06:22:19 +03:00
|
|
|
u_char fg;
|
|
|
|
|
|
|
|
if (cursor_RGB[0] || cursor_RGB[1] || cursor_RGB[2])
|
1995-09-11 11:45:36 +04:00
|
|
|
cm [0] = cm [1] = cm [2] = 0xff;
|
1993-10-12 06:22:19 +03:00
|
|
|
else
|
1995-09-11 11:45:36 +04:00
|
|
|
cm [0] = cm [1] = cm [2] = 0;
|
|
|
|
mfbLoadColorMap(fi, cm, 8, 1);
|
|
|
|
mfbLoadColorMap(fi, cm, 9, 1);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
if (cursor_RGB[3] || cursor_RGB[4] || cursor_RGB[5])
|
|
|
|
fg = 0xf;
|
|
|
|
else
|
|
|
|
fg = 0;
|
|
|
|
regs->addr_ovly = fg;
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
regs->addr_ovly = fg;
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
regs->addr_ovly = fg;
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* Set the color of the cursor. */
|
|
|
|
|
|
|
|
void
|
|
|
|
mfbCursorColor(fi, color)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
unsigned int color[];
|
|
|
|
{
|
1996-05-19 05:18:57 +04:00
|
|
|
register int i;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
cursor_RGB[i] = (u_char)(color[i] >> 8);
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbRestoreCursorColor (fi);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* Position the cursor. */
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
void
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbPosCursor(fi, x, y)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
register int x, y;
|
|
|
|
{
|
1995-09-11 11:45:36 +04:00
|
|
|
bt431_regmap_t *regs = (bt431_regmap_t *)(fi -> fi_base);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
|
|
|
else if (y > fi -> fi_type.fb_width - fi -> fi_cursor.width - 1)
|
|
|
|
y = fi -> fi_type.fb_width - fi -> fi_cursor.width - 1;
|
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
else if (x > fi -> fi_type.fb_height - fi -> fi_cursor.height - 1)
|
|
|
|
x = fi -> fi_type.fb_height - fi -> fi_cursor.height - 1;
|
|
|
|
|
|
|
|
fi -> fi_cursor.x = x;
|
|
|
|
fi -> fi_cursor.y = y;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
#define lo(v) ((v)&0xff)
|
|
|
|
#define hi(v) (((v)&0xf00)>>8)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cx = x + D + H - P
|
|
|
|
* P = 37 if 1:1, 52 if 4:1, 57 if 5:1
|
|
|
|
* D = pixel skew between outdata and external data
|
|
|
|
* H = pixels between HSYNCH falling and active video
|
|
|
|
*
|
|
|
|
* Cy = y + V - 32
|
|
|
|
* V = scanlines between HSYNCH falling, two or more
|
|
|
|
* clocks after VSYNCH falling, and active video
|
|
|
|
*/
|
|
|
|
|
|
|
|
bt431_write_reg(regs, BT431_REG_CXLO, lo(x + 360));
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, hi(x + 360));
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, lo(y + 36));
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, hi(y + 36));
|
|
|
|
}
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* Initialize the color map. */
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
static void
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbInitColorMapBlack(fi, blackpix)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
int blackpix;
|
|
|
|
{
|
1995-09-11 11:45:36 +04:00
|
|
|
u_char rgb [3];
|
1993-10-12 06:22:19 +03:00
|
|
|
register int i;
|
|
|
|
|
|
|
|
if (blackpix)
|
1995-09-11 11:45:36 +04:00
|
|
|
rgb [0] = rgb [1] = rgb [2] = 0xff;
|
1993-10-12 06:22:19 +03:00
|
|
|
else
|
1995-09-11 11:45:36 +04:00
|
|
|
rgb [0] = rgb [1] = rgb [2] = 0;
|
|
|
|
|
|
|
|
mfbLoadColorMap(fi, (caddr_t)rgb, 0, 1);
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
if (blackpix)
|
1995-09-11 11:45:36 +04:00
|
|
|
rgb [0] = rgb [1] = rgb [2] = 0;
|
1993-10-12 06:22:19 +03:00
|
|
|
else
|
1995-09-11 11:45:36 +04:00
|
|
|
rgb [0] = rgb [1] = rgb [2] = 0xff;
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
for (i = 1; i < 16; i++) {
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbLoadColorMap(fi, (caddr_t)rgb, i, 1);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
cursor_RGB[i] = 0;
|
|
|
|
cursor_RGB[i + 3] = 0xff;
|
|
|
|
}
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbRestoreCursorColor (fi);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* set colormap for open/close */
|
1993-10-12 06:22:19 +03:00
|
|
|
static void
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbInitColorMap(fi)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbInitColorMapBlack(fi, fi->fi_open);
|
|
|
|
}
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* Load the color map. */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
int
|
|
|
|
mfbLoadColorMap(fi, bits, index, count)
|
|
|
|
struct fbinfo *fi;
|
|
|
|
caddr_t bits;
|
|
|
|
int index, count;
|
|
|
|
{
|
|
|
|
bt455_regmap_t *regs = (bt455_regmap_t *)(fi -> fi_vdac);
|
|
|
|
u_char *cmap_bits;
|
|
|
|
u_char *cmap;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (index > 15 || index < 0 || index + count > 15)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
cmap_bits = (u_char *)bits;
|
|
|
|
cmap = (u_char *)(fi -> fi_cmap_bits) + index * 3;
|
|
|
|
|
|
|
|
BT455_SELECT_ENTRY(regs, index);
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
cmap [(i + index) * 3]
|
|
|
|
= regs->addr_cmap_data = cmap_bits [i * 3] >> 4;
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1995-09-11 11:45:36 +04:00
|
|
|
cmap [(i + index) * 3 + 1]
|
|
|
|
= regs->addr_cmap_data = cmap_bits [i * 3 + 1] >> 4;
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1995-09-11 11:45:36 +04:00
|
|
|
cmap [(i + index) * 3 + 2]
|
|
|
|
= regs->addr_cmap_data = cmap_bits [i * 3 + 2] >> 4;
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1995-09-11 11:45:36 +04:00
|
|
|
}
|
1996-05-19 05:18:57 +04:00
|
|
|
return 0;
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* stub for driver */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
int
|
|
|
|
mfbLoadColorMapNoop(fi, bits, index, count)
|
|
|
|
struct fbinfo *fi;
|
|
|
|
caddr_t bits;
|
|
|
|
int index, count;
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the color map. */
|
|
|
|
|
|
|
|
int
|
|
|
|
mfbGetColorMap(fi, bits, index, count)
|
|
|
|
struct fbinfo *fi;
|
|
|
|
caddr_t bits;
|
|
|
|
int index, count;
|
|
|
|
{
|
1996-05-19 05:18:57 +04:00
|
|
|
/*bt455_regmap_t *regs = (bt455_regmap_t *)(fi -> fi_vdac);*/
|
1995-09-11 11:45:36 +04:00
|
|
|
u_char *cmap_bits;
|
|
|
|
u_char *cmap;
|
|
|
|
|
|
|
|
if (index > 15 || index < 0 || index + count > 15)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
cmap_bits = (u_char *)bits;
|
|
|
|
cmap = (u_char *)(fi -> fi_cmap_bits) + index * 3;
|
|
|
|
|
|
|
|
bcopy (cmap, cmap_bits, count * 3);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable the video display. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
bt455_video_on(fi)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
|
|
|
register int i;
|
1995-09-11 11:45:36 +04:00
|
|
|
bt455_regmap_t *regs = (bt455_regmap_t *)(fi -> fi_vdac);
|
|
|
|
u_char *cmap;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
if (!fi -> fi_blanked)
|
1996-05-19 05:18:57 +04:00
|
|
|
return 0;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
cmap = (u_char *)(fi -> fi_cmap_bits);
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
/* restore old color map entry zero */
|
|
|
|
BT455_SELECT_ENTRY(regs, 0);
|
|
|
|
for (i = 0; i < 6; i++) {
|
1995-09-11 11:45:36 +04:00
|
|
|
regs->addr_cmap_data = cmap [i];
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
1995-09-11 11:45:36 +04:00
|
|
|
mfbRestoreCursorColor (fi);
|
|
|
|
fi -> fi_blanked = 0;
|
1996-05-19 05:18:57 +04:00
|
|
|
|
|
|
|
return 0;
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* bt455_video_off
|
|
|
|
*
|
|
|
|
* Disable the video display.
|
|
|
|
*
|
|
|
|
* Results:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Side effects:
|
|
|
|
* The display is disabled.
|
|
|
|
*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
static int
|
|
|
|
bt455_video_off(fi)
|
|
|
|
struct fbinfo *fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
|
|
|
register int i;
|
1995-09-11 11:45:36 +04:00
|
|
|
u_char cursor_save [6];
|
|
|
|
bt455_regmap_t *regs = (bt455_regmap_t *)(fi -> fi_vdac);
|
|
|
|
u_char *cmap;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
if (fi -> fi_blanked)
|
1996-05-19 05:18:57 +04:00
|
|
|
return 0;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
cmap = (u_char *)(fi -> fi_cmap_bits);
|
|
|
|
|
|
|
|
bcopy (cursor_RGB, cursor_save, 6);
|
|
|
|
|
|
|
|
/* Zap the cursor and the colormap... */
|
1993-10-12 06:22:19 +03:00
|
|
|
BT455_SELECT_ENTRY(regs, 0);
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
cursor_RGB[i] = 0;
|
1995-09-11 11:45:36 +04:00
|
|
|
regs->addr_cmap_data = 0;
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
1995-09-11 11:45:36 +04:00
|
|
|
|
|
|
|
mfbRestoreCursorColor (fi);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
bcopy (cursor_save, cursor_RGB, 6);
|
|
|
|
fi -> fi_blanked = 0;
|
1996-05-19 05:18:57 +04:00
|
|
|
|
|
|
|
return 0;
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic register access
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
bt431_select_reg(regs, regno)
|
|
|
|
bt431_regmap_t *regs;
|
|
|
|
{
|
|
|
|
regs->addr_lo = SET_VALUE(regno & 0xff);
|
|
|
|
regs->addr_hi = SET_VALUE((regno >> 8) & 0xff);
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
bt431_write_reg(regs, regno, val)
|
|
|
|
bt431_regmap_t *regs;
|
|
|
|
{
|
|
|
|
bt431_select_reg(regs, regno);
|
|
|
|
regs->addr_reg = SET_VALUE(val);
|
1996-05-19 05:18:57 +04:00
|
|
|
wbflush();
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
1996-05-19 05:18:57 +04:00
|
|
|
#ifdef notused
|
1993-10-12 06:22:19 +03:00
|
|
|
static u_char
|
|
|
|
bt431_read_reg(regs, regno)
|
|
|
|
bt431_regmap_t *regs;
|
|
|
|
{
|
|
|
|
bt431_select_reg(regs, regno);
|
|
|
|
return (GET_VALUE(regs->addr_reg));
|
|
|
|
}
|
1996-05-19 05:18:57 +04:00
|
|
|
#endif
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
static void
|
|
|
|
bt431_init(regs)
|
|
|
|
bt431_regmap_t *regs;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* use 4:1 input mux */
|
|
|
|
bt431_write_reg(regs, BT431_REG_CMD,
|
|
|
|
BT431_CMD_CURS_ENABLE|BT431_CMD_OR_CURSORS|
|
|
|
|
BT431_CMD_4_1_MUX|BT431_CMD_THICK_1);
|
|
|
|
|
|
|
|
/* home cursor */
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
|
|
|
|
/* no crosshair window */
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
BT431_WRITE_REG_AUTOI(regs, 0x00);
|
|
|
|
}
|
1996-08-27 06:32:48 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* copied from cfb_intr
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
mfb_intr(sc)
|
|
|
|
void *sc;
|
|
|
|
{
|
|
|
|
struct fbinfo *fi = /* XXX (struct fbinfo *)sc */ &mfbfi;
|
|
|
|
volatile int junk;
|
|
|
|
char *slot_addr = (((char *)fi->fi_base) - MFB_OFFSET_BT431);
|
|
|
|
|
|
|
|
/* reset vertical-retrace interrupt by writing a dont-care */
|
|
|
|
junk = *(volatile int*) (slot_addr + MFB_OFFSET_IREQ);
|
|
|
|
*(volatile int*) (slot_addr + MFB_OFFSET_IREQ) = 0;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1993-10-12 06:22:19 +03:00
|
|
|
#endif /* NMFB */
|
1995-09-11 11:45:36 +04:00
|
|
|
|