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

📄 power.h

📁 VoyagerGX display driver for Windows CE .NET 5.XX Silicon Motion, Inc. VoyagerGX Driver is architec
💻 H
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------
//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//  Copyright (c) 2003 Silicon Motion, Inc.
//
//  Module Name:	power.h
//
//  Abstract:		Power management support definitions
//
//-----------------------------------------------------------------------------

#ifndef _POWER_H_
#define _POWER_H_


///////////////////////////////////////////////////////////////////////////////
// Control vars

//#define DISABLE_AUTO_POWER_MANAGEMENT	// If defined, the power monitor and
										// power hook will be disabled.

//#define FORCE_INITIAL_OFF	// If defined, forces power monitor off initially

#define USE_WATCHDOG		// Comment out to disable the power watchdog

#define USE_POWERHOOK		// Comment out to disable the power hook


///////////////////////////////////////////////////////////////////////////////
// Process vars for Disabled Power Management case

#ifdef DISABLE_AUTO_POWER_MANAGEMENT
#ifdef USE_WATCHDOG
#undef USE_WATCHDOG
#endif
#ifdef USE_POWERHOOK
#undef USE_POWERHOOK
#endif
#ifndef FORCE_INITIAL_OFF
#define FORCE_INITIAL_OFF
#endif
#endif


///////////////////////////////////////////////////////////////////////////////
// SEC2TICKS returns the number of ticks based on given number of seconds.

#define SEC2TICKS(seconds) \
	((seconds) * 1000)


///////////////////////////////////////////////////////////////////////////////
// MIN2TICKS returns the number of ticks based on given number of minutes.

#define MIN2TICKS(minutes) \
	((minutes) * 60 * 1000)


///////////////////////////////////////////////////////////////////////////////
// MODULE_POWER_INFO init macro.
//
// Parameters:
//
//   module     - Specifies the module to initialize.
//                Must be one of the VGXPM_MODULES module constants.
//
//   pdownticks - Amount of idle time for the module before it will be
//                shut down.

#define INITPOWERINFO(module, pdownticks) \
	m_PowerInfo[VGXPM_MODULE_##module].bMonitorEnabled = m_SMISettings.m_bEnablePowerMonitor; \
	m_PowerInfo[VGXPM_MODULE_##module].CurrentState = VGXPowerOff; \
	m_PowerInfo[VGXPM_MODULE_##module].dwLastCallTickCount = GetTickCount(); \
	m_PowerInfo[VGXPM_MODULE_##module].dwTicksToPowerDown = pdownticks; \
	m_PowerInfo[VGXPM_MODULE_##module].dwGateMask = FIELD_SET(0, CURRENT_POWER_GATE, module, ENABLE);


///////////////////////////////////////////////////////////////////////////////
// POWER_HOOK
//
// This macro is created to help embedding power management support into
// driver's functions. The macro usually should be in the very beginnig of
// the function that requires services of a managed hardware module.
//
// Parameters:
//
//   module - specifies the hardware module of the chip the function works with.
//            with. The parameter is one of the VGXPM_MODULES constants and
//            is only the right part after 'VGXPM_MODULE_'. For example, in
//            order to use VGXPM_MODULE_2D constant, one will specify 2D as
//            the parameter.
//
//   minpower - minumum power requirements to run this function.
//              The parameter is one of the VGX_POWER_STATE constants.

#ifdef USE_POWERHOOK
#define POWER_HOOK(module, minpower) \
	PowerHook(VGXPM_MODULE_##module, minpower);
#else
#define POWER_HOOK(module, minpower)
#endif


///////////////////////////////////////////////////////////////////////////////
// DPMS constants definition.

typedef enum _DPMS_t
{
	DPMS_ON,
	DPMS_STANDBY,
	DPMS_SUSPEND,
	DPMS_OFF
}
DPMS_t, *PDPMS_t;


///////////////////////////////////////////////////////////////////////////////
// VGX Power Definition.

typedef enum _VGX_POWER_STATE
{
	VGXPowerOn,
	VGXPowerReduced,
	VGXPowerMinimal,
	VGXPowerStandBy,
	VGXPowerSuspend,
	VGXPowerOff,

	VGXPowerModeCount,				// Number of power modes
	VGXPowerAuto					// Enables power auto-monitoring
}
VGX_POWER_STATE, *PVGX_POWER_STATE;


///////////////////////////////////////////////////////////////////////////////
// Command constants for use with VGXPM_STRUCT.

typedef enum _VGXPM_COMMANDS
{
	VGXPMCMD_INIT,
	VGXPMCMD_SET_MONITOR,
	VGXPMCMD_GET_MONITOR,
	VGXPMCMD_SET_POWER,
	VGXPMCMD_GET_POWER,
	VGXPMCMD_SET_IDLE,
	VGXPMCMD_GET_IDLE,
	VGXPMCMD_SET_MODULE_POWER,
	VGXPMCMD_GET_MODULE_POWER,
	VGXPMCMD_SET_MODULE_MONITOR,
	VGXPMCMD_GET_MODULE_MONITOR,
	VGXPMCMD_SET_MODULE_IDLE,
	VGXPMCMD_GET_MODULE_IDLE,
	VGXPMCMD_SET_CLOCK_ARRAY,
	VGXPMCMD_GET_CLOCK_ARRAY
}
VGXPM_COMMANDS, *PVGXPM_COMMANDS;


///////////////////////////////////////////////////////////////////////////////
// API return codes.

typedef enum _VGXPM_RETURN_CODES
{
	VGXPM_RET_SUCCESS           =  1,
	VGXPM_RET_INVALID_PARAMETER = -1,
	VGXPM_RET_NOT_SUPPORTED     = -2,
	VGXPM_RET_SLEEP_MODE        = -3,
	VGXPM_RET_LOCKED_STATE      = -4,
	VGXPM_RET_QUEUE_FAILED      = -5,
	VGXPM_RET_NOTIFY_FAILED     = -6,
	VGXPM_RET_THREAD_FAILED     = -7,
	VGXPM_RET_HIGH_CONSUMPTION  = -8
}
VGXPM_RETURN_CODES, *PVGXPM_RETURN_CODES;


///////////////////////////////////////////////////////////////////////////////
// Supported modules.

typedef enum _VGXPM_MODULES
{
	VGXPM_MODULE_2D,			// Use '2D' in POWER_HOOK macro.
//	VGXPM_MODULE_DMA,			// Use 'DMA' in POWER_HOOK macro.
//	VGXPM_MODULE_8051,			// Use '8051' in POWER_HOOK macro.
//	VGXPM_MODULE_SSP,			// Use 'SSP' in POWER_HOOK macro.

	VGXPM_MODULE_COUNT,			// Number of supported modules.
}
VGXPM_MODULES, *PVGXPM_MODULES;


///////////////////////////////////////////////////////////////////////////////
// Helper macro for MODE_CLOCK initialization

#define INIT_CLOCK_INFO(var) \
	VGX_POWER_STATE InitClockInfoTempPowerState; \
	INT InitClockInfoTempIndex = -1; \
	PMODE_CLOCK InitClockInfoTempPtr = (PMODE_CLOCK)&var; \
	FillMemory(&var, sizeof(var), 0xFF);

#define INIT_CLOCK_INFO_RES(width, height, bpp) \
	InitClockInfoTempIndex++; \
	InitClockInfoTempPtr[InitClockInfoTempIndex].ScreenWidth  = width; \
	InitClockInfoTempPtr[InitClockInfoTempIndex].ScreenHeigth = height; \
	InitClockInfoTempPtr[InitClockInfoTempIndex].ScreenBpp    = bpp;

#define INIT_CLOCK_INFO_POWER(power) \
	InitClockInfoTempPowerState = power; \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState]. \
			PowerState = InitClockInfoTempPowerState;

#define INIT_CLOCK_INFO_PLL2(pll2) \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState].PLL2Output = \
			SYSTEM_DRAM_CTRL_PLL2_OUTPUT_##pll2;

#define INIT_CLOCK_INFO_MCLK(select, divider, shift) \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState].MCLKSelect = \
			CURRENT_POWER_CLOCK_MCLK_SELECT_##select; \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState].MCLKDivider = \
			CURRENT_POWER_CLOCK_MCLK_DIVIDER_##divider; \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState].MCLKShift = \
			CURRENT_POWER_CLOCK_MCLK_SHIFT_##shift;

#define INIT_CLOCK_INFO_M2XCLK(select, divider, shift) \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState].M2XCLKSelect = \
			CURRENT_POWER_CLOCK_M2XCLK_SELECT_##select; \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState].M2XCLKDivider = \
			CURRENT_POWER_CLOCK_M2XCLK_DIVIDER_##divider; \
	InitClockInfoTempPtr[InitClockInfoTempIndex] \
		.ClockValue[InitClockInfoTempPowerState].M2XCLKShift = \
			CURRENT_POWER_CLOCK_M2XCLK_SHIFT_##shift;


///////////////////////////////////////////////////////////////////////////////
// Clock values for different screen and power modes.

typedef struct _CLOCK_VALUE
{
	VGX_POWER_STATE PowerState;

	DWORD PLL2Output;

	DWORD MCLKSelect;
	DWORD MCLKDivider;
	DWORD MCLKShift;

	DWORD M2XCLKSelect;
	DWORD M2XCLKDivider;
	DWORD M2XCLKShift;
}
CLOCK_VALUE, *PCLOCK_VALUE;

typedef struct _MODE_CLOCK
{
	INT ScreenWidth;
	INT ScreenHeigth;
	UINT ScreenBpp;

	CLOCK_VALUE ClockValue[VGXPowerModeCount];
}
MODE_CLOCK, *PMODE_CLOCK;

typedef MODE_CLOCK CLOCK_ARRAY[10*3];	// Three entries per mode for
										// 8bpp, 16bpp and 32bpp.
										//  1. 320  x 240
										//  2. 400  x 300
										//  3. 640  x 480
										//  4. 720  x 540
										//  5. 800  x 480
										//  6. 800  x 600
										//  7. 1024 x 600
										//  8. 1024 x 768
										//  9. 1280 x 960
										// 10. 1280 x 1200
typedef CLOCK_ARRAY *PCLOCK_ARRAY;


///////////////////////////////////////////////////////////////////////////////
// VGXPM_STRUCT - Power Management ExtEscape() API structure.
// Below follows the list of supported commands and corresponding fields.

typedef struct _VGXPM_STRUCT
{
	VGXPM_COMMANDS Command;				// One of VGXPM_COMMANDS
}
VGXPM_STRUCT, *PVGXPM_STRUCT;


///////////////////////////////////////////////////////////////////////////////
// VGXPMCMD_SET_MONITOR
// ~~~~~~~~~~~~~~~~~~~~
//   Descriptiron:
//     Enables or disables the Power Monitor and hence enables or prevents
//     the posibility of automatical entering Reduced and Minimal power modes.
//     This command has no effect on module power monitor. To enable or
//     disable module monitoring, use VGXPMCMD_SET_MODULE_MONITOR command.
//
//   Input fields:
//     Command         = VGXPMCMD_SET_MONITOR;
//     bMonitorEnabled = monitor_enabled;		// TRUE or FALSE
//
//   Output fields:
//     N/A.
//

⌨️ 快捷键说明

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