summaryrefslogtreecommitdiff
path: root/sys/arch/amiga/dev/grf_rt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amiga/dev/grf_rt.c')
-rw-r--r--sys/arch/amiga/dev/grf_rt.c888
1 files changed, 452 insertions, 436 deletions
diff --git a/sys/arch/amiga/dev/grf_rt.c b/sys/arch/amiga/dev/grf_rt.c
index a398ab52fd4..0a28eed7381 100644
--- a/sys/arch/amiga/dev/grf_rt.c
+++ b/sys/arch/amiga/dev/grf_rt.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_rt.c,v 1.5 1996/05/04 13:54:29 niklas Exp $ */
-/* $NetBSD: grf_rt.c,v 1.26 1996/05/01 09:59:28 veego Exp $ */
+/* $OpenBSD: grf_rt.c,v 1.6 1996/05/29 10:15:15 niklas Exp $ */
+/* $NetBSD: grf_rt.c,v 1.27 1996/05/19 21:05:45 veego Exp $ */
/*
* Copyright (c) 1993 Markus Wild
@@ -305,40 +305,40 @@ rt_load_mon(gp, md)
FW = 0;
if (md->DEP == 4) {
switch (md->FX) {
- case 4:
+ case 4:
FW = 0;
break;
- case 7:
+ case 7:
FW = 1;
break;
- case 8:
+ case 8:
FW = 2;
break;
- case 9:
+ case 9:
FW = 3;
break;
- case 10:
+ case 10:
FW = 4;
break;
- case 11:
+ case 11:
FW = 5;
break;
- case 12:
+ case 12:
FW = 6;
break;
- case 13:
+ case 13:
FW = 7;
break;
- case 14:
+ case 14:
FW = 8;
break;
- case 15:
+ case 15:
FW = 9;
break;
- case 16:
+ case 16:
FW = 11;
break;
- default:
+ default:
return(0);
break;
};
@@ -456,111 +456,111 @@ rt_load_mon(gp, md)
WCrt (ba, CRT_ID_PRESET_ROW_SCAN, 0x00);
if (md->DEP == 4) {
- WCrt (ba, CRT_ID_MAX_SCAN_LINE, (( (md->FLG & MDF_DBL)/ MDF_DBL * 0x80)
- | 0x40
- | ((md->VBS & 0x200)/0x200 * 0x20)
- | ((md->FY-1) & 0x1f)));
+ WCrt (ba, CRT_ID_MAX_SCAN_LINE, (( (md->FLG & MDF_DBL)/ MDF_DBL * 0x80)
+ | 0x40
+ | ((md->VBS & 0x200)/0x200 * 0x20)
+ | ((md->FY-1) & 0x1f)));
}
else {
- WCrt (ba, CRT_ID_MAX_SCAN_LINE, (( (md->FLG & MDF_DBL)/ MDF_DBL * 0x80)
- | 0x40
- | ((md->VBS & 0x200)/0x200 * 0x20)
- | (0 & 0x1f)));
+ WCrt (ba, CRT_ID_MAX_SCAN_LINE, (( (md->FLG & MDF_DBL)/ MDF_DBL * 0x80)
+ | 0x40
+ | ((md->VBS & 0x200)/0x200 * 0x20)
+ | (0 & 0x1f)));
}
- WCrt (ba, CRT_ID_CURSOR_START, (md->FY & 0x1f) - 2);
- WCrt (ba, CRT_ID_CURSOR_END, (md->FY & 0x1f) - 1);
+ WCrt (ba, CRT_ID_CURSOR_START, (md->FY & 0x1f) - 2);
+ WCrt (ba, CRT_ID_CURSOR_END, (md->FY & 0x1f) - 1);
- WCrt (ba, CRT_ID_START_ADDR_HIGH, 0x00);
- WCrt (ba, CRT_ID_START_ADDR_LOW, 0x00);
+ WCrt (ba, CRT_ID_START_ADDR_HIGH, 0x00);
+ WCrt (ba, CRT_ID_START_ADDR_LOW, 0x00);
- WCrt (ba, CRT_ID_CURSOR_LOC_HIGH, 0x00);
- WCrt (ba, CRT_ID_CURSOR_LOC_LOW, 0x00);
+ WCrt (ba, CRT_ID_CURSOR_LOC_HIGH, 0x00);
+ WCrt (ba, CRT_ID_CURSOR_LOC_LOW, 0x00);
- WCrt (ba, CRT_ID_START_VER_RETR, md->VSS & 0xff);
- WCrt (ba, CRT_ID_END_VER_RETR, (md->VSE & 0x0f) | 0x80 | 0x20);
- WCrt (ba, CRT_ID_VER_DISP_ENA_END, VDE & 0xff);
+ WCrt (ba, CRT_ID_START_VER_RETR, md->VSS & 0xff);
+ WCrt (ba, CRT_ID_END_VER_RETR, (md->VSE & 0x0f) | 0x80 | 0x20);
+ WCrt (ba, CRT_ID_VER_DISP_ENA_END, VDE & 0xff);
if (md->DEP == 4)
- WCrt (ba, CRT_ID_OFFSET, (HDE / 2) & 0xff);
+ WCrt (ba, CRT_ID_OFFSET, (HDE / 2) & 0xff);
else
- WCrt (ba, CRT_ID_OFFSET, (md->TX / 8) & 0xff);
+ WCrt (ba, CRT_ID_OFFSET, (md->TX / 8) & 0xff);
- WCrt (ba, CRT_ID_UNDERLINE_LOC, (md->FY-1) & 0x1f);
- WCrt (ba, CRT_ID_START_VER_BLANK, md->VBS & 0xff);
- WCrt (ba, CRT_ID_END_VER_BLANK, md->VBE & 0xff);
+ WCrt (ba, CRT_ID_UNDERLINE_LOC, (md->FY-1) & 0x1f);
+ WCrt (ba, CRT_ID_START_VER_BLANK, md->VBS & 0xff);
+ WCrt (ba, CRT_ID_END_VER_BLANK, md->VBE & 0xff);
/* byte mode + wrap + select row scan counter + cms */
- WCrt (ba, CRT_ID_MODE_CONTROL, 0xe3);
- WCrt (ba, CRT_ID_LINE_COMPARE, 0xff);
+ WCrt (ba, CRT_ID_MODE_CONTROL, 0xe3);
+ WCrt (ba, CRT_ID_LINE_COMPARE, 0xff);
/* enable extended end bits + those bits */
- WCrt (ba, CRT_ID_EXT_HOR_TIMING1, ( 0x20
- | ((md->FLG & MDF_LACE) / MDF_LACE * 0x10)
- | ((md->HT & 0x100) / 0x100 * 0x01)
- | (((HDE-1) & 0x100) / 0x100 * 0x02)
- | ((md->HBS & 0x100) / 0x100 * 0x04)
- | ((md->HSS & 0x100) / 0x100 * 0x08)));
-
+ WCrt (ba, CRT_ID_EXT_HOR_TIMING1, ( 0x20
+ | ((md->FLG & MDF_LACE) / MDF_LACE * 0x10)
+ | ((md->HT & 0x100) / 0x100 * 0x01)
+ | (((HDE-1) & 0x100) / 0x100 * 0x02)
+ | ((md->HBS & 0x100) / 0x100 * 0x04)
+ | ((md->HSS & 0x100) / 0x100 * 0x08)));
+
if (md->DEP == 4)
- WCrt (ba, CRT_ID_EXT_START_ADDR, (((HDE / 2) & 0x100)/0x100 * 16));
+ WCrt (ba, CRT_ID_EXT_START_ADDR, (((HDE / 2) & 0x100)/0x100 * 16));
else
- WCrt (ba, CRT_ID_EXT_START_ADDR, (((md->TX / 8) & 0x100)/0x100 * 16));
+ WCrt (ba, CRT_ID_EXT_START_ADDR, (((md->TX / 8) & 0x100)/0x100 * 16));
- WCrt (ba, CRT_ID_EXT_HOR_TIMING2, ( ((md->HT & 0x200)/ 0x200 * 0x01)
- | (((HDE-1) & 0x200)/ 0x200 * 0x02)
- | ((md->HBS & 0x200)/ 0x200 * 0x04)
- | ((md->HSS & 0x200)/ 0x200 * 0x08)
- | ((md->HBE & 0xc0) / 0x40 * 0x10)
- | ((md->HSE & 0x60) / 0x20 * 0x40)));
-
- WCrt (ba, CRT_ID_EXT_VER_TIMING, ( ((md->VSE & 0x10) / 0x10 * 0x80)
- | ((md->VBE & 0x300)/ 0x100 * 0x20)
- | 0x10
- | ((md->VSS & 0x400)/ 0x400 * 0x08)
- | ((md->VBS & 0x400)/ 0x400 * 0x04)
- | ((VDE & 0x400)/ 0x400 * 0x02)
- | ((md->VT & 0x400)/ 0x400 * 0x01)));
-
- WGfx (ba, GCT_ID_SET_RESET, 0x00);
- WGfx (ba, GCT_ID_ENABLE_SET_RESET, 0x00);
- WGfx (ba, GCT_ID_COLOR_COMPARE, 0x00);
- WGfx (ba, GCT_ID_DATA_ROTATE, 0x00);
- WGfx (ba, GCT_ID_READ_MAP_SELECT, 0x00);
- WGfx (ba, GCT_ID_GRAPHICS_MODE, 0x00);
+ WCrt (ba, CRT_ID_EXT_HOR_TIMING2, ( ((md->HT & 0x200)/ 0x200 * 0x01)
+ | (((HDE-1) & 0x200)/ 0x200 * 0x02)
+ | ((md->HBS & 0x200)/ 0x200 * 0x04)
+ | ((md->HSS & 0x200)/ 0x200 * 0x08)
+ | ((md->HBE & 0xc0) / 0x40 * 0x10)
+ | ((md->HSE & 0x60) / 0x20 * 0x40)));
+
+ WCrt (ba, CRT_ID_EXT_VER_TIMING, ( ((md->VSE & 0x10) / 0x10 * 0x80)
+ | ((md->VBE & 0x300)/ 0x100 * 0x20)
+ | 0x10
+ | ((md->VSS & 0x400)/ 0x400 * 0x08)
+ | ((md->VBS & 0x400)/ 0x400 * 0x04)
+ | ((VDE & 0x400)/ 0x400 * 0x02)
+ | ((md->VT & 0x400)/ 0x400 * 0x01)));
+
+ WGfx (ba, GCT_ID_SET_RESET, 0x00);
+ WGfx (ba, GCT_ID_ENABLE_SET_RESET, 0x00);
+ WGfx (ba, GCT_ID_COLOR_COMPARE, 0x00);
+ WGfx (ba, GCT_ID_DATA_ROTATE, 0x00);
+ WGfx (ba, GCT_ID_READ_MAP_SELECT, 0x00);
+ WGfx (ba, GCT_ID_GRAPHICS_MODE, 0x00);
if (md->DEP == 4)
- WGfx (ba, GCT_ID_MISC, 0x04);
+ WGfx (ba, GCT_ID_MISC, 0x04);
else
- WGfx (ba, GCT_ID_MISC, 0x05);
- WGfx (ba, GCT_ID_COLOR_XCARE, 0xff);
- WGfx (ba, GCT_ID_BITMASK, 0xff);
+ WGfx (ba, GCT_ID_MISC, 0x05);
+ WGfx (ba, GCT_ID_COLOR_XCARE, 0xff);
+ WGfx (ba, GCT_ID_BITMASK, 0xff);
/* reset the Attribute Controller flipflop */
vgar (ba, GREG_STATUS1_R);
- WAttr (ba, ACT_ID_PALETTE0, 0x00);
- WAttr (ba, ACT_ID_PALETTE1, 0x01);
- WAttr (ba, ACT_ID_PALETTE2, 0x02);
- WAttr (ba, ACT_ID_PALETTE3, 0x03);
- WAttr (ba, ACT_ID_PALETTE4, 0x04);
- WAttr (ba, ACT_ID_PALETTE5, 0x05);
- WAttr (ba, ACT_ID_PALETTE6, 0x06);
- WAttr (ba, ACT_ID_PALETTE7, 0x07);
- WAttr (ba, ACT_ID_PALETTE8, 0x08);
- WAttr (ba, ACT_ID_PALETTE9, 0x09);
- WAttr (ba, ACT_ID_PALETTE10, 0x0a);
- WAttr (ba, ACT_ID_PALETTE11, 0x0b);
- WAttr (ba, ACT_ID_PALETTE12, 0x0c);
- WAttr (ba, ACT_ID_PALETTE13, 0x0d);
- WAttr (ba, ACT_ID_PALETTE14, 0x0e);
- WAttr (ba, ACT_ID_PALETTE15, 0x0f);
+ WAttr (ba, ACT_ID_PALETTE0, 0x00);
+ WAttr (ba, ACT_ID_PALETTE1, 0x01);
+ WAttr (ba, ACT_ID_PALETTE2, 0x02);
+ WAttr (ba, ACT_ID_PALETTE3, 0x03);
+ WAttr (ba, ACT_ID_PALETTE4, 0x04);
+ WAttr (ba, ACT_ID_PALETTE5, 0x05);
+ WAttr (ba, ACT_ID_PALETTE6, 0x06);
+ WAttr (ba, ACT_ID_PALETTE7, 0x07);
+ WAttr (ba, ACT_ID_PALETTE8, 0x08);
+ WAttr (ba, ACT_ID_PALETTE9, 0x09);
+ WAttr (ba, ACT_ID_PALETTE10, 0x0a);
+ WAttr (ba, ACT_ID_PALETTE11, 0x0b);
+ WAttr (ba, ACT_ID_PALETTE12, 0x0c);
+ WAttr (ba, ACT_ID_PALETTE13, 0x0d);
+ WAttr (ba, ACT_ID_PALETTE14, 0x0e);
+ WAttr (ba, ACT_ID_PALETTE15, 0x0f);
vgar (ba, GREG_STATUS1_R);
if (md->DEP == 4)
- WAttr (ba, ACT_ID_ATTR_MODE_CNTL, 0x08);
+ WAttr (ba, ACT_ID_ATTR_MODE_CNTL, 0x08);
else
- WAttr (ba, ACT_ID_ATTR_MODE_CNTL, 0x09);
+ WAttr (ba, ACT_ID_ATTR_MODE_CNTL, 0x09);
- WAttr (ba, ACT_ID_OVERSCAN_COLOR, 0x00);
- WAttr (ba, ACT_ID_COLOR_PLANE_ENA, 0x0f);
- WAttr (ba, ACT_ID_HOR_PEL_PANNING, 0x00);
+ WAttr (ba, ACT_ID_OVERSCAN_COLOR, 0x00);
+ WAttr (ba, ACT_ID_COLOR_PLANE_ENA, 0x0f);
+ WAttr (ba, ACT_ID_HOR_PEL_PANNING, 0x00);
WAttr (ba, ACT_ID_COLOR_SELECT, 0x00);
vgar (ba, GREG_STATUS1_R);
@@ -588,9 +588,9 @@ rt_load_mon(gp, md)
registers, thus it works similar to the WD33C93
select/data mechanism */
vgaw (ba, VDAC_REG_SELECT, 0x00);
-
+
{
-
+
short x = 15;
const unsigned char * col = md->PAL;
do {
@@ -779,6 +779,7 @@ int rt_getspritemax __P((struct grf_softc *, struct grf_position *));
int rt_getcmap __P((struct grf_softc *, struct grf_colormap *));
int rt_putcmap __P((struct grf_softc *, struct grf_colormap *));
int rt_bitblt __P((struct grf_softc *, struct grf_bitblt *));
+int rt_blank __P((struct grf_softc *, int *));
struct cfattach grfrt_ca = {
sizeof(struct grf_softc), grfrtmatch, grfrtattach
@@ -901,82 +902,82 @@ grfrtprint(auxp, pnp)
static int
rt_getvmode (gp, vm)
- struct grf_softc *gp;
- struct grfvideo_mode *vm;
+ struct grf_softc *gp;
+ struct grfvideo_mode *vm;
{
- struct MonDef *md;
+ struct MonDef *md;
- if (vm->mode_num && vm->mode_num > retina_mon_max)
- return EINVAL;
+ if (vm->mode_num && vm->mode_num > retina_mon_max)
+ return (EINVAL);
+
+ if (! vm->mode_num)
+ vm->mode_num = (current_mon - monitor_defs) + 1;
+
+ md = monitor_defs + (vm->mode_num - 1);
+ strncpy (vm->mode_descr, monitor_descr[vm->mode_num - 1],
+ sizeof (vm->mode_descr));
+ vm->pixel_clock = md->FQ;
+ vm->disp_width = md->MW;
+ vm->disp_height = md->MH;
+ vm->depth = md->DEP;
+
+ /*
+ * From observation of the monitor definition table above, I guess that
+ * the horizontal timings are in units of longwords. Hence, I get the
+ * pixels by multiplication with 32 and division by the depth.
+ * The text modes, apparently marked by depth == 4, are even more wierd.
+ * According to a comment above, they are computed from a depth==8 mode
+ * (thats for us: * 32 / 8) by applying another factor of 4 / font width.
+ * Reverse applying the latter formula most of the constants cancel
+ * themselves and we are left with a nice (* font width).
+ * That is, internal timings are in units of longwords for graphics
+ * modes, or in units of characters widths for text modes.
+ * We better don't WRITE modes until this has been real live checked.
+ * - Ignatios Souvatzis
+ */
- if (! vm->mode_num)
- vm->mode_num = (current_mon - monitor_defs) + 1;
-
- md = monitor_defs + (vm->mode_num - 1);
- strncpy (vm->mode_descr, monitor_descr[vm->mode_num - 1],
- sizeof (vm->mode_descr));
- vm->pixel_clock = md->FQ;
- vm->disp_width = md->MW;
- vm->disp_height = md->MH;
- vm->depth = md->DEP;
-
- /*
- * From observation of the monitor definition table above, I guess that
- * the horizontal timings are in units of longwords. Hence, I get the
- * pixels by multiplication with 32 and division by the depth.
- * The text modes, apparently marked by depth == 4, are even more wierd.
- * According to a comment above, they are computed from a depth==8 mode
- * (thats for us: * 32 / 8) by applying another factor of 4 / font width.
- * Reverse applying the latter formula most of the constants cancel
- * themselves and we are left with a nice (* font width).
- * That is, internal timings are in units of longwords for graphics
- * modes, or in units of characters widths for text modes.
- * We better don't WRITE modes until this has been real live checked.
- * - Ignatios Souvatzis
- */
-
- if (md->DEP == 4) {
- vm->hblank_start = md->HBS * 32 / md->DEP;
- vm->hblank_stop = md->HBE * 32 / md->DEP;
- vm->hsync_start = md->HSS * 32 / md->DEP;
- vm->hsync_stop = md->HSE * 32 / md->DEP;
- vm->htotal = md->HT * 32 / md->DEP;
- } else {
- vm->hblank_start = md->HBS * md->FX;
- vm->hblank_stop = md->HBE * md->FX;
- vm->hsync_start = md->HSS * md->FX;
- vm->hsync_stop = md->HSE * md->FX;
- vm->htotal = md->HT * md->FX;
- }
- vm->vblank_start = md->VBS;
- vm->vblank_stop = md->VBE;
- vm->vsync_start = md->VSS;
- vm->vsync_stop = md->VSE;
- vm->vtotal = md->VT;
-
- return 0;
+ if (md->DEP == 4) {
+ vm->hblank_start = md->HBS * 32 / md->DEP;
+ vm->hblank_stop = md->HBE * 32 / md->DEP;
+ vm->hsync_start = md->HSS * 32 / md->DEP;
+ vm->hsync_stop = md->HSE * 32 / md->DEP;
+ vm->htotal = md->HT * 32 / md->DEP;
+ } else {
+ vm->hblank_start = md->HBS * md->FX;
+ vm->hblank_stop = md->HBE * md->FX;
+ vm->hsync_start = md->HSS * md->FX;
+ vm->hsync_stop = md->HSE * md->FX;
+ vm->htotal = md->HT * md->FX;
+ }
+ vm->vblank_start = md->VBS;
+ vm->vblank_stop = md->VBE;
+ vm->vsync_start = md->VSS;
+ vm->vsync_stop = md->VSE;
+ vm->vtotal = md->VT;
+
+ return (0);
}
static int
rt_setvmode (gp, mode, txtonly)
- struct grf_softc *gp;
- unsigned mode;
- int txtonly;
+ struct grf_softc *gp;
+ unsigned mode;
+ int txtonly;
{
- int error;
+ int error;
- if (!mode || mode > retina_mon_max)
- return EINVAL;
+ if (!mode || mode > retina_mon_max)
+ return (EINVAL);
- if (txtonly && monitor_defs[mode-1].DEP == 8)
- return EINVAL;
+ if (txtonly && monitor_defs[mode-1].DEP == 8)
+ return (EINVAL);
- current_mon = monitor_defs + (mode - 1);
+ current_mon = monitor_defs + (mode - 1);
- error = rt_load_mon (gp, current_mon) ? 0 : EINVAL;
+ error = rt_load_mon (gp, current_mon) ? 0 : EINVAL;
- return error;
+ return (error);
}
@@ -992,51 +993,50 @@ rt_mode(gp, cmd, arg, a2, a3)
u_long a2;
int a3;
{
- /* implement these later... */
+ /* implement these later... */
- switch (cmd)
- {
- case GM_GRFON:
- rt_setvmode (gp, retina_default_gfx + 1, 0);
- return 0;
+ switch (cmd) {
+ case GM_GRFON:
+ rt_setvmode (gp, retina_default_gfx + 1, 0);
+ return (0);
- case GM_GRFOFF:
- rt_setvmode (gp, retina_default_mon + 1, 0);
- return 0;
+ case GM_GRFOFF:
+ rt_setvmode (gp, retina_default_mon + 1, 0);
+ return (0);
- case GM_GRFCONFIG:
- return 0;
+ case GM_GRFCONFIG:
+ return (0);
- case GM_GRFGETVMODE:
- return rt_getvmode (gp, (struct grfvideo_mode *) arg);
+ case GM_GRFGETVMODE:
+ return (rt_getvmode (gp, (struct grfvideo_mode *) arg));
- case GM_GRFSETVMODE:
- return rt_setvmode (gp, *(unsigned *) arg, 1);
+ case GM_GRFSETVMODE:
+ return (rt_setvmode (gp, *(unsigned *) arg, 1));
- case GM_GRFGETNUMVM:
- *(int *)arg = retina_mon_max;
- return 0;
+ case GM_GRFGETNUMVM:
+ *(int *)arg = retina_mon_max;
+ return (0);
#ifdef BANKEDDEVPAGER
- case GM_GRFGETBANK:
- *(int *)arg = rt_getbank (gp, a2, a3);
- return 0;
+ case GM_GRFGETBANK:
+ *(int *)arg = rt_getbank (gp, a2, a3);
+ return (0);
- case GM_GRFGETCURBANK:
- *(int *)arg = rt_getcurbank (gp);
- return 0;
+ case GM_GRFGETCURBANK:
+ *(int *)arg = rt_getcurbank (gp);
+ return (0);
- case GM_GRFSETBANK:
- return rt_setbank (gp, arg);
+ case GM_GRFSETBANK:
+ return (rt_setbank (gp, arg));
#endif
- case GM_GRFIOCTL:
- return rt_ioctl (gp, a2, arg);
+ case GM_GRFIOCTL:
+ return (rt_ioctl (gp, a2, arg));
- default:
- break;
- }
-
- return EINVAL;
+ default:
+ break;
+ }
+
+ return (EINVAL);
}
int
@@ -1045,34 +1045,36 @@ rt_ioctl (gp, cmd, data)
u_long cmd;
void *data;
{
- switch (cmd)
- {
- case GRFIOCGSPRITEPOS:
- return rt_getspritepos (gp, (struct grf_position *) data);
+ switch (cmd) {
+ case GRFIOCGSPRITEPOS:
+ return (rt_getspritepos (gp, (struct grf_position *) data));
- case GRFIOCSSPRITEPOS:
- return rt_setspritepos (gp, (struct grf_position *) data);
+ case GRFIOCSSPRITEPOS:
+ return (rt_setspritepos (gp, (struct grf_position *) data));
- case GRFIOCSSPRITEINF:
- return rt_setspriteinfo (gp, (struct grf_spriteinfo *) data);
+ case GRFIOCSSPRITEINF:
+ return (rt_setspriteinfo (gp, (struct grf_spriteinfo *) data));
- case GRFIOCGSPRITEINF:
- return rt_getspriteinfo (gp, (struct grf_spriteinfo *) data);
+ case GRFIOCGSPRITEINF:
+ return (rt_getspriteinfo (gp, (struct grf_spriteinfo *) data));
- case GRFIOCGSPRITEMAX:
- return rt_getspritemax (gp, (struct grf_position *) data);
+ case GRFIOCGSPRITEMAX:
+ return (rt_getspritemax (gp, (struct grf_position *) data));
- case GRFIOCGETCMAP:
- return rt_getcmap (gp, (struct grf_colormap *) data);
+ case GRFIOCGETCMAP:
+ return (rt_getcmap (gp, (struct grf_colormap *) data));
- case GRFIOCPUTCMAP:
- return rt_putcmap (gp, (struct grf_colormap *) data);
+ case GRFIOCPUTCMAP:
+ return (rt_putcmap (gp, (struct grf_colormap *) data));
- case GRFIOCBITBLT:
- return rt_bitblt (gp, (struct grf_bitblt *) data);
- }
+ case GRFIOCBITBLT:
+ return (rt_bitblt (gp, (struct grf_bitblt *) data));
+
+ case GRFIOCBLANK:
+ return (rt_blank(gp, (int *)data));
+ }
- return EINVAL;
+ return (EINVAL);
}
#ifdef BANKEDDEVPAGER
@@ -1082,293 +1084,293 @@ rt_ioctl (gp, cmd, data)
int
rt_getbank (gp, offs, prot)
- struct grf_softc *gp;
- u_long offs;
- int prot;
+ struct grf_softc *gp;
+ u_long offs;
+ int prot;
{
- /* XXX */
- if (offs < 0 || offs >= 4*1024*1024)
- return -1;
- else
- return offs >> 16;
+ /* XXX */
+ if (offs < 0 || offs >= 4*1024*1024)
+ return (-1);
+ else
+ return (offs >> 16);
}
+
int
rt_getcurbank (gp)
- struct grf_softc *gp;
+ struct grf_softc *gp;
{
- struct grfinfo *gi = &gp->g_display;
- volatile unsigned char *ba;
- int bank;
+ struct grfinfo *gi = &gp->g_display;
+ volatile unsigned char *ba;
+ int bank;
- ba = gp->g_regkva;
- bank = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO) | (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8);
+ ba = gp->g_regkva;
+ bank = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO) |
+ (RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI) << 8);
- /* bank register is multiple of 64 byte, make this multiple of 64k */
- bank >>= 10;
- return bank;
+ /* bank register is multiple of 64 byte, make this multiple of 64k */
+ bank >>= 10;
+ return (bank);
}
+
int
rt_setbank (gp, bank)
- struct grf_softc *gp;
- int bank;
+ struct grf_softc *gp;
+ int bank;
{
- volatile unsigned char *ba;
+ volatile unsigned char *ba;
- ba = gp->g_regkva;
- /* bank register is multiple of 64 byte, make this multiple of 64k */
- bank <<= 10;
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
- bank >>= 8;
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
+ ba = gp->g_regkva;
+ /* bank register is multiple of 64 byte, make this multiple of 64k */
+ bank <<= 10;
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, (unsigned char) bank);
+ bank >>= 8;
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, (unsigned char) bank);
- return 0;
+ return (0);
}
-#endif
+#endif /* BANKEDDEVPAGER */
+
int
rt_getcmap (gfp, cmap)
- struct grf_softc *gfp;
- struct grf_colormap *cmap;
+ struct grf_softc *gfp;
+ struct grf_colormap *cmap;
{
- volatile unsigned char *ba;
- u_char red[256], green[256], blue[256], *rp, *gp, *bp;
- short x;
- int error;
-
- if (cmap->count == 0 || cmap->index >= 256)
- return 0;
-
- if (cmap->index + cmap->count > 256)
- cmap->count = 256 - cmap->index;
-
- ba = gfp->g_regkva;
- /* first read colors out of the chip, then copyout to userspace */
- vgaw (ba, VDAC_REG_SELECT, cmap->index);
- x = cmap->count - 1;
- rp = red + cmap->index;
- gp = green + cmap->index;
- bp = blue + cmap->index;
- do
- {
- *rp++ = vgar (ba, VDAC_REG_DATA);
- *gp++ = vgar (ba, VDAC_REG_DATA);
- *bp++ = vgar (ba, VDAC_REG_DATA);
- }
- while (x--);
+ volatile unsigned char *ba;
+ u_char red[256], green[256], blue[256], *rp, *gp, *bp;
+ short x;
+ int error;
+
+ if (cmap->count == 0 || cmap->index >= 256)
+ return (0);
+
+ if (cmap->index + cmap->count > 256)
+ cmap->count = 256 - cmap->index;
+
+ ba = gfp->g_regkva;
+ /* first read colors out of the chip, then copyout to userspace */
+ vgaw (ba, VDAC_REG_SELECT, cmap->index);
+ x = cmap->count - 1;
+ rp = red + cmap->index;
+ gp = green + cmap->index;
+ bp = blue + cmap->index;
+ do {
+ *rp++ = vgar (ba, VDAC_REG_DATA);
+ *gp++ = vgar (ba, VDAC_REG_DATA);
+ *bp++ = vgar (ba, VDAC_REG_DATA);
+ }
+ while (x--);
- if (!(error = copyout (red + cmap->index, cmap->red, cmap->count))
- && !(error = copyout (green + cmap->index, cmap->green, cmap->count))
- && !(error = copyout (blue + cmap->index, cmap->blue, cmap->count)))
- return 0;
+ if (!(error = copyout (red + cmap->index, cmap->red, cmap->count))
+ && !(error = copyout (green + cmap->index, cmap->green, cmap->count))
+ && !(error = copyout (blue + cmap->index, cmap->blue, cmap->count)))
+ return (0);
- return error;
+ return (error);
}
int
rt_putcmap (gfp, cmap)
- struct grf_softc *gfp;
- struct grf_colormap *cmap;
+ struct grf_softc *gfp;
+ struct grf_colormap *cmap;
{
- volatile unsigned char *ba;
- u_char red[256], green[256], blue[256], *rp, *gp, *bp;
- short x;
- int error;
+ volatile unsigned char *ba;
+ u_char red[256], green[256], blue[256], *rp, *gp, *bp;
+ short x;
+ int error;
- if (cmap->count == 0 || cmap->index >= 256)
- return 0;
+ if (cmap->count == 0 || cmap->index >= 256)
+ return 0;
- if (cmap->index + cmap->count > 256)
- cmap->count = 256 - cmap->index;
+ if (cmap->index + cmap->count > 256)
+ cmap->count = 256 - cmap->index;
- /* first copy the colors into kernelspace */
- if (!(error = copyin (cmap->red, red + cmap->index, cmap->count))
- && !(error = copyin (cmap->green, green + cmap->index, cmap->count))
- && !(error = copyin (cmap->blue, blue + cmap->index, cmap->count)))
- {
- ba = gfp->g_regkva;
- vgaw (ba, VDAC_REG_SELECT, cmap->index);
- x = cmap->count - 1;
- rp = red + cmap->index;
- gp = green + cmap->index;
- bp = blue + cmap->index;
- do
+ /* first copy the colors into kernelspace */
+ if (!(error = copyin (cmap->red, red + cmap->index, cmap->count))
+ && !(error = copyin (cmap->green, green + cmap->index, cmap->count))
+ && !(error = copyin (cmap->blue, blue + cmap->index, cmap->count)))
{
- vgaw (ba, VDAC_REG_DATA, *rp++);
- vgaw (ba, VDAC_REG_DATA, *gp++);
- vgaw (ba, VDAC_REG_DATA, *bp++);
- }
- while (x--);
- return 0;
- }
- else
- return error;
+ ba = gfp->g_regkva;
+ vgaw (ba, VDAC_REG_SELECT, cmap->index);
+ x = cmap->count - 1;
+ rp = red + cmap->index;
+ gp = green + cmap->index;
+ bp = blue + cmap->index;
+ do {
+ vgaw (ba, VDAC_REG_DATA, *rp++);
+ vgaw (ba, VDAC_REG_DATA, *gp++);
+ vgaw (ba, VDAC_REG_DATA, *bp++);
+ }
+ while (x--);
+ return (0);
+ } else
+ return (error);
}
+
int
rt_getspritepos (gp, pos)
- struct grf_softc *gp;
- struct grf_position *pos;
+ struct grf_softc *gp;
+ struct grf_position *pos;
{
- volatile unsigned char *ba;
-
- ba = gp->g_regkva;
- pos->x = vgar (ba, SEQ_ID_CURSOR_X_LOC_LO) | (vgar (ba, SEQ_ID_CURSOR_X_LOC_HI) << 8);
- pos->y = vgar (ba, SEQ_ID_CURSOR_Y_LOC_LO) | (vgar (ba, SEQ_ID_CURSOR_Y_LOC_HI) << 8);
- return 0;
+ volatile unsigned char *ba;
+
+ ba = gp->g_regkva;
+ pos->x = vgar (ba, SEQ_ID_CURSOR_X_LOC_LO) |
+ (vgar (ba, SEQ_ID_CURSOR_X_LOC_HI) << 8);
+ pos->y = vgar (ba, SEQ_ID_CURSOR_Y_LOC_LO) |
+ (vgar (ba, SEQ_ID_CURSOR_Y_LOC_HI) << 8);
+ return (0);
}
int
rt_setspritepos (gp, pos)
- struct grf_softc *gp;
- struct grf_position *pos;
+ struct grf_softc *gp;
+ struct grf_position *pos;
{
- volatile unsigned char *ba;
-
- ba = gp->g_regkva;
- vgaw (ba, SEQ_ID_CURSOR_X_LOC_LO, pos->x & 0xff);
- vgaw (ba, SEQ_ID_CURSOR_X_LOC_HI, (pos->x >> 8) & 0x07);
- vgaw (ba, SEQ_ID_CURSOR_Y_LOC_LO, pos->y & 0xff);
- vgaw (ba, SEQ_ID_CURSOR_Y_LOC_HI, (pos->y >> 8) & 0x07);
- return 0;
+ volatile unsigned char *ba;
+
+ ba = gp->g_regkva;
+ vgaw (ba, SEQ_ID_CURSOR_X_LOC_LO, pos->x & 0xff);
+ vgaw (ba, SEQ_ID_CURSOR_X_LOC_HI, (pos->x >> 8) & 0x07);
+ vgaw (ba, SEQ_ID_CURSOR_Y_LOC_LO, pos->y & 0xff);
+ vgaw (ba, SEQ_ID_CURSOR_Y_LOC_HI, (pos->y >> 8) & 0x07);
+ return (0);
}
/* assume an at least 2M retina (XXX), sprite is last in memory.
- According to the bogus docs, the cursor can be at most 128 lines
- in height, and the x-hostspot can be placed at most at pos 31,
- this gives width of a long */
+ * According to the bogus docs, the cursor can be at most 128 lines
+ * in height, and the x-hostspot can be placed at most at pos 31,
+ * this gives width of a long
+ */
#define SPRITE_ADDR (2*1024*1024 - 128*4)
int
rt_getspriteinfo (gp, info)
- struct grf_softc *gp;
- struct grf_spriteinfo *info;
+ struct grf_softc *gp;
+ struct grf_spriteinfo *info;
{
- volatile caddr_t ba, fb;
+ volatile caddr_t ba, fb;
- ba = gp->g_regkva;
- fb = gp->g_fbkva;
- if (info->set & GRFSPRSET_ENABLE)
- info->enable = vgar (ba, SEQ_ID_CURSOR_CONTROL) & 0x01;
- if (info->set & GRFSPRSET_POS)
- rt_getspritepos (gp, &info->pos);
- if (info->set & GRFSPRSET_HOT)
- {
- info->hot.x = vgar (ba, SEQ_ID_CURSOR_X_INDEX) & 0x1f;
- info->hot.y = vgar (ba, SEQ_ID_CURSOR_Y_INDEX) & 0x7f;
- }
- if (info->set & GRFSPRSET_CMAP)
- {
- struct grf_colormap cmap;
- int index;
- cmap.index = 0;
- cmap.count = 256;
- rt_getcmap (gp, &cmap);
- index = vgar (ba, SEQ_ID_CURSOR_COLOR0);
- info->cmap.red[0] = cmap.red[index];
- info->cmap.green[0] = cmap.green[index];
- info->cmap.blue[0] = cmap.blue[index];
- index = vgar (ba, SEQ_ID_CURSOR_COLOR1);
- info->cmap.red[1] = cmap.red[index];
- info->cmap.green[1] = cmap.green[index];
- info->cmap.blue[1] = cmap.blue[index];
- }
- if (info->set & GRFSPRSET_SHAPE)
- {
- int saved_bank_lo = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO);
- int saved_bank_hi = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI);
- int last_bank = SPRITE_ADDR >> 6;
- int last_bank_lo = last_bank & 0xff;
- int last_bank_hi = last_bank >> 8;
- u_char mask;
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, last_bank_lo);
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, last_bank_hi);
- copyout (fb, info->image, 128*4);
- mask = RSeq (ba, SEQ_ID_CURSOR_PIXELMASK);
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, saved_bank_lo);
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, saved_bank_hi);
- copyout (&mask, info->mask, 1);
- info->size.x = 32; /* ??? */
- info->size.y = (RSeq (ba, SEQ_ID_CURSOR_CONTROL) & 6) << 4;
- }
+ ba = gp->g_regkva;
+ fb = gp->g_fbkva;
+ if (info->set & GRFSPRSET_ENABLE)
+ info->enable = vgar (ba, SEQ_ID_CURSOR_CONTROL) & 0x01;
+ if (info->set & GRFSPRSET_POS)
+ rt_getspritepos (gp, &info->pos);
+ if (info->set & GRFSPRSET_HOT) {
+ info->hot.x = vgar (ba, SEQ_ID_CURSOR_X_INDEX) & 0x1f;
+ info->hot.y = vgar (ba, SEQ_ID_CURSOR_Y_INDEX) & 0x7f;
+ }
+ if (info->set & GRFSPRSET_CMAP) {
+ struct grf_colormap cmap;
+ int index;
+ cmap.index = 0;
+ cmap.count = 256;
+ rt_getcmap (gp, &cmap);
+ index = vgar (ba, SEQ_ID_CURSOR_COLOR0);
+ info->cmap.red[0] = cmap.red[index];
+ info->cmap.green[0] = cmap.green[index];
+ info->cmap.blue[0] = cmap.blue[index];
+ index = vgar (ba, SEQ_ID_CURSOR_COLOR1);
+ info->cmap.red[1] = cmap.red[index];
+ info->cmap.green[1] = cmap.green[index];
+ info->cmap.blue[1] = cmap.blue[index];
+ }
+ if (info->set & GRFSPRSET_SHAPE) {
+ int saved_bank_lo = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO);
+ int saved_bank_hi = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI);
+ int last_bank = SPRITE_ADDR >> 6;
+ int last_bank_lo = last_bank & 0xff;
+ int last_bank_hi = last_bank >> 8;
+ u_char mask;
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, last_bank_lo);
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, last_bank_hi);
+ copyout (fb, info->image, 128*4);
+ mask = RSeq (ba, SEQ_ID_CURSOR_PIXELMASK);
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, saved_bank_lo);
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, saved_bank_hi);
+ copyout (&mask, info->mask, 1);
+ info->size.x = 32; /* ??? */
+ info->size.y = (RSeq (ba, SEQ_ID_CURSOR_CONTROL) & 6) << 4;
+ }
- return 0;
+ return (0);
}
+
int
rt_setspriteinfo (gp, info)
- struct grf_softc *gp;
- struct grf_spriteinfo *info;
+ struct grf_softc *gp;
+ struct grf_spriteinfo *info;
{
- volatile caddr_t ba, fb;
- u_char control;
+ volatile caddr_t ba, fb;
+ u_char control;
- ba = gp->g_regkva;
- fb = gp->g_fbkva;
- control = vgar (ba, SEQ_ID_CURSOR_CONTROL);
- if (info->set & GRFSPRSET_ENABLE)
- {
- if (info->enable)
- control |= 1;
- else
- control &= ~1;
- vgaw (ba, SEQ_ID_CURSOR_CONTROL, control);
- }
- if (info->set & GRFSPRSET_POS)
- rt_setspritepos (gp, &info->pos);
- if (info->set & GRFSPRSET_HOT)
- {
- vgaw (ba, SEQ_ID_CURSOR_X_INDEX, info->hot.x & 0x1f);
- vgaw (ba, SEQ_ID_CURSOR_Y_INDEX, info->hot.y & 0x7f);
- }
- if (info->set & GRFSPRSET_CMAP)
- {
- /* hey cheat a bit here.. XXX */
- vgaw (ba, SEQ_ID_CURSOR_COLOR0, 0);
- vgaw (ba, SEQ_ID_CURSOR_COLOR1, 1);
- }
- if (info->set & GRFSPRSET_SHAPE)
- {
- int saved_bank_lo = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO);
- int saved_bank_hi = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI);
- int last_bank = SPRITE_ADDR >> 6;
- int last_bank_lo = last_bank & 0xff;
- int last_bank_hi = last_bank >> 8;
- u_char mask;
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, last_bank_lo);
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, last_bank_hi);
- copyin (info->image, fb, 128*4);
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, saved_bank_lo);
- WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, saved_bank_hi);
- copyin (info->mask, &mask, 1);
- WSeq (ba, SEQ_ID_CURSOR_PIXELMASK, mask);
- /* info->size.x = 32; *//* ??? */
-
- info->size.y = (RSeq (ba, SEQ_ID_CURSOR_CONTROL) & 6) << 4;
- control = (control & ~6) | ((info->size.y >> 4) & 6);
- vgaw (ba, SEQ_ID_CURSOR_CONTROL, control);
-
- /* sick intel bull-addressing.. */
- WSeq (ba, SEQ_ID_CURSOR_STORE_LO, SPRITE_ADDR & 0x0f);
- WSeq (ba, SEQ_ID_CURSOR_STORE_HI, 0);
- WSeq (ba, SEQ_ID_CURSOR_ST_OFF_LO, (SPRITE_ADDR >> 4) & 0xff);
- WSeq (ba, SEQ_ID_CURSOR_ST_OFF_HI, ((SPRITE_ADDR >> 4) >> 8) & 0xff);
- }
+ ba = gp->g_regkva;
+ fb = gp->g_fbkva;
+ control = vgar (ba, SEQ_ID_CURSOR_CONTROL);
+ if (info->set & GRFSPRSET_ENABLE) {
+ if (info->enable)
+ control |= 1;
+ else
+ control &= ~1;
+ vgaw (ba, SEQ_ID_CURSOR_CONTROL, control);
+ }
+ if (info->set & GRFSPRSET_POS)
+ rt_setspritepos (gp, &info->pos);
+ if (info->set & GRFSPRSET_HOT) {
+ vgaw (ba, SEQ_ID_CURSOR_X_INDEX, info->hot.x & 0x1f);
+ vgaw (ba, SEQ_ID_CURSOR_Y_INDEX, info->hot.y & 0x7f);
+ }
+ if (info->set & GRFSPRSET_CMAP) {
+ /* hey cheat a bit here.. XXX */
+ vgaw (ba, SEQ_ID_CURSOR_COLOR0, 0);
+ vgaw (ba, SEQ_ID_CURSOR_COLOR1, 1);
+ }
+ if (info->set & GRFSPRSET_SHAPE) {
+ int saved_bank_lo = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO);
+ int saved_bank_hi = RSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI);
+ int last_bank = SPRITE_ADDR >> 6;
+ int last_bank_lo = last_bank & 0xff;
+ int last_bank_hi = last_bank >> 8;
+ u_char mask;
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, last_bank_lo);
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, last_bank_hi);
+ copyin (info->image, fb, 128*4);
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_LO, saved_bank_lo);
+ WSeq (ba, SEQ_ID_PRIM_HOST_OFF_HI, saved_bank_hi);
+ copyin (info->mask, &mask, 1);
+ WSeq (ba, SEQ_ID_CURSOR_PIXELMASK, mask);
+ /* info->size.x = 32; *//* ??? */
+
+ info->size.y = (RSeq (ba, SEQ_ID_CURSOR_CONTROL) & 6) << 4;
+ control = (control & ~6) | ((info->size.y >> 4) & 6);
+ vgaw (ba, SEQ_ID_CURSOR_CONTROL, control);
+
+ /* sick intel bull-addressing.. */
+ WSeq (ba, SEQ_ID_CURSOR_STORE_LO, SPRITE_ADDR & 0x0f);
+ WSeq (ba, SEQ_ID_CURSOR_STORE_HI, 0);
+ WSeq (ba, SEQ_ID_CURSOR_ST_OFF_LO, (SPRITE_ADDR >> 4) & 0xff);
+ WSeq (ba, SEQ_ID_CURSOR_ST_OFF_HI, ((SPRITE_ADDR >> 4) >> 8) & 0xff);
+ }
- return 0;
+ return (0);
}
+
int
rt_getspritemax (gp, pos)
- struct grf_softc *gp;
- struct grf_position *pos;
+ struct grf_softc *gp;
+ struct grf_position *pos;
{
- pos->x = 32;
- pos->y = 128;
+ pos->x = 32;
+ pos->y = 128;
- return 0;
+ return (0);
}
@@ -1378,11 +1380,10 @@ rt_getspritemax (gp, pos)
int
rt_bitblt (gp, bb)
- struct grf_softc *gp;
- struct grf_bitblt *bb;
+ struct grf_softc *gp;
+ struct grf_bitblt *bb;
{
- return EINVAL;
-
+ return (EINVAL);
#if 0
volatile caddr_t ba, fb;
@@ -1454,4 +1455,19 @@ rt_bitblt (gp, bb)
}
+int
+rt_blank(gp, on)
+ struct grf_softc *gp;
+ int *on;
+{
+ int r;
+
+ r = RSeq(gp->g_regkva, SEQ_ID_CLOCKING_MODE);
+ r &= 0xdf; /* set Bit 5 to 0 */
+
+ WSeq(gp->g_regkva, SEQ_ID_CLOCKING_MODE, r | (*on ? 0x00 : 0x20));
+
+ return(0);
+}
+
#endif /* NGRF */