1 /* $NetBSD: grtwo.c,v 1.10 2007/03/04 06:00:39 christos Exp $ */
4 * Copyright (c) 2004 Christopher SEKIYA
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * <<Id: LICENSE_GC,v 1.1 2001/10/01 23:24:05 cgd Exp>>
32 /* wscons driver for SGI GR2 family of framebuffers
34 * Heavily based on the newport wscons driver.
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: grtwo.c,v 1.10 2007/03/04 06:00:39 christos Exp $");
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/device.h>
43 #include <sys/malloc.h>
45 #include <machine/sysconf.h>
47 #include <dev/wscons/wsconsio.h>
48 #include <dev/wscons/wsdisplayvar.h>
49 #include <dev/wsfont/wsfont.h>
51 #include <sgimips/gio/giovar.h>
52 #include <sgimips/gio/grtwovar.h>
53 #include <sgimips/gio/grtworeg.h>
55 #include <sgimips/dev/int2var.h>
60 struct grtwo_devconfig
*sc_dc
;
63 struct grtwo_devconfig
{
67 bus_space_handle_t ioh
;
84 struct wsdisplay_font
*dc_fontdata
;
87 static int grtwo_match(struct device
*, struct cfdata
*, void *);
88 static void grtwo_attach(struct device
*, struct device
*, void *);
90 CFATTACH_DECL(grtwo
, sizeof(struct grtwo_softc
),
91 grtwo_match
, grtwo_attach
, NULL
, NULL
);
94 static void grtwo_cursor(void *, int, int, int);
95 static int grtwo_mapchar(void *, int, unsigned int *);
96 static void grtwo_putchar(void *, int, int, u_int
, long);
97 static void grtwo_copycols(void *, int, int, int, int);
98 static void grtwo_erasecols(void *, int, int, int, long);
99 static void grtwo_copyrows(void *, int, int, int);
100 static void grtwo_eraserows(void *, int, int, long);
101 static int grtwo_allocattr(void *, int, int, int, long *);
104 static int grtwo_ioctl(void *, void *, u_long
, void *, int, struct lwp
*);
105 static paddr_t
grtwo_mmap(void *, void *, off_t
, int);
107 grtwo_alloc_screen(void *, const struct wsscreen_descr
*,
108 void **, int *, int *, long *);
109 static void grtwo_free_screen(void *, void *);
111 grtwo_show_screen(void *, void *, int, void (*) (void *, int, int), void *);
113 static int grtwo_intr0(void *);
114 static int grtwo_intr6(void *);
116 static const struct wsdisplay_emulops grtwo_textops
= {
117 .cursor
= grtwo_cursor
,
118 .mapchar
= grtwo_mapchar
,
119 .putchar
= grtwo_putchar
,
120 .copycols
= grtwo_copycols
,
121 .erasecols
= grtwo_erasecols
,
122 .copyrows
= grtwo_copyrows
,
123 .eraserows
= grtwo_eraserows
,
124 .allocattr
= grtwo_allocattr
127 static const struct wsdisplay_accessops grtwo_accessops
= {
128 .ioctl
= grtwo_ioctl
,
130 .alloc_screen
= grtwo_alloc_screen
,
131 .free_screen
= grtwo_free_screen
,
132 .show_screen
= grtwo_show_screen
,
135 static const struct wsscreen_descr grtwo_screen
= {
138 .nrows
= 64, /* 40 */
139 .textops
= &grtwo_textops
,
142 .capabilities
= WSSCREEN_WSCOLORS
| WSSCREEN_HILIT
| WSSCREEN_REVERSE
145 static const struct wsscreen_descr
*_grtwo_screenlist
[] = {
149 static const struct wsscreen_list grtwo_screenlist
= {
150 sizeof(_grtwo_screenlist
) / sizeof(struct wsscreen_descr
*),
154 static struct grtwo_devconfig grtwo_console_dc
;
155 static int grtwo_is_console
= 0;
157 #define GR2_ATTR_ENCODE(fg,bg) (((fg) << 8) | (bg))
158 #define GR2_ATTR_BG(a) ((a) & 0xff)
159 #define GR2_ATTR_FG(a) (((a) >> 8) & 0xff)
161 static const u_int16_t grtwo_cursor_data
[128] = {
231 static const u_int8_t grtwo_defcmap
[8 * 3] = {
233 0x00, 0x00, 0x00, /* black */
234 0x7f, 0x00, 0x00, /* red */
235 0x00, 0x7f, 0x00, /* green */
236 0x7f, 0x7f, 0x00, /* brown */
237 0x00, 0x00, 0x7f, /* blue */
238 0x7f, 0x00, 0x7f, /* magenta */
239 0x00, 0x7f, 0x7f, /* cyan */
240 0xc7, 0xc7, 0xc7, /* white - XXX too dim? */
244 grtwo_wait_gfifo(struct grtwo_devconfig
* dc
)
250 grtwo_set_color(bus_space_tag_t iot
, bus_space_handle_t ioh
, int color
)
252 bus_space_write_4(iot
, ioh
, GR2_FIFO_COLOR
, color
);
255 /* Helper functions */
257 grtwo_fill_rectangle(struct grtwo_devconfig
* dc
, int x1
, int y1
, int x2
,
258 int y2
, u_int8_t color
)
264 /* gr2 sees coordinate 0,0 as the lower left corner, and 1279,1023
265 as the upper right. To keep things consistent, we shall flip the
268 /* There appears to be a limit to the number of vertical lines that we
269 can run through the graphics engine at one go. This probably has
270 something to do with vertical refresh. Single-row fills are okay,
271 multiple-row screw up the board in exciting ways. The copy_rectangle
272 workaround doesn't work for fills. */
274 /* Coordinates, not length. Remember that! */
276 to_y
= min(dc
->yres
- 1 - y1
, dc
->yres
- 1 - y2
);
277 from_y
= max(dc
->yres
- 1 - y1
, dc
->yres
- 1 - y2
);
279 remaining
= to_y
- from_y
;
281 grtwo_wait_gfifo(dc
);
282 grtwo_set_color(dc
->iot
, dc
->ioh
, color
);
288 grtwo_wait_gfifo(dc
);
289 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_RECTI2D
, x1
);
290 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, from_y
);
291 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, x2
);
292 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, from_y
+ remaining
);
296 grtwo_wait_gfifo(dc
);
297 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_RECTI2D
, x1
);
298 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, from_y
);
299 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, x2
);
300 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, from_y
+ remaining
);
308 grtwo_copy_rectangle(struct grtwo_devconfig
* dc
, int x1
, int y1
, int x2
,
309 int y2
, int width
, int height
)
311 int length
= (width
+ 3) >> 2;
312 int lines
= 4864 / length
;
317 if ((y2
<= y1
) || (height
< lines
)) {
318 grtwo_wait_gfifo(dc
);
319 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_RECTCOPY
, length
);
320 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, lines
);
321 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, x1
);
322 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, y1
);
323 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, width
);
324 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, height
);
325 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, x2
);
326 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, y2
);
328 from_y
= y1
+ height
- lines
;
329 to_y
= y2
+ height
- lines
;
330 temp_height
= MIN(height
, lines
);
332 while (temp_height
) {
333 grtwo_wait_gfifo(dc
);
334 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_RECTCOPY
, length
);
335 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, lines
);
336 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, x1
);
337 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, from_y
);
338 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, width
);
339 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, temp_height
);
340 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, x2
);
341 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, to_y
);
342 height
-= temp_height
;
343 height
= MIN(height
, lines
);
344 from_y
-= temp_height
;
351 grtwo_cmap_setrgb(struct grtwo_devconfig
* dc
, int index
, u_int8_t r
, u_int8_t g
, u_int8_t b
)
353 grtwo_wait_gfifo(dc
);
354 bus_space_write_1(dc
->iot
, dc
->ioh
, XMAPALL_ADDRHI
,
355 ((index
& 0x1f00) >> 8) );
356 bus_space_write_1(dc
->iot
, dc
->ioh
, XMAPALL_ADDRLO
,
358 bus_space_write_1(dc
->iot
, dc
->ioh
, XMAPALL_CLUT
, r
);
359 bus_space_write_1(dc
->iot
, dc
->ioh
, XMAPALL_CLUT
, g
);
360 bus_space_write_1(dc
->iot
, dc
->ioh
, XMAPALL_CLUT
, b
);
364 grtwo_setup_hw(struct grtwo_devconfig
* dc
)
368 /* Get various revisions */
369 dc
->boardrev
= (~(bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD0
))) & GR2_REVISION_RD0_VERSION_MASK
;
372 * boards prior to rev 4 have a pretty whacky config scheme.
373 * what is doubly weird is that i have a rev 2 board, but the rev 4
374 * probe routines work just fine.
375 * we'll trust SGI, though, and separate things a bit. it's only
376 * critical for the display depth calculation.
379 if (dc
->boardrev
< 4) {
380 dc
->backendrev
= ~(bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD2
) & GR2_REVISION_RD2_BACKEND_REV
) >> 2;
381 if (dc
->backendrev
== 0)
383 dc
->zbuffer
= !(bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD1
) & GR2_REVISION_RD1_ZBUFFER
);
384 if ( (bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD3
) & GR2_REVISION_RD3_VMA
) != 3)
386 if ( (bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD3
) & GR2_REVISION_RD3_VMB
) != 0x0c)
388 if ( (bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD3
) & GR2_REVISION_RD3_VMC
) != 0x30)
392 ((bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD2
) & 0x03) << 1) |
393 (bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD1
) & 0x01);
395 dc
->backendrev
= ~(bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD1
)) & 0x03;
396 if (dc
->backendrev
== 0)
398 dc
->zbuffer
= bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD1
) & GR2_REVISION4_RD1_ZBUFFER
;
399 dc
->depth
= ((bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD1
) & GR2_REVISION4_RD1_24BPP
) >> 4) ? 24 : 8;
400 dc
->monitor
= (bus_space_read_4(dc
->iot
, dc
->ioh
, GR2_REVISION_RD0
) & GR2_REVISION4_RD0_MONITOR_MASK
) >> 4;
403 dc
->hq2rev
= (bus_space_read_4(dc
->iot
, dc
->ioh
, HQ2_VERSION
) & HQ2_VERSION_MASK
) >> HQ2_VERSION_SHIFT
;
404 dc
->ge7rev
= (bus_space_read_4(dc
->iot
, dc
->ioh
, GE7_REVISION
) & GE7_REVISION_MASK
) >> 5;
405 /* dc->vc1rev = vc1_read_ireg(dc, 5) & 0x07; */
407 /* gr2 supports 1280x1024 only */
412 /* Setup cursor glyph */
414 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_ADDRHI
,
415 (VC1_SRAM_CURSOR0_BASE
>> 8) & 0xff);
416 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_ADDRLO
,
417 VC1_SRAM_CURSOR0_BASE
& 0xff);
418 for (i
= 0; i
< 128; i
++)
419 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_SRAM
, grtwo_cursor_data
[i
]);
421 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_ADDRHI
,
422 (VC1_CURSOR_EP
>> 8) & 0xff);
423 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_ADDRLO
,
424 VC1_CURSOR_EP
& 0xff);
425 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_COMMAND
, VC1_SRAM_CURSOR0_BASE
);
426 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_COMMAND
, 0);
427 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_COMMAND
, 0);
428 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_COMMAND
, 0);
430 /* Turn on cursor function, display, DID */
431 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_SYSCTL
,
432 VC1_SYSCTL_VC1
| VC1_SYSCTL_DID
|
433 VC1_SYSCTL_CURSOR
| VC1_SYSCTL_CURSOR_DISPLAY
);
437 for (i
= 0; i
< 8; i
++)
438 grtwo_cmap_setrgb(dc
, i
, grtwo_defcmap
[i
* 3],
439 grtwo_defcmap
[i
* 3 + 1], grtwo_defcmap
[i
* 3 + 2]);
442 /* Attach routines */
444 grtwo_match(struct device
* parent
, struct cfdata
* self
, void *aux
)
446 struct gio_attach_args
*ga
= aux
;
448 if (ga
->ga_addr
!= 0x1f000000 && ga
->ga_addr
!= 0x1f400000 &&
449 ga
->ga_addr
!= 0x1f600000)
453 * grtwo doesn't have anything that even vaguely resembles a product
454 * ID. Instead, we determine presence by looking at the HQ2 "mystery"
455 * register, which contains a magic number.
457 if ( platform
.badaddr((void *) (ga
->ga_ioh
+ HQ2_MYSTERY
),
461 if ( (bus_space_read_4(ga
->ga_iot
, ga
->ga_ioh
, HQ2_MYSTERY
)) != 0xdeadbeef)
468 grtwo_attach_common(struct grtwo_devconfig
* dc
, struct gio_attach_args
* ga
)
470 dc
->dc_addr
= ga
->ga_addr
;
472 dc
->iot
= ga
->ga_iot
;
473 dc
->ioh
= ga
->ga_ioh
;
478 dc
->dc_font
= wsfont_find(NULL
, 8, 16, 0, WSDISPLAY_FONTORDER_L2R
,
479 WSDISPLAY_FONTORDER_L2R
);
482 panic("grtwo_attach_common: no suitable fonts");
484 if (wsfont_lock(dc
->dc_font
, &dc
->dc_fontdata
))
485 panic("grtwo_attach_common: unable to lock font data");
489 /* Large fills are broken. For now, clear the screen line-by-line. */
490 for (i
= 0; i
< 64; i
++)
491 grtwo_eraserows(dc
, i
, 1, 0);
493 /* If large fills worked, we'd do this instead:
494 grtwo_fill_rectangle(dc, 0, 0, dc->xres - 1, dc->yres - 1, 0);
499 grtwo_attach(struct device
* parent
, struct device
* self
, void *aux
)
501 struct gio_attach_args
*ga
= aux
;
502 struct grtwo_softc
*sc
= (void *) self
;
503 struct wsemuldisplaydev_attach_args wa
;
505 if (grtwo_is_console
&& ga
->ga_addr
== grtwo_console_dc
.dc_addr
) {
507 sc
->sc_dc
= &grtwo_console_dc
;
510 sc
->sc_dc
= malloc(sizeof(struct grtwo_devconfig
),
511 M_DEVBUF
, M_WAITOK
| M_ZERO
);
512 if (sc
->sc_dc
== NULL
)
513 panic("grtwo_attach: out of memory");
515 grtwo_attach_common(sc
->sc_dc
, ga
);
518 aprint_naive(": Display adapter\n");
520 aprint_normal(": GR2 (board rev %x, monitor %d, depth %d)\n",
521 sc
->sc_dc
->boardrev
, sc
->sc_dc
->monitor
, sc
->sc_dc
->depth
);
523 wa
.scrdata
= &grtwo_screenlist
;
524 wa
.accessops
= &grtwo_accessops
;
525 wa
.accesscookie
= sc
->sc_dc
;
527 if ((cpu_intr_establish(0, IPL_TTY
, grtwo_intr0
, sc
)) == NULL
)
528 printf(": unable to establish interrupt!\n");
530 if ((cpu_intr_establish(6, IPL_TTY
, grtwo_intr6
, sc
)) == NULL
)
531 printf(": unable to establish interrupt!\n");
533 config_found(&sc
->sc_dev
, &wa
, wsemuldisplaydevprint
);
537 grtwo_cnattach(struct gio_attach_args
* ga
)
539 long defattr
= GR2_ATTR_ENCODE(WSCOL_WHITE
, WSCOL_BLACK
);
541 if (!grtwo_match(NULL
, NULL
, ga
)) {
545 grtwo_attach_common(&grtwo_console_dc
, ga
);
546 wsdisplay_cnattach(&grtwo_screen
, &grtwo_console_dc
, 0, 0, defattr
);
548 grtwo_is_console
= 1;
553 /* wsdisplay textops */
555 grtwo_cursor(void *c
, int on
, int row
, int col
)
557 struct grtwo_devconfig
*dc
= (void *) c
;
559 control
= bus_space_read_4(dc
->iot
, dc
->ioh
, VC1_SYSCTL
);
562 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_SYSCTL
,
563 control
& ~VC1_SYSCTL_CURSOR_DISPLAY
);
565 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_ADDRHI
, (VC1_CURSOR_XL
& 0xff00) >> 8
567 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_ADDRLO
, VC1_CURSOR_XL
& 0xff);
568 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_COMMAND
,
569 col
* dc
->dc_fontdata
->fontwidth
);
570 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_COMMAND
,
571 row
* dc
->dc_fontdata
->fontheight
);
572 bus_space_write_4(dc
->iot
, dc
->ioh
, VC1_SYSCTL
,
573 control
| VC1_SYSCTL_CURSOR_DISPLAY
);
578 grtwo_mapchar(void *c
, int ch
, unsigned int *cp
)
580 struct grtwo_devconfig
*dc
= (void *) c
;
582 if (dc
->dc_fontdata
->encoding
!= WSDISPLAY_FONTENC_ISO
) {
583 ch
= wsfont_map_unichar(dc
->dc_fontdata
, ch
);
588 if (ch
< dc
->dc_fontdata
->firstchar
||
589 ch
>= dc
->dc_fontdata
->firstchar
+ dc
->dc_fontdata
->numchars
)
601 grtwo_putchar(void *c
, int row
, int col
, u_int ch
, long attr
)
603 struct grtwo_devconfig
*dc
= (void *) c
;
604 struct wsdisplay_font
*font
= dc
->dc_fontdata
;
605 u_int8_t
*bitmap
= (u_int8_t
*) font
->data
+ (ch
- font
->firstchar
+ 1) * font
->fontheight
* font
->stride
;
608 int x
= col
* font
->fontwidth
;
609 int y
= dc
->yres
- ( (row
+ 1) * font
->fontheight
);
611 /* Set the drawing color */
612 grtwo_wait_gfifo(dc
);
613 grtwo_set_color(dc
->iot
, dc
->ioh
, (((attr
) >> 8) & 0xff));
614 grtwo_wait_gfifo(dc
);
616 /* Set drawing coordinates */
617 grtwo_wait_gfifo(dc
);
618 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_CMOV2I
, x
);
619 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, y
);
621 /* This works for font sizes < 18 */
622 grtwo_wait_gfifo(dc
);
623 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DRAWCHAR
, font
->fontwidth
);
624 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, font
->fontheight
);
625 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, 2);
626 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, 0); /* x offset */
627 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, 0); /* y offset */
628 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, 0);
629 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, 0);
631 for (i
= 0; i
< font
->fontheight
; i
++) {
632 /* It appears that writes have to be 16 bits. An "I tell you
633 two times" sort of thing? Thanks, SGI */
634 pattern
= *bitmap
| (*bitmap
<< 8);
635 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, pattern
);
636 bitmap
-= font
->stride
;
640 for (i
= font
->fontheight
; i
< 18; i
++)
641 bus_space_write_4(dc
->iot
, dc
->ioh
, GR2_FIFO_DATA
, 0x0000);
645 grtwo_copycols(void *c
, int row
, int srccol
, int dstcol
, int ncols
)
648 printf("grtwo_copycols: %i %i %i %i\n", row
, srccol
, dstcol
, ncols
);
650 struct grtwo_devconfig
*dc
= (void *) c
;
651 struct wsdisplay_font
*font
= dc
->dc_fontdata
;
652 grtwo_copy_rectangle(dc
,
653 srccol
* font
->fontwidth
, /* x1 */
655 dstcol
* font
->fontwidth
, /* x2 */
657 ncols
* font
->fontwidth
, /* dx */
663 grtwo_erasecols(void *c
, int row
, int startcol
, int ncols
, long attr
)
665 struct grtwo_devconfig
*dc
= (void *) c
;
666 struct wsdisplay_font
*font
= dc
->dc_fontdata
;
668 grtwo_fill_rectangle(dc
,
669 startcol
* font
->fontwidth
, /* x1 */
671 (startcol
* font
->fontwidth
) + ncols
* font
->fontwidth
, /* x2 */
677 grtwo_copyrows(void *c
, int srcrow
, int dstrow
, int nrows
)
679 struct grtwo_devconfig
*dc
= (void *) c
;
680 struct wsdisplay_font
*font
= dc
->dc_fontdata
;
682 grtwo_copy_rectangle(dc
,
684 srcrow
* font
->fontheight
, /* y1 */
686 dstrow
* font
->fontheight
, /* y2 */
688 nrows
* font
->fontheight
);
692 grtwo_eraserows(void *c
, int startrow
, int nrows
, long attr
)
694 struct grtwo_devconfig
*dc
= (void *) c
;
695 struct wsdisplay_font
*font
= dc
->dc_fontdata
;
696 grtwo_fill_rectangle(dc
,
698 startrow
* font
->fontheight
, /* y1 */
700 (startrow
* font
->fontheight
) + nrows
* font
->fontheight
, /* y2 */
705 grtwo_allocattr(void *c
, int fg
, int bg
, int flags
, long *attr
)
707 if (flags
& WSATTR_BLINK
)
710 if ((flags
& WSATTR_WSCOLORS
) == 0) {
714 if (flags
& WSATTR_HILIT
)
717 if (flags
& WSATTR_REVERSE
) {
722 *attr
= GR2_ATTR_ENCODE(fg
, bg
);
727 /* wsdisplay accessops */
730 grtwo_ioctl(void *c
, void *vs
, u_long cmd
, void *data
, int flag
,
733 struct grtwo_softc
*sc
= c
;
735 #define FBINFO (*(struct wsdisplay_fbinfo*)data)
738 case WSDISPLAYIO_GINFO
:
739 FBINFO
.width
= sc
->sc_dc
->xres
;
740 FBINFO
.height
= sc
->sc_dc
->yres
;
741 FBINFO
.depth
= sc
->sc_dc
->depth
;
742 FBINFO
.cmsize
= 1 << FBINFO
.depth
;
744 case WSDISPLAYIO_GTYPE
:
745 *(u_int
*) data
= WSDISPLAY_TYPE_GR2
;
752 grtwo_mmap(void *c
, void *vs
, off_t offset
, int prot
)
754 struct grtwo_devconfig
*dc
= c
;
756 if (offset
>= 0xfffff)
759 return mips_btop(dc
->dc_addr
+ offset
);
763 grtwo_alloc_screen(void *c
, const struct wsscreen_descr
* type
, void **cookiep
,
764 int *cursxp
, int *cursyp
, long *attrp
)
767 * This won't get called for console screen and we don't support
775 grtwo_free_screen(void *c
, void *cookie
)
777 panic("grtwo_free_screen");
780 grtwo_show_screen(void *c
, void *cookie
, int waitok
,
781 void (*cb
) (void *, int, int), void *cbarg
)
787 grtwo_intr0(void *arg
)
789 /* struct grtwo_devconfig *dc = arg; */
795 grtwo_intr6(void *arg
)
797 /* struct grtwo_devconfig *dc = arg; */