📄 s3c2410disp.cpp
字号:
*surface = new GPESurf(width, height, format);
if (*surface != NULL)
{
// Check that the bits were allocated succesfully
if (((*surface)->Buffer()) == NULL)
{
delete *surface; // Clean up
}
else
{
return S_OK;
}
}
return E_OUTOFMEMORY;
}
SCODE S3C2410DISP::WrappedEmulatedLine (GPELineParms *lineParameters)
{
SCODE retval;
RECT bounds;
int N_plus_1; // Minor length of bounding rect + 1
// calculate the bounding-rect to determine overlap with cursor
if (lineParameters->dN) // The line has a diagonal component (we'll refresh the bounding rect)
{
N_plus_1 = 2 + ((lineParameters->cPels * lineParameters->dN) / lineParameters->dM);
}
else
{
N_plus_1 = 1;
}
switch(lineParameters->iDir)
{
case 0:
bounds.left = lineParameters->xStart;
bounds.top = lineParameters->yStart;
bounds.right = lineParameters->xStart + lineParameters->cPels + 1;
bounds.bottom = bounds.top + N_plus_1;
break;
case 1:
bounds.left = lineParameters->xStart;
bounds.top = lineParameters->yStart;
bounds.bottom = lineParameters->yStart + lineParameters->cPels + 1;
bounds.right = bounds.left + N_plus_1;
break;
case 2:
bounds.right = lineParameters->xStart + 1;
bounds.top = lineParameters->yStart;
bounds.bottom = lineParameters->yStart + lineParameters->cPels + 1;
bounds.left = bounds.right - N_plus_1;
break;
case 3:
bounds.right = lineParameters->xStart + 1;
bounds.top = lineParameters->yStart;
bounds.left = lineParameters->xStart - lineParameters->cPels;
bounds.bottom = bounds.top + N_plus_1;
break;
case 4:
bounds.right = lineParameters->xStart + 1;
bounds.bottom = lineParameters->yStart + 1;
bounds.left = lineParameters->xStart - lineParameters->cPels;
bounds.top = bounds.bottom - N_plus_1;
break;
case 5:
bounds.right = lineParameters->xStart + 1;
bounds.bottom = lineParameters->yStart + 1;
bounds.top = lineParameters->yStart - lineParameters->cPels;
bounds.left = bounds.right - N_plus_1;
break;
case 6:
bounds.left = lineParameters->xStart;
bounds.bottom = lineParameters->yStart + 1;
bounds.top = lineParameters->yStart - lineParameters->cPels;
bounds.right = bounds.left + N_plus_1;
break;
case 7:
bounds.left = lineParameters->xStart;
bounds.bottom = lineParameters->yStart + 1;
bounds.right = lineParameters->xStart + lineParameters->cPels + 1;
bounds.top = bounds.bottom - N_plus_1;
break;
default:
RETAILMSG(0, (TEXT("Invalid direction: %d\r\n"), lineParameters->iDir));
return E_INVALIDARG;
}
// check for line overlap with cursor and turn off cursor if overlaps
if (m_CursorVisible && !m_CursorDisabled &&
m_CursorRect.top < bounds.bottom && m_CursorRect.bottom > bounds.top &&
m_CursorRect.left < bounds.right && m_CursorRect.right > bounds.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
// do emulated line
retval = EmulatedLine (lineParameters);
// se if cursor was forced off because of overlap with line bouneds and turn back on
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
return retval;
}
SCODE S3C2410DISP::Line(GPELineParms *lineParameters, EGPEPhase phase)
{
RETAILMSG(0, (TEXT("S3C2410DISP::Line\r\n")));
if (phase == gpeSingle || phase == gpePrepare)
{
if ((lineParameters->pDst != m_pPrimarySurface))
{
lineParameters->pLine = EmulatedLine;
}
else
{
lineParameters->pLine = (SCODE (GPE::*)(struct GPELineParms *)) WrappedEmulatedLine;
}
}
return S_OK;
}
SCODE S3C2410DISP::BltPrepare(GPEBltParms *blitParameters)
{
RECTL rectl;
RETAILMSG(0, (TEXT("S3C2410DISP::BltPrepare\r\n")));
// default to base EmulatedBlt routine
blitParameters->pBlt = EmulatedBlt;
// see if we need to deal with cursor
if (m_CursorVisible && !m_CursorDisabled)
{
// check for destination overlap with cursor and turn off cursor if overlaps
if (blitParameters->pDst == m_pPrimarySurface) // only care if dest is main display surface
{
if (blitParameters->prclDst != NULL) // make sure there is a valid prclDst
{
rectl = *blitParameters->prclDst; // if so, use it
}
else
{
rectl = m_CursorRect; // if not, use the Cursor rect - this forces the cursor to be turned off in this case
}
if (m_CursorRect.top < rectl.bottom && m_CursorRect.bottom > rectl.top &&
m_CursorRect.left < rectl.right && m_CursorRect.right > rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
// check for source overlap with cursor and turn off cursor if overlaps
if (blitParameters->pSrc == m_pPrimarySurface) // only care if source is main display surface
{
if (blitParameters->prclSrc != NULL) // make sure there is a valid prclSrc
{
rectl = *blitParameters->prclSrc; // if so, use it
}
else
{
rectl = m_CursorRect; // if not, use the CUrsor rect - this forces the cursor to be turned off in this case
}
if (m_CursorRect.top < rectl.bottom && m_CursorRect.bottom > rectl.top &&
m_CursorRect.left < rectl.right && m_CursorRect.right > rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
}
#ifdef ROTATE
if (m_iRotate && (blitParameters->pDst == m_pPrimarySurface || blitParameters->pSrc == m_pPrimarySurface))
{
blitParameters->pBlt = (SCODE (GPE::*)(GPEBltParms *))EmulatedBltRotate;
}
#endif //ROTATE
#ifdef CLEARTYPE
if (((blitParameters->rop4 & 0xffff) == 0xaaf0 ) && (blitParameters->pMask->Format() == gpe8Bpp))
{
switch (m_colorDepth)
{
case 16:
blitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *)) ClearTypeBlt::ClearTypeBltDst16;
return S_OK;
case 24:
blitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *)) ClearTypeBlt::ClearTypeBltDst24;
return S_OK;
case 32:
blitParameters->pBlt = (SCODE (GPE::*)(struct GPEBltParms *)) ClearTypeBlt::ClearTypeBltDst32;
return S_OK;
default:
break;
}
}
#endif //CLEARTYPE
// see if there are any optimized software blits available
EmulatedBltSelect02(blitParameters);
EmulatedBltSelect08(blitParameters);
EmulatedBltSelect16(blitParameters);
return S_OK;
}
SCODE S3C2410DISP::BltComplete(GPEBltParms *blitParameters)
{
RETAILMSG(0, (TEXT("S3C2410DISP::BltComplete\r\n")));
// see if cursor was forced off because of overlap with source or destination and turn back on
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
return S_OK;
}
INT S3C2410DISP::InVBlank(void)
{
RETAILMSG(0, (TEXT("S3C2410DISP::InVBlank\r\n")));
return 0;
}
SCODE S3C2410DISP::SetPalette(const PALETTEENTRY *source, USHORT firstEntry, USHORT numEntries)
{
RETAILMSG(0, (TEXT("S3C2410DISP::SetPalette\r\n")));
if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
{
return E_INVALIDARG;
}
return S_OK;
}
ULONG S3C2410DISP::GetGraphicsCaps()
{
#ifdef CLEARTYPE
return GCAPS_GRAY16 | GCAPS_CLEARTYPE;
#else
return GCAPS_GRAY16;
#endif
}
void RegisterDDHALAPI(void)
{
return; // no DDHAL support
}
//****************************************** CHANGE(5) BEGIN *********************************************//
//Provide escape gates to the app:
ULONG S3C2410DISP::DrvEscape(
SURFOBJ *pso,
ULONG iEsc,
ULONG cjIn,
PVOID pvIn,
ULONG cjOut,
PVOID pvOut)
{
RETAILMSG(0,(_T("S3C2410DISP::DrvEscape entered\r\n")));
PTIMING tm;
unsigned char reg,val;
DWORD *ptemp;
int retval=0;
if(iEsc==QUERYESCSUPPORT)//just for test
{
RETAILMSG(1,(_T("QUERYESCSUPPORT------driver support\r\n")));
if(*(DWORD*)pvIn==DRVESC_JUSTTEST)
return 2;
else
return 4;
}
switch(iEsc)
{
//Just test pvOut:
case DRVESC_JUSTTEST:
RETAILMSG(1,(_T("DRVESC_JUSTTEST------return m_nScreenWidth\r\n")));
*(DWORD*)pvOut=m_nScreenWidth;
//CheckLCDReg();
retval=1;
break;
//change LCD controller timing:
case DRVESC_CHANGELCDTIMING:
tm=(PTIMING)pvIn;
RETAILMSG(1,(_T("DRVESC_CHANGELCDTIMING------\nclkdiv=%d\ntm.ha=%d\rtm.va=%d\ntm.hfp=%d\rtm.vfp=%d\ntm.hw=%d\rtm.vw=%d\ntm.hbp=%d\rtm.vbp=%d\n"),
tm->clkdiv,tm->ha,tm->va,tm->hfp,tm->vfp,tm->hw,tm->vw,tm->hbp,tm->vbp));
Set2410LCDReg(tm);
retval=1;
break;
//Get LCD Controller timing:
case DRVESC_GETLCDTIMING:
Get2410LCDReg((PTIMING)pvOut);
tm=(PTIMING)pvOut;
RETAILMSG(1,(_T("DRVESC_GETLCDTIMING------\nclkdiv=%d\ntm.ha=%d\rtm.va=%d\ntm.hfp=%d\rtm.vfp=%d\ntm.hw=%d\rtm.vw=%d\ntm.hbp=%d\rtm.vbp=%d\n"),
tm->clkdiv,tm->ha,tm->va,tm->hfp,tm->vfp,tm->hw,tm->vw,tm->hbp,tm->vbp));
break;
//IIC read:
case DRVESC_IICREAD:
ptemp=(DWORD*)pvIn;
reg=(UCHAR)(*ptemp);
//RETAILMSG(1,(_T("DRVESC_IICREAD-----reg=0x%x\r\n"),reg));
if(!g_i2c.GetReg(reg,&val))
{
RETAILMSG(1,(_T("Read Register failed!\n")));
break;
}
*((DWORD*)pvOut)=(DWORD)val;
//RETAILMSG(1,(_T("Read:[0x%.2X]=0x%.2x\n"),reg,val));
retval=1;
break;
//IIC write:
case DRVESC_IICWRITE:
ptemp=(DWORD*)pvIn;
reg=(unsigned char)(*ptemp);
val=(unsigned char)(*(ptemp+1));
//RETAILMSG(1,(_T("DRVESC_IICWRITE-----reg=0x%x,val=0x%x\r\n"),reg,val));
if(!g_i2c.SetReg(reg,&val))
{
RETAILMSG(1,(_T("Write Register failed!\n")));
break;
}
//RETAILMSG(1,(_T("Write:[0x%.2X]=0x%.2x\n"),reg,val));
retval=1;
break;
//IIC change devide address:
case DRVESC_IICCHANGEADDR:
ptemp=(DWORD*)pvIn;
RETAILMSG(1,(_T("*****pvIn=0x%.2x*****\n\r"),*ptemp));
g_i2c.SetChipAddr((UCHAR)(*ptemp));
retval=1;
break;
case DRVESC_IICTEST:
RETAILMSG(1,(_T("IICTEST arriverd!!!\n\r")));
//RETAILMSG(1,(_T("IICTEST end!!!\n\r")));
retval=1;
break;
case DRVESC_CHIPRESET:
RETAILMSG(1,(_T("Chip reset arrived!\r\n")));
//RETAILMSG(1,(_T("key=0x%x\r\n"),temp));
retval=1;
break;
}
return retval;
}
//******************************************* CHANGE(5) END **********************************************//
ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
return gBitMasks;
}
#ifdef ROTATE
void S3C2410DISP::SetRotateParms()
{
int iswap;
switch(m_iRotate)
{
case DMDO_0:
m_nScreenHeightSave = m_nScreenHeight;
m_nScreenWidthSave = m_nScreenWidth;
break;
case DMDO_180:
m_nScreenHeightSave = m_nScreenHeight;
m_nScreenWidthSave = m_nScreenWidth;
break;
case DMDO_90:
case DMDO_270:
iswap = m_nScreenHeight;
m_nScreenHeight = m_nScreenWidth;
m_nScreenWidth = iswap;
m_nScreenHeightSave = m_nScreenWidth;
m_nScreenWidthSave = m_nScreenHeight;
break;
default:
m_nScreenHeightSave = m_nScreenHeight;
m_nScreenWidthSave = m_nScreenWidth;
break;
}
return;
}
LONG S3C2410DISP::DynRotate(int angle)
{
GPESurfRotate *pSurf = (GPESurfRotate *)m_pPrimarySurface;
if (angle == m_iRotate)
return DISP_CHANGE_SUCCESSFUL;
m_iRotate = angle;
switch(m_iRotate)
{
case DMDO_0:
case DMDO_180:
m_nScreenHeight = m_nScreenHeightSave;
m_nScreenWidth = m_nScreenWidthSave;
break;
case DMDO_90:
case DMDO_270:
m_nScreenHeight = m_nScreenWidthSave;
m_nScreenWidth = m_nScreenHeightSave;
break;
}
m_pMode->width = m_nScreenWidth;
m_pMode->height = m_nScreenHeight;
pSurf->SetRotation(m_nScreenWidth, m_nScreenHeight, angle);
return DISP_CHANGE_SUCCESSFUL;
}
#endif //ROTATE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -