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

📄 smi.cpp

📁 Sm501 VGA芯片wince下驱动代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - CMDlist buffer size  = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_cmdlist_size = dwVal;
	}
#endif	
	if (RegQueryValueEx(hkDrv, TEXT("SDRAM_BASE"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - SDRAM Base = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - SDRAM Base = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_sdrambase = dwVal;
	}	


#ifdef VGXDMA
	if (RegQueryValueEx(hkDrv, TEXT("VGXDMABUF_ADDR"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - VGXDMA buffer Base = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - VGXDMA buffer Base = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_VGXDMA_address = dwVal;
	}

	if (RegQueryValueEx(hkDrv, TEXT("VGXDMABUF_SIZE"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - VGXDMA buffer size = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - VGXDMA buffer size  = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_VGXDMA_size = dwVal;
	}
#endif	

#ifndef DISABLE_INTERRUPT_MANAGEMENT
	lpSettings->m_IntInfo.SYSINTR = GetSingleValue(hkDrv, TEXT("VgxSysIntr"));
#endif

	// Read Power Monitor initial state
#ifdef FORCE_INITIAL_OFF
	lpSettings->m_bEnablePowerMonitor = FALSE;
	MESSAGE(MESSAGE_ZONE, (TEXT("QueryRegistrySetting() - Initial state of Power Monitor: forced %s\r\n"),
		lpSettings->m_bEnablePowerMonitor? TEXT("ON") : TEXT("OFF")));
#else
	if (RegQueryValueEx(hkDrv, TEXT("PowerMonitor"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		lpSettings->m_bEnablePowerMonitor = dwVal? TRUE : FALSE;
		MESSAGE(MESSAGE_ZONE, (TEXT("QueryRegistrySetting() - Initial state of Power Monitor: %s\r\n"),
			lpSettings->m_bEnablePowerMonitor? TEXT("ON") : TEXT("OFF")));
	}
	else
	{
		// Default value is PCIBus
		lpSettings->m_bEnablePowerMonitor = FALSE;
		MESSAGE(MESSAGE_ZONE, (TEXT("QueryRegistrySetting() - Initial state of Power Monitor: auto %s\r\n"),
			lpSettings->m_bEnablePowerMonitor? TEXT("ON") : TEXT("OFF")));
	}
#endif
	//*********************************************
	//memory size -- mill.chen
	lpSettings->m_dwMemory = 8;	//Cheok(1/31/07): Set default if nothing in registry.
	if (RegQueryValueEx(hkDrv, TEXT("MemorySize"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		lpSettings->m_dwMemory = dwVal;
	}
	//Backlight Enable BacklightEnable
	if (RegQueryValueEx(hkDrv, TEXT("BacklightEnable"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		lpSettings->m_BacklightEnable = dwVal;
		
	}
	else
	{
		lpSettings->m_BacklightEnable = 0;
	}
	//memory clock setting
	if (RegQueryValueEx(hkDrv, TEXT("MemoryClock"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		lpSettings->m_MemoryClock = dwVal;
		
	}
	else
	{
		lpSettings->m_MemoryClock = 3;
	}
	//engine clock setting
	if (RegQueryValueEx(hkDrv, TEXT("EngineClock"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		lpSettings->m_EngineClock = dwVal;
		
	}
	else
	{
		lpSettings->m_EngineClock = 7;
	}
	//
    if (RegQueryValueEx(hkDrv, TEXT("BacklightTimer"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		lpSettings->m_BacklightTimeout = dwVal;		
	}
	else
	{
		lpSettings->m_BacklightTimeout = 0;
	}
	//*********************************************
	RegCloseKey(hkDrv);
}

// 
// QueryRegistrySettingLoadcepc (called when /L option used with Loadcepc)
//
// Inputs:		lpRegString	= The Windows CE registry key for the settings
//				lpSettings	= Pointer to SMISETTINGS class
//
// Outputs:		lpSettings	= Contains the registry settings
//
// Returns:		None
//
void QueryRegistrySettingLoadcepc(LPCTSTR lpRegString, SMISETTINGS *lpSettings)
{
	HKEY hkDrv = NULL;
	DWORD dwType, dwSize, dwVal;
	DWORD dwStatus;

	// open a handle to Driver configuration information
	dwStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRegString,0,0, &hkDrv);
	if(dwStatus != ERROR_SUCCESS) 
		return;

	dwSize = sizeof(DWORD);

	if (RegQueryValueEx(hkDrv, TEXT("RefreshRate"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - Refresh Rate = %d.\r\n"),
				dwVal));
		lpSettings->m_nFrequency = dwVal;
	}

	if (RegQueryValueEx(hkDrv, TEXT("TestClock"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - TestClock = %d.\r\n"),
				dwVal));
		lpSettings->m_nTestClock = dwVal;
	}

    // Query the "DisplayType" setting in the registry. Default is PANEL_OUTPUT.
    if (RegQueryValueEx(hkDrv, TEXT("DisplayType"), NULL, &dwType,
                        (LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - DisplayType = %d.\r\n"),
                 dwVal));
        lpSettings->m_nDisplayType = (BOOL) dwVal;
    }

    // Query the "SaveRestore" setting in the registry. Default is 0.
    if (RegQueryValueEx(hkDrv, TEXT("SaveRestore"), NULL, &dwType,
                        (LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - SaveRestore = %d.\r\n"),
                 dwVal));
        lpSettings->m_nSaveRestoreEnabled = (BOOL) dwVal;
    }

    // Query the "SaveSurface" setting in the registry. Default is FALSE.
    if (RegQueryValueEx(hkDrv, TEXT("SaveSurface"), NULL, &dwType,
                        (LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_INIT, (TEXT("Selecting SaveSurface mode = %d.\r\n"),
                 dwVal));
        g_bSaveSurface = (BOOL) dwVal;
    }

#if defined(HOST_ENABLE)
	if (RegQueryValueEx(hkDrv, TEXT("FB_BASE"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - FrameBuffer Base = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - FrameBuffer Base = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_nLAWPhysical = dwVal;
	}
	if (RegQueryValueEx(hkDrv, TEXT("FG_BASE"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - Register Base = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - Register Base = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_nREGPhysical = dwVal;
	}	
#endif
#ifdef CMDLIST
	if (RegQueryValueEx(hkDrv, TEXT("CMDLISTBUF_ADDR"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - CMDlist buffer Base = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - CMDlist buffer Base = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_cmdlist_address = dwVal;
	}
	if (RegQueryValueEx(hkDrv, TEXT("CMDLISTBUF_SIZE"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - CMDlist buffer size = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - CMDlist buffer size  = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_cmdlist_size = dwVal;
	}	
#endif
	if (RegQueryValueEx(hkDrv, TEXT("SDRAM_BASE"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - SDRAM Base = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - SDRAM Base = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_sdrambase = dwVal;
	}	
#ifdef VGXDMA
	if (RegQueryValueEx(hkDrv, TEXT("VGXDMABUF_ADDR"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - VGXDMA buffer Base = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - VGXDMA buffer Base = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_VGXDMA_address = dwVal;
	}
	if (RegQueryValueEx(hkDrv, TEXT("VGXDMABUF_SIZE"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - VGXDMA buffer size = %d.\r\n"),
				dwVal));
		RETAILMSG(1, (TEXT("SMIVGX - VGXDMA buffer size  = 0x%08X.\r\n"),
				dwVal));
		lpSettings->m_VGXDMA_size = dwVal;
	}	
#endif

#ifndef DISABLE_INTERRUPT_MANAGEMENT
	lpSettings->m_IntInfo.SYSINTR = GetSingleValue(hkDrv, TEXT("VgxSysIntr"));
#endif

	// Read Power Monitor initial state
#ifdef FORCE_INITIAL_OFF
	lpSettings->m_bEnablePowerMonitor = FALSE;
	MESSAGE(MESSAGE_ZONE, (TEXT("QueryRegistrySetting() - Initial state of Power Monitor: forced %s\r\n"),
		lpSettings->m_bEnablePowerMonitor? TEXT("ON") : TEXT("OFF")));
#else
	if (RegQueryValueEx(hkDrv, TEXT("PowerMonitor"), NULL, &dwType,
						(LPBYTE)&dwVal, &dwSize) == ERROR_SUCCESS)
	{
		lpSettings->m_bEnablePowerMonitor = dwVal? TRUE : FALSE;
		MESSAGE(MESSAGE_ZONE, (TEXT("QueryRegistrySettingLoadcepc() - Initial state of Power Monitor: %s\r\n"),
			lpSettings->m_bEnablePowerMonitor? TEXT("ON") : TEXT("OFF")));
	}
	else
	{
		// Default value is PCIBus
		lpSettings->m_bEnablePowerMonitor = FALSE;
		MESSAGE(MESSAGE_ZONE, (TEXT("QueryRegistrySettingLoadcepc() - Initial state of Power Monitor: auto %s\r\n"),
			lpSettings->m_bEnablePowerMonitor? TEXT("ON") : TEXT("OFF")));
	}
#endif

	RegCloseKey(hkDrv);
}

//
// EnableAllSMICards
//
// Detect and create an SMI class for each one of the SMI video card
//
static BOOL EnableAllSMICards()
{
	BOOL bRet = TRUE;
	DWORD dwMonitors;
#ifndef HOST_ENABLE
	DWORD oldMode;
    PBOOT_ARGS args; // Pointer to structure containing boot arguments provided by Loadcepc

    /* Switch to kernel mode */
	oldMode = SetKMode(TRUE);

    args = (PBOOT_ARGS)(*(PBYTE *)BOOT_ARG_PTR_LOCATION);
    args = (PBOOT_ARGS)((DWORD)args | 0x80000000);

#ifndef BOOTARG_UNAVAIL
    // Use boot arguments resolution if available; otherwise get resolution settings from registry
    if (args->ucVideoMode != 0) // args->ucVideoMode is 0xff if boot args resolution available, 0x00 otherwise
    {
	    // Copy needed parameters from boot args
	    g_DefaultSettings.m_dwCxPanel = (DWORD)args->cxDisplayScreen;
	    g_DefaultSettings.m_dwCyPanel = (DWORD)args->cyDisplayScreen;
	    g_DefaultSettings.m_dwCxScreen = (DWORD)args->cxPhysicalScreen;
	    g_DefaultSettings.m_dwCyScreen = (DWORD)args->cyPhysicalScreen;
        g_DefaultSettings.m_dwBpp = (DWORD)args->bppScreen;

        // Read additional settings from registry
        QueryRegistrySettingLoadcepc(DRIVER_REGISTRY_STRING, &g_DefaultSettings);
    }
    else
#endif // BOOTARG_UNAVAIL
    {
        QueryRegistrySetting(DRIVER_REGISTRY_STRING, &g_DefaultSettings);
    }

    /* Restore old kernel/user mode */
	SetKMode(oldMode);

#else // HOST_ENABLE
    QueryRegistrySetting(DRIVER_REGISTRY_STRING, &g_DefaultSettings);
#ifdef UMA
	g_DefaultSettings.m_bUMA = 1;
	g_DefaultSettings.m_nLAWPhysical = DISPLAY_BASE_C_VIRTUAL;
	g_DefaultSettings.m_nUMAOffset = DISPLAY_DMA_OFFSET;
#else
    g_DefaultSettings.m_bUMA = 0; /* Init  g_DefaultSettings.m_bUMA anyway to avoid unexpected effects. */
#endif
#endif

	// look for all the monitors we are supposed to support
	for (dwMonitors = 0; dwMonitors < g_dwMonitorsExpected; dwMonitors++) 
	{
		TCHAR szRegString[256];
		SMISETTINGS ssTemp(g_DefaultSettings);

        wsprintf(szRegString, TEXT("%s%i"), DRIVER_MULTIMON_REGISTRY_STRING, dwMonitors);

#ifndef HOST_ENABLE
        /* Switch to kernel mode */
	    oldMode = SetKMode(TRUE);

#ifndef BOOTARG_UNAVAIL
        // Use boot arguments resolution if available; otherwise get monitor settings from registry
        if (args->ucVideoMode != 0) // args->ucVideoMode is 0xff if boot args resolution available, 0x00 otherwise
        {
	        // Copy needed parameters from boot args
	        ssTemp.m_dwCxPanel = (DWORD)args->cxDisplayScreen;
	        ssTemp.m_dwCyPanel = (DWORD)args->cyDisplayScreen;
	        ssTemp.m_dwCxScreen = (DWORD)args->cxPhysicalScreen;
	        ssTemp.m_dwCyScreen = (DWORD)args->cyPhysicalScreen;
            ssTemp.m_dwBpp = (DWORD)args->bppScreen;

            // Read additional settings from registry
            QueryRegistrySettingLoadcepc(szRegString, &ssTemp);
        }
        else
#endif // BOOTARG_UNAVAIL
        {
            QueryRegistrySetting(szRegString, &ssTemp);
        }

        /* Restore old kernel/user mode */
	    SetKMode(oldMode);

#else // HOST_ENABLE
        QueryRegistrySetting(szRegString, &ssTemp);
#endif

		// Make sure that bpp is the same across the MULTIMON
		ssTemp.m_dwBpp = g_DefaultSettings.m_dwBpp;

#ifdef MULTIMONEMU_ENABLE
		if (dwMonitors % 2 == 1)
			ssTemp.m_nDualMonEnabled = 1;
		else if (dwMonitors+1 < g_dwMonitorsExpected)
				ssTemp.m_nDualMonEnabled = 1;
		bRet = DetectCard(dwMonitors/2,&ssTemp);
#else // MULTIMONEMU_ENABLE
		bRet = DetectCard(dwMonitors,&ssTemp);		
#endif // MULTIMONEMU_ENABLE

		DEBUGMSG(GPE_ZONE_INIT, (TEXT("SMIVGX - MONITOR #%d\r\n"),dwMonitors));
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("m_nChipID = 0x%08X\r\n"),ssTemp.m_nChipID));
 		DEBUGMSG(GPE_ZONE_INIT, (TEXT("m_nLAWPhysical = 0x%08X\r\n"),ssTemp.m_nLAWPhysical));
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("m_pLAW = 0x%08X\r\n"),ssTemp.m_pLAW));
 		DEBUGMSG(GPE_ZONE_INIT, (TEXT("m_nREGPhysical = 0x%08X\r\n"),ssTemp.m_nREGPhysical));
		DEBUGMSG(GPE_ZONE_INIT, (TEXT("m_pREG = 0x%08X\r\n"),ssTemp.m_pREG));
/*
		RETAILMSG(1, (TEXT("SMIVGX - MONITOR #%d\r\n"),dwMonitors));
		RETAILMSG(1, (TEXT("m_nChipID = 0x%08X\r\n"),ssTemp.m_nChipID));
 		RETAILMSG(1, (TEXT("m_nLAWPhysical = 0x%08X\r\n"),ssTemp.m_nLAWPhysical));
		RETAILMSG(1, (TEXT("m_pLAW = 0x%08X\r\n"),ssTemp.m_pLAW));
 		RETAILMSG(1, (TEXT("m_nREGPhysical = 0x%08X\r\n"),ssTemp.m_nREGPhysical));
		RETAILMSG(1, (TEXT("m_pREG = 0x%08X\r\n"),ssTemp.m_pREG));
*/
		switch (ssTemp.m_nChipID)
		{
		case CHIPID_SM501:
#ifdef MULTIMONEMU_ENABLE
			if (dwMonitors % 2 == 1)
				pSMI[dwMonitors] = new SMIVGXEmu(&ssTemp,pSMI[dwMonitors-1]);
			else
#endif // MULTIMONEMU_ENABLE
				pSMI[dwMonitors] = new SMI(&ssTemp);

			break;

		default:
			pSMI[dwMonitors] = NULL;
			bRet = FALSE;
			break;
		}

		if (!bRet)
			break;

	}
	
	// did we find any monitors?
	if(bRet == TRUE && dwMonitors == 0)
		bRet = FALSE;

	// let the user know if there's a problem
	if(bRet == FALSE) 
	{
		// Couldn't find an SMI card, what to do now?
		RETAILMSG (1, (_T("No available SMI Voyager card found!\r\n")));
	}
	
	return bRet;
}

//
// GetGPE
//
// Main entry point for a GPE-compliant driver
//

⌨️ 快捷键说明

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