/*ARGSUSED*/ int grfopen(dev_t dev, int flags, int mode, struct lwp *l) { struct grf_softc *gp; int error = 0; gp = device_lookup_private(&grf_cd, GRFUNIT(dev)); if (gp == NULL) return ENXIO; if ((gp->g_flags & GF_ALIVE) == 0) return ENXIO; if ((gp->g_flags & (GF_OPEN|GF_EXCLUDE)) == (GF_OPEN|GF_EXCLUDE)) return EBUSY; /* * First open. * XXX: always put in graphics mode. */ error = 0; if ((gp->g_flags & GF_OPEN) == 0) { gp->g_flags |= GF_OPEN; error = grfon(gp); } return error; }
/*ARGSUSED*/ int grfioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { int unit = GRFUNIT(dev); struct grf_softc *gp = device_lookup_private(&grf_cd, GRFUNIT(dev)); int error; if ((gp->g_flags & GF_ALIVE) == 0) return ENXIO; error = 0; switch (cmd) { case GRFIOCGINFO: memcpy(data, (void *)&gp->g_display, sizeof(struct grfinfo)); break; case GRFIOCON: error = grfon(gp); break; case GRFIOCOFF: error = grfoff(gp); break; case GRFIOCMAP: error = grfmap(dev, (void **)data, l->l_proc); break; case GRFIOCUNMAP: error = grfunmap(dev, *(void **)data, l->l_proc); break; case GRFSETVMODE: error = (*gp->g_sw->gd_mode)(gp, GM_GRFSETVMODE, data); if (error == 0) ite_reinit(unit); break; default: error = EINVAL; break; } return error; }
/*ARGSUSED*/ int grfioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { struct grf_softc *gp; int error; gp = grfsp[GRFUNIT(dev)]; error = 0; switch (cmd) { case OGRFIOCGINFO: /* argl.. no bank-member.. */ memcpy(data, (void *)&gp->g_display, sizeof(struct grfinfo)-4); break; case GRFIOCGINFO: memcpy(data, (void *)&gp->g_display, sizeof(struct grfinfo)); break; case GRFIOCON: error = grfon(dev); break; case GRFIOCOFF: error = grfoff(dev); break; case GRFIOCSINFO: error = grfsinfo(dev, (struct grfdyninfo *) data); break; case GRFGETVMODE: return(gp->g_mode(gp, GM_GRFGETVMODE, data, 0, 0)); case GRFSETVMODE: error = gp->g_mode(gp, GM_GRFSETVMODE, data, 0, 0); if (error == 0 && gp->g_itedev && !(gp->g_flags & GF_GRFON)) ite_reinit(gp->g_itedev); break; case GRFGETNUMVM: return(gp->g_mode(gp, GM_GRFGETNUMVM, data, 0, 0)); /* * these are all hardware dependent, and have to be resolved * in the respective driver. */ case GRFIOCPUTCMAP: case GRFIOCGETCMAP: case GRFIOCSSPRITEPOS: case GRFIOCGSPRITEPOS: case GRFIOCSSPRITEINF: case GRFIOCGSPRITEINF: case GRFIOCGSPRITEMAX: case GRFIOCBITBLT: case GRFIOCSETMON: case GRFTOGGLE: /* Toggles between Cirrus boards and native ECS on Amiga. 15/11/94 ill */ /* * We need the minor dev number to get the overlay/image * information for grf_ul. */ return(gp->g_mode(gp, GM_GRFIOCTL, data, cmd, dev)); case GRFIOCBLANK: /* blank ioctl, IOCON/OFF will turn ite on */ case FBIOSVIDEO: error = gp->g_mode(gp, GM_GRFIOCTL, data, GRFIOCBLANK, dev); if (!error) gp->g_blank = *(int *)data; return (error); case FBIOGVIDEO: *(int *)data = gp->g_blank; return (0); default: #if NVIEW > 0 /* * check to see whether it's a command recognized by the * view code if the unit is 0 * XXX */ if (GRFUNIT(dev) == 0) { extern const struct cdevsw view_cdevsw; return((*view_cdevsw.d_ioctl)(dev, cmd, data, flag, l)); } #endif error = EPASSTHROUGH; break; } return(error); }