// This routine issues the ATAPI commands necessary to put the disk into a new power state. // The caller must hold the disk critical section. DWORD CDiskPower::SetDiskPower(CEDEVICE_POWER_STATE newDx) { DWORD dwStatus = ERROR_SUCCESS; DEBUGCHK(VALID_DX(newDx)); PREFAST_DEBUGCHK(m_pDisk != NULL); TakeCS(); DEBUGMSG(ZONE_POWER, (_T("CDiskPower::SetDiskPower: updating from D%d to D%d\r\n"), m_curDx, newDx)); if(newDx != m_curDx) { switch(newDx) { case D0: case D1: case D2: if(m_curDx == D4) { // have to reset and reinitialize to come out of SLEEP mode if(!m_pDisk->WakeUp()) { DEBUGMSG(ZONE_ERROR, (_T("CDiskPower::SetDiskPower: couldn't re-initialize hard drive\r\n"))); dwStatus = ERROR_GEN_FAILURE; } } break; case D3: case D4: newDx = D4; // no D3 support break; } // enter the new device state if(dwStatus == ERROR_SUCCESS && !m_pDisk->SetDiskPowerState(newDx)) { DEBUGMSG(ZONE_WARNING, (_T("CDiskPower::SetDiskPower: SetDiskPowerState(D%d) failed\r\n"), newDx)); dwStatus = ERROR_GEN_FAILURE; } // update the device power status if(dwStatus == ERROR_SUCCESS) { LARGE_INTEGER li; BOOL fGotQPC = QueryPerformanceCounter(&li); if(!fGotQPC) { DEBUGMSG(ZONE_WARNING, (_T("CDiskPower::SetDiskPower: QueryPerformanceCounter() failed, can't update statistics\r\n"))); } else { m_dxInfo[m_curDx].totalQPC.QuadPart += li.QuadPart - m_startQPC.QuadPart; } m_curDx = newDx; m_dxInfo[m_curDx].dwCount++; if(fGotQPC) { m_startQPC = li; } } } ReleaseCS(); return dwStatus; }
VOID CSDHCBase::Validate( ) { DEBUGCHK(m_regDevice.IsOK()); DEBUGCHK(m_hBusAccess); ValidateSlotCount(); DEBUGCHK(m_pSlots); DEBUGCHK(m_pSlotInfos); DEBUGCHK(m_pHCDContext); DEBUGCHK(m_dwBusNumber != INVALID_BUS_NUMBER); DEBUGCHK(m_interfaceType != InterfaceTypeUndefined); DEBUGCHK(m_dwSysIntr != SYSINTR_UNDEFINED); DEBUGCHK(VALID_DX(m_cpsCurrent)); if (m_fRegisteredWithBusDriver && !m_fDriverShutdown) { DEBUGCHK(m_htIST); DEBUGCHK(m_fHardwareInitialized); DEBUGCHK(m_fInterruptInitialized); } }
BOOL HW_PowerSet( PI2C_CONTEXT pI2C, PCEDEVICE_POWER_STATE pDx // IN, OUT ) { CEDEVICE_POWER_STATE NewDx = *pDx; if ( VALID_DX(NewDx) ) { // We only support D0, so do nothing. // Just return current state. pI2C->Dx = *pDx = D0; DEBUGMSG(ZONE_POWER, (TEXT("I2C: IOCTL_POWER_SET: D%u => D%u \r\n"), NewDx, pI2C->Dx)); return TRUE; } return FALSE; }
// for wakeup problem. hsjang 070823 DWORD CSDHCBase::IOControl(DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut) { BOOL RetVal = TRUE; DWORD dwErr = ERROR_SUCCESS; switch (dwCode) { //----------------------------------------------------------------------------------------- case IOCTL_POWER_CAPABILITIES: { PPOWER_CAPABILITIES ppc; RETAILMSG(1, (TEXT("[HSMMC] IOCTL_POWER_CAPABILITIES\r\n"))); if ( !pdwActualOut || !pBufOut || (dwLenOut < sizeof(POWER_CAPABILITIES)) ) { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; break; } ppc = (PPOWER_CAPABILITIES)pBufOut; memset(ppc, 0, sizeof(POWER_CAPABILITIES)); // support D0, D4 ppc->DeviceDx = 0x11; // Report our power consumption in uAmps rather than mWatts. ppc->Flags = POWER_CAP_PREFIX_MICRO | POWER_CAP_UNIT_AMPS; // 25 m = 25000 uA // TODO: find out a more accurate value ppc->Power[D0] = 25000; *pdwActualOut = sizeof(POWER_CAPABILITIES); } break; case IOCTL_POWER_SET: { CEDEVICE_POWER_STATE NewDx; if ( !pdwActualOut || !pBufOut || (dwLenOut < sizeof(CEDEVICE_POWER_STATE)) ) { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; break; } NewDx = *(PCEDEVICE_POWER_STATE)pBufOut; if ( VALID_DX(NewDx) ) { switch ( NewDx ) { case D0: if (m_Dx != D0) { PowerUp(); m_Dx = D0; } break; default: if (m_Dx != (_CEDEVICE_POWER_STATE)D4) { PowerDown(); m_Dx = (_CEDEVICE_POWER_STATE)D4; } break; } // return our state *(PCEDEVICE_POWER_STATE)pBufOut = m_Dx; RETAILMSG(1, (TEXT("[HSMMC] IOCTL_POWER_SET : D%u \r\n"), NewDx)); *pdwActualOut = sizeof(CEDEVICE_POWER_STATE); } else { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; } } break; case IOCTL_POWER_GET: if ( !pdwActualOut || !pBufOut || (dwLenOut < sizeof(CEDEVICE_POWER_STATE)) ) { RetVal = FALSE; dwErr = ERROR_INVALID_PARAMETER; break; } *(PCEDEVICE_POWER_STATE)pBufOut = m_Dx; RETAILMSG(1, (TEXT("[HSMMC] IOCTL_POWER_GET : D%u \r\n"), m_Dx)); *pdwActualOut = sizeof(CEDEVICE_POWER_STATE); break; default: RETAILMSG(1, (TEXT("[HSMMC] This IOControl is not supported\r\n"))); dwErr = ERROR_INVALID_PARAMETER; } return dwErr; }
// This routine is called during IOCTL_POWER_CAPABILITIES processing. It // returns TRUE if successful and FALSE if not. The caller is expected to // destroy the CDiskPower object if this routine fails. BOOL CDiskPower::Init(CDisk *pDiskParent) { DWORD dwStatus; GUID gPMClass; int nPriority = 250; // THREAD_PRIORITY_ABOVE_NORMAL HANDLE hActive = NULL; BOOL fOk = TRUE; PREFAST_DEBUGCHK(pDiskParent != NULL); DEBUGMSG(ZONE_INIT, (_T("+CDiskPower::Init(): parent is 0x%08x\r\n"), pDiskParent)); // record the parent device m_pDisk = pDiskParent; // get a pointer to the PM APIs we need if(fOk) { HMODULE hmCoreDll = LoadLibrary(L"coredll.dll"); if(hmCoreDll == NULL) { DEBUGMSG(ZONE_INIT || ZONE_ERROR, (_T("CDevicePower::Init: LoadLibrary('coredll.dll') failed %d\r\n"), GetLastError())); fOk = FALSE; } else { m_pfnDevicePowerNotify = (DWORD ((*)(PVOID, CEDEVICE_POWER_STATE, DWORD))) GetProcAddress(hmCoreDll, L"DevicePowerNotify"); if(m_pfnDevicePowerNotify == NULL) { DEBUGMSG(ZONE_INIT || ZONE_ERROR, (_T("CDevicePower::Init: GetProcAddress('DevicePowerNotify') failed %d\r\n"), GetLastError())); fOk = FALSE; } // we're explicitly linked with coredll so we don't need the handle FreeLibrary(hmCoreDll); } } // read registry configuration if(fOk) { HKEY hk; BOOL fGotClass = FALSE; WCHAR szClass[64] = {0}; // big enough for a GUID // determine the power class we are advertising dwStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, m_pDisk->m_szDeviceKey, 0, 0, &hk); if(dwStatus == ERROR_SUCCESS) { // read the PM class DWORD dwSize = sizeof(szClass); dwStatus = RegQueryValueEx(hk, L"PowerClass", NULL, NULL, (LPBYTE) szClass, &dwSize); if(dwStatus == ERROR_SUCCESS) { fGotClass = TRUE; } // get the inactivity timeout DWORD dwValue; dwSize = sizeof(dwValue); dwStatus = RegQueryValueEx(hk, L"InactivityTimeout", NULL, NULL, (LPBYTE) &dwValue, &dwSize); if(dwStatus == ERROR_SUCCESS) { m_dwPowerTimeout = dwValue; } DEBUGMSG(ZONE_INIT, (_T("CDiskPower::Init: inactivity timeout is %u ms\r\n"), m_dwPowerTimeout)); // get the inactivity timeout dwSize = sizeof(dwValue); dwStatus = RegQueryValueEx(hk, L"TimeoutDx", NULL, NULL, (LPBYTE) &dwValue, &dwSize); if(dwStatus == ERROR_SUCCESS) { if(VALID_DX((CEDEVICE_POWER_STATE)dwValue) && dwValue != D3) { m_timeoutDx = (CEDEVICE_POWER_STATE) dwValue; } else { DEBUGMSG(ZONE_WARNING, (_T("CDiskPower::Init: invalid or unsupported timeout device power state %d (0x%x)\r\n"), dwValue, dwValue)); } } DEBUGMSG(ZONE_INIT, (_T("CDiskPower::Init: timeout state is D%d\r\n"), m_timeoutDx)); // get the inactivity timeout dwSize = sizeof(dwValue); dwStatus = RegQueryValueEx(hk, L"InactivityPriority256", NULL, NULL, (LPBYTE) &dwValue, &dwSize); if(dwStatus == ERROR_SUCCESS) { nPriority = (int) dwValue; } DEBUGMSG(ZONE_INIT, (_T("CDiskPower::Init: inactivity timeout thread priority is %d\r\n"), nPriority)); RegCloseKey(hk); } // did we get a class string? if(!fGotClass) { // no, use the default disk class wcsncpy(szClass, PMCLASS_BLOCK_DEVICE, dim(szClass)); szClass[dim(szClass) - 1] = 0; } // convert to a GUID fOk = GUIDFromString(szClass, &gPMClass); if(!fOk) { DEBUGMSG(ZONE_WARNING || ZONE_INIT, (_T("CDiskPower::Init: invalid power management class '%s'\r\n"), szClass)); } } // get our active key from the registry if(fOk) { HKEY hk; dwStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, m_pDisk->m_szActiveKey, 0, 0, &hk); if(dwStatus == ERROR_SUCCESS) { DWORD dwValue; DWORD dwSize = sizeof(dwValue); dwStatus = RegQueryValueEx(hk, DEVLOAD_HANDLE_VALNAME, NULL, NULL, (LPBYTE) &dwValue, &dwSize); if(dwStatus != ERROR_SUCCESS) { DEBUGMSG(ZONE_WARNING || ZONE_INIT, (_T("CDiskPower::Init: can't read '%s' from '%s'\r\n"), DEVLOAD_HANDLE_VALNAME, m_pDisk->m_szActiveKey)); fOk = FALSE; } else { DEBUGCHK(dwValue != 0); hActive = (HANDLE) dwValue; } } } // figure out the name we are using if(fOk) { WCHAR szName[MAX_PATH]; DWORD dwIndex = 0; do { DWORD dwSize = sizeof(szName); GUID gClass; fOk = EnumDeviceInterfaces(hActive, dwIndex, &gClass, szName, &dwSize); if(fOk && gPMClass == gClass) { // we found the interface break; } dwIndex++; } while(fOk); DEBUGMSG(!fOk && (ZONE_WARNING || ZONE_INIT), (_T("CDiskPower::Init: can't find PM interface\r\n"))); // did we find the name? if(fOk) { // yes, allocate a name buffer to use to talk to the power manager DWORD dwChars = wcslen(PMCLASS_BLOCK_DEVICE) + wcslen(szName) + 2; // class + separator + name + null LPWSTR pszPMName = (LPWSTR) LocalAlloc(LPTR, dwChars * sizeof(WCHAR)); fOk = FALSE; // assume failure if(pszPMName) { HRESULT hr = StringCchPrintfW(pszPMName, dwChars, L"{%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x}\\%s", gPMClass.Data1, gPMClass.Data2, gPMClass.Data3, (gPMClass.Data4[0] << 8) + gPMClass.Data4[1], gPMClass.Data4[2], gPMClass.Data4[3], gPMClass.Data4[4], gPMClass.Data4[5], gPMClass.Data4[6], gPMClass.Data4[7], szName); if(SUCCEEDED(hr)) { m_pszPMName = (LPCWSTR) pszPMName; fOk = TRUE; } } DEBUGMSG(!fOk && (ZONE_WARNING || ZONE_INIT), (_T("CDiskPower::Init: can't find PM interface\r\n"))); } } // create an event to tell the timeout thread about activity if(fOk) { m_hevPowerSignal = CreateEvent(NULL, FALSE, FALSE, NULL); m_hevDummy = CreateEvent(NULL, FALSE, FALSE, NULL); if(!m_hevPowerSignal || !m_hevDummy) { DEBUGMSG(ZONE_WARNING || ZONE_INIT, (_T("CDiskPower::Init: couldn't create status events\r\n"))); fOk = FALSE; } } // create the timeout thread if(fOk) { m_htPower = CreateThread(NULL, 0, DiskPowerThreadStub, this, 0, NULL); if(!m_htPower) { DEBUGMSG(ZONE_WARNING || ZONE_INIT, (_T("CDiskPower::Init: CreateThread() failed %d\r\n"), GetLastError())); fOk = FALSE; } else { BOOL fSuccess = CeSetThreadPriority(m_htPower, nPriority); DEBUGMSG(!fSuccess && (ZONE_WARNING || ZONE_INIT), (_T("CDiskPower::Init: CeSetThreadPriority(%d) failed %d\r\n"), nPriority, GetLastError())); } } // disable the standby timer, since the PM is going to be controlling // the disk power state if(fOk) { if(!m_pDisk->SendDiskPowerCommand(ATA_NEW_CMD_IDLE, 0)) { DEBUGMSG(ZONE_WARNING || ZONE_INIT, (_T("CDiskPower::Init: disable standby timer failed\r\n"))); } } // on error, cleanup will happen in the destructor DEBUGMSG(ZONE_INIT, (_T("-CDiskPower::Init(): returning %d\r\n"), fOk)); return fOk; }
//------------------------------------------------------------------------------ // // Function: KPD_IOControl // // This function sends a command to a device. // BOOL KPD_IOControl( DWORD context, DWORD code, UCHAR *pInBuffer, DWORD inSize, UCHAR *pOutBuffer, DWORD outSize, DWORD *pOutSize) { BOOL rc = FALSE; KeypadDevice_t *pDevice = (KeypadDevice_t*)context; UNREFERENCED_PARAMETER(inSize); UNREFERENCED_PARAMETER(pInBuffer); DEBUGMSG(ZONE_FUNCTION, ( L"+KPD_IOControl(0x%08x, 0x%08x, 0x%08x, %d, 0x%08x, %d, 0x%08x)\r\n", context, code, pInBuffer, inSize, pOutBuffer, outSize, pOutSize )); // Check if we get correct context if ((pDevice == NULL) || (pDevice->cookie != KPD_DEVICE_COOKIE)) { RETAILMSG(ZONE_ERROR, (L"ERROR: KPD_IOControl: " L"Incorrect context parameter\r\n" )); goto cleanUp; } switch (code) { case IOCTL_POWER_CAPABILITIES: DEBUGMSG(ZONE_INFO, (L"KPD: Received IOCTL_POWER_CAPABILITIES\r\n")); if (pOutBuffer && outSize >= sizeof (POWER_CAPABILITIES) && pOutSize) { __try { PPOWER_CAPABILITIES PowerCaps; PowerCaps = (PPOWER_CAPABILITIES)pOutBuffer; // Only supports D0 (permanently on) and D4(off. memset(PowerCaps, 0, sizeof(*PowerCaps)); PowerCaps->DeviceDx = (UCHAR)pDevice->powerMask; *pOutSize = sizeof(*PowerCaps); rc = TRUE; } __except(EXCEPTION_EXECUTE_HANDLER) { RETAILMSG(ZONE_ERROR, (L"exception in ioctl\r\n")); } } break; // determines whether changing power state is feasible case IOCTL_POWER_QUERY: DEBUGMSG(ZONE_INFO,(L"KPD: Received IOCTL_POWER_QUERY\r\n")); if (pOutBuffer && outSize >= sizeof(CEDEVICE_POWER_STATE)) { // Return a good status on any valid query, since we are // always ready to change power states (if asked for state // we don't support, we move to next highest, eg D3->D4). __try { CEDEVICE_POWER_STATE ReqDx = *(PCEDEVICE_POWER_STATE)pOutBuffer; if (VALID_DX(ReqDx)) { // This is a valid Dx state so return a good status. rc = TRUE; } DEBUGMSG(ZONE_INFO, (L"KPD: IOCTL_POWER_QUERY %d\r\n")); } __except(EXCEPTION_EXECUTE_HANDLER) { RETAILMSG(ZONE_ERROR, (L"Exception in ioctl\r\n")); } }
//------------------------------------------------------------------------------ // process_PowerManagementMessage, all messages not handled by the other message // handlers // BOOL CAudioManager::process_PowerManagementMessage( DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut ) { UNREFERENCED_PARAMETER(dwLenIn); UNREFERENCED_PARAMETER(pBufIn); DEBUGMSG(ZONE_FUNCTION, (L"WAV:+process_PowerManagementMessage(dwCode=%d)\r\n", dwCode) ); BOOL bResult = FALSE; POWER_CAPABILITIES powerCaps; CEDEVICE_POWER_STATE dxState; switch (dwCode) { // Return device specific power capabilities. case IOCTL_POWER_CAPABILITIES: DEBUGMSG(ZONE_PM, (L"WAV:IOCTL_POWER_CAPABILITIES\r\n")); // Check arguments. // if ( pBufOut == NULL || dwLenOut < sizeof(POWER_CAPABILITIES)) { RETAILMSG(ZONE_WARN, (L"WAV: Invalid parameter.\r\n")); break; } // Clear capabilities structure. // memset(&powerCaps, 0, sizeof(POWER_CAPABILITIES)); // Set power capabilities. Supports D0 and D4. // powerCaps.DeviceDx = DX_MASK(D0)|DX_MASK(D4); DEBUGMSG(ZONE_PM, (L"WAV:IOCTL_POWER_CAPABILITIES = 0x%x\r\n", powerCaps.DeviceDx) ); if (CeSafeCopyMemory(pBufOut, &powerCaps, sizeof(POWER_CAPABILITIES)) ) { bResult = TRUE; if (pdwActualOut) { *pdwActualOut = sizeof(POWER_CAPABILITIES); } } break; // Indicate if the device is ready to enter a new device power state. case IOCTL_POWER_QUERY: DEBUGMSG(ZONE_PM, (L"WAV:IOCTL_POWER_QUERY = %d\r\n", m_CurPowerState)); // Check arguments. // if (pBufOut == NULL || dwLenOut < sizeof(CEDEVICE_POWER_STATE)) { RETAILMSG(ZONE_WARN, (L"WAV: Invalid parameter.\r\n")); break; } if (CeSafeCopyMemory(pBufOut, &m_CurPowerState, sizeof(CEDEVICE_POWER_STATE)) == 0) { break; } if (!VALID_DX(m_CurPowerState)) { RETAILMSG(ZONE_ERROR, (L"WAV:IOCTL_POWER_QUERY invalid power state.\r\n")); break; } if (pdwActualOut) { *pdwActualOut = sizeof(CEDEVICE_POWER_STATE); } bResult = TRUE; break; // Request a change from one device power state to another. // case IOCTL_POWER_SET: DEBUGMSG(ZONE_PM, (L"WAV:IOCTL_POWER_QUERY\r\n")); // Check arguments. if (pBufOut == NULL || dwLenOut < sizeof(CEDEVICE_POWER_STATE)) { RETAILMSG(ZONE_ERROR, (L"WAVE: Invalid parameter.\r\n")); break; } if (CeSafeCopyMemory(&dxState, pBufOut, sizeof(dxState)) == 0) { break; } DEBUGMSG(ZONE_PM, (L"WAV:IOCTL_POWER_SET = %d.\r\n", dxState)); RETAILMSG(!VALID_DX(dxState), (L"WAV:!ERROR - Setting to invalid power state(%d)", dxState) ); if (dxState == D4) { m_bSuspend = TRUE; } if (D0==dxState) { m_bSuspend = FALSE; } // Check for any valid power state. if (VALID_DX(dxState)) { m_CurPowerState = dxState; get_HardwareAudioBridge()->request_PowerState(dxState); bResult = TRUE; } break; // Return the current device power state. case IOCTL_POWER_GET: DEBUGMSG(ZONE_PM, (L"WAV:IOCTL_POWER_GET\r\n")); dxState = get_HardwareAudioBridge()->get_CurrentPowerState(); // Check input parameters if (pdwActualOut != NULL) { *pdwActualOut = sizeof(CEDEVICE_POWER_STATE); } if (pBufOut == NULL || dwLenOut < sizeof(dxState) || !CeSafeCopyMemory(pBufOut, &dxState, sizeof(dxState))) { SetLastError(ERROR_INVALID_PARAMETER); break; } DEBUGMSG(ZONE_PM, (L"WAV:IOCTL_POWER_GET=%d (%d).\r\n", dxState, m_CurPowerState)); bResult = TRUE; } DEBUGMSG(ZONE_FUNCTION, (L"WAV:-process_PowerManagementMessage(bResult=%d)\r\n", bResult) ); return bResult; }
extern "C" BOOL BKL_IOControl(DWORD dwOpenContext, DWORD dwIoControlCode, LPBYTE lpInBuf, DWORD nInBufSize, LPBYTE lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned) { DWORD dwErr = ERROR_INVALID_PARAMETER; BKL_MDD_INFO *pBKLinfo = NULL; UNREFERENCED_PARAMETER(nInBufSize); UNREFERENCED_PARAMETER(lpInBuf); DEBUGMSG(ZONE_BACKLIGHT,(TEXT("BKL_IOControl IOCTL code = %d\r\n"), dwIoControlCode)); // Verify context if( !dwOpenContext ) { DEBUGMSG(ZONE_ERROR, ( L"ERROR: BKL_Deinit: " L"Incorrect context paramer\r\n" )); return FALSE; } pBKLinfo = (BKL_MDD_INFO *) dwOpenContext; switch (dwIoControlCode) { case IOCTL_POWER_CAPABILITIES: DEBUGMSG(ZONE_BACKLIGHT, (TEXT("BKL: IOCTL_POWER_CAPABILITIES\r\n"))); if (lpOutBuf && nOutBufSize >= sizeof (POWER_CAPABILITIES) && lpBytesReturned) { __try { PPOWER_CAPABILITIES PowerCaps = (PPOWER_CAPABILITIES)lpOutBuf; memset(PowerCaps, 0, sizeof(*PowerCaps)); PowerCaps->DeviceDx = g_pBacklight->BacklightGetSupportedStates(); *lpBytesReturned = sizeof(*PowerCaps); pBKLinfo->ucSupportedStatesMask = PowerCaps->DeviceDx; ASSERT(pBKLinfo->ucSupportedStatesMask < 0x20); dwErr = ERROR_SUCCESS; } __except(EXCEPTION_EXECUTE_HANDLER) { DEBUGMSG(ZONE_BACKLIGHT, (TEXT("exception in ioctl\r\n"))); } } break; case IOCTL_POWER_QUERY: // determines whether changing power state is feasible DEBUGMSG(ZONE_BACKLIGHT,(TEXT("BKL: Received IOCTL_POWER_QUERY\r\n"))); if (lpOutBuf && nOutBufSize >= sizeof(CEDEVICE_POWER_STATE)) { // Return a good status on any valid query, since we are always ready to // change power states (if asked for state we don't support, we move to next highest, eg D3->D4). __try { CEDEVICE_POWER_STATE ReqDx = *(PCEDEVICE_POWER_STATE)lpOutBuf; if (VALID_DX(ReqDx)) { // This is a valid Dx state so return a good status. dwErr = ERROR_SUCCESS; } DEBUGMSG(ZONE_BACKLIGHT, (TEXT("BKL: IOCTL_POWER_QUERY %s\r\n"), dwErr == ERROR_SUCCESS ? (TEXT("succeeded")) : (TEXT("failed")) )); } __except(EXCEPTION_EXECUTE_HANDLER) { DEBUGMSG(ZONE_BACKLIGHT, (TEXT("Exception in ioctl\r\n"))); } }