1996-03-17 04:16:48 +03:00
|
|
|
/* $NetBSD: grf_cc.c,v 1.18 1996/03/17 01:17:10 thorpej Exp $ */
|
1994-02-11 10:00:37 +03:00
|
|
|
|
1995-02-17 00:57:31 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994 Christian E. Hopps
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 Christian E. Hopps.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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-06-15 23:05:55 +04:00
|
|
|
#include "grfcc.h"
|
|
|
|
#if NGRFCC > 0
|
1994-05-08 09:52:54 +04:00
|
|
|
/*
|
|
|
|
* currently this is a backward compat hack that interface to
|
|
|
|
* view.c
|
|
|
|
*/
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-02-14 00:10:20 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/ioctl.h>
|
1994-03-30 21:24:08 +04:00
|
|
|
#include <sys/queue.h>
|
1994-05-08 09:52:54 +04:00
|
|
|
#include <sys/device.h>
|
|
|
|
#include <vm/vm_param.h>
|
1994-02-14 00:10:20 +03:00
|
|
|
#include <machine/cpu.h>
|
1994-05-08 09:52:54 +04:00
|
|
|
#include <amiga/amiga/color.h> /* DEBUG */
|
|
|
|
#include <amiga/amiga/device.h>
|
1994-02-14 00:10:20 +03:00
|
|
|
#include <amiga/amiga/custom.h>
|
|
|
|
#include <amiga/amiga/cia.h>
|
|
|
|
#include <amiga/dev/grfioctl.h>
|
|
|
|
#include <amiga/dev/grfvar.h>
|
|
|
|
#include <amiga/dev/grf_ccreg.h>
|
|
|
|
#include <amiga/dev/grfabs_reg.h>
|
|
|
|
#include <amiga/dev/viewioctl.h>
|
1993-10-31 02:40:53 +03:00
|
|
|
|
1993-07-05 23:19:43 +04:00
|
|
|
|
1996-03-17 04:16:48 +03:00
|
|
|
int grfccmatch __P((struct device *, void *, void *));
|
1994-05-08 09:52:54 +04:00
|
|
|
int grfccprint __P((void *, char *));
|
|
|
|
void grfccattach __P((struct device *, struct device *, void *));
|
|
|
|
void grf_cc_on __P((struct grf_softc *));
|
1993-07-05 23:19:43 +04:00
|
|
|
|
1996-03-17 04:16:48 +03:00
|
|
|
struct cfattach grfcc_ca = {
|
|
|
|
sizeof(struct grf_softc), grfccmatch, grfccattach
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfdriver grfcc_cd = {
|
|
|
|
NULL, "grfcc", DV_DULL, NULL, 0
|
|
|
|
};
|
1993-07-05 23:19:43 +04:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
/*
|
|
|
|
* only used in console init
|
|
|
|
*/
|
|
|
|
static struct cfdata *cfdata;
|
1993-07-05 23:19:43 +04:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
/*
|
|
|
|
* we make sure to only init things once. this is somewhat
|
|
|
|
* tricky regarding the console.
|
|
|
|
*/
|
|
|
|
int
|
1996-03-17 04:16:48 +03:00
|
|
|
grfccmatch(pdp, match, auxp)
|
1994-05-08 09:52:54 +04:00
|
|
|
struct device *pdp;
|
1996-03-17 04:16:48 +03:00
|
|
|
void *match, *auxp;
|
1994-05-08 09:52:54 +04:00
|
|
|
{
|
1996-03-17 04:16:48 +03:00
|
|
|
struct cfdata *cfp = match;
|
1994-05-08 09:52:54 +04:00
|
|
|
static int ccconunit = -1;
|
|
|
|
char *mainbus_name = auxp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* allow only one cc console
|
|
|
|
*/
|
|
|
|
if (amiga_realconfig == 0 && ccconunit != -1)
|
|
|
|
return(0);
|
|
|
|
if (matchname("grfcc", mainbus_name) == 0)
|
|
|
|
return(0);
|
|
|
|
if (amiga_realconfig == 0 || ccconunit != cfp->cf_unit) {
|
|
|
|
if (grfcc_probe() == 0)
|
|
|
|
return(0);
|
|
|
|
viewprobe();
|
|
|
|
/*
|
|
|
|
* XXX nasty hack. opens view[0] and never closes.
|
|
|
|
*/
|
|
|
|
if (viewopen(0, 0))
|
|
|
|
return(0);
|
|
|
|
if (amiga_realconfig == 0) {
|
|
|
|
ccconunit = cfp->cf_unit;
|
|
|
|
cfdata = cfp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(1);
|
1993-07-05 23:19:43 +04:00
|
|
|
}
|
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
/*
|
|
|
|
* attach to the grfbus (mainbus)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
grfccattach(pdp, dp, auxp)
|
|
|
|
struct device *pdp, *dp;
|
|
|
|
void *auxp;
|
1993-07-05 23:19:43 +04:00
|
|
|
{
|
1994-05-08 09:52:54 +04:00
|
|
|
static struct grf_softc congrf;
|
|
|
|
static int coninited;
|
|
|
|
struct grf_softc *gp;
|
1993-07-05 23:19:43 +04:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
if (dp == NULL)
|
|
|
|
gp = &congrf;
|
|
|
|
else
|
|
|
|
gp = (struct grf_softc *)dp;
|
|
|
|
|
|
|
|
if (dp != NULL && congrf.g_regkva != 0) {
|
|
|
|
/*
|
|
|
|
* we inited earlier just copy the info
|
|
|
|
* take care not to copy the device struct though.
|
|
|
|
*/
|
|
|
|
bcopy(&congrf.g_display, &gp->g_display,
|
|
|
|
(char *)&gp[1] - (char *)&gp->g_display);
|
|
|
|
} else {
|
|
|
|
gp->g_unit = GRF_CC_UNIT;
|
1994-06-13 12:12:30 +04:00
|
|
|
gp->g_flags = GF_ALIVE;
|
1994-05-08 09:52:54 +04:00
|
|
|
gp->g_mode = cc_mode;
|
|
|
|
gp->g_conpri = grfcc_cnprobe();
|
|
|
|
grfcc_iteinit(gp);
|
|
|
|
grf_cc_on(gp);
|
|
|
|
}
|
|
|
|
if (dp != NULL)
|
|
|
|
printf("\n");
|
|
|
|
/*
|
|
|
|
* attach grf
|
|
|
|
*/
|
|
|
|
amiga_config_found(cfdata, &gp->g_device, gp, grfccprint);
|
1993-07-05 23:19:43 +04:00
|
|
|
}
|
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
int
|
|
|
|
grfccprint(auxp, pnp)
|
|
|
|
void *auxp;
|
|
|
|
char *pnp;
|
|
|
|
{
|
|
|
|
if (pnp)
|
|
|
|
printf("grf%d at %s", ((struct grf_softc *)auxp)->g_unit,
|
|
|
|
pnp);
|
|
|
|
return(UNCONF);
|
|
|
|
}
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1993-07-05 23:19:43 +04:00
|
|
|
/*
|
|
|
|
* Change the mode of the display.
|
|
|
|
* Right now all we can do is grfon/grfoff.
|
|
|
|
* Return a UNIX error number or 0 for success.
|
|
|
|
*/
|
1994-05-08 09:52:54 +04:00
|
|
|
/*ARGSUSED*/
|
|
|
|
int
|
|
|
|
cc_mode(gp, cmd, arg, a2, a3)
|
|
|
|
struct grf_softc *gp;
|
|
|
|
int cmd, a2, a3;
|
1993-07-05 23:19:43 +04:00
|
|
|
void *arg;
|
|
|
|
{
|
1994-05-08 09:52:54 +04:00
|
|
|
switch (cmd) {
|
|
|
|
case GM_GRFON:
|
|
|
|
grf_cc_on(gp);
|
|
|
|
return(0);
|
|
|
|
case GM_GRFOFF:
|
|
|
|
viewioctl(0, VIOCREMOVE, NULL, 0, -1);
|
|
|
|
return(0);
|
|
|
|
case GM_GRFCONFIG:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(EINVAL);
|
1993-07-05 23:19:43 +04:00
|
|
|
}
|
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
void
|
|
|
|
grf_cc_on(gp)
|
|
|
|
struct grf_softc *gp;
|
1994-01-27 00:05:34 +03:00
|
|
|
{
|
1994-05-08 09:52:54 +04:00
|
|
|
struct view_size vs;
|
|
|
|
bmap_t bm;
|
|
|
|
struct grfinfo *gi;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
gi = &gp->g_display;
|
|
|
|
|
|
|
|
viewioctl(0, VIOCGBMAP, &bm, 0, -1);
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
gp->g_data = (caddr_t) 0xDeadBeaf; /* not particularly clean.. */
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
gi->gd_regaddr = (caddr_t) 0xdff000; /* depricated */
|
|
|
|
gi->gd_regsize = round_page(sizeof (custom));
|
|
|
|
gi->gd_fbaddr = bm.hardware_address;
|
|
|
|
gi->gd_fbsize = bm.depth*bm.bytes_per_row*bm.rows;
|
|
|
|
|
|
|
|
if (viewioctl (0, VIOCGSIZE, &vs, 0, -1)) {
|
|
|
|
/* fill in some default values... XXX */
|
|
|
|
vs.width = 640;
|
|
|
|
vs.height = 400;
|
|
|
|
vs.depth = 2;
|
|
|
|
}
|
|
|
|
gi->gd_colors = 1 << vs.depth;
|
|
|
|
gi->gd_planes = vs.depth;
|
1994-01-27 00:05:34 +03:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
gi->gd_fbwidth = vs.width;
|
|
|
|
gi->gd_fbheight = vs.height;
|
|
|
|
gi->gd_fbx = 0;
|
|
|
|
gi->gd_fby = 0;
|
|
|
|
gi->gd_dwidth = vs.width;
|
|
|
|
gi->gd_dheight = vs.height;
|
|
|
|
gi->gd_dx = 0;
|
|
|
|
gi->gd_dy = 0;
|
|
|
|
|
|
|
|
gp->g_regkva = (void *)0xDeadBeaf; /* builtin */
|
|
|
|
gp->g_fbkva = NULL; /* not needed, view internal */
|
|
|
|
|
|
|
|
viewioctl(0, VIOCDISPLAY, NULL, 0, -1);
|
|
|
|
}
|
1993-07-05 23:19:43 +04:00
|
|
|
#endif
|
1993-10-31 02:40:53 +03:00
|
|
|
|