32-bits 'mllions of colors'

This commit is contained in:
Romain Dolbeau 2022-04-18 17:04:32 +02:00
parent e2994879bc
commit 3be6333be7
7 changed files with 137 additions and 40 deletions

View File

@ -3,12 +3,13 @@
NuBusFPGAID = 0xC0
defMinorBase = 0 /* beginning */
defMinorLength = 0x200000 /* 2048 KiB */
defMinorLength = 0x800000 /* 8192 KiB */
Pages8s = 1
Pages4s = 1
Pages2s = 1
Pages1s = 1
Pages24s = 1
defmBounds_Ls = 0
defmBounds_Ts = 0
@ -22,6 +23,7 @@ RB8s = HRES
RB4s = HRES/2
RB2s = HRES/4
RB1s = HRES/8
RB24s = HRES*4
DrHwNuBusFPGA = 0xBEEF /* placeholder */
@ -32,7 +34,8 @@ devVersion = 0 /* placeholder */
defmHRes = 0x480000 /* Horizontal Pixels/inch */
defmVRes = 0x480000 /* Vertical pixels/inch */
defmDevType = 0 /* 0 = CLUTType */
clutType = 0
directType = 2
defmPlaneBytes = 0 /* Offset from one plane to the next. */
@ -40,6 +43,7 @@ SGammaResID = 0
ChunkyIndexed = 0
ChunkyDirect = 16
defVersion = 0 /* Version = 0 */

View File

@ -41,7 +41,7 @@
#define GOBOFB_MODE_2BIT 0x1
#define GOBOFB_MODE_4BIT 0x2
#define GOBOFB_MODE_8BIT 0x3
//#define GOBOFB_MODE_24BIT 0x10
#define GOBOFB_MODE_24BIT 0x10
struct MyGammaTbl {
short gVersion; /*gamma version number*/

View File

@ -106,6 +106,7 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
write_reg(dce, GOBOFB_DEBUG, 0xBEEF0001);
write_reg(dce, GOBOFB_DEBUG, pb->csCode);
#if 1
switch (pb->csCode)
{
@ -146,17 +147,23 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
SwapMMUMode ( &busMode );
break;
case thirdVidMode:
dStore->curMode = secondVidMode;
dStore->curMode = thirdVidMode;
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_2BIT);
SwapMMUMode ( &busMode );
break;
case fourthVidMode:
dStore->curMode = secondVidMode;
dStore->curMode = fourthVidMode;
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_1BIT);
SwapMMUMode ( &busMode );
break;
case fifthVidMode:
dStore->curMode = fifthVidMode;
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_24BIT);
SwapMMUMode ( &busMode );
break;
default:
return paramErr;
}
@ -267,20 +274,38 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
return paramErr;
SwapMMUMode ( &busMode );
/* grey the screen */
a32_l0 = a32;
a32_l1 = a32 + wb;
for (j = 0 ; j < VRES ; j+= 2) {
a32_4p0 = a32_l0;
a32_4p1 = a32_l1;
for (i = 0 ; i < wb ; i += 4) {
*((UInt32*)a32_4p0) = 0xFF00FF00;
*((UInt32*)a32_4p1) = 0x00FF00FF;
a32_4p0 += 4;
a32_4p1 += 4;
if (dStore->curMode != kDepthMode5) {
/* grey the screen */
a32_l0 = a32;
a32_l1 = a32 + wb;
for (j = 0 ; j < VRES ; j+= 2) {
a32_4p0 = a32_l0;
a32_4p1 = a32_l1;
for (i = 0 ; i < wb ; i += 4) {
*((UInt32*)a32_4p0) = 0xFF00FF00;
*((UInt32*)a32_4p1) = 0x00FF00FF;
a32_4p0 += 4;
a32_4p1 += 4;
}
a32_l0 += 2*wb;
a32_l1 += 2*wb;
}
} else {
/* testing */
a32_l0 = a32;
a32_l1 = a32 + HRES*4;
for (j = 0 ; j < VRES ; j+= 2) {
a32_4p0 = a32_l0;
a32_4p1 = a32_l1;
for (i = 0 ; i < HRES ; i ++ ) {
*((UInt32*)a32_4p0) = (i&0xFF);//(i&0xFF) | (i&0xFF)<<8 | (i&0xff)<<24;
*((UInt32*)a32_4p1) = (i&0xFF)<<16;//(i&0xFF) | (i&0xFF)<<8 | (i&0xff)<<24;
a32_4p0 += 4;
a32_4p1 += 4;
}
a32_l0 += 2*HRES*4;
a32_l1 += 2*HRES*4;
}
a32_l0 += 2*wb;
a32_l1 += 2*wb;
}
SwapMMUMode ( &busMode );
@ -315,6 +340,12 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
break;
case secondVidMode:
break;
case thirdVidMode:
break;
case fourthVidMode:
break;
case fifthVidMode:
break;
default:
return paramErr;
}
@ -348,6 +379,11 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_1BIT);
SwapMMUMode ( &busMode );
break;
case kDepthMode5:
SwapMMUMode ( &busMode );
write_reg(dce, GOBOFB_MODE, GOBOFB_MODE_24BIT);
SwapMMUMode ( &busMode );
break;
default:
return paramErr;
}
@ -361,11 +397,17 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
#if 1
{
VDSwitchInfoRec *vdswitch = *(VDSwitchInfoRec **)(long *)pb->csParam;
switch (vdswitch->csMode) {
switch (vdswitch->csMode) { // checkme: really mode?
case firstVidMode:
break;
case secondVidMode:
break;
case thirdVidMode:
break;
case fourthVidMode:
break;
case fifthVidMode:
break;
default:
return paramErr;
}
@ -374,6 +416,12 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
break;
case secondVidMode:
break;
case thirdVidMode:
break;
case fourthVidMode:
break;
case fifthVidMode:
break;
default:
return paramErr;
}

View File

@ -38,8 +38,10 @@ 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);
#if 1
switch (pb->csCode)
{
@ -77,6 +79,8 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
break;
case fourthVidMode:
break;
case fifthVidMode:
break;
default:
return paramErr;
}
@ -202,11 +206,11 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
break;
case kDisplayModeIDFindFirstResolution:
vdres->csDisplayModeID = firstVidMode;
vdres->csMaxDepthMode = kDepthMode4;
vdres->csMaxDepthMode = kDepthMode5;
break;
case kDisplayModeIDCurrent:
vdres->csDisplayModeID = firstVidMode;
vdres->csMaxDepthMode = kDepthMode4;
vdres->csMaxDepthMode = kDepthMode5;
break;
default:
return paramErr;
@ -225,14 +229,13 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
if ((vdparam->csDepthMode != kDepthMode1) &&
(vdparam->csDepthMode != kDepthMode2) &&
(vdparam->csDepthMode != kDepthMode3) &&
(vdparam->csDepthMode != kDepthMode4))
(vdparam->csDepthMode != kDepthMode4) &&
(vdparam->csDepthMode != kDepthMode5))
return paramErr;
VPBlock* vpblock = vdparam->csVPBlockPtr;
/* basically the same as the EBVParms ? */
vdparam->csPageCount = 0;
vdparam->csDeviceType = clutType;
vpblock->vpBaseOffset = 0;
vpblock->vpRowBytes = HRES;
vpblock->vpBounds.left = 0;
vpblock->vpBounds.top = 0;
vpblock->vpBounds.right = HRES;
@ -242,23 +245,37 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
vpblock->vpPackSize = 0;
vpblock->vpHRes = 0x480000;
vpblock->vpVRes = 0x480000;
vpblock->vpPixelType = chunky;
vpblock->vpPixelType = chunky; // checkme?
if (vdparam->csDepthMode == kDepthMode1) {
vpblock->vpRowBytes = HRES;
vdparam->csDeviceType = clutType;
vpblock->vpPixelSize = 8;
vpblock->vpCmpCount = 1;
vpblock->vpCmpSize = 8;
} else if (vdparam->csDepthMode == kDepthMode2) {
vpblock->vpRowBytes = HRES/2;
vdparam->csDeviceType = clutType;
vpblock->vpPixelSize = 4;
vpblock->vpCmpCount = 1;
vpblock->vpCmpSize = 4;
} else if (vdparam->csDepthMode == kDepthMode3) {
vpblock->vpRowBytes = HRES/4;
vdparam->csDeviceType = clutType;
vpblock->vpPixelSize = 2;
vpblock->vpCmpCount = 1;
vpblock->vpCmpSize = 2;
} else if (vdparam->csDepthMode == kDepthMode4) {
vpblock->vpRowBytes = HRES/8;
vdparam->csDeviceType = clutType;
vpblock->vpPixelSize = 1;
vpblock->vpCmpCount = 1;
vpblock->vpCmpSize = 1;
} else if (vdparam->csDepthMode == kDepthMode5) {
vpblock->vpRowBytes = HRES*4;
vdparam->csDeviceType = directType;
vpblock->vpPixelSize = 32;
vpblock->vpCmpCount = 3;
vpblock->vpCmpSize = 8;
}
vpblock->vpPlaneBytes = 0;
ret = noErr;

View File

@ -99,6 +99,7 @@ _sRsrc_VidHiRes:
OSLstEntry secondVidMode,_HiRes4Modes /* offset to 4 Bit Mode parms */
OSLstEntry thirdVidMode,_HiRes2Modes /* offset to 2 Bit Mode parms */
OSLstEntry fourthVidMode,_HiRes1Modes /* offset to 1 Bit Mode parms */
OSLstEntry fifthVidMode,_HiRes24Modes /* offset to 24 Bit Mode parms */
.long EndOfList /* end of list */
ALIGN 2
@ -164,7 +165,7 @@ _End020Drvr:
_HiRes8Modes:
OSLstEntry mVidParams,_HRV8Parms /* offset to vid parameters */
DatLstEntry mPageCnt,Pages8s /* number of video pages */
DatLstEntry mDevType,defmDevType /* device type */
DatLstEntry mDevType,clutType /* device type */
.long EndOfList /* end of list */
_HRV8Parms:
.long _EndHRV8Parms-_HRV8Parms /* physical block size */
@ -186,7 +187,7 @@ _EndHRV8Parms:
_HiRes4Modes:
OSLstEntry mVidParams,_HRV4Parms /* offset to vid parameters */
DatLstEntry mPageCnt,Pages4s /* number of video pages */
DatLstEntry mDevType,defmDevType /* device type */
DatLstEntry mDevType,clutType /* device type */
.long EndOfList /* end of list */
_HRV4Parms:
.long _EndHRV4Parms-_HRV4Parms /* physical block size */
@ -208,7 +209,7 @@ _EndHRV4Parms:
_HiRes2Modes:
OSLstEntry mVidParams,_HRV2Parms /* offset to vid parameters */
DatLstEntry mPageCnt,Pages2s /* number of video pages */
DatLstEntry mDevType,defmDevType /* device type */
DatLstEntry mDevType,clutType /* device type */
.long EndOfList /* end of list */
_HRV2Parms:
.long _EndHRV2Parms-_HRV2Parms /* physical block size */
@ -230,7 +231,7 @@ _EndHRV2Parms:
_HiRes1Modes:
OSLstEntry mVidParams,_HRV1Parms /* offset to vid parameters */
DatLstEntry mPageCnt,Pages1s /* number of video pages */
DatLstEntry mDevType,defmDevType /* device type */
DatLstEntry mDevType,clutType /* device type */
.long EndOfList /* end of list */
_HRV1Parms:
.long _EndHRV1Parms-_HRV1Parms /* physical block size */
@ -248,6 +249,28 @@ _HRV1Parms:
.word 1 /* bmCmpSize */
.long defmPlaneBytes /* bmPlaneBytes */
_EndHRV1Parms:
ALIGN 2
_HiRes24Modes:
OSLstEntry mVidParams,_HRV24Parms /* offset to vid parameters */
DatLstEntry mPageCnt,Pages24s /* number of video pages */
DatLstEntry mDevType,directType /* device type */
.long EndOfList /* end of list */
_HRV24Parms:
.long _EndHRV24Parms-_HRV24Parms /* physical block size */
.long defmBaseOffset /* QuickDraw base offset ; vpBaseOffset */
.word RB24s /* 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 ChunkyDirect /* bmPixelType */
.word 32 /* bmPixelSize */
.word 3 /* bmCmpCount */
.word 8 /* bmCmpSize */
.long defmPlaneBytes /* bmPlaneBytes */
_EndHRV24Parms:
/* Declaration ROM directory at end */
ALIGN 2

View File

@ -161,21 +161,26 @@ class VideoFrameBufferMultiDepth(Module, AutoCSR):
handle_truecolor_sink = [ self.cdc.source.connect(self.conv32.sink) ]
handle_truecolor_source = [ source_buf_valid.eq(self.conv32.source.valid),
self.conv32.source.connect(source, keep={"ready"}), ]
handle_truecolor_databuf = [ data_buf_direct[0].eq(self.conv32.source.data[24:32]),
data_buf_direct[1].eq(self.conv32.source.data[16:24]),
data_buf_direct[2].eq(self.conv32.source.data[8:16]), ]
if (endian == "big"): # this starts to _really_ mean "i'm in the SBusFPGA"...
handle_truecolor_databuf = [ data_buf_direct[0].eq(self.conv32.source.data[24:32]),
data_buf_direct[1].eq(self.conv32.source.data[16:24]),
data_buf_direct[2].eq(self.conv32.source.data[8:16]), ]
else:
handle_truecolor_databuf = [ data_buf_direct[2].eq(self.conv32.source.data[24:32]),
data_buf_direct[1].eq(self.conv32.source.data[16:24]),
data_buf_direct[0].eq(self.conv32.source.data[8:16]), ]
handle_truecolor_databuf_b = [ data_buf_b_direct[0].eq(data_buf_direct[0]),
data_buf_b_direct[1].eq(data_buf_direct[1]),
data_buf_b_direct[2].eq(data_buf_direct[2]), ]
handle_truecolor_source = [ source_out_r.eq(data_buf_b_direct[2]),
source_out_g.eq(data_buf_b_direct[1]),
source_out_b.eq(data_buf_b_direct[0]), ]
handle_truecolor_final_source = [ source_out_r.eq(data_buf_b_direct[2]),
source_out_g.eq(data_buf_b_direct[1]),
source_out_b.eq(data_buf_b_direct[0]), ]
else:
handle_truecolor_sink = [ ]
handle_truecolor_source = [ ]
handle_truecolor_databuf = [ ]
handle_truecolor_databuf_b = [ ]
handle_truecolor_source = [ ]
handle_truecolor_final_source = [ ]
self.submodules.conv8 = ClockDomainsRenamer({"sys": clock_domain})(stream.Converter(dram_port.data_width, 8))
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))
@ -296,7 +301,7 @@ class VideoFrameBufferMultiDepth(Module, AutoCSR):
source_out_g.eq(clut[data_buf_b_index][1]),
source_out_b.eq(clut[data_buf_b_index][0])
).Else(
*handle_truecolor_source,
*handle_truecolor_final_source,
),
).Else(source_out_r.eq(0),
source_out_g.eq(0),
@ -311,7 +316,7 @@ class VideoFrameBufferMultiDepth(Module, AutoCSR):
source_out_g.eq(clut[data_buf_b_index][1]),
source_out_b.eq(clut[data_buf_b_index][0])
).Else(
*handle_truecolor_source,
*handle_truecolor_final_source,
),
).Else(source_out_r.eq(0),
source_out_g.eq(0),

View File

@ -355,10 +355,10 @@ class NuBusFPGA(SoCCore):
if (goblin):
if (not hdmi):
self.submodules.videophy = VideoVGAPHY(platform.request("vga"), clock_domain="vga")
self.submodules.goblin = goblin_fb.goblin(soc=self, phy=self.videophy, timings=goblin_res, clock_domain="vga", irq_line=self.platform.request("nmrq_3v3_n"), endian="little", truecolor=False) # clock_domain for the VGA side, goblin is running in cd_sys
self.submodules.goblin = goblin_fb.goblin(soc=self, phy=self.videophy, timings=goblin_res, clock_domain="vga", irq_line=self.platform.request("nmrq_3v3_n"), endian="little", truecolor=True) # clock_domain for the VGA side, goblin is running in cd_sys
else:
self.submodules.videophy = VideoS7HDMIPHY(platform.request("hdmi"), clock_domain="hdmi")
self.submodules.goblin = goblin_fb.goblin(soc=self, phy=self.videophy, timings=goblin_res, clock_domain="hdmi", irq_line=self.platform.request("nmrq_3v3_n"), endian="little", truecolor=False) # clock_domain for the HDMI side, goblin is running in cd_sys
self.submodules.goblin = goblin_fb.goblin(soc=self, phy=self.videophy, timings=goblin_res, clock_domain="hdmi", irq_line=self.platform.request("nmrq_3v3_n"), endian="little", truecolor=True) # clock_domain for the HDMI side, goblin is running in cd_sys
self.bus.add_slave("goblin_bt", self.goblin.bus, SoCRegion(origin=self.mem_map.get("goblin_bt", None), size=0x1000, cached=False))
pad_user_led_0 = platform.request("user_led", 0)
pad_user_led_1 = platform.request("user_led", 1)