/*
* 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.
*/
/*
* only used in console init
*/
static cfdata_t cfdata;
/*
* we make sure to only init things once. this is somewhat
* tricky regarding the console.
*/
int
grfccmatch(device_t parent, cfdata_t cf, void *aux)
{
static int ccconunit = -1;
char *mainbus_name = aux;
extern const struct cdevsw view_cdevsw;
/*
* 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 != cf->cf_unit) {
if (grfcc_probe() == 0)
return(0);
viewprobe();
/*
* XXX nasty hack. opens view[0] and never closes.
*/
if ((*view_cdevsw.d_open)(0, 0, 0, NULL))
return(0);
if (amiga_realconfig == 0) {
ccconunit = cf->cf_unit;
cfdata = cf;
}
}
return(1);
}
if (self == NULL) {
gp = &congrf;
gp->g_device = &temp;
temp.dv_private = gp;
} else {
gp = device_private(self);
gp->g_device = self;
}
if (self != NULL && congrf.g_regkva != 0) {
/*
* we inited earlier just copy the info
* take care not to copy the device struct though.
*/
memcpy(&gp->g_display, &congrf.g_display,
(char *)&gp[1] - (char *)&gp->g_display);
} else {
gp->g_unit = GRF_CC_UNIT;
gp->g_flags = GF_ALIVE;
gp->g_mode = cc_mode;
#if NITE > 0
gp->g_conpri = grfcc_cnprobe();
grfcc_iteinit(gp);
#endif
grf_cc_on(gp);
}
if (self != NULL)
printf("\n");
/*
* attach grf
*/
amiga_config_found(cfdata, gp->g_device, gp, grfccprint, CFARGS_NONE);
}
int
grfccprint(void *aux, const char *pnp)
{
if (pnp)
aprint_normal("grf%d at %s", ((struct grf_softc *)aux)->g_unit,
pnp);
return(UNCONF);
}
/*
* Change the mode of the display.
* Right now all we can do is grfon/grfoff.
* Return a UNIX error number or 0 for success.
*/
/*ARGSUSED*/
int
cc_mode(struct grf_softc *gp, u_long cmd, void *arg, u_long a2, int a3)
{
extern const struct cdevsw view_cdevsw;
switch (cmd) {
case GM_GRFON:
grf_cc_on(gp);
return(0);
case GM_GRFOFF:
(*view_cdevsw.d_ioctl)(0, VIOCREMOVE, NULL, -1, NULL);
return(0);
case GM_GRFCONFIG:
default:
break;
}
return(EPASSTHROUGH);
}