Home | History | Annotate | Line # | Download | only in dev
grf_gv.c revision 1.5.32.1
      1  1.5.32.1  nathanw /*	$NetBSD: grf_gv.c,v 1.5.32.1 2002/01/08 00:28:38 nathanw Exp $	*/
      2       1.1      oki 
      3       1.1      oki /*
      4       1.1      oki  * Copyright (c) 1988 University of Utah.
      5       1.1      oki  * Copyright (c) 1990, 1993
      6       1.1      oki  *	The Regents of the University of California.  All rights reserved.
      7       1.1      oki  *
      8       1.1      oki  * This code is derived from software contributed to Berkeley by
      9       1.1      oki  * the Systems Programming Group of the University of Utah Computer
     10       1.1      oki  * Science Department.
     11       1.1      oki  *
     12       1.1      oki  * Redistribution and use in source and binary forms, with or without
     13       1.1      oki  * modification, are permitted provided that the following conditions
     14       1.1      oki  * are met:
     15       1.1      oki  * 1. Redistributions of source code must retain the above copyright
     16       1.1      oki  *    notice, this list of conditions and the following disclaimer.
     17       1.1      oki  * 2. Redistributions in binary form must reproduce the above copyright
     18       1.1      oki  *    notice, this list of conditions and the following disclaimer in the
     19       1.1      oki  *    documentation and/or other materials provided with the distribution.
     20       1.1      oki  * 3. All advertising materials mentioning features or use of this software
     21       1.1      oki  *    must display the following acknowledgement:
     22       1.1      oki  *	This product includes software developed by the University of
     23       1.1      oki  *	California, Berkeley and its contributors.
     24       1.1      oki  * 4. Neither the name of the University nor the names of its contributors
     25       1.1      oki  *    may be used to endorse or promote products derived from this software
     26       1.1      oki  *    without specific prior written permission.
     27       1.1      oki  *
     28       1.1      oki  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29       1.1      oki  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30       1.1      oki  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31       1.1      oki  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32       1.1      oki  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33       1.1      oki  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34       1.1      oki  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35       1.1      oki  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36       1.1      oki  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37       1.1      oki  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38       1.1      oki  * SUCH DAMAGE.
     39       1.1      oki  *
     40       1.1      oki  * from: Utah $Hdr: grf_tc.c 1.20 93/08/13$
     41       1.1      oki  *
     42       1.1      oki  *	@(#)grf_tc.c	8.4 (Berkeley) 1/12/94
     43       1.1      oki  */
     44       1.1      oki 
     45       1.1      oki /*
     46       1.1      oki  * Graphics routines for the X68K native custom chip set.
     47       1.1      oki  */
     48       1.4  thorpej 
     49       1.4  thorpej #include "opt_compat_hpux.h"
     50       1.4  thorpej 
     51       1.1      oki #include <sys/param.h>
     52       1.1      oki #include <sys/device.h>
     53       1.1      oki #include <sys/errno.h>
     54       1.1      oki 
     55       1.5  minoura #include <machine/grfioctl.h>
     56       1.5  minoura 
     57       1.1      oki #include <x68k/dev/grfvar.h>
     58       1.1      oki #include <x68k/x68k/iodevice.h>
     59       1.1      oki 
     60       1.1      oki #include <machine/cpu.h>
     61       1.3      oki 
     62       1.3      oki int gv_init __P((struct grf_softc *, caddr_t));
     63       1.3      oki int gv_mode __P((struct grf_softc *, u_long, caddr_t));
     64       1.1      oki 
     65       1.1      oki /* Initialize hardware.
     66       1.1      oki  * Must fill in the grfinfo structure in g_softc.
     67       1.1      oki  * Returns 0 if hardware not present, non-zero ow.
     68       1.1      oki  */
     69       1.2      oki int
     70       1.1      oki gv_init(gp, addr)
     71       1.1      oki 	struct grf_softc *gp;
     72       1.1      oki 	caddr_t addr;
     73       1.1      oki {
     74       1.1      oki 	struct grfinfo *gi = &gp->g_display;
     75       1.1      oki 
     76       1.1      oki 	gi->gd_fbwidth  = 1024;
     77       1.1      oki 	gi->gd_fbheight = 1024;
     78       1.1      oki 	gi->gd_planes  = 4;
     79       1.1      oki 	gi->gd_regaddr = (void *)0x00e80000;
     80       1.1      oki 	gi->gd_regsize = 0x00010000;  /* contains system port */
     81       1.1      oki 	gi->gd_fbaddr  = (void *)0x00c00000;
     82       1.1      oki 	gi->gd_fbsize  = gi->gd_fbwidth * gi->gd_fbheight * 2;
     83       1.1      oki 	gp->g_regkva   = addr;
     84       1.1      oki 	gp->g_fbkva    = addr;
     85       1.1      oki 	switch(IODEVbase->io_sram[0x1d]) {
     86       1.1      oki 	case 18:
     87       1.1      oki 		/*
     88       1.1      oki 		 * mode 18, 24kHz
     89       1.1      oki 		 */
     90       1.1      oki 		gi->gd_dwidth  = 1024;
     91       1.1      oki 		gi->gd_dheight =  848;
     92       1.1      oki 		break;
     93       1.1      oki 	case 19:
     94       1.1      oki 		/*
     95       1.1      oki 		 * mode 19, 31kHz VGA mode
     96       1.1      oki 		 */
     97       1.1      oki 		gi->gd_dwidth  = 640;
     98       1.1      oki 		gi->gd_dheight = 480;
     99       1.1      oki 		break;
    100       1.1      oki 	default:
    101       1.1      oki 		/*
    102       1.1      oki 		 * mode 16, 31kHz (default)
    103       1.1      oki 		 */
    104       1.1      oki 		gi->gd_dwidth  = 768;
    105       1.1      oki 		gi->gd_dheight = 512;
    106       1.1      oki 		break;
    107       1.1      oki 	}
    108       1.1      oki 	gi->gd_colors  = 16;
    109       1.1      oki 
    110       1.1      oki 	return(1);
    111       1.1      oki }
    112       1.1      oki 
    113       1.1      oki /*
    114       1.1      oki  * Change the mode of the display.
    115       1.1      oki  * Right now all we can do is grfon/grfoff.
    116       1.1      oki  * Return a UNIX error number or 0 for success.
    117       1.1      oki  */
    118       1.1      oki /*ARGSUSED*/
    119       1.2      oki int
    120       1.1      oki gv_mode(gp, cmd, data)
    121       1.1      oki 	register struct grf_softc *gp;
    122       1.1      oki 	u_long cmd;
    123       1.1      oki 	caddr_t data;
    124       1.1      oki {
    125       1.1      oki 	int error = 0;
    126       1.1      oki 
    127       1.1      oki 	switch (cmd) {
    128       1.1      oki 	case GM_GRFON:
    129       1.1      oki 	case GM_GRFOFF:
    130       1.1      oki 		break;
    131       1.1      oki 
    132       1.1      oki 	/*
    133       1.1      oki 	 * Remember UVA of mapping for GCDESCRIBE.
    134       1.1      oki 	 * XXX this should be per-process.
    135       1.1      oki 	 */
    136       1.1      oki 	case GM_MAP:
    137       1.1      oki 		gp->g_data = data;
    138       1.1      oki 		break;
    139       1.1      oki 
    140       1.1      oki 	case GM_UNMAP:
    141       1.1      oki 		gp->g_data = 0;
    142       1.1      oki 		break;
    143       1.1      oki 
    144       1.1      oki #ifdef COMPAT_HPUX
    145       1.1      oki 	case GM_DESCRIBE:
    146       1.1      oki 	{
    147       1.1      oki 		struct grf_fbinfo *fi = (struct grf_fbinfo *)data;
    148       1.1      oki 		struct grfinfo *gi = &gp->g_display;
    149       1.1      oki 		int i;
    150       1.1      oki 
    151       1.1      oki 		/* feed it what HP-UX expects */
    152       1.1      oki 		fi->id = gi->gd_id;
    153       1.1      oki 		fi->mapsize = gi->gd_fbsize;
    154       1.1      oki 		fi->dwidth = gi->gd_dwidth;
    155       1.1      oki 		fi->dlength = gi->gd_dheight;
    156       1.1      oki 		fi->width = gi->gd_fbwidth;
    157       1.1      oki 		fi->length = gi->gd_fbheight;
    158       1.1      oki 		fi->bpp = NBBY;
    159       1.1      oki 		fi->xlen = (fi->width * fi->bpp) / NBBY;
    160       1.1      oki 		fi->npl = gi->gd_planes;
    161       1.1      oki 		fi->bppu = fi->npl;
    162       1.1      oki 		fi->nplbytes = fi->xlen * ((fi->length * fi->bpp) / NBBY);
    163       1.1      oki 		/* XXX */
    164       1.1      oki 		switch (gp->g_sw->gd_hwid) {
    165       1.1      oki 		case GID_HRCCATSEYE:
    166  1.5.32.1  nathanw 			memcpy(fi->name, "HP98550", 8);
    167       1.1      oki 			break;
    168       1.1      oki 		case GID_LRCATSEYE:
    169  1.5.32.1  nathanw 			memcpy(fi->name, "HP98549", 8);
    170       1.1      oki 			break;
    171       1.1      oki 		case GID_HRMCATSEYE:
    172  1.5.32.1  nathanw 			memcpy(fi->name, "HP98548", 8);
    173       1.1      oki 			break;
    174       1.1      oki 		case GID_TOPCAT:
    175       1.1      oki 			switch (gi->gd_colors) {
    176       1.1      oki 			case 64:
    177  1.5.32.1  nathanw 				memcpy(fi->name, "HP98547", 8);
    178       1.1      oki 				break;
    179       1.1      oki 			case 16:
    180  1.5.32.1  nathanw 				memcpy(fi->name, "HP98545", 8);
    181       1.1      oki 				break;
    182       1.1      oki 			case 2:
    183  1.5.32.1  nathanw 				memcpy(fi->name, "HP98544", 8);
    184       1.1      oki 				break;
    185       1.1      oki 			}
    186       1.1      oki 			break;
    187       1.1      oki 		}
    188       1.1      oki 		fi->attr = 2;	/* HW block mover */
    189       1.1      oki 		/*
    190       1.1      oki 		 * If mapped, return the UVA where mapped.
    191       1.1      oki 		 */
    192       1.1      oki 		if (gp->g_data) {
    193       1.1      oki 			fi->regbase = gp->g_data;
    194       1.1      oki 			fi->fbbase = fi->regbase + gp->g_display.gd_regsize;
    195       1.1      oki 		} else {
    196       1.1      oki 			fi->fbbase = 0;
    197       1.1      oki 			fi->regbase = 0;
    198       1.1      oki 		}
    199       1.1      oki 		for (i = 0; i < 6; i++)
    200       1.1      oki 			fi->regions[i] = 0;
    201       1.1      oki 		break;
    202       1.1      oki 	}
    203       1.1      oki #endif
    204       1.1      oki #if 1
    205       1.1      oki 	case GM_GRFSETVMODE:
    206       1.1      oki 		if (*(int *)data == 1) {
    207       1.1      oki 			struct grfinfo *gi = &gp->g_display;
    208       1.1      oki 			volatile struct crtc *crtc = &IODEVbase->io_crtc;
    209       1.1      oki 			/* CRTC $B$K@_Dj$r9T$J$$!"(Bdwidth $B$H(B dheight $B$r$$$8$k(B */
    210       1.1      oki 			crtc->r20 = (crtc->r20 & 0xFF00) | 0x1a;
    211       1.1      oki 			crtc->r08 = 0x1b;
    212       1.1      oki 			crtc->r07 = 0x19c;
    213       1.1      oki 			crtc->r06 = 0x1c;
    214       1.1      oki 			crtc->r05 = 0x02;
    215       1.1      oki 			crtc->r04 = 0x019f;
    216       1.1      oki 			crtc->r03 = 0x9a;
    217       1.1      oki 			crtc->r02 = 0x1a;
    218       1.1      oki 			crtc->r01 = 0x09;
    219       1.1      oki 			crtc->r00 = 0xa4;
    220       1.1      oki 			gi->gd_dwidth = 1024;
    221       1.1      oki 			gi->gd_dheight = 768;
    222       1.1      oki 		}
    223       1.1      oki 		break;
    224       1.1      oki #endif
    225       1.1      oki 
    226       1.1      oki 	default:
    227       1.1      oki 		error = EINVAL;
    228       1.1      oki 		break;
    229       1.1      oki 	}
    230       1.1      oki 	return(error);
    231       1.1      oki }
    232