mirror of
https://github.com/reactos/reactos.git
synced 2025-05-22 02:25:18 +00:00
[DEVMGR] Implement missing device power information (current power state, power capabilities and power state mappings).
This commit is contained in:
parent
46598fe04a
commit
9d29ee3a62
1 changed files with 230 additions and 4 deletions
|
@ -33,6 +33,28 @@
|
|||
|
||||
#include <winver.h>
|
||||
|
||||
#define PDCAP_D0_SUPPORTED 0x00000001
|
||||
#define PDCAP_D1_SUPPORTED 0x00000002
|
||||
#define PDCAP_D2_SUPPORTED 0x00000004
|
||||
#define PDCAP_D3_SUPPORTED 0x00000008
|
||||
#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010
|
||||
#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020
|
||||
#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040
|
||||
#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080
|
||||
#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100
|
||||
|
||||
typedef struct CM_Power_Data_s
|
||||
{
|
||||
ULONG PD_Size;
|
||||
DEVICE_POWER_STATE PD_MostRecentPowerState;
|
||||
ULONG PD_Capabilities;
|
||||
ULONG PD_D1Latency;
|
||||
ULONG PD_D2Latency;
|
||||
ULONG PD_D3Latency;
|
||||
DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum];
|
||||
SYSTEM_POWER_STATE PD_DeepestSystemWake;
|
||||
} CM_POWER_DATA, *PCM_POWER_DATA;
|
||||
|
||||
|
||||
static UINT WINAPI
|
||||
EnumDeviceDriverFilesCallback(IN PVOID Context,
|
||||
|
@ -1381,6 +1403,204 @@ DisplayDeviceRelations(
|
|||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DisplayCurrentPowerState(
|
||||
IN PDEVADVPROP_INFO dap,
|
||||
IN HWND hwndListView)
|
||||
{
|
||||
HDEVINFO DeviceInfoSet;
|
||||
PSP_DEVINFO_DATA DeviceInfoData;
|
||||
CM_POWER_DATA PowerData;
|
||||
DWORD dwSize, dwType;
|
||||
PCWSTR lpText = NULL;
|
||||
|
||||
if (dap->CurrentDeviceInfoSet != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DeviceInfoSet = dap->CurrentDeviceInfoSet;
|
||||
DeviceInfoData = &dap->CurrentDeviceInfoData;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceInfoSet = dap->DeviceInfoSet;
|
||||
DeviceInfoData = &dap->DeviceInfoData;
|
||||
}
|
||||
|
||||
dwSize = sizeof(CM_POWER_DATA);
|
||||
if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
SPDRP_DEVICE_POWER_DATA,
|
||||
&dwType,
|
||||
(LPBYTE)&PowerData,
|
||||
dwSize,
|
||||
&dwSize))
|
||||
return;
|
||||
|
||||
switch (PowerData.PD_MostRecentPowerState)
|
||||
{
|
||||
// case PowerDeviceUnspecified:
|
||||
|
||||
case PowerDeviceD0:
|
||||
lpText = L"D0";
|
||||
break;
|
||||
|
||||
case PowerDeviceD1:
|
||||
lpText = L"D1";
|
||||
break;
|
||||
|
||||
case PowerDeviceD2:
|
||||
lpText = L"D2";
|
||||
break;
|
||||
|
||||
case PowerDeviceD3:
|
||||
lpText = L"D3";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (lpText != NULL)
|
||||
SetListViewText(hwndListView, 0, lpText);
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DisplayPowerCapabilities(
|
||||
IN PDEVADVPROP_INFO dap,
|
||||
IN HWND hwndListView)
|
||||
{
|
||||
HDEVINFO DeviceInfoSet;
|
||||
PSP_DEVINFO_DATA DeviceInfoData;
|
||||
CM_POWER_DATA PowerData;
|
||||
DWORD dwSize, dwType;
|
||||
INT index = 0;
|
||||
|
||||
if (dap->CurrentDeviceInfoSet != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DeviceInfoSet = dap->CurrentDeviceInfoSet;
|
||||
DeviceInfoData = &dap->CurrentDeviceInfoData;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceInfoSet = dap->DeviceInfoSet;
|
||||
DeviceInfoData = &dap->DeviceInfoData;
|
||||
}
|
||||
|
||||
dwSize = sizeof(CM_POWER_DATA);
|
||||
if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
SPDRP_DEVICE_POWER_DATA,
|
||||
&dwType,
|
||||
(LPBYTE)&PowerData,
|
||||
dwSize,
|
||||
&dwSize))
|
||||
return;
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_D0_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_D0_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_D1_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_D1_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_D2_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_D2_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_D3_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_D3_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_WAKE_FROM_D0_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_WAKE_FROM_D0_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_WAKE_FROM_D1_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_WAKE_FROM_D1_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_WAKE_FROM_D2_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_WAKE_FROM_D2_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_WAKE_FROM_D3_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_WAKE_FROM_D3_SUPPORTED");
|
||||
|
||||
if (PowerData.PD_Capabilities & PDCAP_WARM_EJECT_SUPPORTED)
|
||||
SetListViewText(hwndListView, index++, L"PDCAP_WARM_EJECT_SUPPORTED");
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DisplayPowerStateMappings(
|
||||
IN PDEVADVPROP_INFO dap,
|
||||
IN HWND hwndListView)
|
||||
{
|
||||
HDEVINFO DeviceInfoSet;
|
||||
PSP_DEVINFO_DATA DeviceInfoData;
|
||||
CM_POWER_DATA PowerData;
|
||||
DWORD dwSize, dwType;
|
||||
INT i;
|
||||
DEVICE_POWER_STATE PowerState;
|
||||
WCHAR szSystemStateBuffer[40];
|
||||
WCHAR szDeviceStateBuffer[40];
|
||||
WCHAR szOutBuffer[100];
|
||||
|
||||
if (dap->CurrentDeviceInfoSet != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DeviceInfoSet = dap->CurrentDeviceInfoSet;
|
||||
DeviceInfoData = &dap->CurrentDeviceInfoData;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceInfoSet = dap->DeviceInfoSet;
|
||||
DeviceInfoData = &dap->DeviceInfoData;
|
||||
}
|
||||
|
||||
dwSize = sizeof(CM_POWER_DATA);
|
||||
if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
|
||||
DeviceInfoData,
|
||||
SPDRP_DEVICE_POWER_DATA,
|
||||
&dwType,
|
||||
(LPBYTE)&PowerData,
|
||||
dwSize,
|
||||
&dwSize))
|
||||
return;
|
||||
|
||||
for (i = PowerSystemWorking; i < PowerSystemMaximum; i++)
|
||||
{
|
||||
PowerState = PowerData.PD_PowerStateMapping[i];
|
||||
if ((PowerState >= PowerDeviceUnspecified) && (PowerState <= PowerDeviceD3))
|
||||
{
|
||||
swprintf(szSystemStateBuffer, L"S%u", i - 1);
|
||||
|
||||
switch (PowerState)
|
||||
{
|
||||
case PowerDeviceUnspecified:
|
||||
wcscpy(szDeviceStateBuffer, L"Not specified");
|
||||
break;
|
||||
|
||||
case PowerDeviceD0:
|
||||
wcscpy(szDeviceStateBuffer, L"D0");
|
||||
break;
|
||||
|
||||
case PowerDeviceD1:
|
||||
wcscpy(szDeviceStateBuffer, L"D1");
|
||||
break;
|
||||
|
||||
case PowerDeviceD2:
|
||||
wcscpy(szDeviceStateBuffer, L"D2");
|
||||
break;
|
||||
|
||||
case PowerDeviceD3:
|
||||
wcscpy(szDeviceStateBuffer, L"D3");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
swprintf(szOutBuffer, L"%s -> %s", szSystemStateBuffer, szDeviceStateBuffer);
|
||||
SetListViewText(hwndListView, i, szOutBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
DisplayDeviceProperties(IN PDEVADVPROP_INFO dap,
|
||||
IN HWND hwndComboBox,
|
||||
|
@ -1399,7 +1619,7 @@ DisplayDeviceProperties(IN PDEVADVPROP_INFO dap,
|
|||
|
||||
switch (Index)
|
||||
{
|
||||
case 0:
|
||||
case 0: /* Device ID */
|
||||
SetListViewText(hwndListView, 0, dap->szDeviceID);
|
||||
break;
|
||||
|
||||
|
@ -1514,16 +1734,22 @@ DisplayDeviceProperties(IN PDEVADVPROP_INFO dap,
|
|||
#if 0
|
||||
case 20: /* Firmware Revision */
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 21: /* Current Power State */
|
||||
DisplayCurrentPowerState(dap,
|
||||
hwndListView);
|
||||
break;
|
||||
|
||||
case 20: /* Power Capabilities */
|
||||
case 22: /* Power Capabilities */
|
||||
DisplayPowerCapabilities(dap,
|
||||
hwndListView);
|
||||
break;
|
||||
|
||||
case 21: /* Power State Mappings */
|
||||
case 23: /* Power State Mappings */
|
||||
DisplayPowerStateMappings(dap,
|
||||
hwndListView);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
SetListViewText(hwndListView, 0, L"<Not implemented yet>");
|
||||
|
|
Loading…
Reference in a new issue