📄 ddipu_sdc.cpp
字号:
//-----------------------------------------------------------------------------
// Copyright (C) 2004-2005, MOTOROLA, INC. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// MOTOROLA, INC.
//------------------------------------------------------------------------------
//
// Copyright (C) 2005-2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//
// File: DDIPU_SDC.cpp
//
// Implementation of class DDIPU_SDC.
//
//------------------------------------------------------------------------------
#include "precomp.h"
#ifdef PLAT_PMC
#include <disppm.h>
#endif
#include "ipu.h"
//------------------------------------------------------------------------------
// External Functions
// This prototype avoids problems exporting from .lib
BOOL APIENTRY GPEEnableDriver(ULONG engineVersion, ULONG cj, DRVENABLEDATA *data,
PENGCALLBACKS engineCallbacks);
BOOL APIENTRY DrvEnableDriver(ULONG engineVersion, ULONG cj, DRVENABLEDATA *data,
PENGCALLBACKS engineCallbacks)
{
return GPEEnableDriver(engineVersion, cj, data, engineCallbacks);
}
extern BOOL BSPDeinitializeTVOut();
extern BOOL BSPInitializeTVOut(BOOL tv_out_ntsc);
extern BOOL BSPInitializeLCD();
extern BOOL BSPEnableLCD();
extern BOOL BSPDisableLCD();
//------------------------------------------------------------------------------
// External Variables
extern "C" PANEL_INFO g_PanelArray[];
//------------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------------
// Local Variables
static PCSP_PBC_REGS g_pPBC;
static GPE *gGPE = (GPE *) NULL;
INSTANTIATE_GPE_ZONES((GPE_ZONE_ERROR|GPE_ZONE_INIT|GPE_ZONE_WARNING),"IPU SDC Driver","unused1","unused2");
static EGPEFormat eFormat[] =
{
gpe8Bpp,
gpe16Bpp,
gpe24Bpp,
gpe32Bpp,
};
static EDDGPEPixelFormat ePixelFormat[4] =
{
ddgpePixelFormat_8bpp,
ddgpePixelFormat_565,
ddgpePixelFormat_8880, // not supported, just for possible future expansion
ddgpePixelFormat_8888, // not supported, just for possible future expansion
};
static ULONG BitMasks[][3] =
{
{ 0, 0, 0 },
{ 0xF800, 0x07E0, 0x001F },
{ 0xFF0000, 0x00FF00, 0x0000FF },
{ 0x00FF0000, 0x0000FF00, 0x000000FF }
};
static GPEMode ModeArray[numPanels] =
{
// Sharp QVGA panel
{DISPLAY_MODE_DEVICE, SCREEN_PIX_WIDTH, SCREEN_PIX_HEIGHT, DISP_BPP, 60, gpe16Bpp}, // 240*320*16bpp
// NEW VGA panel
{DISPLAY_MODE_DEVICE, SCREEN_PIX_WIDTH_VGA, SCREEN_PIX_HEIGHT_VGA, DISP_BPP, 60, gpe16Bpp}, //640*480*16bpp
// Put other panel info here in future expasion
// ... ...
};
static GPEMode NTSCMode = {DISPLAY_MODE_NTSC, SCREEN_PIX_WIDTH, SCREEN_PIX_HEIGHT, DISP_BPP, 60, gpe16Bpp}; //mode listed as 320*240*16, but upsized to 640*480*16bpp
static GPEMode PALMode = {DISPLAY_MODE_PAL, SCREEN_PIX_WIDTH, SCREEN_PIX_HEIGHT, DISP_BPP, 60, gpe16Bpp}; //mode listed as 320*240*16, but upsized to 640*480*16bpp
//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------
//
// Function: DrvGetMasks
//
// This function retrieves the color masks for the display device's current
// mode. The ClearType and anti-aliased font libraries use this function.
//
// Parameters:
// dhpdev
// [in] Handle to the display device for which to retrieve color
// mask information.
//
// Returns:
// A pointer to three consecutive ULONG values. Each ULONG represents
// the mask for a particular color component, red, green, or blue. For
// example, a RGB565 based display returns (0xf800, 0x07e0, 0x001f).
//
//------------------------------------------------------------------------------
PULONG APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
if (gGPE == NULL)
return(BitMasks[0]);
int nBPP = ((DDIPU_SDC *)gGPE)->GetBpp()/8 - 1;
switch (((DDIPU_SDC *)gGPE)->GetBpp())
{
case 8:
case 16:
case 24:
case 32:
return(BitMasks[nBPP]);
break;
}
return(BitMasks[0]);
}
//------------------------------------------------------------------------------
//
// Function: GetGPE
//
// Main entry point for a GPE-compliant driver.
//
// Parameters:
// None.
//
// Returns:
// GPE class pointer.
//
//------------------------------------------------------------------------------
GPE *GetGPE(VOID)
{
if (!gGPE)
{
BOOL result;
gGPE = new DDIPU_SDC(&result);
if(!result)
{
DEBUGMSG(GPE_ZONE_ERROR, (TEXT("%s: Failed to get GPE instance!\r\n"), __WFUNCTION__));
gGPE = NULL;
}
}
return gGPE;
}
//*********************************************************************
// CLASS MEMBER FUNCTIONS
//*********************************************************************
//------------------------------------------------------------------------------
//
// Function: DDIPU_SDC
//
// Constructor of DDIPU_SDC class.
//
// Parameters:
// pbRet
// [in] Pointer to return value. TRUE if success, FALSE if failure.
//
// Returns:
//
//------------------------------------------------------------------------------
DDIPU_SDC::DDIPU_SDC(BOOL * pbRet)
{
BOOL result = TRUE;
// Initialze IPU_SDC class on software perspective
if(!Init())
{
result = FALSE;
goto _done;
}
// Setup video buffer
if(!SetupVideoMemory())
{
result = FALSE;
goto _done;
}
m_pPrimarySurface->SetRotation(m_nScreenWidth, m_nScreenHeight, m_iRotate);
// Setup IPU SDC of i.MX31 processor
if(!InitHardware())
{
result = FALSE;
goto _done;
}
// Notify the system that we are a power-manageable device
#ifdef PLAT_PMC // PMC doesn't support cursors
// intialize display power management
m_Dx = D4;
if (!DISPLInitPM(g_hmodDisplayDll))
{
result = FALSE;
goto _done;
}
// Set the initial display mode
DISPLSetMode((DWORD)this, DISPLAY_MODE_DEVICE, FALSE);
// PMC doesn't use a display cursor
m_CursorDisabled = TRUE;
#else
m_Dx = D0;
if(!AdvertisePowerInterface(g_hmodDisplayDll))
{
result = FALSE;
goto _done;
}
#endif // PLAT_PMC
_done:
if(!result)
Cleanup();
DEBUGMSG(GPE_ZONE_INIT, (TEXT("IPU_SDC IPU_SDC: class construction %s!!\r\n"), result ? L"succeeds" : L"fails"));
*pbRet = result;
}
//------------------------------------------------------------------------------
//
// Function: ~DDIPU_SDC
//
// Destructor of DDIPU_SDC class.
//
// Parameters:
// None.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
DDIPU_SDC::~DDIPU_SDC()
{
Cleanup();
}
//------------------------------------------------------------------------------
//
// Function: SetMode
//
// This method executes to enable the device driver
// based on the Graphics Primitive Engine (GPE)
// and to request a specific mode for the display.
//
// Parameters:
// modeID
// [in] Mode number to set.
//
// pPalette
// [in/out] Handle of palette.
//
// Returns:
// S_OK successful
// others failed
//
//------------------------------------------------------------------------------
SCODE DDIPU_SDC::SetMode(int modeNo, HPALETTE * pPalette)
{
static int savedOrientation = -1;
DEVMODE dmDispMode;
EnterCriticalSection(&m_csDrawLock);
// Cannot set to any TV mode if TV is not supported by the platform
if ((modeNo == DISPLAY_MODE_NTSC) || (modeNo == DISPLAY_MODE_PAL))
{
if (!m_bTVSupported)
{
// Unsupported mode requested
DEBUGMSG(GPE_ZONE_ERROR, (TEXT("%s: SetMode: TV modes unsupported\r\n"), __WFUNCTION__));
LeaveCriticalSection(&m_csDrawLock);
return S_FALSE;
}
else
{
// We must be rotated to 320x240 in order to properly
// upsize to 640x480. So, if we are not already rotated,
// change orientation to 270 degrees rotated
if (m_iRotate == DMDO_0)
{
dmDispMode.dmSize = sizeof(DEVMODE);
savedOrientation = m_iRotate;
// We must be rotated to 320x240 in order to properly
// upsize to 640x480. So, if we are not already rotated,
// change orientation to 270 degrees rotated
dmDispMode.dmFields = DM_DISPLAYORIENTATION;
dmDispMode.dmDisplayOrientation = DMDO_270;
LeaveCriticalSection(&m_csDrawLock);
ChangeDisplaySettingsEx(NULL,&dmDispMode,NULL,CDS_RESET,NULL);
EnterCriticalSection(&m_csDrawLock);
}
// Changing to TV mode.
// We want to leave the m_pMode settings the same so that
// the UI uses the same dimensions. We only want to set up
// variables so that we will upsize the UI to fit TV.
m_bTVModeActive = TRUE;
// Set the current panel
// Index is computed by adding the TV mode number to the
// total number of panels, because the TV PANEL_INFOs come
// after the LCD panels in the array.
m_CurrentPanel = (PANEL_INFO*)&g_PanelArray[(numPanels - 1) + modeNo];
// Change mode to TV mode
m_pMode->modeId = modeNo;
m_nScreenWidth = m_pMode->width;
m_nScreenHeight = m_pMode->height;
m_nScreenBpp = m_pMode->Bpp;
if(modeNo == DISPLAY_MODE_NTSC)
m_bTVNTSCOut = TRUE;
else
m_bTVNTSCOut = FALSE;
InitHardware();
if(m_pTVBuffer1->OffsetInVideoMemory())
SetVisibleSurface((GPESurf *) m_pTVBuffer1);
// Request an update to display the UI to TV
SetEvent(m_hTVUpdateRequest);
}
}
else
{
DWORD dwOldMode = m_pMode->modeId;
if ((modeNo <= MAX_NUM_MODES) && (m_pMode->modeId != modeNo))
{
DEBUGMSG(GPE_ZONE_INIT, (TEXT("%s: Got display mode, %d!\r\n"), __WFUNCTION__, m_SupportedModes[modeNo].modeId));
memcpy(m_pMode, &(m_SupportedModes[modeNo]), sizeof(GPEMode));
}
// If we are changing to LCD mode from TV mode,
// restore old orientation.
if (dwOldMode != DISPLAY_MODE_DEVICE)
{
if (savedOrientation != -1)
{
dmDispMode.dmSize = sizeof(DEVMODE);
dmDispMode.dmFields = DM_DISPLAYORIENTATION;
dmDispMode.dmDisplayOrientation = savedOrientation;
LeaveCriticalSection(&m_csDrawLock);
ChangeDisplaySettingsEx(NULL,&dmDispMode,NULL,CDS_RESET,NULL);
EnterCriticalSection(&m_csDrawLock);
savedOrientation = -1;
}
}
// Changing to LCD mode
m_bTVModeActive = FALSE;
// Set the current panel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -