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

📄 config.cpp

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


	cx5530addr = regaddr + 0x10000;

	// SETUP GX REGISTER MEMORY MAPPED ADDRESS RANGE

	GXregisters = (unsigned char *)VirtualAlloc(
		0,
		0x10000,               // Reserve 64k of virtual address space
		MEM_RESERVE,
		PAGE_NOACCESS );

	VirtualCopy(
		GXregisters,
		(LPVOID)(regaddr>>8),
		0x10000,
		PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);

	// SETUP CX5530 MEMORY MAPPED ADDRESS RANGE

	CX5530registers = (unsigned char *)VirtualAlloc(
		0,
		0x10000,                // Reserve 64k of virtual address space
		MEM_RESERVE,
		PAGE_NOACCESS );

	VirtualCopy(
		CX5530registers,
		(LPVOID)(cx5530addr>>8),
		0x10000,
		PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);

#ifdef DD_SUPPORT
    pDriverData = &DriverData; //This is for Directdraw register access
    pDriverData->RegLinear = (unsigned long)GXregisters; //This is for Directdraw register access
    pDriverData->DhruvaLinear = (unsigned long)GXregisters + 0x10000; //This is for Directdraw register access
    pDriverData->VIPLinear = (unsigned long)GXregisters + 0x15000; //This is for Directdraw register access
	// saving the device id
	pDriverData->DeviceID=DeviceId;
#endif //DD_SUPPORT

	// SETUP FRAME BUFFER MEMORY MAPPED ADDRESS RANGE

#ifdef DD_SUPPORT
	m_nVideoMemorySize = 4 * 1024 * 1024;
#else
	m_nVideoMemorySize = 2 * 1024 * 1280; // This the highest resolution, needs 2.5Mb
#endif

	m_pLAW = (unsigned char *)VirtualAlloc(
		0,
		m_nVideoMemorySize,
		MEM_RESERVE,
		PAGE_NOACCESS );

	VirtualCopy(
		m_pLAW,
		(LPVOID)(fbaddr>>8), // | CE_ADDR_KLUDGE),
		m_nVideoMemorySize,
		PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL);

#ifdef DD_SUPPORT
    pDriverData->FbLinear = (unsigned long)m_pLAW; //This is for Directdraw FrameBuffer access
#endif //DD_SUPPORT

	// CHECK SCRATCHPAD SIZE
	// Bits [3:2] specify the scratchpad size:
	// (0x00 = none, 0x04 = 2K, 0x08 = 3K, 0x0C = 4K)

	if (GCRvalue & 0x08)
	{
		// SET THE BLT BUFFERS FOR 3K (ALSO OK FOR 4K) 

		BB0_Size_Bytes = 1328;
		BB0_Base_Address = 0x400;
		BB1_Base_Address = BB0_Base_Address + BB0_Size_Bytes;
		execute_cpu_write(GX_BB0_BASE, BB0_Base_Address);  // BB0 BASE
		execute_cpu_write(GX_BB1_BASE, BB1_Base_Address);  // BB1 BASE
	} else	{
		// SET THE BLT BUFFERS FOR 2K 

		BB0_Size_Bytes = 816;
		BB0_Base_Address = 0x800;
		BB1_Base_Address = BB0_Base_Address + BB0_Size_Bytes;
		execute_cpu_write(GX_BB0_BASE, BB0_Base_Address);  // BB0 BASE
		execute_cpu_write(GX_BB1_BASE, BB1_Base_Address);  // BB1 BASE
	}		

	//Default CurrentMode -1
	CurrentMode = -1;

	DEBUGMSG( 0,(TEXT("%X %X\n"),GXregisters,CX5530registers));
#ifdef DD_SUPPORT
	DEBUGMSG( 0,(TEXT("pDriverData: %X %X\n"),pDriverData->FbLinear,pDriverData->RegLinear));
#endif //DD_SUPPORT


	// default to lowest resolution
#ifdef FB16BPP
	m_resolution = DDI_640x480x16x60;
#else
	m_resolution = DDI_640x480x8x60;
#endif
	m_unlock = 0xFFFFFFFF;	//some invalid value

	// Read the resolution and refresh rate from registry.
	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\WBT"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
	{
	    DWORD	size;
		DWORD	type;
		PBYTE   pByte;

		pByte = NULL;
		if (RegQueryValueEx(hKey, TEXT("Resolution"), NULL, &type, NULL, &size) == ERROR_SUCCESS)
		{
			pByte = (PBYTE) malloc(size);
			if (RegQueryValueEx(hKey, TEXT("Resolution"), NULL, NULL, pByte, &size) !=
				ERROR_SUCCESS || pByte[0] == 0)
			{
				free(pByte);
				pByte = NULL;
			}
			else
			{
				DEBUGMSG( 0,(TEXT("modeIsSupported %s\n"),(LPCTSTR)pByte));

#ifdef FB16BPP
				if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 60")) == 0)
					m_resolution = DDI_640x480x16x60;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 72")) == 0)
					m_resolution = DDI_640x480x16x72;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 75")) == 0)
					m_resolution = DDI_640x480x16x75;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 85")) == 0)
					m_resolution = DDI_640x480x16x85;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 60")) == 0)
					m_resolution = DDI_800x600x16x60;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 72")) == 0)
					m_resolution = DDI_800x600x16x72;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 75")) == 0)
					m_resolution = DDI_800x600x16x75;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 85")) == 0)
					m_resolution = DDI_800x600x16x85;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 60")) == 0)
					m_resolution = DDI_1024x768x16x60;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 70")) == 0)
					m_resolution = DDI_1024x768x16x70;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 75")) == 0)
					m_resolution = DDI_1024x768x16x75;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 85")) == 0)
					m_resolution = DDI_1024x768x16x85;
#else
				if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 60")) == 0)
					m_resolution = DDI_640x480x8x60;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 72")) == 0)
					m_resolution = DDI_640x480x8x72;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 75")) == 0)
					m_resolution = DDI_640x480x8x75;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("640 480 85")) == 0)
					m_resolution = DDI_640x480x8x85;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 60")) == 0)
					m_resolution = DDI_800x600x8x60;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 72")) == 0)
					m_resolution = DDI_800x600x8x72;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 75")) == 0)
					m_resolution = DDI_800x600x8x75;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("800 600 85")) == 0)
					m_resolution = DDI_800x600x8x85;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 60")) == 0)
					m_resolution = DDI_1024x768x8x60;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 70")) == 0)
					m_resolution = DDI_1024x768x8x70;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 75")) == 0)
					m_resolution = DDI_1024x768x8x75;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1024 768 85")) == 0)
					m_resolution = DDI_1024x768x8x85;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1280 1024 60")) == 0)
					m_resolution = DDI_1280x1024x8x60;
				else if (lstrcmp((LPCTSTR)pByte, TEXT("1280 1024 75")) == 0)
					m_resolution = DDI_1280x1024x8x75;
#endif
			}
		} else { 
		//If no Resolution Tag means that the resolution is automatic which is using DDC
#if SUPPORT_DDC

			DDC1_2B *ddc = new DDC1_2B(CX5530registers);
			long best_ddc=-1;

			// Bind the DDC modes with that of the modes supported by MediaGXm.
			Display_DDC_Modes display_ddc_modes[] = { //Defined in ddc.h
#ifdef FB16BPP
				{DDC_1024x768x75, DDI_1024x768x16x75},
				{DDC_1024x768x70, DDI_1024x768x16x70},
				{DDC_1024x768x60, DDI_1024x768x16x60},
				{DDC_800x600x75, DDI_800x600x16x75},
				{DDC_800x600x72, DDI_800x600x16x72},
				{DDC_800x600x60, DDI_800x600x16x60},
				{DDC_640x480x75, DDI_640x480x16x75},
				{DDC_640x480x72, DDI_640x480x16x72},
				{DDC_640x480x60, DDI_640x480x16x60}
#else
				{DDC_1280x1024x75, DDI_1280x1024x8x75},
				{DDC_1024x768x75, DDI_1024x768x8x75},
				{DDC_1024x768x70, DDI_1024x768x8x70},
				{DDC_1024x768x60, DDI_1024x768x8x60},
				{DDC_800x600x75, DDI_800x600x8x75},
				{DDC_800x600x72, DDI_800x600x8x72},
				{DDC_800x600x60, DDI_800x600x8x60},
				{DDC_640x480x75, DDI_640x480x8x75},
				{DDC_640x480x72, DDI_640x480x8x72},
				{DDC_640x480x60, DDI_640x480x8x60}
#endif
			};

			//Find the best ddc avilable and use the MediaGXm's mode values to 
			//program the timings for the chip
			for(int i=0; i< sizeof(display_ddc_modes)/sizeof(Display_DDC_Modes); i++) {
			  if (ddc->doesDisplaySupport(display_ddc_modes[i].ddc_mode)) {
				  best_ddc=display_ddc_modes[i].ddi_mode;
					DEBUGMSG( 0,(TEXT("modeIsSupported %X\n"),best_ddc));
					//RETAILMSG( 1,(_T("modeIsSupported %X\n"),best_ddc));
				  break;
			  }
			}

			//Done with the DDC, Delete the ddc class
			delete ddc;
			if(best_ddc >= 0) //Check if we were able to get a valid mode
				m_resolution = best_ddc;
		} 
#endif
//		NKDbgPrintfW(TEXT("Resolution = %s, m_resolution = %d\n"), pByte, m_resolution); 
		RegCloseKey(hKey);
		if (pByte)
		{
			free(pByte);
			pByte = NULL;
		}
	}
#ifdef DURANGO
	gfx_regptr = GXregisters;
	gfx_vidptr = gfx_regptr+0x10000;
#ifdef FB16BPP
	gfx_set_bpp(16);
#else
	gfx_set_bpp(8);
#endif
#endif
}

//modeId is always ZERO for now
SCODE GxVideo::SetMode( int modeId, HPALETTE *pPalette )
{
	SCODE sc;
	DEBUGMSG( 0,(TEXT("GxVideo::SetMode %d\n"),modeId));
	DISPLAYMODE *pMode;
#ifndef DURANGO
	unsigned long cx55xx_clock;		//hrhr - warning treated as error - unref loval var
#endif	
	unsigned long value=0;

	//Override the value sent
	modeId = m_resolution;

#ifdef DD_SUPPORT
    // If TV is enabled then we override the mode and set a 
	// standard TV resolution - ullas.
#ifdef TV_PAL_ENABLE
    TVMODE *tvMode;
    unsigned long tvtemp;
	modeId = DDI_TV_PAL;
    tvMode = &TvParams[1];	
#endif //TV_PAL_ENABLE

#ifdef TV_NTSC_ENABLE
    TVMODE *tvMode;
    unsigned long tvtemp;
	modeId = DDI_TV_NTSC;
	tvMode = &TvParams[0];
#endif //TV_NTSC_ENABLE

#else //DD_SUPPORT
	if( modeId == CurrentMode )
	{
		// The mode is already set, just return
		return S_OK;
	}
#endif //DD_SUPPORT

	//Check if the required mode exists
	if ((pMode = GetDisplayParams(modeId)) == NULL)
	{
		DEBUGMSG( 0,(TEXT("GxVideo::SetMode mode %d, Dosen't exist\n"),modeId ));
		return E_INVALIDARG;
	}

	DEBUGMSG( 0,(TEXT("SetMode = id=%d w=%d h=%d bpp=%d Hz=%d fmt=%d\n"),
	pMode->gpeMode.modeId, pMode->gpeMode.width, pMode->gpeMode.height, 
	pMode->gpeMode.Bpp, pMode->gpeMode.frequency, pMode->gpeMode.format));


	CurrentMode = modeId; //Save the set mode

	m_pMode = &(pMode->gpeMode);
	m_nScreenWidth = m_pMode->width;
	m_nScreenHeight = m_pMode->height;
	m_nScreenStride = (((m_nScreenWidth * m_pMode->Bpp) >> 3) > 1024) ? 2048 : 1024;

#ifdef DD_SUPPORT
    //Update DDRAWDATA Structure for use by Directdraw
	pDriverData->lPitch = m_nScreenStride;
	pDriverData->dwWidth = m_nScreenWidth;
	pDriverData->dwHeight = m_nScreenHeight;
	pDriverData->dwBpp = m_pMode->Bpp;
	pDriverData->dwRefreshRate = m_pMode->frequency;
	pDriverData->wPanY = 0;
	pDriverData->wPanX = 0;
	if (pDriverData->dwBpp == 8) 
	{
		//execute_cpu_write(BB0_BASE, BLIT_BUFFER_0_8BPP);
		//execute_cpu_write(BB1_BASE, BLIT_BUFFER_1_8BPP);
		//BlitBufferSize = 800;
		pDriverData->MaxBufferPixels = 800;
		//BB0Base = BLIT_BUFFER_0_8BPP;
		pDriverData->BB1Base = BLIT_BUFFER_1_8BPP;
	}
	else
	{
		//execute_cpu_write(BB0_BASE, BLIT_BUFFER_0_16BPP);
		//execute_cpu_write(BB1_BASE, BLIT_BUFFER_1_16BPP);
		//BlitBufferSize = 1312;
		pDriverData->MaxBufferPixels = 640;
		//BB0Base = BLIT_BUFFER_0_16BPP;
		pDriverData->BB1Base = BLIT_BUFFER_1_16BPP;
	}

#endif //DD_SUPPORT
	
	// On an GX, video memory is layed out as having the same width as
	// the display and height determined by available memory
#ifdef FB16BPP
	m_p2DVideoMemory = new Node2D( (m_nScreenStride >> 1), m_nVideoMemorySize / m_nScreenStride, 0, 0, 32/m_pMode->Bpp );	// force allocations to align to 32 bits
#else
	m_p2DVideoMemory = new Node2D( m_nScreenStride, m_nVideoMemorySize / m_nScreenStride, 0, 0, 32/m_pMode->Bpp );	// force allocations to align to 32 bits
#endif
	//GPESurf *pDummy;

	// Allocate surface for cursor
	//AllocSurface( &pDummy, 640, 2, m_pMode->format, GPE_REQUIRE_VIDEO_MEMORY );
	if( FAILED( sc = AllocSurface(
						&m_pPrimarySurface,
						m_nScreenWidth,
						m_nScreenHeight,
						m_pMode->format,
						GPE_REQUIRE_VIDEO_MEMORY ) ) ) {
		OutputDebugString(TEXT("Failed AllocSurface for Cursor\r\n"));
		return sc;
	}


#if COMPRESSION_ENABLE
	// Enable Compression...

⌨️ 快捷键说明

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