2002-10-02 08:06:36 +04:00
|
|
|
/* $NetBSD: cfb.c,v 1.42 2002/10/02 04:15:06 thorpej 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.
|
|
|
|
*
|
1995-09-11 11:45:36 +04:00
|
|
|
* from: @(#)sfb.c 8.1 (Berkeley) 6/10/93
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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,
|
1999-04-24 12:01:01 +04:00
|
|
|
* provided that the above copyright notice appears in all copies.
|
1993-10-12 06:22:19 +03:00
|
|
|
* 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
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
1999-04-13 00:38:17 +04:00
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
1993-10-12 06:22:19 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
2000-01-10 06:24:31 +03:00
|
|
|
#include <sys/systm.h>
|
1995-09-11 11:45:36 +04:00
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/device.h>
|
1996-01-30 01:52:15 +03:00
|
|
|
#include <dev/tc/tcvar.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
|
2000-01-10 06:24:31 +03:00
|
|
|
#include <machine/autoconf.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <machine/pmioctl.h>
|
2001-09-19 23:04:16 +04:00
|
|
|
#include <dev/sun/fbio.h>
|
1995-09-11 11:45:36 +04:00
|
|
|
#include <machine/fbvar.h>
|
|
|
|
#include <pmax/dev/bt459.h>
|
2000-01-10 06:24:31 +03:00
|
|
|
#include <pmax/dev/cfbvar.h>
|
1993-10-12 06:22:19 +03:00
|
|
|
#include <pmax/dev/fbreg.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These need to be mapped into user space.
|
|
|
|
*/
|
2000-01-09 06:55:28 +03:00
|
|
|
static struct fbuaccess cfbu;
|
|
|
|
static struct pmax_fbtty cfbfb;
|
2000-02-03 07:09:01 +03:00
|
|
|
static struct fbinfo *cfb_fi;
|
1995-09-11 11:45:36 +04:00
|
|
|
|
1996-01-30 01:52:15 +03:00
|
|
|
/*
|
|
|
|
* Method table for standard framebuffer operations on a CFB.
|
2000-01-10 06:24:31 +03:00
|
|
|
* The CFB uses a Brooktree bt479 ramdac.
|
1996-01-30 01:52:15 +03:00
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
struct fbdriver cfb_driver = {
|
|
|
|
bt459_video_on,
|
|
|
|
bt459_video_off,
|
|
|
|
bt459InitColorMap,
|
|
|
|
bt459GetColorMap,
|
|
|
|
bt459LoadColorMap,
|
|
|
|
bt459PosCursor,
|
|
|
|
bt459LoadCursor,
|
|
|
|
bt459CursorColor
|
|
|
|
};
|
1993-10-12 06:22:19 +03:00
|
|
|
|
2000-02-03 07:09:01 +03:00
|
|
|
#define CFB_OFFSET_VRAM 0x0 /* from module's base */
|
1993-10-12 06:22:19 +03:00
|
|
|
#define CFB_OFFSET_BT459 0x200000 /* Bt459 registers */
|
|
|
|
#define CFB_OFFSET_IREQ 0x300000 /* Interrupt req. control */
|
|
|
|
#define CFB_OFFSET_ROM 0x380000 /* Diagnostic ROM */
|
|
|
|
#define CFB_OFFSET_RESET 0x3c0000 /* Bt459 resets on writes */
|
1994-05-27 12:39:00 +04:00
|
|
|
#define CFB_FB_SIZE 0x100000 /* frame buffer size */
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1995-08-04 04:26:35 +04:00
|
|
|
/*
|
|
|
|
* Autoconfiguration data for config.new.
|
|
|
|
* Use static-sized softc until config.old and old autoconfig
|
|
|
|
* code is completely gone.
|
|
|
|
*/
|
|
|
|
|
2000-01-09 06:55:28 +03:00
|
|
|
static int cfbmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void cfbattach __P((struct device *, struct device *, void *));
|
2000-02-03 07:09:01 +03:00
|
|
|
static int cfbinit __P((struct fbinfo *, caddr_t, int, int));
|
2000-01-09 06:55:28 +03:00
|
|
|
static int cfb_intr __P((void *sc));
|
1995-08-04 04:26:35 +04:00
|
|
|
|
2002-10-02 08:06:36 +04:00
|
|
|
CFATTACH_DECL(cfb, sizeof(struct fbsoftc),
|
|
|
|
cfbmatch, cfbattach, NULL, NULL);
|
1996-03-17 04:38:52 +03:00
|
|
|
|
2000-02-03 07:09:01 +03:00
|
|
|
int
|
|
|
|
cfb_cnattach(addr)
|
|
|
|
paddr_t addr;
|
|
|
|
{
|
|
|
|
struct fbinfo *fi;
|
|
|
|
|
|
|
|
fbcnalloc(&fi);
|
|
|
|
cfbinit(fi, (caddr_t)addr, 0, 1);
|
|
|
|
cfb_fi = fi;
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2000-01-09 06:55:28 +03:00
|
|
|
static int
|
1995-08-04 04:26:35 +04:00
|
|
|
cfbmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
1997-07-21 09:39:02 +04:00
|
|
|
struct cfdata *match;
|
1995-08-04 04:26:35 +04:00
|
|
|
void *aux;
|
|
|
|
{
|
1996-05-29 10:15:40 +04:00
|
|
|
struct tc_attach_args *ta = aux;
|
1995-09-11 11:45:36 +04:00
|
|
|
|
1995-08-04 04:26: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-BA "))
|
1995-08-04 04:26:35 +04:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
1995-08-29 13:56:23 +04:00
|
|
|
/*
|
1995-09-11 11:45:36 +04:00
|
|
|
* Attach a device. Hand off all the work to cfbinit(),
|
1996-01-30 01:52:15 +03:00
|
|
|
* so console-config code can attach cfb devices very early in boot,
|
|
|
|
* to use as system console.
|
1995-08-29 13:56:23 +04:00
|
|
|
*/
|
2000-01-09 06:55:28 +03:00
|
|
|
static void
|
1995-08-04 04:26:35 +04:00
|
|
|
cfbattach(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;
|
2001-07-07 18:20:59 +04:00
|
|
|
caddr_t base = (caddr_t)(ta->ta_addr);
|
1995-09-11 11:45:36 +04:00
|
|
|
int unit = self->dv_unit;
|
1999-07-26 02:50:28 +04:00
|
|
|
struct fbinfo *fi;
|
|
|
|
|
2000-02-03 07:09:01 +03:00
|
|
|
if (cfb_fi)
|
|
|
|
fi = cfb_fi;
|
|
|
|
else {
|
|
|
|
/* Allocate a struct fbinfo and point the softc at it */
|
|
|
|
if (fballoc(&fi) < 0 || cfbinit(fi, base, unit, 0) < 0)
|
|
|
|
return; /* failed */
|
|
|
|
}
|
|
|
|
((struct fbsoftc *)self)->sc_fi = fi;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
2000-02-03 07:09:01 +03:00
|
|
|
printf(": %dx%dx%d%s",
|
|
|
|
fi->fi_type.fb_width,
|
|
|
|
fi->fi_type.fb_height,
|
|
|
|
fi->fi_type.fb_depth,
|
|
|
|
(cfb_fi) ? " console" : "");
|
1993-10-12 06:22:19 +03:00
|
|
|
|
|
|
|
/*
|
1997-07-01 02:08:58 +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.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
1997-07-01 02:08:58 +04:00
|
|
|
tc_intr_establish(parent, ta->ta_cookie, TC_IPL_NONE, cfb_intr, fi);
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("\n");
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1996-01-30 01:52:15 +03:00
|
|
|
* CFB initialization. This is divorced from cfbattch() so that
|
|
|
|
* a console framebuffer can be initialized early during boot.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
2000-02-03 07:09:01 +03:00
|
|
|
static int
|
1995-09-11 11:45:36 +04:00
|
|
|
cfbinit(fi, cfbaddr, unit, silent)
|
|
|
|
struct fbinfo *fi;
|
|
|
|
caddr_t cfbaddr;
|
|
|
|
int unit;
|
|
|
|
int silent;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
/* check for no frame buffer */
|
1995-09-11 11:45:36 +04:00
|
|
|
if (badaddr(cfbaddr, 4)) {
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("cfb: bad address 0x%p\n", cfbaddr);
|
1993-10-12 06:22:19 +03:00
|
|
|
return (0);
|
1995-09-11 11:45:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in main frame buffer info struct. */
|
|
|
|
fi->fi_unit = unit;
|
|
|
|
fi->fi_pixels = (caddr_t)(cfbaddr + CFB_OFFSET_VRAM);
|
|
|
|
fi->fi_pixelsize = 1024 * 864;
|
|
|
|
fi->fi_base = (caddr_t)(cfbaddr + CFB_OFFSET_VRAM);
|
|
|
|
fi->fi_vdac = (caddr_t)(cfbaddr + CFB_OFFSET_BT459);
|
|
|
|
fi->fi_size = (fi->fi_pixels + CFB_FB_SIZE) - fi->fi_base;
|
|
|
|
fi->fi_linebytes = 1024;
|
|
|
|
fi->fi_driver = &cfb_driver;
|
|
|
|
fi->fi_blanked = 0;
|
|
|
|
|
|
|
|
/* Fill in Frame Buffer Type struct. */
|
2001-09-19 23:04:16 +04:00
|
|
|
fi->fi_type.fb_type = PMAX_FBTYPE_CFB;
|
1995-09-11 11:45:36 +04:00
|
|
|
fi->fi_type.fb_width = 1024;
|
|
|
|
fi->fi_type.fb_height = 864;
|
|
|
|
fi->fi_type.fb_depth = 8;
|
|
|
|
fi->fi_type.fb_cmsize = 256;
|
|
|
|
fi->fi_type.fb_size = CFB_FB_SIZE;
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1999-07-26 02:50:28 +04:00
|
|
|
/* Reset the chip */
|
1995-09-11 11:45:36 +04:00
|
|
|
if (!bt459init(fi)) {
|
1996-10-13 07:39:27 +04:00
|
|
|
printf("cfb%d: vdac init failed.\n", unit);
|
1993-10-12 06:22:19 +03:00
|
|
|
return (0);
|
1995-09-11 11:45:36 +04:00
|
|
|
}
|
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.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
1995-09-11 11:45:36 +04:00
|
|
|
fi->fi_fbu = (struct fbuaccess *)
|
1997-06-22 11:42:25 +04:00
|
|
|
MIPS_PHYS_TO_KSEG1(MIPS_KSEG0_TO_PHYS(&cfbu));
|
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 = 56;
|
|
|
|
fi->fi_fbu->scrInfo.max_col = 80;
|
|
|
|
init_pmaxfbu(fi);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
1999-07-26 02:50:28 +04:00
|
|
|
/* Initialize old-style pmax glass-tty screen info. */
|
1995-09-11 11:45:36 +04:00
|
|
|
fi->fi_glasstty = &cfbfb;
|
|
|
|
|
2000-02-03 07:09:01 +03:00
|
|
|
if (tb_kbdmouseconfig(fi))
|
|
|
|
return (-1);
|
1993-10-12 06:22:19 +03:00
|
|
|
|
2000-02-03 07:09:01 +03:00
|
|
|
fbconnect(fi);
|
1995-09-11 11:45:36 +04:00
|
|
|
return (1);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
1995-09-11 11:45:36 +04:00
|
|
|
* The original TURBOChannel cfb interrupts on every vertical
|
|
|
|
* retrace, and we can't disable the board from requesting those
|
|
|
|
* interrupts. The 4.4BSD kernel never enabled those interrupts;
|
1996-01-30 01:52:15 +03:00
|
|
|
* but there's a kernel design bug on the 3MIN, where disabling
|
|
|
|
* (or enabling) TC option interrupts has no effect the interrupts
|
|
|
|
* are mapped to R3000 interrupts and always seem to be taken.
|
|
|
|
* This function simply dismisses CFB interrupts, or the interrupt
|
|
|
|
* request from the card will still be active.
|
1993-10-12 06:22:19 +03:00
|
|
|
*/
|
2000-01-09 06:55:28 +03:00
|
|
|
static int
|
1995-09-11 11:45:36 +04:00
|
|
|
cfb_intr(sc)
|
|
|
|
void *sc;
|
1993-10-12 06:22:19 +03:00
|
|
|
{
|
1999-07-26 02:50:28 +04:00
|
|
|
struct fbinfo *fi;
|
|
|
|
caddr_t slot_addr;
|
1999-04-24 12:01:01 +04:00
|
|
|
|
1999-07-26 02:50:28 +04:00
|
|
|
fi = (struct fbinfo *)sc;
|
|
|
|
slot_addr = (((caddr_t)fi->fi_base) - CFB_OFFSET_VRAM);
|
|
|
|
|
1995-09-11 11:45:36 +04:00
|
|
|
/* reset vertical-retrace interrupt by writing a dont-care */
|
1999-07-26 02:50:28 +04:00
|
|
|
*(int*) (slot_addr + CFB_OFFSET_IREQ) = 0;
|
1996-04-08 04:57:37 +04:00
|
|
|
return (0);
|
1993-10-12 06:22:19 +03:00
|
|
|
}
|