⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//	}

	// Print Virtual Copy Errors (If Any)
	DEBUGMSG (GPE_ZONE_INIT, (TEXT("MMFB =%08x, vcrc=%d\r\n"),
				m_nLAWPhysical, vcrc));

	//Index 0 is the current mode - set it up for GetModeInfo() to
	//return proper mode information.
	m_pMode = &MQVideoMode[0].gpeMode;

	m_pMode->Bpp	    = OemInfo.usBPP;
	m_ulBPP				= (ULONG)OemInfo.usBPP;
	m_nCursorColor		= OemInfo.usCursorColor;
	
	switch( m_ulBPP )
	{
		case 8:	m_pMode->format = gpe8Bpp;
				m_nBytesPerPixel = 1;
			 	break;
		case 16:m_pMode->format = gpe16Bpp;
				m_nBytesPerPixel = 2;
			 	break;
		case 24:m_pMode->format = gpe24Bpp;
				m_nBytesPerPixel = 3;
			 	break;
		case 32:m_pMode->format = gpe32Bpp;
				m_nBytesPerPixel = 4;
			 	break;
		case 4: m_pMode->format = gpe4Bpp;
				break;
		case 2: m_pMode->format = gpe2Bpp;
				break;
		case 1: m_pMode->format = gpe1Bpp;
				break;
	}

	m_nActualWidth = OemInfo.usX;
	m_nActualHeight= OemInfo.usY;

	m_nScreenWidth 	= m_pMode->width  = OemInfo.usX;
	m_nScreenHeight = m_pMode->height = OemInfo.usY;

	m_ulScreenStride 	= m_nActualWidth  * m_ulBPP / 8;
	m_nScreenSize		= m_ulScreenStride * m_nActualHeight;

	//Try to figure out how much frame buffer needed for D-STN panel and
	//set up proper pointer of panel data.
	m_nDSTNFBControl 	= -1;   // for non-DSTN panels

	//Asume panel is ALWAYS in the system
	usTemp = (USHORT)(m_nMQFlag & 0xff);   //Get panel type
	m_pFPControl = &FPControlData[usTemp];

	//Only required for DSTN panel
	if ( (m_pFPControl->ulFPControl & FP_TYPE_MASK) == FP_TYPE_DSTN )
	{
		//Mono D-STN memory requirement
     	m_nDSTNFBSize = m_pFPControl->usHoriSize;

  		//For color panel
     	if ( !(m_pFPControl->ulFPControl & FP_MONO) )
        	m_nDSTNFBSize *= 3;
				
		m_nDSTNFBSize = (((m_nDSTNFBSize + 127) >> 7) *
					 	m_pFPControl->usVertSize) << 3;
	
  		//Make D-STN buffer starting at KB boundary due to HW cursor
  		ULONG	ulStartAddr = (m_nScreenSize + 127) >> 7;
  		ULONG	ulEndAddr = (m_nScreenSize + m_nDSTNFBSize + 15) >> 4;
		m_nDSTNFBControl = 1;
	}

	DEFINE_BLT_TABLES
	DEFINE_LINE_TABLES
	DEFINE_PATSETUP_TABLES
}


//SetMode is called to enable the GPE-based device driver (if it isn't 
//already enabled) and request a specific mode for the display. The modeId 
//here is the value from the modeId field of the GPEMode structure populated 
//by a prior call to GPE::GetModeInfo. This may not be the same as the modeNo 
//value used in the GetModeInfo call.
SCODE
MQGC::SetMode( int modeId, HPALETTE *pPalette )
{
	SCODE sc;

	if ( (sc = AllocMQSurfaces()) != S_OK )
		return sc;				//Allocate surfaces

	m_nMQFlag |= FULL_SETMODE;
	SetMQMode(); 				//Establish video mode
	m_nMQFlag &= (~FULL_SETMODE);
	
	SetVisibleSurface( (MQGCSurf *)m_pPrimarySurface );

	// Create palette
	if( pPalette )
		CreatePal(pPalette);

	// Default gamma (ie. no gamma by degault)
	ULONG	ulPalData=0;
	for ( int i = 0; i < 256; i++ )
	{
		m_nGammaRGB[i] = ulPalData;
		ulPalData += 0x00010101;
	}

	DumpPal();	// no op for non-emulation
	return S_OK;
}

SCODE
MQGC::AllocMQSurfaces( void )
{
	GPESurf *pDummy;
	SCODE sc;
	ULONG	ulAllocWidth, ulAllocHeight;
	ULONG	ulStridePixels, ulStrideLines;

	ulAllocWidth = ulStridePixels = m_ulScreenStride * 8UL / m_ulBPP;
	ulAllocHeight = ulStrideLines  = (ULONG)(m_nVideoMemorySize/m_ulScreenStride);

	m_p2DVideoMemory = new Node2D(ulAllocWidth, ulAllocHeight,0,0,32/m_ulBPP);

	// ===========================================================
	//Allocate primary surface for DDI.DLL
	// ===========================================================
	if( FAILED( sc = AllocSurface(
					&m_pPrimarySurface,
					m_nScreenWidth,
					m_nScreenHeight,
					m_pMode->format,
					GPE_REQUIRE_VIDEO_MEMORY ) ) )
		return sc;

	// ===========================================================
	//Allocate surface for	DSTN half frame buffer
	// ===========================================================
  	if (m_nDSTNFBControl != -1)
	{
		m_nDSTNFBSize += 128;
		ulAllocHeight = m_nDSTNFBSize / m_ulScreenStride;
		ulAllocHeight += (ulAllocHeight*m_ulScreenStride >= m_nDSTNFBSize ? 0: 1);
		ulAllocWidth = ulStridePixels;

		SWAP_WIDTH_HEIGHT( ulAllocWidth, ulAllocHeight )
		if( FAILED( sc = AllocSurface(
						&pDummy,
						ulAllocWidth,
						ulAllocHeight,
						m_pMode->format,
						GPE_REQUIRE_VIDEO_MEMORY ) ) )
			return sc;

		ROTATE_VRAMSURF(pDummy, DummySave,NULL,NULL);

  		ULONG	ulStartAddr = ((ADDRESS)(pDummy->OffsetInVideoMemory()+ 127) >> 7);
  		ULONG	ulEndAddr = ((ulStartAddr<<7) + (m_nDSTNFBSize-128) + 15) >> 4;
			
		// Save DSTN frame buffer start and ending address
		m_nDSTNFBControl = ulStartAddr | ((ulEndAddr - 1) << 16);
	}

	// ===========================================================
	//Allocate surface for HW_CURSOR
	// ===========================================================

	ULONG ulCursorSize = (1024 +1024);
	ulAllocHeight = ulCursorSize / m_ulScreenStride;
	ulAllocHeight += (ulAllocHeight*m_ulScreenStride >= ulCursorSize ? 0: 1);
	ulAllocWidth = ulStridePixels;

	SWAP_WIDTH_HEIGHT( ulAllocWidth, ulAllocHeight )
	if( FAILED( sc = AllocSurface(
					&pDummy,
					ulAllocWidth,
					ulAllocHeight,
					m_pMode->format,
					GPE_REQUIRE_VIDEO_MEMORY ) ) )
			return sc;

	ROTATE_VRAMSURF(pDummy, DummySave,NULL,NULL);

	m_nCursorStart = (ADDRESS)((pDummy->OffsetInVideoMemory()+1023)>>10);

	// ===========================================================
	//Allocate surface for	scratch buffer
	// ===========================================================
#ifdef	CHECK_24BPP
	//Allocate 1 line of video buffer if 24BPP
	if ( m_ulBPP == 24UL )
	{
		ulAllocWidth = ulStridePixels;
		ulAllocHeight = 1UL;
		SWAP_WIDTH_HEIGHT( ulAllocWidth, ulAllocHeight )
		if( FAILED( sc = AllocSurface(
						&pDummy,
						ulAllocWidth,
						ulAllocHeight,
						m_pMode->format,
						GPE_REQUIRE_VIDEO_MEMORY ) ) )
			return sc;

		ROTATE_VRAMSURF(pDummy, DummySave,NULL,NULL);
		
		m_pScratchBuffer = pDummy->Buffer();
		m_ulScratchTopLeft = (ULONG)(pDummy->OffsetInVideoMemory()
								/ pDummy->Stride()) << 16;	//Left always = 0
	#if ETARGET == IS_CEPC
		//Need to subtract 2 lines if S3 emulation
		m_ulScratchTopLeft -= 0x00020000UL;
	#endif
	}
#endif	//CHECK_24BPP

	return	sc;
}


//-------------------------------------------------------------------------
//
// This routine is responsible for setting proper timing parameters and
// related registers for GC1 or/and GC2.
//
// For single display mode (LCD or CRT or simultaneous LCD/CRT),
//		GC1 is used only
//
// For QView configuration, such as LargeDesktop, SameImage etc.,
//
// 	LCD is always controlled by GC2
// 	CRT is always driven by GC1
//
// Parameters
//
//		usGCUseFlag		USE_OneGC or USE_TwoGCs
//		usOriginAt		(0,0) is located at GC1 or GC2
//		usNonOriginX
//		usNonOriginY	2nd display top-left coordinate for LargeDesktop
//							(0,0) if SameImage or single GC configuration
//
//-------------------------------------------------------------------------
void
MQGC::SetupGCs(USHORT usGCUseFlag,
			   USHORT usOriginAt,
			   USHORT usNonOriginX,
			   USHORT usNonOriginY)
{
	int		x, y;
	USHORT	aws;
	USHORT 	xc, yc, fc, xl, yl, fl;
	ULONG	ulTemp;
	ULONG	ulIW_Stride00, ulIW_StrideXX, ulIW_StartAddr00, ulIW_StartAddrXX;

	aws = (USHORT)m_ulScreenStride; 		//make alt win same as window

	//Based on the passing parameters, we initialize and set up locals
	//to support various configurations.
	ulIW_Stride00 =
	ulIW_StrideXX = (aws << 16) | m_ulScreenStride;

	ulIW_StartAddr00 =
	ulIW_StartAddrXX = (ADDRESS)(m_pPrimarySurface->OffsetInVideoMemory());

	if ( usNonOriginX == 0 && usNonOriginY == 0 )
	{
		//Single GC or QView Same Image cases
		x = m_nScreenWidth;
		y = m_nScreenHeight;
	}
	else if ( usNonOriginX )
	{
		//QView horizontal LargeDesktop
		x = usNonOriginX;
		y = m_nScreenHeight;
		ulIW_StartAddrXX += m_ulScreenStride / 2;
		m_nMQFlag &= ~VERTICAL_LAYOUT;
	}
	else
	{
		//QView vertical LargeDesktop
		x = m_nScreenWidth;
		y = usNonOriginY;
		ulIW_StartAddrXX += m_ulScreenStride * y;
		m_nMQFlag |= VERTICAL_LAYOUT;
	}

	//Set up some data members for Cursor boundary checking
	CursorData.us1GCWidth = x;
	CursorData.us1GCHeight = y;

	//By definition, this mode exists only in low-end flat panel
	ulTemp = m_nMQFlag & LAYOUT_MODE_MASK;
	if ( ulTemp && (m_nMQFlag & LCD_ON) )	//Valid for LCD only
	{
		ulIW_StartAddr00 =
		ulIW_StartAddrXX = (ADDRESS)(m_pPrimarySurface->OffsetInVideoMemory());

		//LAYOUT_MODE_SCROLL - stride remains.
		if ((usNonOriginX == 0 && usNonOriginY == 0) || (usOriginAt == AT_GC2))
		{
			//Here is,
			//- Single GC modes
			//- 2GC with SameImage
			//- 2GC with LargeDesktop but usOriginAt = AT_GC2
			//
			if (ulTemp == LAYOUT_MODE_EVEN)
				ulIW_Stride00 = (aws << 16) | (m_ulScreenStride * 2);
			else if (ulTemp == LAYOUT_MODE_ODD)
			{
				ulIW_Stride00 = (aws << 16) | (m_ulScreenStride * 2);
				ulIW_StartAddr00 += m_ulScreenStride;
			}
		}
		else
		{
			//LCD is not at (0,0)
			if (ulTemp == LAYOUT_MODE_EVEN)
			{
				ulIW_Stride00 = (aws << 16) | (m_ulScreenStride * 2);
			  	if (usNonOriginX)
					ulIW_StartAddrXX += m_ulScreenStride / 2;
				else
					ulIW_StartAddrXX += m_ulScreenStride * y;
			}
			else if (ulTemp == LAYOUT_MODE_ODD)
			{
				ulIW_Stride00 = (aws << 16) | (m_ulScreenStride * 2);
			  	if (usNonOriginX)
					ulIW_StartAddrXX += m_ulScreenStride + m_ulScreenStride / 2;
				else
					ulIW_StartAddrXX += m_ulScreenStride * (y + 1);
			}
		} //LATGEDESKTOP
	} //LAYOUT_MODE

	//Program registers here
	if ( usGCUseFlag == USE_OneGC_PP)
	{
		gc1REG(IW1_STRIDE, 		ulIW_StrideXX);
		gc1REG(IW1_START_ADDR,	ulIW_StartAddrXX);
		m_nIW1StartAddr = ulIW_StartAddrXX;	//for panning
	}
	else
	if ( usOriginAt == AT_GC2 || usGCUseFlag == USE_OneGC)
	{
		gc2REG(IW2_STRIDE,		ulIW_Stride00);
		gc2REG(IW2_START_ADDR,	ulIW_StartAddr00);
		gc1REG(IW1_STRIDE,		ulIW_StrideXX);
		gc1REG(IW1_START_ADDR,	ulIW_StartAddrXX);
		m_nIW1StartAddr = ulIW_StartAddrXX;
		m_nIW2StartAddr = ulIW_StartAddr00;
	}
	else
	{
		gc2REG(IW2_STRIDE,		ulIW_StrideXX);
		gc2REG(IW2_START_ADDR,	ulIW_StartAddrXX);
		gc1REG(IW1_STRIDE,		ulIW_Stride00);
		gc1REG(IW1_START_ADDR,	ulIW_StartAddr00);
		m_nIW1StartAddr = ulIW_StartAddr00;
		m_nIW2StartAddr = ulIW_StartAddrXX;
	}

	//Set up cursor start address for both GCs anyway ...
	if ( usGCUseFlag != USE_OneGC_PP)	// Not PowerPoint case
	{
		gc1REG(HW_CURSOR1_ADDR, m_nCursorStart);
  		gc2REG(HW_CURSOR2_ADDR, m_nCursorStart);
	}
		
	if (m_nDSTNFBControl != -1) 		// DSTN is used in the system
  		fpREG(DSTN_FB_CONTROL, m_nDSTNFBControl);
	
	//Set up the rest of flat panel registers - ALWAYS
	fpREG(FP_CONTROL, 		m_pFPControl->ulFPControl);
	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);
	if (m_nMQFlag & SWAP_PWM01)
	// Swap PWM 0 and PWM 1 functionality 
	// -
	//
		ulTemp = (OemInfo.ulPWMControl << 16)
				| (OemInfo.ulPWMControl >> 16)
				| (OemInfo.usContrast << 24)
				| ((ULONG)(OemInfo.usBright) << 8);
	else
		ulTemp = OemInfo.ulPWMControl
				| (OemInfo.usContrast << 8)
				| ((ULONG)(OemInfo.usBright) << 24);
	fpREG(PWM_CONTROL,		ulTemp);
	//OemSetContrast(OemInfo.usContrast);

	//FRC is NOT needed for TFT panel
	int j = 0;
	if ( (m_pFPControl->ulFPControl & FP_TYPE_MASK) != FP_TYPE_TFT )
	{
		int		i;
		
		if ((m_pFPControl->ulFPControl & FP_TYPE_MASK) == FP_TYPE_SSTN)
			j++;
		for ( i = 0; i < FRC_PATTERN_CNT; i++ )
  			fpREG((FRC_PATTERN + i * uBUSW), FRCControlData[j].ulFRCPattern[i]);
		for ( i = 0; i < FRC_WEIGHT_CNT; i++ )
  			fpREG((FRC_WEIGHT + i * uBUSW), FRCControlData[j].ulFRCWeight[i]);
	}

	// Set up CRT control register - don't enable yet
	gc1REG(GC1_CRT_CONTROL, BLANK_PED_ENABLE|MON_SENSE_ENABLE);
	
	xc = OemInfo.usVXCrt;
	yc = OemInfo.usVYCrt;
	fc = OemInfo.usFreqCrt;
	xl = OemInfo.usVX;
	yl = OemInfo.usVY;
	fl = OemInfo.usFreq;

	if (usGCUseFlag == USE_OneGC || usGCUseFlag == USE_OneGC_PP)
	{
		//Set up timing parameters for LCD and simul LCD/CRT
		if ( m_nMQFlag & LCD_ON )
		{
			SetupLCDTiming( xl, yl, fl, RELOAD_TIMING );
			HW_Enable_LCD( GC1 );
			if ( m_nMQFlag & CRT_ON )
				HW_Enable_CRT( GC1 );
		}
		else
		//Set up timing parameters for CRT only
		{
			SetupCRTTiming( xc, yc, fc );
			HW_Enable_CRT(GC1);
		}
	}
	else
	{
		//Set up GC2 timing registers to drive LCD
		SetupLCDTiming( xl, yl, fl, RELOAD_TIMING|LCD_BY_GC2 );

		//Set up GC1 timing registers for CRT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -