summaryrefslogtreecommitdiff
path: root/sys/arch/amiga/dev/grf_et.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amiga/dev/grf_et.c')
-rw-r--r--sys/arch/amiga/dev/grf_et.c246
1 files changed, 103 insertions, 143 deletions
diff --git a/sys/arch/amiga/dev/grf_et.c b/sys/arch/amiga/dev/grf_et.c
index 411a974b915..242c6762c31 100644
--- a/sys/arch/amiga/dev/grf_et.c
+++ b/sys/arch/amiga/dev/grf_et.c
@@ -1,4 +1,4 @@
-/* $NetBSD: grf_et.c,v 1.1 1996/05/19 21:05:32 veego Exp $ */
+/* $NetBSD: grf_et.c,v 1.1.4.2 1996/06/04 09:01:21 is Exp $ */
/*
* Copyright (c) 1996 Tobias Abt
@@ -71,39 +71,40 @@
#include <amiga/dev/grf_etreg.h>
#include <amiga/dev/zbusvar.h>
-int et_mondefok __P((struct grfvideo_mode * gv));
-void et_boardinit __P((struct grf_softc * gp));
-static void et_CompFQ __P((u_int fq, u_char * num, u_char * denom));
-int et_getvmode __P((struct grf_softc * gp, struct grfvideo_mode * vm));
-int et_setvmode __P((struct grf_softc * gp, unsigned int mode));
-int et_toggle __P((struct grf_softc * gp, unsigned short));
-int et_getcmap __P((struct grf_softc * gfp, struct grf_colormap * cmap));
-int et_putcmap __P((struct grf_softc * gfp, struct grf_colormap * cmap));
+int et_mondefok __P((struct grfvideo_mode *gv));
+void et_boardinit __P((struct grf_softc *gp));
+static void et_CompFQ __P((u_int fq, u_char *num, u_char *denom));
+int et_getvmode __P((struct grf_softc *gp, struct grfvideo_mode *vm));
+int et_setvmode __P((struct grf_softc *gp, unsigned int mode));
+int et_toggle __P((struct grf_softc *gp, unsigned short));
+int et_getcmap __P((struct grf_softc *gfp, struct grf_colormap *cmap));
+int et_putcmap __P((struct grf_softc *gfp, struct grf_colormap *cmap));
#ifndef TSENGCONSOLE
-void et_off __P((struct grf_softc * gp));
+void et_off __P((struct grf_softc *gp));
#endif
-void et_inittextmode __P((struct grf_softc * gp));
-int et_ioctl __P((register struct grf_softc * gp, u_long cmd, void *data));
-int et_getmousepos __P((struct grf_softc * gp, struct grf_position * data));
+void et_inittextmode __P((struct grf_softc *gp));
+int et_ioctl __P((register struct grf_softc *gp, u_long cmd, void *data));
+int et_getmousepos __P((struct grf_softc *gp, struct grf_position *data));
void et_writesprpos __P((volatile char *ba, short x, short y));
-#ifdef notyet
-void et_writeshifted __P((unsigned char *to, char shiftx, char shifty));
-#endif
-int et_setmousepos __P((struct grf_softc * gp, struct grf_position * data));
-static int et_setspriteinfo __P((struct grf_softc * gp, struct grf_spriteinfo * data));
-int et_getspriteinfo __P((struct grf_softc * gp, struct grf_spriteinfo * data));
-static int et_getspritemax __P((struct grf_softc * gp, struct grf_position * data));
-int et_setmonitor __P((struct grf_softc * gp, struct grfvideo_mode * gv));
-int et_blank __P((struct grf_softc * gp, int * on));
-static int et_getControllerType __P((struct grf_softc * gp));
-static int et_getDACType __P((struct grf_softc * gp));
+int et_setmousepos __P((struct grf_softc *gp, struct grf_position *data));
+static int et_setspriteinfo __P((struct grf_softc *gp,
+ struct grf_spriteinfo *data));
+int et_getspriteinfo __P((struct grf_softc *gp,
+ struct grf_spriteinfo *data));
+static int et_getspritemax __P((struct grf_softc *gp,
+ struct grf_position *data));
+int et_setmonitor __P((struct grf_softc *gp, struct grfvideo_mode *gv));
+int et_blank __P((struct grf_softc *gp, int *on));
+static int et_getControllerType __P((struct grf_softc *gp));
+static int et_getDACType __P((struct grf_softc *gp));
int grfetmatch __P((struct device *, void *, void *));
void grfetattach __P((struct device *, struct device *, void *));
int grfetprint __P((void *, char *));
void et_memset __P((unsigned char *d, unsigned char c, int l));
-/* Graphics display definitions.
+/*
+ * Graphics display definitions.
* These are filled by 'grfconfig' using GRFIOCSETMON.
*/
#define monitor_def_max 8
@@ -133,30 +134,6 @@ struct grfettext_mode etconsole_mode = {
8, TSENGFONTY, 640 / 8, 480 / TSENGFONTY, TSENGFONT, 32, 255
};
-/* some modes
-# 640x480 256colors 41kHz 79Hz active
-x 31500000 640 480 8 640 752 672 768 728 487 505 488 490 512
-# 31500000 640 480 8 80 94 84 96 91 487 505 488 490 512
-# 640x512 256colors 42kHz 76Hz active
-x 32500000 640 512 8 640 760 664 760 736 519 536 520 522 543
-# 32500000 640 512 8 80 95 83 95 92 519 536 520 522 543
-# 720x540 256colors 43kHz 74Hz active
-x 37500000 720 540 8 720 856 744 840 832 547 565 548 550 572
-# 37500000 720 540 8 90 107 93 105 104 547 565 548 550 572
-# 800x600 256colors 48kHz 73Hz active
-x 50350000 800 600 8 792 1048 864 960 1016 599 648 615 617 647
-# 50350000 800 600 8 99 131 108 120 127 599 648 615 617 647
-# 912x684 256colors 57kHz 78Hz active
-x 65000000 912 684 8 904 1136 944 1040 1104 683 725 693 695 724
-# 65000000 912 684 8 113 142 118 130 138 683 725 693 695 724
-# 1024x768 256colors 61kHz 75Hz active
-x 80000000 1024 768 8 1024 1288 1072 1168 1264 775 806 780 782 813
-# 80000000 1024 768 8 128 161 134 146 158 775 806 780 782 813
-# 1120x832 256colors 56kHz 64Hz active
-x 80000000 1120 832 8 1120 1424 1152 1248 1400 839 848 833 835 855
-# 80000000 1120 832 8 140 178 144 156 175 839 848 833 835 855
-*/
-
/* Console colors */
unsigned char etconscolors[3][3] = { /* background, foreground, hilite */
{0, 0x40, 0x50}, {152, 152, 152}, {255, 255, 255}
@@ -171,7 +148,8 @@ unsigned char pass_toggle; /* passthru status tracker */
unsigned char Merlin_switch = 0;
-/* because all Tseng-boards have 2 configdev entries, one for
+/*
+ * Because all Tseng-boards have 2 configdev entries, one for
* framebuffer mem and the other for regs, we have to hold onto
* the pointers globally until we match on both. This and 'ettype'
* are the primary obsticles to multiple board support, but if you
@@ -200,8 +178,8 @@ struct cfattach grfet_ca = {
struct cfdriver grfet_cd = {
NULL, "grfet", DV_DULL, NULL, 0
};
-static struct cfdata *cfdata;
+static struct cfdata *cfdata;
int
grfetmatch(pdp, match, auxp)
@@ -243,13 +221,6 @@ grfetmatch(pdp, match, auxp)
return (0);
regprod = 4;
fbprod = 3;
- /*
- * This card works only in ZorroII mode.
- * ZorroIII needs different initialisations,
- * which will be implemented later.
- */
- if iszthreepa(zap->pa)
- return (0);
break;
default:
return (0);
@@ -264,13 +235,13 @@ grfetmatch(pdp, match, auxp)
/* Configure either registers or framebuffer in any order */
/* as said before, oMniBus does not support ProdID */
if (ettype == OMNIBUS) {
- if (zap->size == 64 * 1024) {
+ if (zap->size == 64*1024) {
/* register area */
- et_regaddr = zap->va;
+ et_regaddr=zap->va;
} else {
/* memory area */
- et_fbaddr = zap->va;
- et_fbsize = zap->size;
+ et_fbaddr=zap->va;
+ et_fbsize=zap->size;
}
} else {
if (zap->prodid == regprod) {
@@ -313,13 +284,6 @@ grfetattach(pdp, dp, auxp)
if (!et_regaddr || !et_fbaddr)
return;
- if (zap->manid == MERLIN && iszthreepa(zap->pa)) {
- printf("grfet: WARNING: It is not possible to use the Merlin in ZorroIII mode.\n");
- printf("grfet: Switch the Jumper to use it in ZorroII mode.\n");
- printf("grfet unattached!!\n");
- return;
- }
-
/* do all that messy console/grf stuff */
if (dp == NULL)
gp = &congrf;
@@ -431,7 +395,7 @@ et_boardinit(gp)
vgaw(ba, MERLIN_SWITCH_REG, 0);
delay(20000);
vgaw(ba, MERLIN_VDAC_DATA, 1);
-
+
vgaw(ba, MERLIN_VDAC_INDEX, 0x00);
vgaw(ba, MERLIN_VDAC_SPRITE, 0xff);
vgaw(ba, MERLIN_VDAC_INDEX, 0x01);
@@ -444,7 +408,7 @@ et_boardinit(gp)
vgaw(ba, MERLIN_VDAC_DATA, 0);
}
-
+
/* setup initial unchanging parameters */
vgaw(ba, GREG_HERCULESCOMPAT, 0x03);
@@ -470,15 +434,19 @@ et_boardinit(gp)
WCrt(ba, CRT_ID_UNDERLINE_LOC, 0x07);
WCrt(ba, CRT_ID_MODE_CONTROL, 0xa3); /* c3 */
WCrt(ba, CRT_ID_LINE_COMPARE, 0xff); /* ff */
-/*
- WCrt(ba, CRT_ID_EXT_DISP_CNTL, 0x22);
-*/
/* ET4000 special */
WCrt(ba, CRT_ID_RASCAS_CONFIG, 0x28);
WCrt(ba, CTR_ID_EXT_START, 0x00);
WCrt(ba, CRT_ID_6845_COMPAT, 0x08);
WCrt(ba, CRT_ID_VIDEO_CONFIG1, 0xd3);
- WCrt(ba, CRT_ID_VIDEO_CONFIG2, 0x0f);
+ WCrt(ba, CRT_ID_VIDEO_CONFIG2, 0x0f); /* assume ZorroII first */
+
+ if (iszthreepa(ba)) {
+ if (((vgar(ba, GREG_FEATURE_CONTROL_R) & 12) |
+ (vgar(ba, GREG_STATUS0_R) & 0x60)) == 0x24 )
+ WCrt(ba, CRT_ID_VIDEO_CONFIG2, 0x07); /* ZorroIII */
+ }
+
WCrt(ba, CRT_ID_HOR_OVERFLOW, 0x00);
WGfx(ba, GCT_ID_SET_RESET, 0x00);
@@ -537,16 +505,16 @@ et_boardinit(gp)
/* card spezific initialisations */
switch(ettype) {
case OMNIBUS:
- etctype = et_getControllerType(gp);
- etdtype = et_getDACType(gp);
+ etctype=et_getControllerType(gp);
+ etdtype=et_getDACType(gp);
break;
case MERLIN:
- etctype = ETW32;
- etdtype = MERLINDAC;
+ etctype=ETW32;
+ etdtype=MERLINDAC;
break;
case DOMINO:
- etctype = ET4000;
- etdtype = SIERRA11483;
+ etctype=ET4000;
+ etdtype=SIERRA11483;
break;
}
}
@@ -613,9 +581,6 @@ et_off(gp)
{
char *ba = gp->g_regkva;
- /* we'll put the pass-through on for cc ite and set Full Bandwidth bit
- * on just in case it didn't work...but then it doesn't matter does
- * it? =) */
RegOnpass(ba);
WSeq(ba, SEQ_ID_CLOCKING_MODE, 0x21);
}
@@ -627,7 +592,7 @@ et_blank(gp, on)
struct grf_softc *gp;
int *on;
{
- WSeq(gp->g_regkva, SEQ_ID_CLOCKING_MODE, *on ? 0x21 : 0x01);
+ WSeq(gp->g_regkva, SEQ_ID_CLOCKING_MODE, *on ? 0x01 : 0x21);
return(0);
}
@@ -751,27 +716,12 @@ et_writesprpos(ba, x, y)
}
-#ifdef notyet
-void
-et_writeshifted(to, shiftx, shifty)
- unsigned char *to;
- char shiftx;
- char shifty;
-{
-}
-#endif
-
-
int
et_setmousepos(gp, data)
struct grf_softc *gp;
struct grf_position *data;
{
volatile char *ba = gp->g_regkva;
-#if 0
- volatile char *fb = gp->g_fbkva;
- volatile char *sprite = fb + (et_fbsize - 1024);
-#endif
short rx, ry, prx, pry;
/* no movement */
@@ -788,11 +738,6 @@ et_setmousepos(gp, data)
* ripped out optimization (not extremely worthwhile,
* and kind of buggy anyhow).
*/
-#ifdef notyet
- if (rx < 0 || ry < 0 || prx < 0 || pry < 0) {
- et_writeshifted(sprite, rx < 0 ? -rx : 0, ry < 0 ? -ry : 0);
- }
-#endif
/* do movement, save position */
et_writesprpos(ba, rx < 0 ? 0 : rx, ry < 0 ? 0 : ry);
@@ -919,10 +864,11 @@ et_getcmap(gfp, cmap)
break;
}
- 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);
+ error = copyout(red + cmap->index, cmap->red, cmap->count);
+ if (!error)
+ error = copyout(green + cmap->index, cmap->green, cmap->count);
+ if (!error)
+ error = copyout(blue + cmap->index, cmap->blue, cmap->count);
return (error);
}
@@ -945,38 +891,42 @@ et_putcmap(gfp, cmap)
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;
- x = cmap->count - 1;
-
- rp = red + cmap->index;
- gp = green + cmap->index;
- bp = blue + cmap->index;
-
- switch(ettype){
- case MERLIN:
- vgaw(ba, MERLIN_VDAC_INDEX, cmap->index);
- do {
- vgaw(ba, MERLIN_VDAC_COLORS, *rp++);
- vgaw(ba, MERLIN_VDAC_COLORS, *gp++);
- vgaw(ba, MERLIN_VDAC_COLORS, *bp++);
- } while (x-- > 0);
- break;
- default:
- vgaw(ba, VDAC_ADDRESS_W, cmap->index);
- do {
- vgaw(ba, VDAC_DATA, *rp++ >> etcmap_shift);
- vgaw(ba, VDAC_DATA, *gp++ >> etcmap_shift);
- vgaw(ba, VDAC_DATA, *bp++ >> etcmap_shift);
- } while (x-- > 0);
- break;
- }
+ if ((error = copyin(cmap->red, red + cmap->index, cmap->count)))
+ return (error);
- return (0);
- } else
+ if ((error = copyin(cmap->green, green + cmap->index, cmap->count)))
+ return (error);
+
+ if ((error = copyin(cmap->blue, blue + cmap->index, cmap->count)))
return (error);
+
+ ba = gfp->g_regkva;
+ x = cmap->count - 1;
+
+ rp = red + cmap->index;
+ gp = green + cmap->index;
+ bp = blue + cmap->index;
+
+ switch(ettype){
+ case MERLIN:
+ vgaw(ba, MERLIN_VDAC_INDEX, cmap->index);
+ do {
+ vgaw(ba, MERLIN_VDAC_COLORS, *rp++);
+ vgaw(ba, MERLIN_VDAC_COLORS, *gp++);
+ vgaw(ba, MERLIN_VDAC_COLORS, *bp++);
+ } while (x-- > 0);
+ break;
+ default:
+ vgaw(ba, VDAC_ADDRESS_W, cmap->index);
+ do {
+ vgaw(ba, VDAC_DATA, *rp++ >> etcmap_shift);
+ vgaw(ba, VDAC_DATA, *gp++ >> etcmap_shift);
+ vgaw(ba, VDAC_DATA, *bp++ >> etcmap_shift);
+ } while (x-- > 0);
+ break;
+ }
+
+ return (0);
}
@@ -1387,8 +1337,10 @@ et_inittextmode(gp)
unsigned short z;
- /* load text font into beginning of display memory. Each character
- * cell is 32 bytes long (enough for 4 planes) */
+ /*
+ * load text font into beginning of display memory. Each character
+ * cell is 32 bytes long (enough for 4 planes)
+ */
SetTextPlane(ba, 0x02);
et_memset(fb, 0, 256 * 32);
@@ -1522,7 +1474,11 @@ et_getDACType(gp)
/* check for MUSIC DAC */
- if(vgar(ba, HDR)); if(vgar(ba, HDR)); if(vgar(ba, HDR)); if(vgar(ba, HDR));
+ if(vgar(ba, HDR)); /* We MUST do 4 HW reads to switch into command mode */
+ if(vgar(ba, HDR));
+ if(vgar(ba, HDR));
+ if(vgar(ba, HDR));
+
vgaw(ba, VDAC_COMMAND, 0x02); /* set some strange MUSIC mode (???) */
vgaw(ba, VDAC_XINDEX, 0x01);
@@ -1534,7 +1490,11 @@ et_getDACType(gp)
return(MUSICDAC);
}
- /* nothing else found, so let us pretend it is a stupid Sierra SC 11483 */
+ /*
+ * nothing else found, so let us pretend it is a stupid
+ * Sierra SC 11483
+ */
+
/* shift color values by 2 */
etcmap_shift = 2;