grf.c revision 1.6 1 1.6 leo /* $NetBSD: grf.c,v 1.6 1995/06/26 19:55:45 leo Exp $ */
2 1.1 leo
3 1.1 leo /*
4 1.1 leo * Copyright (c) 1995 Leo Weppelman
5 1.1 leo * Copyright (c) 1988 University of Utah.
6 1.1 leo * Copyright (c) 1990 The Regents of the University of California.
7 1.1 leo * All rights reserved.
8 1.1 leo *
9 1.1 leo * This code is derived from software contributed to Berkeley by
10 1.1 leo * the Systems Programming Group of the University of Utah Computer
11 1.1 leo * Science Department.
12 1.1 leo *
13 1.1 leo * Redistribution and use in source and binary forms, with or without
14 1.1 leo * modification, are permitted provided that the following conditions
15 1.1 leo * are met:
16 1.1 leo * 1. Redistributions of source code must retain the above copyright
17 1.1 leo * notice, this list of conditions and the following disclaimer.
18 1.1 leo * 2. Redistributions in binary form must reproduce the above copyright
19 1.1 leo * notice, this list of conditions and the following disclaimer in the
20 1.1 leo * documentation and/or other materials provided with the distribution.
21 1.1 leo * 3. All advertising materials mentioning features or use of this software
22 1.1 leo * must display the following acknowledgement:
23 1.1 leo * This product includes software developed by the University of
24 1.1 leo * California, Berkeley and its contributors.
25 1.1 leo * 4. Neither the name of the University nor the names of its contributors
26 1.1 leo * may be used to endorse or promote products derived from this software
27 1.1 leo * without specific prior written permission.
28 1.1 leo *
29 1.1 leo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 1.1 leo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 1.1 leo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 1.1 leo * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 1.1 leo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 1.1 leo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 1.1 leo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 1.1 leo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 1.1 leo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 1.1 leo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 1.1 leo * SUCH DAMAGE.
40 1.1 leo *
41 1.1 leo * from: Utah $Hdr: grf.c 1.31 91/01/21$
42 1.1 leo *
43 1.1 leo * @(#)grf.c 7.8 (Berkeley) 5/7/91
44 1.1 leo */
45 1.1 leo
46 1.1 leo /*
47 1.1 leo * Graphics display driver for the Atari
48 1.1 leo * This is the hardware-independent portion of the driver.
49 1.1 leo * Hardware access is through the grf_softc->g_mode routine.
50 1.1 leo */
51 1.1 leo
52 1.1 leo #include <sys/param.h>
53 1.1 leo #include <sys/proc.h>
54 1.1 leo #include <sys/ioctl.h>
55 1.1 leo #include <sys/device.h>
56 1.1 leo #include <sys/file.h>
57 1.1 leo #include <sys/malloc.h>
58 1.1 leo #include <sys/conf.h>
59 1.1 leo #include <sys/systm.h>
60 1.1 leo #include <sys/vnode.h>
61 1.1 leo #include <sys/mman.h>
62 1.1 leo #include <vm/vm.h>
63 1.1 leo #include <vm/vm_kern.h>
64 1.1 leo #include <vm/vm_page.h>
65 1.1 leo #include <vm/vm_pager.h>
66 1.1 leo #include <machine/cpu.h>
67 1.1 leo #include <atari/atari/device.h>
68 1.1 leo #include <atari/dev/grfioctl.h>
69 1.1 leo #include <atari/dev/grfabs_reg.h>
70 1.1 leo #include <atari/dev/grfvar.h>
71 1.1 leo #include <atari/dev/itevar.h>
72 1.1 leo #include <atari/dev/viewioctl.h>
73 1.1 leo #include <atari/dev/viewvar.h>
74 1.1 leo
75 1.1 leo #include "grf.h"
76 1.1 leo #if NGRF > 0
77 1.1 leo
78 1.1 leo #include "ite.h"
79 1.1 leo #if NITE == 0
80 1.1 leo #define ite_on(u,f)
81 1.1 leo #define ite_off(u,f)
82 1.1 leo #define ite_reinit(d)
83 1.1 leo #endif
84 1.1 leo
85 1.1 leo int grfopen __P((dev_t, int, int, struct proc *));
86 1.1 leo int grfclose __P((dev_t, int));
87 1.1 leo int grfioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
88 1.1 leo int grfselect __P((dev_t, int));
89 1.2 mycroft int grfmmap __P((dev_t, int, int));
90 1.1 leo
91 1.1 leo int grfon __P((dev_t));
92 1.1 leo int grfoff __P((dev_t));
93 1.1 leo int grfsinfo __P((dev_t, struct grfdyninfo *));
94 1.1 leo #ifdef BANKEDDEVPAGER
95 1.1 leo int grfbanked_get __P((dev_t, off_t, int));
96 1.1 leo int grfbanked_cur __P((dev_t));
97 1.1 leo int grfbanked_set __P((dev_t, int));
98 1.1 leo #endif
99 1.1 leo static void grf_viewsync __P((struct grf_softc *));
100 1.1 leo static int grf_mode __P((struct grf_softc *, int, void *, int, int));
101 1.1 leo
102 1.1 leo int grfbusprint __P((void *auxp, char *));
103 1.1 leo int grfbusmatch __P((struct device *, struct cfdata *, void *));
104 1.1 leo void grfbusattach __P((struct device *, struct device *, void *));
105 1.1 leo
106 1.1 leo void grfattach __P((struct device *, struct device *, void *));
107 1.1 leo int grfmatch __P((struct device *, struct cfdata *, void *));
108 1.1 leo int grfprint __P((void *, char *));
109 1.1 leo /*
110 1.1 leo * pointers to grf drivers device structs
111 1.1 leo */
112 1.1 leo struct grf_softc *grfsp[NGRF];
113 1.1 leo
114 1.1 leo
115 1.1 leo struct cfdriver grfbuscd = {
116 1.1 leo NULL, "grfbus", (cfmatch_t)grfbusmatch, grfbusattach, DV_DULL,
117 1.1 leo sizeof(struct device)
118 1.1 leo };
119 1.1 leo
120 1.1 leo struct cfdriver grfcd = {
121 1.1 leo NULL, "grf", (cfmatch_t)grfmatch, grfattach, DV_DULL,
122 1.1 leo sizeof(struct grf_softc), NULL, 0
123 1.1 leo };
124 1.1 leo
125 1.1 leo /*
126 1.1 leo * only used in console init.
127 1.1 leo */
128 1.1 leo static struct cfdata *cfdata_gbus = NULL;
129 1.1 leo static struct cfdata *cfdata_grf = NULL;
130 1.1 leo
131 1.1 leo int
132 1.1 leo grfbusmatch(pdp, cfp, auxp)
133 1.1 leo struct device *pdp;
134 1.1 leo struct cfdata *cfp;
135 1.1 leo void *auxp;
136 1.1 leo {
137 1.1 leo if(strcmp(auxp, grfbuscd.cd_name))
138 1.1 leo return(0);
139 1.1 leo
140 1.1 leo if((atari_realconfig == 0) || (cfdata_gbus == NULL)) {
141 1.1 leo /*
142 1.1 leo * Probe layers we depend on
143 1.1 leo */
144 1.1 leo if(grfabs_probe() == 0)
145 1.1 leo return(0);
146 1.1 leo viewprobe();
147 1.1 leo
148 1.1 leo if(atari_realconfig == 0) {
149 1.1 leo /*
150 1.1 leo * XXX: console init opens view 0
151 1.1 leo */
152 1.1 leo if(viewopen(0, 0))
153 1.1 leo return(0);
154 1.1 leo cfdata_gbus = cfp;
155 1.1 leo }
156 1.1 leo }
157 1.1 leo return(1); /* Always there */
158 1.1 leo }
159 1.1 leo
160 1.1 leo void
161 1.1 leo grfbusattach(pdp, dp, auxp)
162 1.1 leo struct device *pdp, *dp;
163 1.1 leo void *auxp;
164 1.1 leo {
165 1.1 leo static int did_cons = 0;
166 1.1 leo int i;
167 1.1 leo
168 1.1 leo if(dp == NULL) { /* Console init */
169 1.1 leo did_cons = 1;
170 1.1 leo i = 0;
171 1.1 leo atari_config_found(cfdata_gbus, NULL, (void*)&i, grfbusprint);
172 1.1 leo }
173 1.1 leo else {
174 1.1 leo printf("\n");
175 1.1 leo for(i = 0; i < NGRF; i++) {
176 1.1 leo /*
177 1.1 leo * Skip opening view[0] when we this is the console.
178 1.1 leo */
179 1.1 leo if(!did_cons || (i > 0))
180 1.1 leo if(viewopen(i, 0))
181 1.1 leo break;
182 1.1 leo config_found(dp, (void*)&i, grfbusprint);
183 1.1 leo }
184 1.1 leo }
185 1.1 leo }
186 1.1 leo
187 1.1 leo int
188 1.1 leo grfbusprint(auxp, name)
189 1.1 leo void *auxp;
190 1.1 leo char *name;
191 1.1 leo {
192 1.1 leo if(name == NULL)
193 1.1 leo return(UNCONF);
194 1.1 leo return(QUIET);
195 1.1 leo }
196 1.1 leo
197 1.1 leo
198 1.1 leo int
199 1.1 leo grfmatch(pdp, cfp, auxp)
200 1.1 leo struct device *pdp;
201 1.1 leo struct cfdata *cfp;
202 1.1 leo void *auxp;
203 1.1 leo {
204 1.1 leo int unit = *(int*)auxp;
205 1.1 leo
206 1.1 leo /*
207 1.1 leo * Match only on unit indicated by grfbus attach.
208 1.1 leo */
209 1.1 leo if(cfp->cf_unit != unit)
210 1.1 leo return(0);
211 1.1 leo
212 1.1 leo cfdata_grf = cfp;
213 1.1 leo return(1);
214 1.1 leo }
215 1.1 leo
216 1.1 leo /*
217 1.1 leo * attach: initialize the grf-structure and try to attach an ite to us.
218 1.1 leo * note : dp is NULL during early console init.
219 1.1 leo */
220 1.1 leo void
221 1.1 leo grfattach(pdp, dp, auxp)
222 1.1 leo struct device *pdp, *dp;
223 1.1 leo void *auxp;
224 1.1 leo {
225 1.1 leo static struct grf_softc congrf;
226 1.1 leo struct grf_softc *gp;
227 1.1 leo int maj;
228 1.1 leo
229 1.1 leo /*
230 1.1 leo * find our major device number
231 1.1 leo */
232 1.1 leo for(maj = 0; maj < nchrdev; maj++)
233 1.1 leo if (cdevsw[maj].d_open == grfopen)
234 1.1 leo break;
235 1.1 leo
236 1.1 leo /*
237 1.1 leo * Handle exeption case: early console init
238 1.1 leo */
239 1.1 leo if(dp == NULL) {
240 1.1 leo congrf.g_unit = 0;
241 1.1 leo congrf.g_grfdev = makedev(maj, 0);
242 1.1 leo congrf.g_flags = GF_ALIVE;
243 1.1 leo congrf.g_mode = grf_mode;
244 1.1 leo congrf.g_conpri = grfcc_cnprobe();
245 1.1 leo congrf.g_viewdev = congrf.g_unit;
246 1.1 leo grfcc_iteinit(&congrf);
247 1.1 leo grf_viewsync(&congrf);
248 1.1 leo
249 1.1 leo /* Attach console ite */
250 1.1 leo atari_config_found(cfdata_grf, NULL, &congrf, grfprint);
251 1.1 leo return;
252 1.1 leo }
253 1.1 leo
254 1.1 leo gp = (struct grf_softc *)dp;
255 1.1 leo gp->g_unit = gp->g_device.dv_unit;
256 1.1 leo grfsp[gp->g_unit] = gp;
257 1.1 leo
258 1.1 leo if((cfdata_grf != NULL) && (gp->g_unit == 0)) {
259 1.1 leo /*
260 1.1 leo * We inited earlier just copy the info, take care
261 1.1 leo * not to copy the device struct though.
262 1.1 leo */
263 1.1 leo bcopy(&congrf.g_display, &gp->g_display,
264 1.1 leo (char *)&gp[1] - (char *)&gp->g_display);
265 1.1 leo }
266 1.1 leo else {
267 1.1 leo gp->g_grfdev = makedev(maj, gp->g_unit);
268 1.1 leo gp->g_flags = GF_ALIVE;
269 1.1 leo gp->g_mode = grf_mode;
270 1.1 leo gp->g_conpri = 0;
271 1.1 leo gp->g_viewdev = gp->g_unit;
272 1.1 leo grfcc_iteinit(gp);
273 1.1 leo grf_viewsync(gp);
274 1.1 leo }
275 1.1 leo
276 1.1 leo printf(": width %d height %d", gp->g_display.gd_dwidth,
277 1.1 leo gp->g_display.gd_dheight);
278 1.1 leo if(gp->g_display.gd_colors == 2)
279 1.1 leo printf(" monochrome\n");
280 1.1 leo else printf(" colors %d\n", gp->g_display.gd_colors);
281 1.1 leo
282 1.1 leo /*
283 1.1 leo * try and attach an ite
284 1.1 leo */
285 1.1 leo config_found(dp, gp, grfprint);
286 1.1 leo }
287 1.1 leo
288 1.1 leo int
289 1.1 leo grfprint(auxp, pnp)
290 1.1 leo void *auxp;
291 1.1 leo char *pnp;
292 1.1 leo {
293 1.1 leo if(pnp)
294 1.1 leo printf("ite at %s", pnp);
295 1.1 leo return(UNCONF);
296 1.1 leo }
297 1.1 leo
298 1.1 leo /*ARGSUSED*/
299 1.1 leo int
300 1.1 leo grfopen(dev, flags, devtype, p)
301 1.1 leo dev_t dev;
302 1.1 leo int flags, devtype;
303 1.1 leo struct proc *p;
304 1.1 leo {
305 1.1 leo struct grf_softc *gp;
306 1.1 leo
307 1.1 leo if (GRFUNIT(dev) >= NGRF)
308 1.1 leo return(ENXIO);
309 1.1 leo
310 1.1 leo gp = grfsp[GRFUNIT(dev)];
311 1.1 leo
312 1.1 leo if ((gp->g_flags & GF_ALIVE) == 0)
313 1.1 leo return(ENXIO);
314 1.1 leo
315 1.1 leo if ((gp->g_flags & (GF_OPEN|GF_EXCLUDE)) == (GF_OPEN|GF_EXCLUDE))
316 1.1 leo return(EBUSY);
317 1.6 leo grf_viewsync(gp);
318 1.1 leo
319 1.1 leo return(0);
320 1.1 leo }
321 1.1 leo
322 1.1 leo /*ARGSUSED*/
323 1.1 leo int
324 1.1 leo grfclose(dev, flags)
325 1.1 leo dev_t dev;
326 1.1 leo int flags;
327 1.1 leo {
328 1.1 leo struct grf_softc *gp;
329 1.1 leo
330 1.1 leo gp = grfsp[GRFUNIT(dev)];
331 1.1 leo (void)grfoff(dev);
332 1.1 leo gp->g_flags &= GF_ALIVE;
333 1.1 leo return(0);
334 1.1 leo }
335 1.1 leo
336 1.1 leo /*ARGSUSED*/
337 1.1 leo int
338 1.1 leo grfioctl(dev, cmd, data, flag, p)
339 1.1 leo dev_t dev;
340 1.1 leo u_long cmd;
341 1.1 leo int flag;
342 1.1 leo caddr_t data;
343 1.1 leo struct proc *p;
344 1.1 leo {
345 1.1 leo struct grf_softc *gp;
346 1.1 leo int error;
347 1.1 leo
348 1.1 leo gp = grfsp[GRFUNIT(dev)];
349 1.1 leo error = 0;
350 1.1 leo
351 1.1 leo switch (cmd) {
352 1.1 leo case OGRFIOCGINFO:
353 1.1 leo /* argl.. no bank-member.. */
354 1.1 leo bcopy((caddr_t)&gp->g_display, data, sizeof(struct grfinfo)-4);
355 1.1 leo break;
356 1.1 leo case GRFIOCGINFO:
357 1.1 leo bcopy((caddr_t)&gp->g_display, data, sizeof(struct grfinfo));
358 1.1 leo break;
359 1.1 leo case GRFIOCON:
360 1.1 leo error = grfon(dev);
361 1.1 leo break;
362 1.1 leo case GRFIOCOFF:
363 1.1 leo error = grfoff(dev);
364 1.1 leo break;
365 1.1 leo case GRFIOCSINFO:
366 1.1 leo error = grfsinfo(dev, (struct grfdyninfo *) data);
367 1.1 leo break;
368 1.1 leo case GRFGETVMODE:
369 1.1 leo return(gp->g_mode(gp, GM_GRFGETVMODE, data));
370 1.1 leo case GRFSETVMODE:
371 1.1 leo error = gp->g_mode(gp, GM_GRFSETVMODE, data);
372 1.1 leo if (error == 0 && gp->g_itedev)
373 1.1 leo ite_reinit(gp->g_itedev);
374 1.1 leo break;
375 1.1 leo case GRFGETNUMVM:
376 1.1 leo return(gp->g_mode(gp, GM_GRFGETNUMVM, data));
377 1.1 leo /*
378 1.1 leo * these are all hardware dependant, and have to be resolved
379 1.1 leo * in the respective driver.
380 1.1 leo */
381 1.1 leo case GRFIOCPUTCMAP:
382 1.1 leo case GRFIOCGETCMAP:
383 1.1 leo case GRFIOCSSPRITEPOS:
384 1.1 leo case GRFIOCGSPRITEPOS:
385 1.1 leo case GRFIOCSSPRITEINF:
386 1.1 leo case GRFIOCGSPRITEINF:
387 1.1 leo case GRFIOCGSPRITEMAX:
388 1.1 leo default:
389 1.1 leo /*
390 1.1 leo * check to see whether it's a command recognized by the
391 1.1 leo * view code.
392 1.1 leo */
393 1.4 leo return(viewioctl(gp->g_viewdev, cmd, data, flag, p));
394 1.1 leo error = EINVAL;
395 1.1 leo break;
396 1.1 leo
397 1.1 leo }
398 1.1 leo return(error);
399 1.1 leo }
400 1.1 leo
401 1.1 leo /*ARGSUSED*/
402 1.1 leo int
403 1.1 leo grfselect(dev, rw)
404 1.1 leo dev_t dev;
405 1.1 leo int rw;
406 1.1 leo {
407 1.1 leo if (rw == FREAD)
408 1.1 leo return(0);
409 1.1 leo return(1);
410 1.1 leo }
411 1.1 leo
412 1.1 leo /*
413 1.1 leo * map the contents of a graphics display card into process'
414 1.1 leo * memory space.
415 1.1 leo */
416 1.1 leo int
417 1.2 mycroft grfmmap(dev, off, prot)
418 1.1 leo dev_t dev;
419 1.1 leo int off, prot;
420 1.1 leo {
421 1.5 leo struct grf_softc *gp;
422 1.5 leo struct grfinfo *gi;
423 1.5 leo
424 1.5 leo gp = grfsp[GRFUNIT(dev)];
425 1.5 leo gi = &gp->g_display;
426 1.5 leo
427 1.5 leo /*
428 1.5 leo * frame buffer
429 1.5 leo */
430 1.5 leo if ((off >= 0) && (off < gi->gd_fbsize))
431 1.5 leo return (((u_int)gi->gd_fbaddr + off) >> PGSHIFT);
432 1.5 leo return(-1);
433 1.1 leo }
434 1.1 leo
435 1.1 leo int
436 1.1 leo grfon(dev)
437 1.1 leo dev_t dev;
438 1.1 leo {
439 1.1 leo struct grf_softc *gp;
440 1.1 leo
441 1.1 leo gp = grfsp[GRFUNIT(dev)];
442 1.1 leo
443 1.1 leo if (gp->g_flags & GF_GRFON)
444 1.1 leo return(0);
445 1.1 leo
446 1.1 leo gp->g_flags |= GF_GRFON;
447 1.1 leo if (gp->g_itedev != NODEV)
448 1.1 leo ite_off(gp->g_itedev, 3);
449 1.1 leo
450 1.1 leo return(gp->g_mode(gp, (dev & GRFOVDEV) ? GM_GRFOVON : GM_GRFON));
451 1.1 leo }
452 1.1 leo
453 1.1 leo int
454 1.1 leo grfoff(dev)
455 1.1 leo dev_t dev;
456 1.1 leo {
457 1.1 leo struct grf_softc *gp;
458 1.1 leo int error;
459 1.1 leo
460 1.1 leo gp = grfsp[GRFUNIT(dev)];
461 1.1 leo
462 1.1 leo if ((gp->g_flags & GF_GRFON) == 0)
463 1.1 leo return(0);
464 1.1 leo
465 1.1 leo gp->g_flags &= ~GF_GRFON;
466 1.1 leo error = gp->g_mode(gp, (dev & GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF);
467 1.1 leo
468 1.1 leo /*
469 1.1 leo * Closely tied together no X's
470 1.1 leo */
471 1.1 leo if (gp->g_itedev != NODEV)
472 1.1 leo ite_on(gp->g_itedev, 2);
473 1.1 leo
474 1.1 leo return(error);
475 1.1 leo }
476 1.1 leo
477 1.1 leo int
478 1.1 leo grfsinfo(dev, dyninfo)
479 1.1 leo dev_t dev;
480 1.1 leo struct grfdyninfo *dyninfo;
481 1.1 leo {
482 1.1 leo struct grf_softc *gp;
483 1.1 leo int error;
484 1.1 leo
485 1.1 leo gp = grfsp[GRFUNIT(dev)];
486 1.1 leo error = gp->g_mode(gp, GM_GRFCONFIG, dyninfo);
487 1.1 leo
488 1.1 leo /*
489 1.1 leo * Closely tied together no X's
490 1.1 leo */
491 1.1 leo if (gp->g_itedev != NODEV)
492 1.1 leo ite_reinit(gp->g_itedev);
493 1.1 leo return(error);
494 1.1 leo }
495 1.1 leo
496 1.1 leo /*
497 1.1 leo * Get the grf-info in sync with underlying view.
498 1.1 leo */
499 1.1 leo static void
500 1.1 leo grf_viewsync(gp)
501 1.1 leo struct grf_softc *gp;
502 1.1 leo {
503 1.1 leo struct view_size vs;
504 1.1 leo bmap_t bm;
505 1.1 leo struct grfinfo *gi;
506 1.1 leo
507 1.1 leo gi = &gp->g_display;
508 1.1 leo
509 1.1 leo viewioctl(gp->g_viewdev, VIOCGBMAP, &bm, 0, -1);
510 1.1 leo
511 1.1 leo gp->g_data = (caddr_t) 0xDeadBeaf; /* not particularly clean.. */
512 1.1 leo
513 1.1 leo gi->gd_fbaddr = bm.hw_address;
514 1.1 leo gi->gd_fbsize = bm.depth*bm.bytes_per_row*bm.rows;
515 1.1 leo
516 1.1 leo if(viewioctl(gp->g_viewdev, VIOCGSIZE, &vs, 0, -1)) {
517 1.1 leo /*
518 1.1 leo * fill in some default values...
519 1.1 leo * XXX: Should _never_ happen
520 1.1 leo */
521 1.1 leo vs.width = 640;
522 1.1 leo vs.height = 400;
523 1.3 leo vs.depth = 1;
524 1.1 leo }
525 1.1 leo gi->gd_colors = 1 << vs.depth;
526 1.1 leo gi->gd_planes = vs.depth;
527 1.1 leo
528 1.1 leo gi->gd_fbwidth = vs.width;
529 1.1 leo gi->gd_fbheight = vs.height;
530 1.1 leo gi->gd_dyn.gdi_fbx = 0;
531 1.1 leo gi->gd_dyn.gdi_fby = 0;
532 1.1 leo gi->gd_dyn.gdi_dwidth = vs.width;
533 1.1 leo gi->gd_dyn.gdi_dheight = vs.height;
534 1.1 leo gi->gd_dyn.gdi_dx = 0;
535 1.1 leo gi->gd_dyn.gdi_dy = 0;
536 1.1 leo }
537 1.1 leo
538 1.1 leo /*
539 1.1 leo * Change the mode of the display.
540 1.1 leo * Right now all we can do is grfon/grfoff.
541 1.1 leo * Return a UNIX error number or 0 for success.
542 1.1 leo */
543 1.1 leo /*ARGSUSED*/
544 1.1 leo static int
545 1.1 leo grf_mode(gp, cmd, arg, a2, a3)
546 1.1 leo struct grf_softc *gp;
547 1.1 leo int cmd, a2, a3;
548 1.1 leo void *arg;
549 1.1 leo {
550 1.1 leo switch (cmd) {
551 1.1 leo case GM_GRFON:
552 1.1 leo /*
553 1.1 leo * Get in sync with view, ite might have changed it.
554 1.1 leo */
555 1.1 leo grf_viewsync(gp);
556 1.1 leo viewioctl(gp->g_viewdev, VIOCDISPLAY, NULL, 0, -1);
557 1.1 leo return(0);
558 1.1 leo case GM_GRFOFF:
559 1.1 leo viewioctl(gp->g_viewdev, VIOCREMOVE, NULL, 0, -1);
560 1.1 leo return(0);
561 1.1 leo case GM_GRFCONFIG:
562 1.1 leo default:
563 1.1 leo break;
564 1.1 leo }
565 1.1 leo return(EINVAL);
566 1.1 leo }
567 1.1 leo #endif /* NGRF > 0 */
568