📄 dispdrvr.c
字号:
// }
// }
// SetKMode(FALSE);
gFrameBuffer =(PBYTE)FRAME_BUFFER_0_BASE_VIRTUAL;// (PBYTE)OALPAtoVA(FRAME_BUFFER_0_BASE_PHYSICAL, FALSE);
if (!gFrameBuffer)
{
Cleanup();
return FALSE;
}
//OALPAtoVA(INTERNAL_MEMORY_START, FALSE);
/*if (bDoRotation)
{
// if rotating the display, the actual frame buffer should be configured as bufferable for max write performance into the frame buffer.
VirtualSetAttributes(gFrameBuffer, frameBufferSize*NUM_FRAME_BUFFERS, 4, 4, NULL);
}
else
{
// if not rotating the dispay, we can draw directly into the frame buffer, and use write-through cache mode to improve frame buffer throughput
VirtualSetAttributes(gFrameBuffer, frameBufferSize*NUM_FRAME_BUFFERS, 8, 8, NULL);
}*/
/*gBlankFrameBuffer = (PBYTE) VirtualAlloc(0, frameBufferSize, MEM_RESERVE | MEM_COMMIT,PAGE_READWRITE);
if (!gBlankFrameBuffer)
{
Cleanup();
return FALSE;
}*/
return TRUE;
}
// Free all the global memory resources
void Cleanup(void)
{
// DMA_ADAPTER_OBJECT Adapter;
// PHYSICAL_ADDRESS PhysAddr;
if (v_pDMAC)
{
// VirtualFree((PVOID)v_pDMAC,0,MEM_RELEASE);
v_pDMAC = NULL;
}
if (v_pI2C)
{
// VirtualFree((PVOID)v_pI2C,0,MEM_RELEASE);
v_pI2C = NULL;
}
if (v_pOSTRegs)
{
// VirtualFree((PVOID)v_pOSTRegs,0,MEM_RELEASE);
v_pOSTRegs = NULL;
}
if (v_pLcdRegs)
{
// VirtualFree((PVOID)v_pLcdRegs,0,MEM_RELEASE);
v_pLcdRegs = NULL;
}
if (v_pClkRegs)
{
// VirtualFree((PVOID)v_pClkRegs,0,MEM_RELEASE);
v_pClkRegs = NULL;
}
if (v_pGPIORegs)
{
// VirtualFree((PVOID)v_pGPIORegs,0,MEM_RELEASE);
v_pGPIORegs = NULL;
}
if (gFrameBuffer)
{
// VirtualFree((PVOID)gFrameBuffer,0,MEM_RELEASE);
gFrameBuffer = NULL;
}
if (gBlankFrameBuffer)
{
// VirtualFree((PVOID)gBlankFrameBuffer,0,MEM_RELEASE);
gBlankFrameBuffer = NULL;
}
if (frameDescriptorCh2_YCbCr_Y)
{
// VirtualFree((PVOID)frameDescriptorCh2_YCbCr_Y,0,MEM_RELEASE);
frameDescriptorCh2_YCbCr_Y = NULL;
}
if (frameDescriptorCh3_YCbCr_Cb)
{
// VirtualFree((PVOID)frameDescriptorCh3_YCbCr_Cb,0,MEM_RELEASE);
frameDescriptorCh3_YCbCr_Cb = NULL;
}
if (frameDescriptorCh4_YCbCr_Cr)
{
// VirtualFree((PVOID)frameDescriptorCh4_YCbCr_Cr,0,MEM_RELEASE);
frameDescriptorCh4_YCbCr_Cr = NULL;
}
// Adapter.ObjectSize = sizeof (DMA_ADAPTER_OBJECT);
// Adapter.InterfaceType = Internal;
// Adapter.BusNumber = 0;
//
// PhysAddr.HighPart = 0;
// PhysAddr.LowPart = g_DisplayBasePhysical;
//
// HalFreeCommonBuffer(&Adapter, DISPLAY_BUFFER_SIZE, PhysAddr, (void *)g_DisplayBaseVirtual, FALSE);
}
void DispDrvrPowerHandler(BOOL bOff)
{
if(bOff)
{
// Copy the active frame buffer into a temporary buffer
// because we are going to write over the active frame buffer
// with a blank all black display. When we restore the display
// when we wake up, we want to be able to copy the original
// frame buffer back in.
CopyFrameBuffer(TRUE);
// Turn the display to black
// and allow a few frames to display
ClearFrameBuffer(FALSE);
XllpLCDSuspend(&XllpLCD, Suspend_Graceful);
}
else
{
// Copy the original frame buffer back in.
CopyFrameBuffer(FALSE);
XllpLCDResume(&XllpLCD);
}
}
void CopyFrameBuffer(BOOL gDirection)
{
DWORD i;
unsigned * cfbp = (unsigned *)gBlankFrameBuffer;
unsigned * fbp = (unsigned *)gFrameBuffer + (activeFrameBuffer * frameBufferSize);
for(i = 0; i < (DispDrvr_cxScreen * DispDrvr_cyScreen * (bpp )/ 8 / 4); i++)
{
if (gDirection)
{
*cfbp++ = *fbp++;
}
else
{
*fbp++ = *cfbp++;
}
}
}
void ClearFrameBuffer(BOOL color)
{
DWORD i;
unsigned * fbp = (unsigned *)gFrameBuffer + (activeFrameBuffer * frameBufferSize);
for(i = 0; i < (DispDrvr_cxScreen * DispDrvr_cyScreen * (bpp) / 8 / 4); i++)
{
if (color)
{
*fbp++ = 0xFFFFFFFF; // Ones turn it white
}
else
{
*fbp++ = 0x00000000; // Zeros turn it black
}
}
}
//**********************************************************************
//
//DispDrvrContrastControl:
//
// Modify the contrast according to the Cmd parameter.
// Not supported
//
BOOL DispDrvrContrastControl(int Cmd,DWORD *pValue)
{
// currently does not support changing contrast in software.
return TRUE;
}
//void DirtyRectDumpPortraitLoop_C(BYTE *pDstBuf, BYTE *pSrcBuf, DWORD yTop, DWORD yBottom,
// DWORD srcWidthB, DWORD bytesPerRow, DWORD bytesPerPixel,
// DWORD srcMarginWidth, DWORD dstMarginWidth)
//{
// DWORD row;
// DWORD i;
// DWORD j;
//
// if ( bytesPerPixel != 2 )
// {
// //not 16-bit
// for (i = 0; i < srcWidthB / bytesPerPixel; i++)
// {
// for (row = yTop; row < yBottom; row++)
// {
// for (j = 0; j < bytesPerPixel; j++)
// {
// *pDstBuf++ = *(pSrcBuf + j);
// }
//
// pSrcBuf -= bytesPerRow;
// }
//
// pDstBuf += dstMarginWidth;
// pSrcBuf += srcMarginWidth + 2;
// }
// }
// else
// {
// WORD * pwDst;
// WORD * pwSrc;
// int rowLen;
//
// //16-bit
// srcWidthB >>= 1;
//
// pwDst = (WORD *)pDstBuf;
// pwSrc = (WORD *)pSrcBuf;
//
// //first row for pwSrc, then column for pwDst
// rowLen = yBottom - yTop;
//
//#ifndef _OPT_ASM
// bytesPerRow >>= 1;
// dstMarginWidth >>= 1;
// srcMarginWidth >>= 1;
//
// for (i = 0; i < srcWidthB; i++)
// {
// for (row = 0; row < (rowLen >> 2); row++)
// {
// *pwDst++ = *pwSrc;
// pwSrc -= bytesPerRow;
//
// *pwDst++ = *pwSrc;
// pwSrc -= bytesPerRow;
//
// *pwDst++ = *pwSrc;
// pwSrc -= bytesPerRow;
//
// *pwDst++ = *pwSrc;
// pwSrc -= bytesPerRow;
// }
//
// for (row = 0; row < (rowLen & 0x3); row++)
// {
// *pwDst++ = *pwSrc;
// pwSrc -= bytesPerRow;
// }
//
// pwDst += dstMarginWidth;
// pwSrc += srcMarginWidth + 1;
// }
//#else
// dirtyRectDump_core_ASM(pwSrc, pwDst, rowLen, srcWidthB, bytesPerRow, srcMarginWidth, dstMarginWidth);
//#endif
// }
//}
//void DispDrvrDirtyRectDump(LPCRECT prc)
//{
// BYTE * pDstBuf;
// BYTE * pSrcBuf;
// DWORD xLeft;
// DWORD yTop;
// DWORD xRight;
// DWORD yBottom;
// DWORD bytesPerRow;
// DWORD bytesPerPixel;
// DWORD srcWidthB;
// DWORD srcMarginWidth;
// DWORD dstMarginWidth;
// DWORD srcStartRow;
// DWORD dstStartRow;
//
// bytesPerPixel = bpp / 8;
//
// xLeft = prc->left < 0 ? 0 : prc->left;
// yTop = prc->top < 0 ? 0 : prc->top;
// xRight = prc->right > DispDrvr_cxScreen ? DispDrvr_cxScreen : prc->right;
// yBottom = prc->bottom > DispDrvr_cyScreen ? DispDrvr_cyScreen : prc->bottom;
//
// if ((LONG)xLeft >= (LONG)xRight || (LONG)yTop >= (LONG)yBottom)
// {
// return;
// }
//
// xLeft *= bytesPerPixel;
// xRight *= bytesPerPixel;
// bytesPerRow = DispDrvr_cxScreen * bytesPerPixel;
//
// srcWidthB = xRight - xLeft;
// srcStartRow = (yBottom - 1) * bytesPerRow;
// srcMarginWidth = (yBottom - yTop) * bytesPerRow;
// dstStartRow = xLeft * DispDrvr_cyScreen;
// dstMarginWidth = (DispDrvr_cyScreen - (yBottom - yTop)) * bytesPerPixel;
// pDstBuf = gFrameBuffer + dstStartRow + (DispDrvr_cyScreen - yBottom) * bytesPerPixel;
//
// pSrcBuf = gDibBuffer + srcStartRow + xLeft;
//
////2007-9-12 10:38 Bruce
//// EnterCriticalSection(&displayMutex);
//
// DirtyRectDumpPortraitLoop_C(pDstBuf, pSrcBuf, yTop, yBottom, srcWidthB, bytesPerRow,
// bytesPerPixel, srcMarginWidth, dstMarginWidth);
////2007-9-12 10:37 Bruce
//// LeaveCriticalSection(&displayMutex);
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -