try for 1/8 bpp support in rom/drvr

This commit is contained in:
Romain Dolbeau 2022-04-18 11:51:07 +02:00
parent b5a718a2b5
commit 8a3e58a75c
8 changed files with 241 additions and 66 deletions

View File

@ -5,7 +5,8 @@ NuBusFPGAID = 0xC0
defMinorBase = 0 /* beginning */
defMinorLength = 0x200000 /* 2048 KiB */
Pages8s = 1 /* no idea */
Pages8s = 1
Pages1s = 1
defmBounds_Ls = 0
defmBounds_Ts = 0
@ -13,7 +14,10 @@ defmBounds_Rs = HRES
defmBounds_Bs = VRES
defScrnRow = HRES
/* row bytes */
RB8s = HRES
RB1s = HRES/8
DrHwNuBusFPGA = 0xBEEF /* placeholder */

View File

@ -57,6 +57,8 @@ struct NuBusFPGADriverGlobals {
AuxDCEPtr dce; // unused
SlotIntQElement *siqel;
//unsigned char shadowClut[768];
unsigned short curMode; /* mode include depth in <= 7.1 ROM-based mode */
unsigned short curDepth; /* depth separate from mode in >= 7.5 driver-based mode */
char gray;
char irqen;
struct MyGammaTbl gamma;

View File

@ -104,8 +104,8 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
short ret = -1;
char busMode = 1;
/* write_reg(dce, GOBOFB_DEBUG, 0xBEEF0001); */
/* write_reg(dce, GOBOFB_DEBUG, pb->csCode); */
write_reg(dce, GOBOFB_DEBUG, 0xBEEF0001);
write_reg(dce, GOBOFB_DEBUG, pb->csCode);
#if 1
switch (pb->csCode)
{
@ -115,7 +115,9 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscReset:
{
VDPageInfo *vPInfo = (VDPageInfo *)*(long *)pb->csParam;
vPInfo->csMode = eightBitMode;
dStore->curMode = firstVidMode;
dStore->curDepth = kDepthMode1;
vPInfo->csMode = firstVidMode;
vPInfo->csPage = 0;
vPInfo->csBaseAddr = 0;
ret = noErr;
@ -125,13 +127,27 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
asm volatile(".word 0xfe16\n");
ret = noErr;
break;
case cscSetMode:
case cscSetMode: /* 2 */
{
VDPageInfo *vPInfo = (VDPageInfo *)*(long *)pb->csParam;
if (vPInfo->csMode != eightBitMode)
return paramErr;
if (vPInfo->csPage != 0)
return paramErr;
switch (vPInfo->csMode) {
case firstVidMode:
dStore->curMode = firstVidMode;
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_8BIT);
SwapMMUMode ( &busMode );
break;
case secondVidMode:
dStore->curMode = secondVidMode;
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_1BIT);
SwapMMUMode ( &busMode );
break;
default:
return paramErr;
}
vPInfo->csBaseAddr = 0;
ret = noErr;
}
@ -232,6 +248,58 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
VDPageInfo *vPInfo = (VDPageInfo *)*(long *)pb->csParam;
if (vPInfo->csPage != 0)
return paramErr;
SwapMMUMode ( &busMode );
switch (dStore->curMode) {
case firstVidMode: // 8bpp
{
/* grey the screen */
UInt32 a32 = dce->dCtlDevBase;
UInt32 a32_l0, a32_l1;
UInt32 a32_4p0, a32_4p1;
short j, i;
a32_l0 = a32;
a32_l1 = a32 + HRES;
for (j = 0 ; j < VRES ; j+= 2) {
a32_4p0 = a32_l0;
a32_4p1 = a32_l1;
for (i = 0 ; i < HRES ; i += 4) {
*((UInt32*)a32_4p0) = 0xFF00FF00;
*((UInt32*)a32_4p1) = 0x00FF00FF;
a32_4p0 += 4;
a32_4p1 += 4;
}
a32_l0 += 2*HRES;
a32_l1 += 2*HRES;
}
} break;
case secondVidMode: // 1bpp
{
/* grey the screen */
UInt32 a32 = dce->dCtlDevBase;
UInt32 a32_l0, a32_l1;
UInt32 a32_4p0, a32_4p1;
short j, i;
a32_l0 = a32;
a32_l1 = a32 + HRES/8;
for (j = 0 ; j < VRES ; j+= 2) {
a32_4p0 = a32_l0;
a32_4p1 = a32_l1;
for (i = 0 ; i < HRES/8 ; i += 4) {
*((UInt32*)a32_4p0) = 0xAAAAAAAA;
*((UInt32*)a32_4p1) = 0x55555555;
a32_4p0 += 4;
a32_4p1 += 4;
}
a32_l0 += 2*HRES/8;
a32_l1 += 2*HRES/8;
}
} break;
}
SwapMMUMode ( &busMode );
ret = noErr;
}
break;
@ -258,8 +326,14 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscSetDefaultMode: /* 9 */
{
VDDefMode *vddefm = (VDDefMode *)*(long *)pb->csParam;
if (vddefm->csID != 128)
switch (vddefm->csID) { // checkme: really mode?
case firstVidMode:
break;
case secondVidMode:
break;
default:
return paramErr;
}
ret = noErr;
}
break;
@ -267,12 +341,22 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscSwitchMode: /* 0xa */
{
VDSwitchInfoRec *vdswitch = *(VDSwitchInfoRec **)(long *)pb->csParam;
if (vdswitch->csMode != eightBitMode)
return paramErr;
if (vdswitch->csData != 128)
return paramErr;
if (vdswitch->csPage != 0)
return paramErr;
switch (vdswitch->csData) {
case kDepthMode1:
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_8BIT);
SwapMMUMode ( &busMode );
break;
case kDepthMode2:
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_1BIT);
SwapMMUMode ( &busMode );
break;
default:
return paramErr;
}
vdswitch->csBaseAddr = 0;
ret = noErr;
}
@ -283,10 +367,22 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
#if 1
{
VDSwitchInfoRec *vdswitch = *(VDSwitchInfoRec **)(long *)pb->csParam;
if (vdswitch->csMode != eightBitMode)
switch (vdswitch->csMode) {
case firstVidMode:
break;
case secondVidMode:
break;
default:
return paramErr;
if (vdswitch->csData != 128)
}
switch (vdswitch->csData) { // checkme: really mode?
case firstVidMode:
break;
case secondVidMode:
break;
default:
return paramErr;
}
if (vdswitch->csPage != 0)
return paramErr;
vdswitch->csBaseAddr = 0;

View File

@ -38,8 +38,8 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
NuBusFPGADriverGlobalsHdl dStoreHdl = (NuBusFPGADriverGlobalsHdl)dce->dCtlStorage;
NuBusFPGADriverGlobalsPtr dStore = *dStoreHdl;
short ret = -1;
/* write_reg(dce, GOBOFB_DEBUG, 0xBEEF0002); */
/* write_reg(dce, GOBOFB_DEBUG, pb->csCode); */
write_reg(dce, GOBOFB_DEBUG, 0xBEEF0002);
write_reg(dce, GOBOFB_DEBUG, pb->csCode);
#if 1
switch (pb->csCode)
{
@ -54,7 +54,7 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscGetMode: /* 2 */
{
VDPageInfo *vPInfo = (VDPageInfo *)*(long *)pb->csParam;
vPInfo->csMode = eightBitMode;
vPInfo->csMode = dStore->curMode; /* checkme: PCI says depth, 7.5+ doesn't call anyway? */
vPInfo->csPage = 0;
vPInfo->csBaseAddr = 0;
ret = noErr;
@ -68,8 +68,14 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscGetPageCnt: /* 4 == cscGetPages */
{
VDPageInfo *vPInfo = (VDPageInfo *)*(long *)pb->csParam;
if (vPInfo->csMode != eightBitMode)
switch (vPInfo->csMode) {
case firstVidMode:
break;
case secondVidMode:
break;
default:
return paramErr;
}
vPInfo->csPage = 0;
ret = noErr;
}
@ -111,9 +117,9 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
}
break;
case cscGetDefaultMode: /* 9 */
{
{ /* obsolete in PCI, not called >= 7.5 */
VDDefMode *vddefm = (VDDefMode *)*(long *)pb->csParam;
vddefm->csID = 128;
vddefm->csID = firstVidMode;
ret = noErr;
}
break;
@ -121,8 +127,8 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscGetCurMode: /* 0xa */
{
VDSwitchInfoRec *vdswitch = *(VDSwitchInfoRec **)(long *)pb->csParam;
vdswitch->csMode = eightBitMode;
vdswitch->csData = 128;
vdswitch->csMode = dStore->curDepth;
vdswitch->csData = dStore->curMode;
vdswitch->csPage = 0;
vdswitch->csBaseAddr = 0;
ret = noErr;
@ -150,7 +156,7 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
{
VDTimingInfoRec *vdtim = *(VDTimingInfoRec **)(long *)pb->csParam;
ret = noErr;
if ((vdtim->csTimingMode != 128) &&
if ((vdtim->csTimingMode != firstVidMode) &&
(vdtim->csTimingMode != kDisplayModeIDFindFirstResolution) &&
(vdtim->csTimingMode != kDisplayModeIDCurrent))
return paramErr;
@ -161,16 +167,20 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
break;
case cscGetModeBaseAddress: /* 0xe */
asm volatile(".word 0xfe16\n");
/* undocumented ??? */
ret = statusErr;
{
VDBaseAddressInfoRec *vdbase = *(VDBaseAddressInfoRec **)(long *)pb->csParam;
vdbase->csDevBase = 0;
ret = noErr;
}
ret = noErr;
break;
case cscGetPreferredConfiguration: /* 0x10 */
{
VDSwitchInfoRec *vdswitch = *(VDSwitchInfoRec **)(long *)pb->csParam;
vdswitch->csMode = eightBitMode;
vdswitch->csData = 128;
vdswitch->csMode = kDepthMode1; //dStore->curDepth; /* fixme: prefered not current / default */
vdswitch->csData = firstVidMode; //dStore->curMode;
ret = noErr;
}
break;
@ -178,18 +188,21 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscGetNextResolution: /* 0x11 */
{
VDResolutionInfoRec *vdres = *(VDResolutionInfoRec **)(long *)pb->csParam;
vdres->csHorizontalPixels = HRES;
vdres->csVerticalLines = VRES;
vdres->csRefreshRate = 60 << 16; /* Fixed 16+16 */
switch (vdres->csPreviousDisplayModeID)
{
case 128:
case firstVidMode:
vdres->csDisplayModeID = kDisplayModeIDNoMoreResolutions;
break;
case kDisplayModeIDFindFirstResolution:
vdres->csDisplayModeID = firstVidMode;
vdres->csMaxDepthMode = kDepthMode2;
break;
case kDisplayModeIDCurrent:
vdres->csDisplayModeID = 128;
vdres->csHorizontalPixels = HRES;
vdres->csVerticalLines = VRES;
vdres->csRefreshRate = 60 << 16; /* Fixed 16+16 */
vdres->csMaxDepthMode = kDepthMode1;
vdres->csDisplayModeID = firstVidMode;
vdres->csMaxDepthMode = kDepthMode2;
break;
default:
return paramErr;
@ -201,11 +214,12 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
case cscGetVideoParameters: /* 0x12 */
{
VDVideoParametersInfoRec *vdparam = *(VDVideoParametersInfoRec **)(long *)pb->csParam;
if ((vdparam->csDisplayModeID != 128) &&
if ((vdparam->csDisplayModeID != firstVidMode) &&
(vdparam->csDisplayModeID != kDisplayModeIDFindFirstResolution) &&
(vdparam->csDisplayModeID != kDisplayModeIDCurrent))
return paramErr;
if (vdparam->csDepthMode != kDepthMode1)
if ((vdparam->csDepthMode != kDepthMode1) &&
(vdparam->csDepthMode != kDepthMode2))
return paramErr;
VPBlock* vpblock = vdparam->csVPBlockPtr;
/* basically the same as the EBVParms ? */
@ -223,14 +237,22 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
vpblock->vpHRes = 0x480000;
vpblock->vpVRes = 0x480000;
vpblock->vpPixelType = chunky;
vpblock->vpPixelSize = 8;
vpblock->vpCmpCount = 1;
vpblock->vpCmpSize = 8;
if (vdparam->csDepthMode == kDepthMode1) {
vpblock->vpPixelSize = 8;
vpblock->vpCmpCount = 1;
vpblock->vpCmpSize = 8;
} else if (vdparam->csDepthMode == kDepthMode2) {
vpblock->vpPixelSize = 1;
vpblock->vpCmpCount = 1;
vpblock->vpCmpSize = 1;
}
vpblock->vpPlaneBytes = 0;
ret = noErr;
}
break;
/* 0x13 */ /* nothing */
case cscGetGammaInfoList: /* 0x14 */
ret = statusErr;
break;

View File

@ -79,6 +79,13 @@ UInt32 Primary(SEBlock* seblock) {
spblock.spSlot = seblock->seSlot;
spblock.spResult = (UInt32)pram;
err = SReadPRAMRec(&spblock);
#if 0
PRIM_WRITEREG(GOBOFB_DEBUG, 0x88888888);
for (j = 0 ; j < 8 ; j++)
PRIM_WRITEREG(GOBOFB_DEBUG, (uint32_t)pram[j]);
PRIM_WRITEREG(GOBOFB_DEBUG, 0x88888888);
#endif
busMode = 1;
SwapMMUMode ( &busMode ); // to32

View File

@ -30,8 +30,8 @@ BeginSecondary:
/* param block in %A3, our HW (32-bits mode) in %A1 */
addl #0x00900000, %A1
movel #0x0f0f0f0f,%A1@(0x20) /* marker to qemu */
movel %D1,%A1@(0x20) /*_sVersion spResult to Qemu */
movel #0x0f0f0f0f,%A1@(0x1c) /* marker to qemu */
movel %D1,%A1@(0x1c) /*_sVersion spResult to Qemu */
ExitSecondary:
RTS /* Return */

View File

@ -7,11 +7,11 @@
.include "DepVideo.inc"
sRsrc_Board = 1 /* board sResource (>0 & <128) */
sRsrc_VidS8 = 0x80 /* functional sResources */
sRsrc_VidHiRes = 0x80 /* functional sResources */
_sRsrcDir:
OSLstEntry sRsrc_Board,_sRsrc_Board /* board sRsrc List */
OSLstEntry sRsrc_VidS8,_sRsrc_VidS8 /* video sRsrc List */
OSLstEntry sRsrc_VidHiRes,_sRsrc_VidHiRes /* video sRsrc List */
.long EndOfList
_sRsrc_Board:
@ -74,18 +74,18 @@ _Date:
ALIGN 2
_VModeName:
OSLstEntry sRsrc_VidS8, _ScreenNameVidS8
OSLstEntry sRsrc_VidHiRes, _ScreenNameVidHiRes
DatLstEntry endOfList, 0
ALIGN 2
_ScreenNameVidS8:
.long _ScreenNameVidS8End - _ScreenNameVidS8
_ScreenNameVidHiRes:
.long _ScreenNameVidHiResEnd - _ScreenNameVidHiRes
.word 0
.string "That one resolution\0"
_ScreenNameVidS8End:
_ScreenNameVidHiResEnd:
ALIGN 2
_sRsrc_VidS8:
_sRsrc_VidHiRes:
OSLstEntry sRsrcType,_VideoType /* video type descriptor */
OSLstEntry sRsrcName,_VideoName /* offset to driver name string */
OSLstEntry sRsrcDrvrDir,_VidDrvrDir /* offset to driver directory */
@ -95,7 +95,8 @@ _sRsrc_VidS8:
OSLstEntry MinorLength,_MinorLength /* offset to frame buffer length */
/* OSLstEntry sGammaDir,_GammaDirS /* directory for 640x480 monitor */
/* Parameters */
OSLstEntry firstVidMode,_EBMs /* offset to EightBitMode parms */
OSLstEntry firstVidMode,_HiRes8Modes /* offset to 8 Bit Mode parms */
OSLstEntry secondVidMode,_HiRes1Modes /* offset to 1 Bit Mode parms */
.long EndOfList /* end of list */
ALIGN 2
@ -158,13 +159,13 @@ _End020Drvr:
/* _EndSmallGamma: */
ALIGN 2
_EBMs:
OSLstEntry mVidParams,_EBVParms /* offset to vid parameters */
_HiRes8Modes:
OSLstEntry mVidParams,_HRV8Parms /* offset to vid parameters */
DatLstEntry mPageCnt,Pages8s /* number of video pages */
DatLstEntry mDevType,defmDevType /* device type */
.long EndOfList /* end of list */
_EBVParms:
.long _EndEBVParms-_EBVParms /* physical block size */
_HRV8Parms:
.long _EndHRV8Parms-_HRV8Parms /* physical block size */
.long defmBaseOffset /* QuickDraw base offset ; vpBaseOffset */
.word RB8s /* physRowBytes ; vpRowBytes */
.word defmBounds_Ts,defmBounds_Ls,defmBounds_Bs,defmBounds_Rs /* vpBounds */
@ -178,7 +179,29 @@ _EBVParms:
.word 1 /* bmCmpCount */
.word 8 /* bmCmpSize */
.long defmPlaneBytes /* bmPlaneBytes */
_EndEBVParms:
_EndHRV8Parms:
ALIGN 2
_HiRes1Modes:
OSLstEntry mVidParams,_HRV1Parms /* offset to vid parameters */
DatLstEntry mPageCnt,Pages1s /* number of video pages */
DatLstEntry mDevType,defmDevType /* device type */
.long EndOfList /* end of list */
_HRV1Parms:
.long _EndHRV1Parms-_HRV1Parms /* physical block size */
.long defmBaseOffset /* QuickDraw base offset ; vpBaseOffset */
.word RB1s /* physRowBytes ; vpRowBytes */
.word defmBounds_Ts,defmBounds_Ls,defmBounds_Bs,defmBounds_Rs /* vpBounds */
.word defVersion /* bmVersion ; vpVersion */
.word 0 /* packType not used ; vpPackType */
.long 0 /* packSize not used ; vpPackSize */
.long defmHRes /* bmHRes */
.long defmVRes /* bmVRes */
.word ChunkyIndexed /* bmPixelType */
.word 1 /* bmPixelSize */
.word 1 /* bmCmpCount */
.word 1 /* bmCmpSize */
.long defmPlaneBytes /* bmPlaneBytes */
_EndHRV1Parms:
/* Declaration ROM directory at end */
ALIGN 2

View File

@ -40,7 +40,7 @@ def goblin_rounded_size(hres, vres):
class VideoFrameBufferMultiDepth(Module, AutoCSR):
"""Video FrameBufferMultiDepth"""
def __init__(self, dram_port, upd_clut_fifo = None, hres=800, vres=600, base=0x00000000, fifo_depth=65536, clock_domain="sys", clock_faster_than_sys=False, hwcursor=False, upd_overlay_fifo=False, upd_omap_fifo=False, truecolor=True):
def __init__(self, dram_port, upd_clut_fifo = None, hres=800, vres=600, base=0x00000000, fifo_depth=65536, clock_domain="sys", clock_faster_than_sys=False, hwcursor=False, upd_overlay_fifo=False, upd_omap_fifo=False, truecolor=True, endian="big"):
print(f"FRAMEBUFFER: dram_port.data_width = {dram_port.data_width}, {hres}x{vres}, 0x{base:x}, in {clock_domain}, clock_faster_than_sys={clock_faster_than_sys}")
@ -180,18 +180,38 @@ class VideoFrameBufferMultiDepth(Module, AutoCSR):
self.submodules.conv4 = ClockDomainsRenamer({"sys": clock_domain})(stream.Converter(dram_port.data_width, 4))
self.submodules.conv2 = ClockDomainsRenamer({"sys": clock_domain})(stream.Converter(dram_port.data_width, 2))
self.submodules.conv1 = ClockDomainsRenamer({"sys": clock_domain})(stream.Converter(dram_port.data_width, 1))
self.comb += [
If(self.use_indexed,
Case(self.indexed_mode, {
0x3: self.cdc.source.connect(self.conv8.sink),
0x2: self.cdc.source.connect(self.conv4.sink),
0x1: self.cdc.source.connect(self.conv2.sink),
0x0: self.cdc.source.connect(self.conv1.sink),
})
).Else(
*handle_truecolor_sink
)
]
# not sure the bit-reversal needed in the NuBusFPGA is really tied to the endianess (didn't really try < 8 bits on SBusFPGA)
if (endian == "big"):
self.comb += [
If(self.use_indexed,
Case(self.indexed_mode, {
0x3: [ self.cdc.source.connect(self.conv8.sink), ],
0x2: [ self.cdc.source.connect(self.conv4.sink), ],
0x1: [ self.cdc.source.connect(self.conv2.sink), ],
0x0: [ self.cdc.source.connect(self.conv1.sink), ],
})
).Else(
*handle_truecolor_sink
)
]
else:
self.comb += [
If(self.use_indexed,
Case(self.indexed_mode, {
0x3: [ self.cdc.source.connect(self.conv8.sink), ],
0x2: [ self.cdc.source.connect(self.conv4.sink), ],
0x1: [ self.cdc.source.connect(self.conv2.sink), ],
0x0: [ self.cdc.source.connect(self.conv1.sink, omit={"data"}),
*[ self.conv1.sink.data[xbyte*8 + xbit].eq(self.cdc.source.data[xbyte*8 + 7-xbit]) for xbit in range(0,8) for xbyte in range(0, dram_port.data_width//8) ],
],
})
).Else(
*handle_truecolor_sink
)
]
# Video Generation.
self.comb += [
@ -372,6 +392,7 @@ class goblin(Module, AutoCSR):
upd_overlay_fifo = upd_overlay_fifo,
upd_omap_fifo = upd_omap_fifo,
truecolor = truecolor,
endian = endian,
)
setattr(self.submodules, name, vfb)
##dma_reset = Signal(reset = 0)