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