📄 sa2video.cpp
字号:
pgxoi->cbStride = 1280;
pgxoi->cBPP = 16;
}
if (bpp == 8)
{
pgxoi->cbStride = 640;
pgxoi->cBPP = 16;
}
}
pgxoi->cxWidth = DispDrvr_cxScreen;
pgxoi->cyHeight = DispDrvr_cyScreen;
// Set kfLandscape only if the display orientation is not in its native format
pgxoi->ffFormat= kfDirect565;
pgxoi->vkButtonUpPortrait = VK_UP;
pgxoi->vkButtonUpLandscape = 0xC3;
pgxoi->ptButtonUp.x = -50;
pgxoi->ptButtonUp.y = 0;
pgxoi->vkButtonDownPortrait = VK_DOWN;
pgxoi->vkButtonDownLandscape = 0xC4;
pgxoi->ptButtonDown.x = -50;
pgxoi->ptButtonDown.y = 30;
pgxoi->vkButtonLeftPortrait = 0xC2;
pgxoi->vkButtonLeftLandscape = VK_DOWN;
pgxoi->ptButtonLeft.x = 25;
pgxoi->ptButtonLeft.y = 400;
pgxoi->vkButtonRightPortrait = 0xC3;
pgxoi->vkButtonRightLandscape = VK_UP;
pgxoi->ptButtonRight.x = 90;
pgxoi->ptButtonRight.y = 410;
pgxoi->vkButtonAPortrait = 0xC4;
pgxoi->vkButtonALandscape = 0xC2;
pgxoi->ptButtonA.x = 150;
pgxoi->ptButtonA.y = 410;
pgxoi->vkButtonBPortrait = 0xC5;
pgxoi->vkButtonBLandscape = 0xC5;
pgxoi->ptButtonB.x = 220;
pgxoi->ptButtonB.y = 400;
pgxoi->vkButtonCPortrait = VK_ESCAPE;
pgxoi->vkButtonCLandscape = VK_ESCAPE;
pgxoi->ptButtonC.x = -50;
pgxoi->ptButtonC.y = 100;
pgxoi->vkButtonStartPortrait = VK_F23;
pgxoi->vkButtonStartLandscape = VK_F23;
pgxoi->ptButtonStart.x = -50;
pgxoi->ptButtonStart.y = 15;
pgxoi->pvReserved1 = (void *) 0;
pgxoi->pvReserved2 = (void *) 0;
RetVal = 1;
} else
{
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = -1;
}
} else {
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = -1;
}
break;
/* add nwe code by Xiexy 06-09-05 */
case IOCTL_POWER_CAPABILITIES:
// tell the power manager about ourselves
DEBUGMSG(1, (L"%s: IOCTL_POWER_CAPABILITIES\r\n", pszFname));
RETAILMSG(1, (TEXT("IOCTL_POWER_CAPABILITIES\r\n")));
if (pvOut != NULL && cjOut == sizeof(POWER_CAPABILITIES))
{
__try
{
PPOWER_CAPABILITIES ppc = (PPOWER_CAPABILITIES) pvOut;
memset(ppc, 0, sizeof(*ppc));
ppc->DeviceDx = 0x09; // support D0 and D3
RetVal = 1;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DEBUGMSG(1, (L"%s: exception in ioctl\r\n"));
}
}
break;
case IOCTL_POWER_QUERY:
RETAILMSG(1, (TEXT("IOCTL_POWER_QUERY\r\n")));
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
// return a good status on any valid query, since we are always ready to
// change power states.
__try
{
CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE) pvOut;
if(VALID_DX(NewDx))
{
// this is a valid Dx state so return a good status
RetVal = 1;
}
DEBUGMSG(1, (L"%s: IOCTL_POWER_QUERY %u %s\r\n", pszFname,
NewDx, RetVal == 1 ? L"succeeded" : L"failed"));
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DEBUGMSG(1, (L"%s: exception in ioctl\r\n"));
}
}
break;
case IOCTL_POWER_SET:
RETAILMSG(1, (TEXT("IOCTL_POWER_SET\r\n")));
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
__try
{
CEDEVICE_POWER_STATE NewDx = *(PCEDEVICE_POWER_STATE) pvOut;
CEDEVICE_POWER_STATE CurrentDx;
if(VALID_DX(NewDx))
{
VIDEO_POWER_STATE ulPowerState = PmToVideoPowerState(NewDx);
SetDisplayPower(ulPowerState);
CurrentDx = m_Dx;
RetVal = 1;
DEBUGMSG(1, (L"%s: IOCTL_POWER_SET %u: passing back %u\r\n", pszFname,
NewDx, CurrentDx));
}
else
{
DEBUGMSG(1,
(L"%s: IOCTL_POWER_SET: invalid state request %u\r\n", pszFname, NewDx));
}
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DEBUGMSG(1, (L"%s: exception in ioctl\r\n"));
}
}
break;
case IOCTL_POWER_GET:
RETAILMSG(1, (TEXT("IOCTL_POWER_GET\r\n")));
if(pvOut != NULL && cjOut == sizeof(CEDEVICE_POWER_STATE))
{
__try
{
CEDEVICE_POWER_STATE CurrentDx = m_Dx;
*(PCEDEVICE_POWER_STATE) pvOut = CurrentDx;
RetVal = 1;
DEBUGMSG(1, (L"%s: IOCTL_POWER_GET: passing back %u\r\n", pszFname,
CurrentDx));
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DEBUGMSG(1, (L"%s: exception in ioctl\r\n"));
}
}
break;
/* end of new code by Xiexy*/
default:
RetVal = 0;
break;
}
return RetVal;
}
void SA2Video::ContrastCmd(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
}
#ifndef DD_ENABLE
void RegisterDDHALAPI()
{
; // No DDHAL support in wrapper
}
#endif
#ifdef DD_ENABLE
void SA2Video::GetVirtualVideoMemory(unsigned long *virtualMemoryBase, unsigned long *videoMemorySize)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEFlat::GetVirtualVideoMemory\r\n")));
*virtualMemoryBase = m_VirtualFrameBuffer;
*videoMemorySize = DispDrvr_cdwStride * DispDrvr_cyScreen;
}
#endif
#ifdef DD_ENABLE
SCODE
SA2Video::AllocSurface(DDGPESurf **ppSurf, int width, int height, EGPEFormat format, EDDGPEPixelFormat pixelFormat, int surfaceFlags)
{
if (surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY)
{
*ppSurf = (DDGPESurf *)NULL;
RETAILMSG (1, (L"AllocSurface - Out of Memory 3\n"));
return E_OUTOFMEMORY;
}
// Allocate from system memory
RETAILMSG(0, (TEXT("Creating a GPESurf in system memory. EGPEFormat = %d\r\n"), (int) format));
{
DWORD bpp = EGPEFormatToBpp[format];
DWORD stride = ((bpp * width + 31) >> 5) << 2;
DWORD nSurfaceBytes = stride * height;
*ppSurf = new DDGPESurf(width, height, stride, format, pixelFormat);
}
if (*ppSurf != NULL)
{
// check we allocated bits succesfully
if (((*ppSurf)->Buffer()) == NULL)
{
delete *ppSurf;
}
else
{
return S_OK;
}
}
RETAILMSG (1, (L"AllocSurface - Out of Memory 4\n"));
return E_OUTOFMEMORY;
}
#endif
#if 0
void SA2Video::SetVisibleSurface( GPESurf *pTempSurf, BOOL bWaitForVBlank)
{
GPEFlatSurf *pSurf = (GPEFlatSurf *) pTempSurf;
// if(bWaitForVBlank)
// {
// WAIT_FOR_VBLANK;
// }
// // set CRT memory offset without changing CRT pitch
// _memwD_reg(CRTC_OFF_PITCH, (_memrD_reg(CRTC_OFF_PITCH) & 0xffc00000) | ((pSurf->Stride() * pSurf->Top()) >> 3));
}
#endif
/* add new functiong by Xiexy 06-09-05 */
void KnlSleep(int a)
{
int b;
b=a*100000;
for (volatile int i=0; i< b; i++);
}
void
SA2Video::SetDisplayPower(VIDEO_POWER_STATE vps)
{
//bOff = TRUE : power off
//bOff = FALSE : power on
//
//SA2Video implements D0 to D3 state for power management. However, since CE
//has not adapted OnNow/ACPI initiative, D1 and D2 state will not be used
//here. However, OEM can use them in system-wide power management routine
//controlled by either hard botton or software.
int i=0,j=0;
BOOL bOff = FALSE;
/* if (vps == VideoPowerOff)
{
if (m_Dx == D3)
return;
// geWAITNOTBUSY needs m_Dx to be D0 to not return early
m_Dx = D3;
// Save required registers ...
while (MediaQRegs[i].ulOffset != 0xffffffff)
{
MediaQRegs[i].ulData =
*((PLONG)(m_pMMIO + MediaQRegs[i].ulOffset));
i++;
}
// Save hw cursor
ULONG *pULONG = (ULONG *)(&m_pLAW[m_nCursorStart << 10]);
for (i = 0; i < 256; i++)
{
ulHWCursorArea[i] = *pULONG++;
}
// Set up the MQ200 D2 power state with cursor and memory refresh enabled.
// Since it is possible that both cursors could be active
// we enable them both. It might be possible to optimize this code by only
// enabling the one that's being used (if only one is being used).
KnlSleep(40);
pciREG(PCI_PM_CNTL_STATUS, ENTER_D2); // put the display to sleep
}
else // vps must be VideoPowerOn
{
if (m_Dx == D0)
return;
// Restore registers ...
dcREG(DC_0, MediaQRegs[0].ulData);
pmuREG(D1_STATE, OemInfo.ulD1State);
pmuREG(D2_STATE, OemInfo.ulD2State);
KnlSleep(1);
pciREG(PCI_PM_CNTL_STATUS, ENTER_D0);
KnlSleep(40);
CHECK_IF_STATE_D(0); //Make sure in a stable state
// This will fail resume if not doing this ...
pmuREG(PM_MISC, (GE_ENABLE | GE_BY_PLL1) );
miuREG(MIU_CONTROL1, DRAM_RESET_DISABLE);
KnlSleep(5);
miuREG(MIU_CONTROL1, 0x00);
KnlSleep(5);
miuREG(MIU_CONTROL2, MediaQRegs[1].ulData);
miuREG(MIU_CONTROL3, MediaQRegs[2].ulData);
miuREG(MIU_CONTROL4, MediaQRegs[3].ulData);
miuREG(MIU_CONTROL5, MediaQRegs[4].ulData);
KnlSleep(1);
miuREG(MIU_CONTROL1, MIU_ENABLE | MIU_RESET_DISABLE);
KnlSleep(5);
// Restore FPI from pre-defined table ...
fpREG(FP_PIN_CONTROL, m_pFPControl->ulFPPinControl);
fpREG(FP_GPO_CONTROL, OemInfo.ulFPGPO);
fpREG(FP_GPIO_CONTROL, OemInfo.ulFPGPIO);
fpREG(STN_CONTROL, m_pFPControl->ulSTNControl);
for ( i = j = 0; i < FRC_PATTERN_CNT; i++, j+=4 )
fpREG((FRC_PATTERN + j), FRCControlData[0].ulFRCPattern[i]);
for ( i = j = 0; i < FRC_WEIGHT_CNT; i++, j+=4 )
fpREG((FRC_WEIGHT + j), FRCControlData[0].ulFRCWeight[i]);
// Restore hw cursor
ULONG *pULONG = (ULONG *)(&m_pLAW[m_nCursorStart << 10]);
for (i = 0; i < 256; i++)
{
*pULONG++ = ulHWCursorArea[i];
}
i=5; // Start from index 5 ...
while (MediaQRegs[i].ulOffset != 0xffffffff)
{
*((PLONG)(m_pMMIO + MediaQRegs[i].ulOffset)) =
MediaQRegs[i].ulData;
i++;
}
// Reload DAC if palette is used ...
if (usBPP == 8)
SetPalette(_rgbIdentity256, 0, 256);
// geWAITNOTBUSY needs m_Dx to be D0 only when in full power mode
m_Dx = D0;
}
*/
// Simple power state switch only ...
if(vps == VideoPowerOff)
{
if (m_Dx == D3)
return;
else
{
m_Dx = D3;
bOff = TRUE;
//OemInfo.ulFPGPO &=~GPO4_DATA_HIGH;// Turn GPIO to low
//fpREG(FP_GPO_CONTROL, OemInfo.ulFPGPO);
//pciREG(PCI_PM_CNTL_STATUS, ENTER_D3);
RETAILMSG(1,(TEXT("LCD is entering to D3!\r\n")));
DispDrvrPowerHandler(bOff);
KnlSleep(40);
//OemEnterPowerSave(ENTER_D3);
}
}
else // vps must be VideoPowerOn
{
if (m_Dx == D0)
return;
else
{
m_Dx = D0;
bOff = FALSE;
//- since chip was properly initialized during reset, entering D0 state
//is enough to get it back to normal operation mode.
//
//pciREG(PCI_PM_CNTL_STATUS, ENTER_D0);
RETAILMSG(1,(TEXT("LCD is entering to D0!\r\n")));
DispDrvrPowerHandler(bOff);
KnlSleep(40);
//OemInfo.ulFPGPO |=GPO4_DATA_HIGH;// Turn GPIO to low
//fpREG(FP_GPO_CONTROL, OemInfo.ulFPGPO);
//OemEnterPowerSave(ENTER_D0);
}
}
}
/* end of new function by Xiexy */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -