Sat Nov 7 14:29:10 2015 UTC ()
Improved wscons support. Virtual screens are now working.


(phx)
diff -r1.62 -r1.63 src/sys/arch/amiga/dev/grf.c
diff -r1.56 -r1.57 src/sys/arch/amiga/dev/grf_cv.c
diff -r1.30 -r1.31 src/sys/arch/amiga/dev/grf_cv3d.c
diff -r1.24 -r1.25 src/sys/arch/amiga/dev/grfvar.h
diff -r1.1 -r0 src/sys/arch/amiga/dev/grfws.h

cvs diff -r1.62 -r1.63 src/sys/arch/amiga/dev/grf.c (expand / switch to unified diff)

--- src/sys/arch/amiga/dev/grf.c 2014/07/25 08:10:31 1.62
+++ src/sys/arch/amiga/dev/grf.c 2015/11/07 14:29:10 1.63
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: grf.c,v 1.62 2014/07/25 08:10:31 dholland Exp $ */ 1/* $NetBSD: grf.c,v 1.63 2015/11/07 14:29:10 phx Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1990 The Regents of the University of California. 5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department. 10 * Science Department.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * from: Utah $Hdr: grf.c 1.31 91/01/21$ 36 * from: Utah $Hdr: grf.c 1.31 91/01/21$
37 * 37 *
38 * @(#)grf.c 7.8 (Berkeley) 5/7/91 38 * @(#)grf.c 7.8 (Berkeley) 5/7/91
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: grf.c,v 1.62 2014/07/25 08:10:31 dholland Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: grf.c,v 1.63 2015/11/07 14:29:10 phx Exp $");
43 43
44/* 44/*
45 * Graphics display driver for the Amiga 45 * Graphics display driver for the Amiga
46 * This is the hardware-independent portion of the driver. 46 * This is the hardware-independent portion of the driver.
47 * Hardware access is through the grf_softc->g_mode routine. 47 * Hardware access is through the grf_softc->g_mode routine.
48 */ 48 */
49 49
50#include "view.h" 50#include "view.h"
51#include "grf.h" 51#include "grf.h"
52#include "kbd.h" 52#include "kbd.h"
53#include "wsdisplay.h" 53#include "wsdisplay.h"
54 54
55#include <sys/param.h> 55#include <sys/param.h>
@@ -66,27 +66,26 @@ __KERNEL_RCSID(0, "$NetBSD: grf.c,v 1.62 @@ -66,27 +66,26 @@ __KERNEL_RCSID(0, "$NetBSD: grf.c,v 1.62
66 66
67#include <machine/cpu.h> 67#include <machine/cpu.h>
68 68
69#include <dev/cons.h> 69#include <dev/cons.h>
70#include <dev/sun/fbio.h> 70#include <dev/sun/fbio.h>
71#include <dev/wscons/wsconsio.h> 71#include <dev/wscons/wsconsio.h>
72#include <dev/wscons/wsdisplayvar.h> 72#include <dev/wscons/wsdisplayvar.h>
73#include <dev/rasops/rasops.h> 73#include <dev/rasops/rasops.h>
74#include <dev/wscons/wsdisplay_vconsvar.h> 74#include <dev/wscons/wsdisplay_vconsvar.h>
75 75
76#include <amiga/amiga/color.h> /* DEBUG */ 76#include <amiga/amiga/color.h> /* DEBUG */
77#include <amiga/amiga/device.h> 77#include <amiga/amiga/device.h>
78#include <amiga/dev/grfioctl.h> 78#include <amiga/dev/grfioctl.h>
79#include <amiga/dev/grfws.h> 
80#include <amiga/dev/grfvar.h> 79#include <amiga/dev/grfvar.h>
81#include <amiga/dev/itevar.h> 80#include <amiga/dev/itevar.h>
82#include <amiga/dev/kbdvar.h> 81#include <amiga/dev/kbdvar.h>
83#include <amiga/dev/viewioctl.h> 82#include <amiga/dev/viewioctl.h>
84 83
85#include <sys/conf.h> 84#include <sys/conf.h>
86 85
87#if NGRF > 0 86#if NGRF > 0
88#include "ite.h" 87#include "ite.h"
89#if NITE == 0 88#if NITE == 0
90#define ite_on(u,f) 89#define ite_on(u,f)
91#define ite_off(u,f) 90#define ite_off(u,f)
92#define ite_reinit(d) 91#define ite_reinit(d)
@@ -172,55 +171,57 @@ grfattach(device_t parent, device_t self @@ -172,55 +171,57 @@ grfattach(device_t parent, device_t self
172{ 171{
173#if NWSDISPLAY > 0 172#if NWSDISPLAY > 0
174 struct wsemuldisplaydev_attach_args wa; 173 struct wsemuldisplaydev_attach_args wa;
175 long defattr; 174 long defattr;
176#endif 175#endif
177 struct grf_softc *gp; 176 struct grf_softc *gp;
178 int maj; 177 int maj;
179 178
180 gp = device_private(parent); 179 gp = device_private(parent);
181 gp->g_device = self; 180 gp->g_device = self;
182 grfsp[gp->g_unit] = gp; 181 grfsp[gp->g_unit] = gp;
183 182
184 /* 183 /*
185 * find our major device number 184 * find our major device number, make device
186 */ 185 */
187 maj = cdevsw_lookup_major(&grf_cdevsw); 186 maj = cdevsw_lookup_major(&grf_cdevsw);
188 
189 gp->g_grfdev = makedev(maj, gp->g_unit); 187 gp->g_grfdev = makedev(maj, gp->g_unit);
 188
190 if (self != NULL) { 189 if (self != NULL) {
191 printf(": width %d height %d", gp->g_display.gd_dwidth, 190 printf(": width %d height %d", gp->g_display.gd_dwidth,
192 gp->g_display.gd_dheight); 191 gp->g_display.gd_dheight);
193 if (gp->g_display.gd_colors == 2) 192 if (gp->g_display.gd_colors == 2)
194 printf(" monochrome\n"); 193 printf(" monochrome\n");
195 else 194 else
196 printf(" colors %d\n", gp->g_display.gd_colors); 195 printf(" colors %d\n", gp->g_display.gd_colors);
 196
197#if NWSDISPLAY > 0 197#if NWSDISPLAY > 0
198 vcons_init(&gp->g_vd, gp, gp->g_screens[0], gp->g_accessops); 198 vcons_init(&gp->g_vd, gp, gp->g_defaultscr, gp->g_accessops);
199 gp->g_vd.init_screen = grf_init_screen; 199 gp->g_vd.init_screen = grf_init_screen;
 200
200 if (gp->g_flags & GF_CONSOLE) { 201 if (gp->g_flags & GF_CONSOLE) {
201 console_vcons.scr_flags |= VCONS_SCREEN_IS_STATIC; 202 console_vcons.scr_flags |= VCONS_SCREEN_IS_STATIC;
202 vcons_init_screen(&gp->g_vd, 203 vcons_init_screen(&gp->g_vd,
203 &console_vcons, 1, &defattr); 204 &console_vcons, 1, &defattr);
204 gp->g_screens[0]->textops = 205 gp->g_defaultscr->textops =
205 &console_vcons.scr_ri.ri_ops; 206 &console_vcons.scr_ri.ri_ops;
206 wsdisplay_cnattach(gp->g_screens[0], 207 wsdisplay_cnattach(gp->g_defaultscr,
207 &console_vcons.scr_ri, 0, 0, defattr); 208 &console_vcons.scr_ri, 0, 0, defattr);
208 vcons_replay_msgbuf(&console_vcons); 209 vcons_replay_msgbuf(&console_vcons);
209 } 210 }
210 211
211 /* attach wsdisplay */ 212 /* attach wsdisplay */
212 wa.console = (gp->g_flags & GF_CONSOLE) != 0; 213 wa.console = (gp->g_flags & GF_CONSOLE) != 0;
213 wa.scrdata = &gp->g_screenlist; 214 wa.scrdata = gp->g_scrlist;
214 wa.accessops = gp->g_accessops; 215 wa.accessops = gp->g_accessops;
215 wa.accesscookie = &gp->g_vd; 216 wa.accesscookie = &gp->g_vd;
216 config_found(self, &wa, wsemuldisplaydevprint); 217 config_found(self, &wa, wsemuldisplaydevprint);
217#endif /* NWSDISPLAY > 0 */ 218#endif /* NWSDISPLAY > 0 */
218 } 219 }
219 220
220#if NWSDISPLAY == 0 221#if NWSDISPLAY == 0
221 /* 222 /*
222 * try and attach an ite 223 * try and attach an ite
223 */ 224 */
224 amiga_config_found(cfdata, self, gp, grfprint); 225 amiga_config_found(cfdata, self, gp, grfprint);
225#endif 226#endif
226} 227}
@@ -467,36 +468,37 @@ grfcnprobe(struct consdev *cd) @@ -467,36 +468,37 @@ grfcnprobe(struct consdev *cd)
467void 468void
468grfcninit(struct consdev *cd) 469grfcninit(struct consdev *cd)
469{ 470{
470 struct grf_softc *gp; 471 struct grf_softc *gp;
471 struct rasops_info *ri; 472 struct rasops_info *ri;
472 long defattr; 473 long defattr;
473 int unit; 474 int unit;
474 475
475 /* find console grf and set up wsdisplay for it */ 476 /* find console grf and set up wsdisplay for it */
476 for (unit = 1; unit < NGRF; unit++) { 477 for (unit = 1; unit < NGRF; unit++) {
477 gp = grfsp[unit]; 478 gp = grfsp[unit];
478 if (gp != NULL && (gp->g_flags & GF_ALIVE)) { 479 if (gp != NULL && (gp->g_flags & GF_ALIVE)) {
479 gp->g_flags |= GF_CONSOLE; /* we are console! */ 480 gp->g_flags |= GF_CONSOLE; /* we are console! */
480 gp->g_screens[0]->ncols = gp->g_display.gd_fbwidth / 481
481 gp->g_screens[0]->fontwidth; 482 gp->g_defaultscr->ncols = gp->g_display.gd_fbwidth /
482 gp->g_screens[0]->nrows = gp->g_display.gd_fbheight / 483 gp->g_defaultscr->fontwidth;
483 gp->g_screens[0]->fontheight; 484 gp->g_defaultscr->nrows = gp->g_display.gd_fbheight /
 485 gp->g_defaultscr->fontheight;
484 486
485 ri = grf_setup_rasops(gp, &console_vcons); 487 ri = grf_setup_rasops(gp, &console_vcons);
486 console_vcons.scr_cookie = gp; 488 console_vcons.scr_cookie = gp;
487 defattr = 0; /* XXX */ 489 defattr = 0; /* XXX */
488 490
489 wsdisplay_preattach(gp->g_screens[0], ri, 0, 0, 491 wsdisplay_preattach(gp->g_defaultscr, ri, 0, 0,
490 defattr); 492 defattr);
491#if NKBD > 0 493#if NKBD > 0
492 /* tell kbd device it is used as console keyboard */ 494 /* tell kbd device it is used as console keyboard */
493 kbd_cnattach(); 495 kbd_cnattach();
494#endif 496#endif
495 return; 497 return;
496 } 498 }
497 } 499 }
498 panic("grfcninit: lost console"); 500 panic("grfcninit: lost console");
499} 501}
500 502
501static void 503static void
502grf_init_screen(void *cookie, struct vcons_screen *scr, int existing, 504grf_init_screen(void *cookie, struct vcons_screen *scr, int existing,
@@ -509,45 +511,105 @@ grf_init_screen(void *cookie, struct vco @@ -509,45 +511,105 @@ grf_init_screen(void *cookie, struct vco
509 ri = grf_setup_rasops(gp, scr); 511 ri = grf_setup_rasops(gp, scr);
510} 512}
511 513
512static struct rasops_info * 514static struct rasops_info *
513grf_setup_rasops(struct grf_softc *gp, struct vcons_screen *scr) 515grf_setup_rasops(struct grf_softc *gp, struct vcons_screen *scr)
514{ 516{
515 struct rasops_info *ri; 517 struct rasops_info *ri;
516 int i; 518 int i;
517 519
518 ri = &scr->scr_ri; 520 ri = &scr->scr_ri;
519 scr->scr_flags |= VCONS_DONT_READ; 521 scr->scr_flags |= VCONS_DONT_READ;
520 memset(ri, 0, sizeof(struct rasops_info)); 522 memset(ri, 0, sizeof(struct rasops_info));
521 523
522 ri->ri_rows = gp->g_screens[0]->nrows; 524 ri->ri_rows = gp->g_defaultscr->nrows;
523 ri->ri_cols = gp->g_screens[0]->ncols; 525 ri->ri_cols = gp->g_defaultscr->ncols;
524 ri->ri_hw = scr; 526 ri->ri_hw = scr;
525 ri->ri_ops.cursor = gp->g_emulops->cursor; 527 ri->ri_ops.cursor = gp->g_emulops->cursor;
526 ri->ri_ops.mapchar = gp->g_emulops->mapchar; 528 ri->ri_ops.mapchar = gp->g_emulops->mapchar;
527 ri->ri_ops.copyrows = gp->g_emulops->copyrows; 529 ri->ri_ops.copyrows = gp->g_emulops->copyrows;
528 ri->ri_ops.eraserows = gp->g_emulops->eraserows; 530 ri->ri_ops.eraserows = gp->g_emulops->eraserows;
529 ri->ri_ops.copycols = gp->g_emulops->copycols; 531 ri->ri_ops.copycols = gp->g_emulops->copycols;
530 ri->ri_ops.erasecols = gp->g_emulops->erasecols; 532 ri->ri_ops.erasecols = gp->g_emulops->erasecols;
531 ri->ri_ops.putchar = gp->g_emulops->putchar; 533 ri->ri_ops.putchar = gp->g_emulops->putchar;
532 ri->ri_ops.allocattr = gp->g_emulops->allocattr; 534 ri->ri_ops.allocattr = gp->g_emulops->allocattr;
533 535
534 /* multiplication table for row-offsets */ 536 /* multiplication table for row-offsets */
535 for (i = 0; i < ri->ri_rows; i++) 537 for (i = 0; i < ri->ri_rows; i++)
536 gp->g_rowoffset[i] = i * ri->ri_cols; 538 gp->g_rowoffset[i] = i * ri->ri_cols;
537 539
538 return ri; 540 return ri;
539} 541}
540 542
 543/*
 544 * Called as fallback for ioctls which are not handled by the specific
 545 * grf driver.
 546 */
 547int
 548grf_wsioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
 549{
 550 struct wsdisplayio_fbinfo *iofbi;
 551 struct wsdisplay_fbinfo *fbinfo;
 552 struct vcons_data *vd;
 553 struct grf_softc *gp;
 554 struct vcons_screen *scr;
 555 struct grfinfo *gi;
 556
 557 vd = v;
 558 gp = vd->cookie;
 559 scr = vd->active;
 560
 561 switch (cmd) {
 562 case WSDISPLAYIO_GET_FBINFO:
 563 if (scr != NULL) {
 564 iofbi = data;
 565 return wsdisplayio_get_fbinfo(&scr->scr_ri, iofbi);
 566 }
 567 return ENODEV;
 568
 569 case WSDISPLAYIO_GINFO:
 570 if (scr != NULL) {
 571 fbinfo = (struct wsdisplay_fbinfo *)data;
 572 gi = &gp->g_display;
 573
 574 /*
 575 * We should return truth about the current mode here,
 576 * because X11 wsfb driver depends on this!
 577 */
 578 fbinfo->height = gi->gd_fbheight;
 579 fbinfo->width = gi->gd_fbwidth;
 580 fbinfo->depth = gi->gd_planes;
 581 fbinfo->cmsize = gi->gd_colors;
 582 return 0;
 583 }
 584 return ENODEV;
 585
 586 case WSDISPLAYIO_GTYPE:
 587 *(u_int *)data = WSDISPLAY_TYPE_GRF;
 588 return 0;
 589
 590 case WSDISPLAYIO_SMODE:
 591 if ((*(int *)data) != gp->g_wsmode) {
 592 gp->g_wsmode = *(int *)data;
 593 if (gp->g_wsmode == WSDISPLAYIO_MODE_EMUL &&
 594 scr != NULL)
 595 vcons_redraw_screen(scr);
 596 }
 597 return 0;
 598 }
 599
 600 return EPASSTHROUGH;
 601}
 602
541paddr_t 603paddr_t
542grf_wsmmap(void *v, void *vs, off_t off, int prot) 604grf_wsmmap(void *v, void *vs, off_t off, int prot)
543{ 605{
544 struct vcons_data *vd; 606 struct vcons_data *vd;
545 struct grf_softc *gp; 607 struct grf_softc *gp;
546 struct grfinfo *gi; 608 struct grfinfo *gi;
547 609
548 vd = v; 610 vd = v;
549 gp = vd->cookie; 611 gp = vd->cookie;
550 gi = &gp->g_display; 612 gi = &gp->g_display;
551 613
552 /* Normal fb mapping */ 614 /* Normal fb mapping */
553 if (off < gi->gd_fbsize) 615 if (off < gi->gd_fbsize)
@@ -572,246 +634,16 @@ grf_wsmmap(void *v, void *vs, off_t off, @@ -572,246 +634,16 @@ grf_wsmmap(void *v, void *vs, off_t off,
572 return -1; 634 return -1;
573} 635}
574 636
575static paddr_t 637static paddr_t
576grf_wsmmap_md(off_t off)  638grf_wsmmap_md(off_t off)
577{ 639{
578#if defined(__m68k__) 640#if defined(__m68k__)
579 return (paddr_t) m68k_btop(off); 641 return (paddr_t) m68k_btop(off);
580#else 642#else
581 return -1; /* FIXME */ 643 return -1; /* FIXME */
582#endif 644#endif
583} 645}
584 646
585int 
586grf_wsioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l) 
587{ 
588 struct vcons_data *vd; 
589 struct grf_softc *gp; 
590 
591 vd = v; 
592 gp = vd->cookie; 
593 
594 switch (cmd) { 
595 /* XXX: check if ptr to implementation is not null */ 
596 case WSDISPLAYIO_GINFO: 
597 return gp->g_wsioctl->ginfo(gp, data); 
598 case WSDISPLAYIO_SMODE: 
599 return gp->g_wsioctl->smode(gp, data); 
600 case WSDISPLAYIO_GMODE: 
601 return gp->g_wsioctl->gmode(gp, data); 
602 case WSDISPLAYIO_GTYPE: 
603 return gp->g_wsioctl->gtype(gp, data); 
604 case WSDISPLAYIO_SVIDEO: 
605 return gp->g_wsioctl->svideo(gp, data); 
606 case WSDISPLAYIO_GVIDEO: 
607 return gp->g_wsioctl->gvideo(gp, data); 
608 case WSDISPLAYIO_GETCMAP: 
609 return gp->g_wsioctl->getcmap(gp, data); 
610 case WSDISPLAYIO_PUTCMAP: 
611 return gp->g_wsioctl->putcmap(gp, data); 
612 } 
613 
614 return EPASSTHROUGH; 
615} 
616 
617/* wsdisplay_accessops ioctls */ 
618 
619int  
620grf_wsaogetcmap(void *c, void *data)  
621{ 
622 u_int index, count; 
623 struct grf_softc *gp; 
624 struct wsdisplay_cmap *cm __unused; 
625 
626 cm = (struct wsdisplay_cmap*) data; 
627 gp = c; 
628 index = 0; 
629 count = 0; 
630 
631 if (gp->g_wsmode == WSDISPLAYIO_MODE_EMUL) 
632 return EINVAL; 
633 
634 if (index >= 255 || count > 256 || index + count > 256) 
635 return EINVAL; 
636 
637 /*  
638 * TODO: copyout values for r, g, b. This function should be  
639 * driver-specific...  
640 */ 
641 
642 return 0; 
643} 
644 
645int 
646grf_wsaoputcmap(void *c, void *data) 
647{ 
648 /* 
649 * We probably couldn't care less about color map in MODE_EMUL, 
650 * I don't know about X11 yet. Also, these ioctls could be used by 
651 * fullscreen console programs (think wsdisplay picture viewer, or 
652 * the wsimgshow tool written by Yasushi Oshima). 
653 */ 
654 struct grf_softc *gp; 
655 
656 gp = c; 
657 
658 if (gp->g_wsmode == WSDISPLAYIO_MODE_EMUL) 
659 return EINVAL; 
660 /* ... */ 
661 
662 return 0; 
663} 
664 
665int 
666grf_wsaosvideo(void *c, void *data) 
667{ 
668#if 0 
669 struct grf_softc *gp; 
670 dev_t dev;  
671 int rv; 
672 
673 gp = c; 
674 dev = (dev_t) &gp->g_grfdev; 
675 
676 if (*(u_int *)data == WSDISPLAYIO_VIDEO_OFF) { 
677 if ((gp->g_flags & GF_GRFON) == 0) 
678 rv = 0; 
679 else { 
680 gp->g_flags &= ~GF_GRFON; 
681 rv = gp->g_mode(gp, (dev & GRFOVDEV) ?  
682 GM_GRFOVOFF : GM_GRFOFF, NULL, 0, 0); 
683 } 
684 
685 } else { 
686 if ((gp->g_flags & GF_GRFON)) 
687 rv = 0; 
688 else 
689 gp->g_flags |= GF_GRFON; 
690 rv = gp->g_mode(gp, (dev & GRFOVDEV) ?  
691 GM_GRFOVON : GM_GRFON, NULL, 0, 0); 
692 } 
693 
694 return rv; 
695#endif 
696 return 0; 
697} 
698 
699int 
700grf_wsaogvideo(void *c, void *data)  
701{ 
702 struct grf_softc *gp; 
703 
704 gp = c; 
705 
706 if(gp->g_flags & GF_GRFON)  
707 *(u_int *)data = WSDISPLAYIO_VIDEO_ON; 
708 else 
709 *(u_int *)data = WSDISPLAYIO_VIDEO_OFF; 
710 
711 return 0; 
712} 
713 
714int 
715grf_wsaogtype(void *c, void *data) 
716{ 
717 struct grf_softc *gp __unused; 
718 
719 gp = c; 
720 
721 *(u_int *)data = WSDISPLAY_TYPE_GRF; 
722 return 0; 
723} 
724 
725int 
726grf_wsaogmode(void *c, void *data) 
727{ 
728 struct grf_softc *gp; 
729 
730 gp = c; 
731 
732 *(u_int *)data = gp->g_wsmode; 
733 return 0; 
734} 
735 
736int 
737grf_wsaosmode(void *c, void *data) 
738{ 
739 /* XXX: should provide hw-dependent impl of this in grf_xxx driver? */ 
740 struct grf_softc *gp; 
741 
742 gp = c; 
743 
744 if ((*(int*) data) != gp->g_wsmode) { 
745 gp->g_wsmode = (*(int*) data); 
746 if ((*(int*) data) == WSDISPLAYIO_MODE_EMUL) { 
747 //vcons_redraw_screen( active vcons screen ); 
748 }  
749 } 
750 return 0; 
751} 
752 
753int 
754grf_wsaoginfo(void *c, void *data)  
755{ 
756 struct wsdisplay_fbinfo *fbinfo; 
757 struct grf_softc *gp; 
758 struct grfinfo *gi; 
759 
760 gp = c; 
761 
762 fbinfo = (struct wsdisplay_fbinfo *)data; 
763 gi = &gp->g_display; 
764 
765 /* 
766 * TODO: better sanity checking, it is possible that  
767 * wsdisplay is initialized, but no screen is opened 
768 * (for example, device is not used). 
769 */ 
770 
771 /* 
772 * We shold return truth about current mode here because 
773 * X11 wsfb driver denepds on this! 
774 */ 
775 fbinfo->height = gi->gd_fbheight; 
776 fbinfo->width = gi->gd_fbwidth; 
777 fbinfo->depth = gi->gd_planes; 
778 fbinfo->cmsize = gi->gd_colors; 
779 
780 return 0; 
781} 
782 
783#endif /* NWSDISPLAY > 0 */ 647#endif /* NWSDISPLAY > 0 */
784 648
785#ifdef DEBUG 
786void 
787grfdebug(struct grf_softc *gp, const char *fmt, ...) 
788{ 
789 static int ccol = 0, crow = 1; 
790 volatile char *cp; 
791 char buf[256]; 
792 va_list ap; 
793 int ncols; 
794 char *bp; 
795 
796 va_start(ap, fmt); 
797 vsnprintf(buf, 256, fmt, ap); 
798 va_end(ap); 
799 
800 cp = gp->g_fbkva; 
801 ncols = gp->g_display.gd_fbwidth / 8; 
802 cp += (crow * ncols + ccol) << 2; 
803 for (bp = buf; *bp != '\0'; bp++) { 
804 if (*bp == '\n') { 
805 ccol = 0; 
806 crow++; 
807 continue; 
808 } 
809 *cp++ = *bp; 
810 *cp = 0x0a; 
811 cp += 3; 
812 ccol++; 
813 } 
814} 
815#endif /* DEBUG */ 
816 
817#endif /* NGRF > 0 */ 649#endif /* NGRF > 0 */

cvs diff -r1.56 -r1.57 src/sys/arch/amiga/dev/grf_cv.c (expand / switch to unified diff)

--- src/sys/arch/amiga/dev/grf_cv.c 2014/01/22 00:25:16 1.56
+++ src/sys/arch/amiga/dev/grf_cv.c 2015/11/07 14:29:10 1.57
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: grf_cv.c,v 1.56 2014/01/22 00:25:16 christos Exp $ */ 1/* $NetBSD: grf_cv.c,v 1.57 2015/11/07 14:29:10 phx Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995 Michael Teske 4 * Copyright (c) 1995 Michael Teske
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33#include "opt_amigacons.h" 33#include "opt_amigacons.h"
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: grf_cv.c,v 1.56 2014/01/22 00:25:16 christos Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: grf_cv.c,v 1.57 2015/11/07 14:29:10 phx Exp $");
37 37
38#include "grfcv.h" 38#include "grfcv.h"
39#include "ite.h" 39#include "ite.h"
40#include "wsdisplay.h" 40#include "wsdisplay.h"
41#if NGRFCV > 0 41#if NGRFCV > 0
42 42
43/* 43/*
44 * Graphics routines for the CyberVision 64 board, using the S3 Trio64. 44 * Graphics routines for the CyberVision 64 board, using the S3 Trio64.
45 * 45 *
46 * Modified for CV64 from 46 * Modified for CV64 from
47 * Kari Mettinen's Cirrus driver by Michael Teske 10/95 47 * Kari Mettinen's Cirrus driver by Michael Teske 10/95
48 * 48 *
49 * Thanks to Tekelec Airtronic for providing me with a S3 Trio64 documentation. 49 * Thanks to Tekelec Airtronic for providing me with a S3 Trio64 documentation.
@@ -65,42 +65,42 @@ __KERNEL_RCSID(0, "$NetBSD: grf_cv.c,v 1 @@ -65,42 +65,42 @@ __KERNEL_RCSID(0, "$NetBSD: grf_cv.c,v 1
65 65
66#include <dev/cons.h> 66#include <dev/cons.h>
67#if NWSDISPLAY > 0 67#if NWSDISPLAY > 0
68#include <dev/wscons/wsconsio.h> 68#include <dev/wscons/wsconsio.h>
69#include <dev/wscons/wsdisplayvar.h> 69#include <dev/wscons/wsdisplayvar.h>
70#include <dev/rasops/rasops.h> 70#include <dev/rasops/rasops.h>
71#include <dev/wscons/wsdisplay_vconsvar.h> 71#include <dev/wscons/wsdisplay_vconsvar.h>
72#endif 72#endif
73 73
74#include <amiga/dev/itevar.h> 74#include <amiga/dev/itevar.h>
75#include <amiga/amiga/device.h> 75#include <amiga/amiga/device.h>
76#include <amiga/amiga/isr.h> 76#include <amiga/amiga/isr.h>
77#include <amiga/dev/grfioctl.h> 77#include <amiga/dev/grfioctl.h>
78#include <amiga/dev/grfws.h> 
79#include <amiga/dev/grfvar.h> 78#include <amiga/dev/grfvar.h>
80#include <amiga/dev/grf_cvreg.h> 79#include <amiga/dev/grf_cvreg.h>
81#include <amiga/dev/zbusvar.h> 80#include <amiga/dev/zbusvar.h>
82 81
83int grfcvmatch(device_t, cfdata_t, void *); 82int grfcvmatch(device_t, cfdata_t, void *);
84void grfcvattach(device_t, device_t, void *); 83void grfcvattach(device_t, device_t, void *);
85int grfcvprint(void *, const char *); 84int grfcvprint(void *, const char *);
86 85
87int cvintr(void *); 86int cvintr(void *);
88static int cv_has_4mb(volatile void *); 87static int cv_has_4mb(volatile void *);
89static unsigned short cv_compute_clock(unsigned long); 88static unsigned short cv_compute_clock(unsigned long);
90void cv_boardinit(struct grf_softc *); 89void cv_boardinit(struct grf_softc *);
91int cv_getvmode(struct grf_softc *, struct grfvideo_mode *); 90int cv_getvmode(struct grf_softc *, struct grfvideo_mode *);
92int cv_setvmode(struct grf_softc *, unsigned int); 91int cv_setvmode(struct grf_softc *, unsigned int);
93int cv_blank(struct grf_softc *, int *); 92int cv_blank(struct grf_softc *, int);
 93int cv_isblank(struct grf_softc *);
94int cv_mode(register struct grf_softc *, u_long, void *, u_long, int); 94int cv_mode(register struct grf_softc *, u_long, void *, u_long, int);
95int cv_ioctl(register struct grf_softc *gp, u_long cmd, void *data); 95int cv_ioctl(register struct grf_softc *gp, u_long cmd, void *data);
96int cv_setmonitor(struct grf_softc *, struct grfvideo_mode *); 96int cv_setmonitor(struct grf_softc *, struct grfvideo_mode *);
97int cv_getcmap(struct grf_softc *, struct grf_colormap *); 97int cv_getcmap(struct grf_softc *, struct grf_colormap *);
98int cv_putcmap(struct grf_softc *, struct grf_colormap *); 98int cv_putcmap(struct grf_softc *, struct grf_colormap *);
99int cv_toggle(struct grf_softc *); 99int cv_toggle(struct grf_softc *);
100int cv_mondefok(struct grfvideo_mode *); 100int cv_mondefok(struct grfvideo_mode *);
101int cv_load_mon(struct grf_softc *, struct grfcvtext_mode *); 101int cv_load_mon(struct grf_softc *, struct grfcvtext_mode *);
102void cv_inittextmode(struct grf_softc *); 102void cv_inittextmode(struct grf_softc *);
103static inline void cv_write_port(unsigned short, volatile void *); 103static inline void cv_write_port(unsigned short, volatile void *);
104static inline void cvscreen(int, volatile void *); 104static inline void cvscreen(int, volatile void *);
105static inline void gfx_on_off(int, volatile void *); 105static inline void gfx_on_off(int, volatile void *);
106 106
@@ -260,70 +260,69 @@ static int cv_fbsize; @@ -260,70 +260,69 @@ static int cv_fbsize;
260 * if you set this flag. Again: This flag may destroy your CV Board. 260 * if you set this flag. Again: This flag may destroy your CV Board.
261 * Use it at your own risk!!! 261 * Use it at your own risk!!!
262 * Anyway, this doesn't imply that I'm responsible if your board breaks 262 * Anyway, this doesn't imply that I'm responsible if your board breaks
263 * without setting this flag :-). 263 * without setting this flag :-).
264 */ 264 */
265#ifdef CV_AGGRESSIVE_TIMING 265#ifdef CV_AGGRESSIVE_TIMING
266long cv_memclk = 55000000; 266long cv_memclk = 55000000;
267#else 267#else
268long cv_memclk = 50000000; 268long cv_memclk = 50000000;
269#endif 269#endif
270 270
271#if NWSDISPLAY > 0 271#if NWSDISPLAY > 0
272/* wsdisplay acessops, emulops */ 272/* wsdisplay acessops, emulops */
 273static int cv_wsioctl(void *, void *, u_long, void *, int, struct lwp *);
 274
273static void cv_wscursor(void *, int, int, int); 275static void cv_wscursor(void *, int, int, int);
274static void cv_wsputchar(void *, int, int, u_int, long); 276static void cv_wsputchar(void *, int, int, u_int, long);
275static void cv_wscopycols(void *, int, int, int, int); 277static void cv_wscopycols(void *, int, int, int, int);
276static void cv_wserasecols(void *, int, int, int, long); 278static void cv_wserasecols(void *, int, int, int, long);
277static void cv_wscopyrows(void *, int, int, int); 279static void cv_wscopyrows(void *, int, int, int);
278static void cv_wseraserows(void *, int, int, long); 280static void cv_wseraserows(void *, int, int, long);
279static int cv_wsallocattr(void *, int, int, int, long *); 281static int cv_wsallocattr(void *, int, int, int, long *);
280static int cv_wsmapchar(void *, int, unsigned int *); 282static int cv_wsmapchar(void *, int, unsigned int *);
281 283
282static struct wsdisplay_accessops cv_accessops = { 284static struct wsdisplay_accessops cv_accessops = {
283 .ioctl = grf_wsioctl, 285 .ioctl = cv_wsioctl,
284 .mmap = grf_wsmmap 286 .mmap = grf_wsmmap
285}; 287};
286 288
287static struct wsdisplay_emulops cv_textops = { 289static struct wsdisplay_emulops cv_textops = {
288 .cursor = cv_wscursor, 290 .cursor = cv_wscursor,
289 .mapchar = cv_wsmapchar, 291 .mapchar = cv_wsmapchar,
290 .putchar = cv_wsputchar, 292 .putchar = cv_wsputchar,
291 .copycols = cv_wscopycols, 293 .copycols = cv_wscopycols,
292 .erasecols = cv_wserasecols, 294 .erasecols = cv_wserasecols,
293 .copyrows = cv_wscopyrows, 295 .copyrows = cv_wscopyrows,
294 .eraserows = cv_wseraserows, 296 .eraserows = cv_wseraserows,
295 .allocattr = cv_wsallocattr 297 .allocattr = cv_wsallocattr
296}; 298};
297 299
298static struct ws_ao_ioctl cv_wsioctl = { 300static struct wsscreen_descr cv_defaultscreen = {
299 grf_wsaoginfo, 
300 grf_wsaogetcmap, 
301 grf_wsaoputcmap, 
302 grf_wsaogvideo, 
303 grf_wsaosvideo, 
304 grf_wsaogmode, 
305 grf_wsaosmode, 
306 grf_wsaogtype 
307}; 
308 
309static struct wsscreen_descr cv_screen = { 
310 .name = "default", 301 .name = "default",
311 .textops = &cv_textops, 302 .textops = &cv_textops,
312 .fontwidth = 8, 303 .fontwidth = 8,
313 .fontheight = S3FONTY, 304 .fontheight = S3FONTY,
314 .capabilities = WSSCREEN_HILIT | WSSCREEN_BLINK | 305 .capabilities = WSSCREEN_HILIT | WSSCREEN_BLINK |
315 WSSCREEN_REVERSE | WSSCREEN_UNDERLINE 306 WSSCREEN_REVERSE | WSSCREEN_UNDERLINE
316}; 307};
 308
 309static const struct wsscreen_descr *cv_screens[] = {
 310 &cv_defaultscreen,
 311};
 312
 313static struct wsscreen_list cv_screenlist = {
 314 sizeof(cv_screens) / sizeof(struct wsscreen_descr *), cv_screens
 315};
317#endif /* NWSDISPLAY > 0 */ 316#endif /* NWSDISPLAY > 0 */
318 317
319/* standard driver stuff */ 318/* standard driver stuff */
320CFATTACH_DECL_NEW(grfcv, sizeof(struct grf_cv_softc), 319CFATTACH_DECL_NEW(grfcv, sizeof(struct grf_cv_softc),
321 grfcvmatch, grfcvattach, NULL, NULL); 320 grfcvmatch, grfcvattach, NULL, NULL);
322 321
323static struct cfdata *cfdata; 322static struct cfdata *cfdata;
324 323
325#define CV_INT_NUM 6 /* CV interrupt Level: #2 or #6 */ 324#define CV_INT_NUM 6 /* CV interrupt Level: #2 or #6 */
326#define CV_ULCURSOR 1 /* Underlined Cursor in textmode */ 325#define CV_ULCURSOR 1 /* Underlined Cursor in textmode */
327 326
328#ifndef CV_NO_HARDWARE_CURSOR 327#ifndef CV_NO_HARDWARE_CURSOR
329 328
@@ -530,29 +529,28 @@ grfcvattach(device_t parent, device_t se @@ -530,29 +529,28 @@ grfcvattach(device_t parent, device_t se
530 /* add Interrupt Handler */ 529 /* add Interrupt Handler */
531 gcp->gcs_isr.isr_ipl = CV_INT_NUM; 530 gcp->gcs_isr.isr_ipl = CV_INT_NUM;
532 gcp->gcs_isr.isr_intr = cvintr; 531 gcp->gcs_isr.isr_intr = cvintr;
533 gcp->gcs_isr.isr_arg = (void *)gp; 532 gcp->gcs_isr.isr_arg = (void *)gp;
534 add_isr(&gcp->gcs_isr); 533 add_isr(&gcp->gcs_isr);
535 534
536 /* wakeup the board */ 535 /* wakeup the board */
537 cv_boardinit(gp); 536 cv_boardinit(gp);
538 537
539#ifdef CV64CONSOLE 538#ifdef CV64CONSOLE
540#if NWSDISPLAY > 0 539#if NWSDISPLAY > 0
541 gp->g_accessops = &cv_accessops; 540 gp->g_accessops = &cv_accessops;
542 gp->g_emulops = &cv_textops; 541 gp->g_emulops = &cv_textops;
543 gp->g_defaultscreen = cv_screen; 542 gp->g_defaultscr = &cv_defaultscreen;
544 gp->g_screens[0] = &gp->g_defaultscreen; 543 gp->g_scrlist = &cv_screenlist;
545 gp->g_wsioctl = &cv_wsioctl; 
546#else 544#else
547 grfcv_iteinit(gp); 545 grfcv_iteinit(gp);
548#endif 546#endif
549 (void)cv_load_mon(gp, &cvconsole_mode); 547 (void)cv_load_mon(gp, &cvconsole_mode);
550#endif 548#endif
551 } 549 }
552 550
553 /* 551 /*
554 * attach grf 552 * attach grf
555 */ 553 */
556 if (amiga_config_found(cfdata, gp->g_device, gp, grfcvprint)) { 554 if (amiga_config_found(cfdata, gp->g_device, gp, grfcvprint)) {
557 if (self != NULL) 555 if (self != NULL)
558 printf("grfcv: CyberVision64 with %dMB being used\n", 556 printf("grfcv: CyberVision64 with %dMB being used\n",
@@ -936,36 +934,48 @@ cv_setvmode(struct grf_softc *gp, unsign @@ -936,36 +934,48 @@ cv_setvmode(struct grf_softc *gp, unsign
936{ 934{
937 935
938 if (!mode || (mode > monitor_def_max) || 936 if (!mode || (mode > monitor_def_max) ||
939 monitor_def[mode - 1].mode_num == 0) 937 monitor_def[mode - 1].mode_num == 0)
940 return (EINVAL); 938 return (EINVAL);
941 939
942 monitor_current = monitor_def + (mode - 1); 940 monitor_current = monitor_def + (mode - 1);
943 941
944 return (0); 942 return (0);
945} 943}
946 944
947 945
948int 946int
949cv_blank(struct grf_softc *gp, int *on) 947cv_blank(struct grf_softc *gp, int on)
950{ 948{
951 volatile void *ba; 949 volatile void *ba;
952 950
953 ba = gp->g_regkva; 951 ba = gp->g_regkva;
954 gfx_on_off(*on > 0 ? 0 : 1, ba); 952 gfx_on_off(on > 0 ? 0 : 1, ba);
955 return (0); 953 return (0);
956} 954}
957 955
958 956
 957int
 958cv_isblank(struct grf_softc *gp)
 959{
 960 volatile void *ba;
 961 int r;
 962
 963 ba = gp->g_regkva;
 964 r = RSeq(ba, SEQ_ID_CLOCKING_MODE);
 965 return (r & 0x20) != 0;
 966}
 967
 968
959/* 969/*
960 * Change the mode of the display. 970 * Change the mode of the display.
961 * Return a UNIX error number or 0 for success. 971 * Return a UNIX error number or 0 for success.
962 */ 972 */
963int 973int
964cv_mode(register struct grf_softc *gp, u_long cmd, void *arg, u_long a2, 974cv_mode(register struct grf_softc *gp, u_long cmd, void *arg, u_long a2,
965 int a3) 975 int a3)
966{ 976{
967 int error; 977 int error;
968 978
969 switch (cmd) { 979 switch (cmd) {
970 case GM_GRFON: 980 case GM_GRFON:
971 error = cv_load_mon (gp, 981 error = cv_load_mon (gp,
@@ -1045,27 +1055,27 @@ cv_ioctl(register struct grf_softc *gp,  @@ -1045,27 +1055,27 @@ cv_ioctl(register struct grf_softc *gp,
1045 case GRFIOCPUTCMAP: 1055 case GRFIOCPUTCMAP:
1046 return (cv_putcmap (gp, (struct grf_colormap *) data)); 1056 return (cv_putcmap (gp, (struct grf_colormap *) data));
1047 1057
1048 case GRFIOCBITBLT: 1058 case GRFIOCBITBLT:
1049 break; 1059 break;
1050 1060
1051 case GRFTOGGLE: 1061 case GRFTOGGLE:
1052 return (cv_toggle (gp)); 1062 return (cv_toggle (gp));
1053 1063
1054 case GRFIOCSETMON: 1064 case GRFIOCSETMON:
1055 return (cv_setmonitor (gp, (struct grfvideo_mode *)data)); 1065 return (cv_setmonitor (gp, (struct grfvideo_mode *)data));
1056 1066
1057 case GRFIOCBLANK: 1067 case GRFIOCBLANK:
1058 return (cv_blank (gp, (int *)data)); 1068 return (cv_blank (gp, *(int *)data));
1059 } 1069 }
1060 return (EPASSTHROUGH); 1070 return (EPASSTHROUGH);
1061} 1071}
1062 1072
1063 1073
1064int 1074int
1065cv_setmonitor(struct grf_softc *gp, struct grfvideo_mode *gv) 1075cv_setmonitor(struct grf_softc *gp, struct grfvideo_mode *gv)
1066{ 1076{
1067 struct grfvideo_mode *md; 1077 struct grfvideo_mode *md;
1068 1078
1069 if (!cv_mondefok(gv)) 1079 if (!cv_mondefok(gv))
1070 return (EINVAL); 1080 return (EINVAL);
1071 1081
@@ -2434,16 +2444,53 @@ cv_wsallocattr(void *c, int fg, int bg,  @@ -2434,16 +2444,53 @@ cv_wsallocattr(void *c, int fg, int bg,
2434/* our font does not support unicode extensions */ 2444/* our font does not support unicode extensions */
2435static int  2445static int
2436cv_wsmapchar(void *c, int ch, unsigned int *cp) 2446cv_wsmapchar(void *c, int ch, unsigned int *cp)
2437{ 2447{
2438 2448
2439 if (ch > 0 && ch < 256) { 2449 if (ch > 0 && ch < 256) {
2440 *cp = ch; 2450 *cp = ch;
2441 return 5; 2451 return 5;
2442 } 2452 }
2443 *cp = ' '; 2453 *cp = ' ';
2444 return 0; 2454 return 0;
2445} 2455}
2446 2456
 2457static int
 2458cv_wsioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
 2459{
 2460 struct vcons_data *vd;
 2461 struct grf_softc *gp;
 2462
 2463 vd = v;
 2464 gp = vd->cookie;
 2465
 2466 switch (cmd) {
 2467 case WSDISPLAYIO_GETCMAP:
 2468 /* Note: wsdisplay_cmap and grf_colormap have same format */
 2469 if (gp->g_display.gd_planes == 8)
 2470 return cv_getcmap(gp, (struct grf_colormap *)data);
 2471 return EINVAL;
 2472
 2473 case WSDISPLAYIO_PUTCMAP:
 2474 /* Note: wsdisplay_cmap and grf_colormap have same format */
 2475 if (gp->g_display.gd_planes == 8)
 2476 return cv_putcmap(gp, (struct grf_colormap *)data);
 2477 return EINVAL;
 2478
 2479 case WSDISPLAYIO_GVIDEO:
 2480 if (cv_isblank(gp))
 2481 *(u_int *)data = WSDISPLAYIO_VIDEO_OFF;
 2482 else
 2483 *(u_int *)data = WSDISPLAYIO_VIDEO_ON;
 2484 return 0;
 2485
 2486 case WSDISPLAYIO_SVIDEO:
 2487 return cv_blank(gp, *(u_int *)data == WSDISPLAYIO_VIDEO_OFF);
 2488 }
 2489
 2490 /* handle this command hw-independant in grf(4) */
 2491 return grf_wsioctl(v, vs, cmd, data, flag, l);
 2492}
 2493
2447#endif /* NWSDISPLAY > 0 */ 2494#endif /* NWSDISPLAY > 0 */
2448 2495
2449#endif /* NGRFCV */ 2496#endif /* NGRFCV */

cvs diff -r1.30 -r1.31 src/sys/arch/amiga/dev/grf_cv3d.c (expand / switch to unified diff)

--- src/sys/arch/amiga/dev/grf_cv3d.c 2014/01/22 00:25:16 1.30
+++ src/sys/arch/amiga/dev/grf_cv3d.c 2015/11/07 14:29:10 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: grf_cv3d.c,v 1.30 2014/01/22 00:25:16 christos Exp $ */ 1/* $NetBSD: grf_cv3d.c,v 1.31 2015/11/07 14:29:10 phx Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995 Michael Teske 4 * Copyright (c) 1995 Michael Teske
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33#include "opt_amigacons.h" 33#include "opt_amigacons.h"
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: grf_cv3d.c,v 1.30 2014/01/22 00:25:16 christos Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: grf_cv3d.c,v 1.31 2015/11/07 14:29:10 phx Exp $");
37 37
38#include "ite.h" 38#include "ite.h"
39#include "wsdisplay.h" 39#include "wsdisplay.h"
40#include "grfcv3d.h" 40#include "grfcv3d.h"
41#if NGRFCV3D > 0 41#if NGRFCV3D > 0
42 42
43/* 43/*
44 * Graphics routines for the CyberVision 64/3D board, using the S3 ViRGE. 44 * Graphics routines for the CyberVision 64/3D board, using the S3 ViRGE.
45 * 45 *
46 * Modified for CV64/3D from Michael Teske's CV driver by Tobias Abt 10/97. 46 * Modified for CV64/3D from Michael Teske's CV driver by Tobias Abt 10/97.
47 * Bugfixes by Bernd Ernesti 10/97. 47 * Bugfixes by Bernd Ernesti 10/97.
48 * Many thanks to Richard Hartmann who gave us his board so we could make 48 * Many thanks to Richard Hartmann who gave us his board so we could make
49 * driver. 49 * driver.
@@ -89,51 +89,51 @@ Note: IO Regbase is needed fo wakeup of  @@ -89,51 +89,51 @@ Note: IO Regbase is needed fo wakeup of
89#include <dev/cons.h> 89#include <dev/cons.h>
90 90
91#if NWSDISPLAY > 0  91#if NWSDISPLAY > 0
92#include <dev/wscons/wsdisplayvar.h> 92#include <dev/wscons/wsdisplayvar.h>
93#include <dev/wscons/wsconsio.h> 93#include <dev/wscons/wsconsio.h>
94#include <dev/wsfont/wsfont.h> 94#include <dev/wsfont/wsfont.h>
95#include <dev/rasops/rasops.h> 95#include <dev/rasops/rasops.h>
96#include <dev/wscons/wsdisplay_vconsvar.h> 96#include <dev/wscons/wsdisplay_vconsvar.h>
97#endif 97#endif
98 98
99#include <amiga/dev/itevar.h> 99#include <amiga/dev/itevar.h>
100#include <amiga/amiga/device.h> 100#include <amiga/amiga/device.h>
101#include <amiga/dev/grfioctl.h> 101#include <amiga/dev/grfioctl.h>
102#include <amiga/dev/grfws.h> 
103#include <amiga/dev/grfvar.h> 102#include <amiga/dev/grfvar.h>
104#include <amiga/dev/grf_cv3dreg.h> 103#include <amiga/dev/grf_cv3dreg.h>
105#include <amiga/dev/zbusvar.h> 104#include <amiga/dev/zbusvar.h>
106 105
107 106
108/* 107/*
109 * finish all bus operations, flush pipelines 108 * finish all bus operations, flush pipelines
110 */ 109 */
111#if defined(__m68k__) 110#if defined(__m68k__)
112#define cpu_sync() __asm volatile ("nop") 111#define cpu_sync() __asm volatile ("nop")
113#elif defined(__powerpc__) 112#elif defined(__powerpc__)
114#define cpu_sync() __asm volatile ("sync; isync") 113#define cpu_sync() __asm volatile ("sync; isync")
115#endif 114#endif
116 115
117int grfcv3dmatch(device_t, cfdata_t, void *); 116int grfcv3dmatch(device_t, cfdata_t, void *);
118void grfcv3dattach(device_t, device_t, void *); 117void grfcv3dattach(device_t, device_t, void *);
119int grfcv3dprint(void *, const char *); 118int grfcv3dprint(void *, const char *);
120 119
121static int cv3d_has_4mb(volatile void *); 120static int cv3d_has_4mb(volatile void *);
122static unsigned short cv3d_compute_clock(unsigned long); 121static unsigned short cv3d_compute_clock(unsigned long);
123void cv3d_boardinit(struct grf_softc *); 122void cv3d_boardinit(struct grf_softc *);
124int cv3d_getvmode(struct grf_softc *, struct grfvideo_mode *); 123int cv3d_getvmode(struct grf_softc *, struct grfvideo_mode *);
125int cv3d_setvmode(struct grf_softc *, unsigned int); 124int cv3d_setvmode(struct grf_softc *, unsigned int);
126int cv3d_blank(struct grf_softc *, int *); 125int cv3d_blank(struct grf_softc *, int);
 126int cv3d_isblank(struct grf_softc *);
127int cv3d_mode(register struct grf_softc *, u_long, void *, u_long, int); 127int cv3d_mode(register struct grf_softc *, u_long, void *, u_long, int);
128int cv3d_ioctl(register struct grf_softc *gp, u_long cmd, void *data); 128int cv3d_ioctl(register struct grf_softc *gp, u_long cmd, void *data);
129int cv3d_setmonitor(struct grf_softc *, struct grfvideo_mode *); 129int cv3d_setmonitor(struct grf_softc *, struct grfvideo_mode *);
130int cv3d_getcmap(struct grf_softc *, struct grf_colormap *); 130int cv3d_getcmap(struct grf_softc *, struct grf_colormap *);
131int cv3d_putcmap(struct grf_softc *, struct grf_colormap *); 131int cv3d_putcmap(struct grf_softc *, struct grf_colormap *);
132int cv3d_toggle(struct grf_softc *); 132int cv3d_toggle(struct grf_softc *);
133int cv3d_mondefok(struct grfvideo_mode *); 133int cv3d_mondefok(struct grfvideo_mode *);
134int cv3d_load_mon(struct grf_softc *, struct grfcv3dtext_mode *); 134int cv3d_load_mon(struct grf_softc *, struct grfcv3dtext_mode *);
135void cv3d_inittextmode(struct grf_softc *); 135void cv3d_inittextmode(struct grf_softc *);
136static inline void cv3dscreen(int, volatile void *); 136static inline void cv3dscreen(int, volatile void *);
137static inline void cv3d_gfx_on_off(int, volatile void *); 137static inline void cv3d_gfx_on_off(int, volatile void *);
138 138
139#ifdef CV3D_HARDWARE_CURSOR 139#ifdef CV3D_HARDWARE_CURSOR
@@ -280,69 +280,68 @@ static int cv3d_fbsize; @@ -280,69 +280,68 @@ static int cv3d_fbsize;
280 280
281static volatile void *cv3d_memory_io_base; 281static volatile void *cv3d_memory_io_base;
282static volatile void *cv3d_register_base; 282static volatile void *cv3d_register_base;
283static volatile void *cv3d_vcode_switch_base; 283static volatile void *cv3d_vcode_switch_base;
284static volatile void *cv3d_special_register_base; 284static volatile void *cv3d_special_register_base;
285 285
286/* 286/*
287 * Memory clock (binpatchable). 287 * Memory clock (binpatchable).
288 */ 288 */
289long cv3d_memclk = 55000000; 289long cv3d_memclk = 55000000;
290 290
291#if NWSDISPLAY > 0  291#if NWSDISPLAY > 0
292/* wsdisplay accessops, emulops */ 292/* wsdisplay accessops, emulops */
 293static int cv3d_wsioctl(void *, void *, u_long, void *, int, struct lwp *);
 294
293static void cv3d_wscursor(void *, int, int, int); 295static void cv3d_wscursor(void *, int, int, int);
294static void cv3d_wsputchar(void *, int, int, u_int, long); 296static void cv3d_wsputchar(void *, int, int, u_int, long);
295static void cv3d_wscopycols(void *, int, int, int, int); 297static void cv3d_wscopycols(void *, int, int, int, int);
296static void cv3d_wserasecols(void *, int, int, int, long); 298static void cv3d_wserasecols(void *, int, int, int, long);
297static void cv3d_wscopyrows(void *, int, int, int); 299static void cv3d_wscopyrows(void *, int, int, int);
298static void cv3d_wseraserows(void *, int, int, long); 300static void cv3d_wseraserows(void *, int, int, long);
299static int cv3d_wsallocattr(void *, int, int, int, long *); 301static int cv3d_wsallocattr(void *, int, int, int, long *);
300static int cv3d_wsmapchar(void *, int, unsigned int *); 302static int cv3d_wsmapchar(void *, int, unsigned int *);
301 303
302struct wsdisplay_accessops cv3d_accessops = { 304struct wsdisplay_accessops cv3d_accessops = {
303 .ioctl = grf_wsioctl, 305 .ioctl = cv3d_wsioctl,
304 .mmap = grf_wsmmap 306 .mmap = grf_wsmmap
305}; 307};
306 308
307static struct wsdisplay_emulops cv3d_textops = { 309static struct wsdisplay_emulops cv3d_textops = {
308 .cursor = cv3d_wscursor, 310 .cursor = cv3d_wscursor,
309 .mapchar = cv3d_wsmapchar,  311 .mapchar = cv3d_wsmapchar,
310 .putchar = cv3d_wsputchar, 312 .putchar = cv3d_wsputchar,
311 .copycols = cv3d_wscopycols, 313 .copycols = cv3d_wscopycols,
312 .copyrows = cv3d_wscopyrows, 314 .copyrows = cv3d_wscopyrows,
313 .erasecols = cv3d_wserasecols, 315 .erasecols = cv3d_wserasecols,
314 .eraserows = cv3d_wseraserows, 316 .eraserows = cv3d_wseraserows,
315 .allocattr = cv3d_wsallocattr 317 .allocattr = cv3d_wsallocattr
316}; 318};
317 319
318static struct ws_ao_ioctl cv3d_wsioctl = { 320static struct wsscreen_descr cv3d_defaultscreen = {
319 grf_wsaoginfo, 
320 grf_wsaogetcmap, 
321 grf_wsaoputcmap, 
322 grf_wsaogvideo, 
323 grf_wsaosvideo, 
324 grf_wsaogmode, 
325 grf_wsaosmode, 
326 grf_wsaogtype 
327}; 
328 
329static struct wsscreen_descr cv3d_screen = { 
330 .name = "default", 321 .name = "default",
331 .textops = &cv3d_textops, 322 .textops = &cv3d_textops,
332 .fontwidth = 8, 323 .fontwidth = 8,
333 .fontheight = S3FONTY, 324 .fontheight = S3FONTY,
334 .capabilities = WSSCREEN_HILIT | WSSCREEN_REVERSE | 325 .capabilities = WSSCREEN_HILIT | WSSCREEN_BLINK |
335 WSSCREEN_BLINK | WSSCREEN_UNDERLINE 326 WSSCREEN_REVERSE | WSSCREEN_UNDERLINE
 327};
 328
 329static const struct wsscreen_descr *cv3d_screens[] = {
 330 &cv3d_defaultscreen,
 331};
 332
 333static struct wsscreen_list cv3d_screenlist = {
 334 sizeof(cv3d_screens) / sizeof(struct wsscreen_descr *), cv3d_screens
336}; 335};
337#endif /* NWSDISPLAY > 0 */ 336#endif /* NWSDISPLAY > 0 */
338 337
339/* standard driver stuff */ 338/* standard driver stuff */
340CFATTACH_DECL_NEW(grfcv3d, sizeof(struct grf_softc), 339CFATTACH_DECL_NEW(grfcv3d, sizeof(struct grf_softc),
341 grfcv3dmatch, grfcv3dattach, NULL, NULL); 340 grfcv3dmatch, grfcv3dattach, NULL, NULL);
342 341
343static struct cfdata *cfdata; 342static struct cfdata *cfdata;
344 343
345#define CV3D_ULCURSOR 1 /* Underlined Cursor in textmode */ 344#define CV3D_ULCURSOR 1 /* Underlined Cursor in textmode */
346 345
347/* 346/*
348 * Get frambuffer memory size. 347 * Get frambuffer memory size.
@@ -477,32 +476,31 @@ grfcv3dattach(device_t parent, device_t  @@ -477,32 +476,31 @@ grfcv3dattach(device_t parent, device_t
477 gp->g_regkva = (volatile void *)cv3d_register_base; 476 gp->g_regkva = (volatile void *)cv3d_register_base;
478 477
479 gp->g_unit = GRF_CV3D_UNIT; 478 gp->g_unit = GRF_CV3D_UNIT;
480 gp->g_mode = cv3d_mode; 479 gp->g_mode = cv3d_mode;
481#if NITE > 0 480#if NITE > 0
482 gp->g_conpri = grfcv3d_cnprobe(); 481 gp->g_conpri = grfcv3d_cnprobe();
483#endif  482#endif
484 gp->g_flags = GF_ALIVE; 483 gp->g_flags = GF_ALIVE;
485 484
486 /* wakeup the board */ 485 /* wakeup the board */
487 cv3d_boardinit(gp); 486 cv3d_boardinit(gp);
488 487
489#ifdef CV3DCONSOLE 488#ifdef CV3DCONSOLE
490#if NWSDISPLAY > 0  489#if NWSDISPLAY > 0
491 gp->g_accessops = &cv3d_accessops; 490 gp->g_accessops = &cv3d_accessops;
492 gp->g_emulops = &cv3d_textops; 491 gp->g_emulops = &cv3d_textops;
493 gp->g_defaultscreen = cv3d_screen; 492 gp->g_defaultscr = &cv3d_defaultscreen;
494 gp->g_screens[0] = &gp->g_defaultscreen;  493 gp->g_scrlist = &cv3d_screenlist;
495 gp->g_wsioctl = &cv3d_wsioctl; 
496#else 494#else
497 grfcv3d_iteinit(gp); 495 grfcv3d_iteinit(gp);
498#endif /* NWSDISPLAY > 0 */ 496#endif /* NWSDISPLAY > 0 */
499 (void)cv3d_load_mon(gp, &cv3dconsole_mode);  497 (void)cv3d_load_mon(gp, &cv3dconsole_mode);
500#endif 498#endif
501 } 499 }
502 500
503 /* 501 /*
504 * attach grf 502 * attach grf
505 */ 503 */
506 if (amiga_config_found(cfdata, gp->g_device, gp, grfcv3dprint)) { 504 if (amiga_config_found(cfdata, gp->g_device, gp, grfcv3dprint)) {
507 if (self != NULL) 505 if (self != NULL)
508 printf("%s: CyberVision64/3D with %dMB being used\n", 506 printf("%s: CyberVision64/3D with %dMB being used\n",
@@ -857,36 +855,48 @@ cv3d_setvmode(struct grf_softc *gp, unsi @@ -857,36 +855,48 @@ cv3d_setvmode(struct grf_softc *gp, unsi
857{ 855{
858 856
859 if (!mode || (mode > monitor_def_max) || 857 if (!mode || (mode > monitor_def_max) ||
860 monitor_def[mode - 1].mode_num == 0) 858 monitor_def[mode - 1].mode_num == 0)
861 return (EINVAL); 859 return (EINVAL);
862 860
863 monitor_current = monitor_def + (mode - 1); 861 monitor_current = monitor_def + (mode - 1);
864 862
865 return (0); 863 return (0);
866} 864}
867 865
868 866
869int 867int
870cv3d_blank(struct grf_softc *gp, int *on) 868cv3d_blank(struct grf_softc *gp, int on)
871{ 869{
872 volatile void *ba; 870 volatile void *ba;
873 871
874 ba = gp->g_regkva; 872 ba = gp->g_regkva;
875 cv3d_gfx_on_off(*on > 0 ? 0 : 1, ba); 873 cv3d_gfx_on_off(on > 0 ? 0 : 1, ba);
876 return (0); 874 return (0);
877} 875}
878 876
879 877
 878int
 879cv3d_isblank(struct grf_softc *gp)
 880{
 881 volatile void *ba;
 882 int r;
 883
 884 ba = gp->g_regkva;
 885 r = RSeq(ba, SEQ_ID_CLOCKING_MODE);
 886 return (r & 0x20) != 0;
 887}
 888
 889
880/* 890/*
881 * Change the mode of the display. 891 * Change the mode of the display.
882 * Return a UNIX error number or 0 for success. 892 * Return a UNIX error number or 0 for success.
883 */ 893 */
884int 894int
885cv3d_mode(register struct grf_softc *gp, u_long cmd, void *arg, u_long a2, 895cv3d_mode(register struct grf_softc *gp, u_long cmd, void *arg, u_long a2,
886 int a3) 896 int a3)
887{ 897{
888 int error; 898 int error;
889 899
890 switch (cmd) { 900 switch (cmd) {
891 case GM_GRFON: 901 case GM_GRFON:
892 error = cv3d_load_mon (gp, 902 error = cv3d_load_mon (gp,
@@ -966,27 +976,27 @@ cv3d_ioctl(register struct grf_softc *gp @@ -966,27 +976,27 @@ cv3d_ioctl(register struct grf_softc *gp
966 case GRFIOCPUTCMAP: 976 case GRFIOCPUTCMAP:
967 return (cv3d_putcmap (gp, (struct grf_colormap *) data)); 977 return (cv3d_putcmap (gp, (struct grf_colormap *) data));
968 978
969 case GRFIOCBITBLT: 979 case GRFIOCBITBLT:
970 break; 980 break;
971 981
972 case GRFTOGGLE: 982 case GRFTOGGLE:
973 return (cv3d_toggle (gp)); 983 return (cv3d_toggle (gp));
974 984
975 case GRFIOCSETMON: 985 case GRFIOCSETMON:
976 return (cv3d_setmonitor (gp, (struct grfvideo_mode *)data)); 986 return (cv3d_setmonitor (gp, (struct grfvideo_mode *)data));
977 987
978 case GRFIOCBLANK: 988 case GRFIOCBLANK:
979 return (cv3d_blank (gp, (int *)data)); 989 return (cv3d_blank (gp, *(int *)data));
980 } 990 }
981 return (EPASSTHROUGH); 991 return (EPASSTHROUGH);
982} 992}
983 993
984 994
985int 995int
986cv3d_setmonitor(struct grf_softc *gp, struct grfvideo_mode *gv) 996cv3d_setmonitor(struct grf_softc *gp, struct grfvideo_mode *gv)
987{ 997{
988 struct grfvideo_mode *md; 998 struct grfvideo_mode *md;
989 999
990 if (!cv3d_mondefok(gv)) 1000 if (!cv3d_mondefok(gv))
991 return (EINVAL); 1001 return (EINVAL);
992 1002
@@ -2289,16 +2299,53 @@ cv3d_wsmapchar(void *c, int ch, unsigned @@ -2289,16 +2299,53 @@ cv3d_wsmapchar(void *c, int ch, unsigned
2289 2299
2290static int 2300static int
2291cv3d_wsallocattr(void *c, int fg, int bg, int flg, long *attr) 2301cv3d_wsallocattr(void *c, int fg, int bg, int flg, long *attr)
2292{ 2302{
2293 2303
2294 /* XXX color support? */ 2304 /* XXX color support? */
2295 *attr = (flg & WSATTR_REVERSE) ? 0x70 : 0x07; 2305 *attr = (flg & WSATTR_REVERSE) ? 0x70 : 0x07;
2296 if (flg & WSATTR_UNDERLINE) *attr = 0x01; 2306 if (flg & WSATTR_UNDERLINE) *attr = 0x01;
2297 if (flg & WSATTR_HILIT) *attr |= 0x08; 2307 if (flg & WSATTR_HILIT) *attr |= 0x08;
2298 if (flg & WSATTR_BLINK) *attr |= 0x80; 2308 if (flg & WSATTR_BLINK) *attr |= 0x80;
2299 return 0; 2309 return 0;
2300} 2310}
2301 2311
 2312static int
 2313cv3d_wsioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
 2314{
 2315 struct vcons_data *vd;
 2316 struct grf_softc *gp;
 2317
 2318 vd = v;
 2319 gp = vd->cookie;
 2320
 2321 switch (cmd) {
 2322 case WSDISPLAYIO_GETCMAP:
 2323 /* Note: wsdisplay_cmap and grf_colormap have same format */
 2324 if (gp->g_display.gd_planes == 8)
 2325 return cv3d_getcmap(gp, (struct grf_colormap *)data);
 2326 return EINVAL;
 2327
 2328 case WSDISPLAYIO_PUTCMAP:
 2329 /* Note: wsdisplay_cmap and grf_colormap have same format */
 2330 if (gp->g_display.gd_planes == 8)
 2331 return cv3d_putcmap(gp, (struct grf_colormap *)data);
 2332 return EINVAL;
 2333
 2334 case WSDISPLAYIO_GVIDEO:
 2335 if (cv3d_isblank(gp))
 2336 *(u_int *)data = WSDISPLAYIO_VIDEO_OFF;
 2337 else
 2338 *(u_int *)data = WSDISPLAYIO_VIDEO_ON;
 2339 return 0;
 2340
 2341 case WSDISPLAYIO_SVIDEO:
 2342 return cv3d_blank(gp, *(u_int *)data == WSDISPLAYIO_VIDEO_OFF);
 2343 }
 2344
 2345 /* handle this command hw-independant in grf(4) */
 2346 return grf_wsioctl(v, vs, cmd, data, flag, l);
 2347}
 2348
2302#endif /* NWSDISPLAY > 0 */ 2349#endif /* NWSDISPLAY > 0 */
2303 2350
2304#endif /* NGRFCV3D */ 2351#endif /* NGRFCV3D */

cvs diff -r1.24 -r1.25 src/sys/arch/amiga/dev/grfvar.h (expand / switch to unified diff)

--- src/sys/arch/amiga/dev/grfvar.h 2012/10/27 17:17:29 1.24
+++ src/sys/arch/amiga/dev/grfvar.h 2015/11/07 14:29:10 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: grfvar.h,v 1.24 2012/10/27 17:17:29 chs Exp $ */ 1/* $NetBSD: grfvar.h,v 1.25 2015/11/07 14:29:10 phx Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1990 The Regents of the University of California. 5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department. 10 * Science Department.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -56,44 +56,51 @@ struct grf_softc { @@ -56,44 +56,51 @@ struct grf_softc {
56 volatile void *g_regkva; /* KVA of registers */ 56 volatile void *g_regkva; /* KVA of registers */
57 volatile void *g_fbkva; /* KVA of framebuffer */ 57 volatile void *g_fbkva; /* KVA of framebuffer */
58 int g_flags; /* software flags */ 58 int g_flags; /* software flags */
59 int g_unit; /* grf unit we want/have */ 59 int g_unit; /* grf unit we want/have */
60 dev_t g_itedev; /* ite device number */ 60 dev_t g_itedev; /* ite device number */
61 dev_t g_grfdev; /* grf device number */ 61 dev_t g_grfdev; /* grf device number */
62 void *g_data; /* device dependent data */ 62 void *g_data; /* device dependent data */
63 int g_blank; /* shadow copy of blank value */ 63 int g_blank; /* shadow copy of blank value */
64 int (*g_mode)(struct grf_softc *, u_long, void *, 64 int (*g_mode)(struct grf_softc *, u_long, void *,
65 u_long, int); 65 u_long, int);
66#if NWSDISPLAY > 0 66#if NWSDISPLAY > 0
67 struct wsdisplay_accessops *g_accessops; 67 struct wsdisplay_accessops *g_accessops;
68 struct wsdisplay_emulops *g_emulops; 68 struct wsdisplay_emulops *g_emulops;
69 struct wsscreen_descr g_defaultscreen; 69 struct wsscreen_descr *g_defaultscr;
70 struct wsscreen_descr *g_screens[1]; 70 struct wsscreen_list *g_scrlist;
71 struct wsscreen_list g_screenlist; 
72 struct vcons_data g_vd; 71 struct vcons_data g_vd;
73 struct ws_ao_ioctl *g_wsioctl; 
74 uint16_t g_rowoffset[MAXROWS]; /* speed up putchar-multiplication */ 72 uint16_t g_rowoffset[MAXROWS]; /* speed up putchar-multiplication */
75 int g_wsmode; /* current wsdisplay mode */  73 int g_wsmode; /* current wsdisplay mode */
76  74
77#else 75#else
78 int g_conpri; /* priority of ite as console */ 76 int g_conpri; /* priority of ite as console */
79 void (*g_iteinit)(struct ite_softc *); 77 void (*g_iteinit)(struct ite_softc *);
80 void (*g_itedeinit)(struct ite_softc *); 78 void (*g_itedeinit)(struct ite_softc *);
81 void (*g_iteclear)(struct ite_softc *, int, int, int, int); 79 void (*g_iteclear)(struct ite_softc *, int, int, int, int);
82 void (*g_iteputc)(struct ite_softc *, int, int, int, int); 80 void (*g_iteputc)(struct ite_softc *, int, int, int, int);
83 void (*g_itecursor)(struct ite_softc *, int); 81 void (*g_itecursor)(struct ite_softc *, int);
84 void (*g_itescroll)(struct ite_softc *, int, int, int, int); 82 void (*g_itescroll)(struct ite_softc *, int, int, int, int);
85#endif /* NWSDISPLAY */ 83#endif /* NWSDISPLAY */
86}; 84};
 85
 86#if NWSDISPLAY > 0
 87/*
 88 * Generic wsdisplay access ops that can be used from all grf drivers.
 89 */
 90paddr_t grf_wsmmap(void *, void *, off_t, int);
 91int grf_wsioctl(void *, void *, u_long, void *, int, struct lwp *);
 92#endif /* NWSDISPLAY */
 93
87#endif /* _KERNEL */ 94#endif /* _KERNEL */
88 95
89/* flags */ 96/* flags */
90#define GF_ALIVE 0x01 97#define GF_ALIVE 0x01
91#define GF_OPEN 0x02 98#define GF_OPEN 0x02
92#define GF_EXCLUDE 0x04 99#define GF_EXCLUDE 0x04
93#define GF_WANTED 0x08 100#define GF_WANTED 0x08
94#define GF_GRFON 0x10 101#define GF_GRFON 0x10
95#define GF_CONSOLE 0x20 102#define GF_CONSOLE 0x20
96 103
97/* software ids defined in grfioctl.h */ 104/* software ids defined in grfioctl.h */
98 105
99/* requests to mode routine (g_mode())*/ 106/* requests to mode routine (g_mode())*/

File Deleted: src/sys/arch/amiga/dev/Attic/grfws.h