SD_API_STATUS CSDHCBase::SetControllerPowerState( CEDEVICE_POWER_STATE cpsNew ) { if (cpsNew != m_cpsCurrent) { switch (cpsNew) { case D0: case D4: KernelIoControl(IOCTL_HAL_DISABLE_WAKE, &m_dwSysIntr, sizeof(m_dwSysIntr), NULL, 0, NULL); break; case D3: KernelIoControl(IOCTL_HAL_ENABLE_WAKE, &m_dwSysIntr, sizeof(m_dwSysIntr), NULL, 0, NULL); break; } SetDevicePowerState(m_hBusAccess, cpsNew, NULL); m_cpsCurrent = cpsNew; } return SD_API_STATUS_SUCCESS; }
//------------------------------------------------------------------------------ // Puts CAudioManager in an initialized state // BOOL CAudioManager::deinitialize() { DEBUGMSG(ZONE_FUNCTION, (L"WAV:+deinitialize()\r\n")); if (m_hParentBus) { SetDevicePowerState(m_hParentBus, D4 , NULL); CloseBusAccessHandle(m_hParentBus); m_hParentBus = NULL; } DEBUGMSG(ZONE_FUNCTION, (L"WAV:-deinitialize()\r\n")); return TRUE; }
//------------------------------------------------------------------------------ // central routine which ensures all resources are freed for the class // void CAudioManager::InternalCleanUp() { DEBUGMSG(ZONE_FUNCTION, (L"WAV:+InternalCleanUp()\r\n")); if (m_state != kUninitialized) { // clean-up some resources // if (m_hParentBus) { SetDevicePowerState(m_hParentBus, D4 , NULL); CloseBusAccessHandle(m_hParentBus) ; } m_state = kUninitialized; } DEBUGMSG(ZONE_FUNCTION, (L"WAV:-InternalCleanUp()\r\n")); }
BOOL ACAudioHWContext::HWMapControllerRegs() { PHYSICAL_ADDRESS pa; DEBUGMSG(ZONE_AC, (L"+ACAudioHWContext::HWMapControllerRegs()\r\n")); // set the power state if (!m_hParent) { DEBUGMSG(ZONE_ERROR, (L"ACAudioHWContext::HWMapControllerRegs: " L"ERROR setting the power state.\r\n" )); goto ErrExit; } m_CurPowerState = D2; SetDevicePowerState(m_hParent, D2 , NULL); // get the McBSP pointer pa.HighPart= 0; pa.LowPart = AUDIO_MCBSP_REGS_PA; m_pMCBSPRegisters = (OMAP2420_McBSP_REGS *)MmMapIoSpace(pa, N1KB, FALSE); if (!m_pMCBSPRegisters) { DEBUGMSG(ZONE_ERROR, (L"ACAudioHWContext::HWMapControllerRegs: " L"ERROR mapping MCBSP registers.\r\n" )); goto ErrExit; } // get the PRCM registers pointer pa.LowPart = OMAP2420_PRCM_REGS_PA; m_pPRCMRegs = (OMAP2420_PRCM_REGS *)MmMapIoSpace(pa, sizeof(OMAP2420_PRCM_REGS), FALSE); if (!m_pPRCMRegs) { DEBUGMSG(ZONE_ERROR, (L"ACAudioHWContext::HWMapControllerRegs: " L"Allocating PRCM register failed.\r\n" )); goto ErrExit; } // open the SPI device m_hSPI = SPIOpen(); if (!m_hSPI) { DEBUGMSG(ZONE_ERROR, (L"ACAudioHWContext::HWMapControllerRegs: " L"Failed to open the SPI device driver.\r\n" )); goto ErrExit; } // configure the SPI device if (!SPISetSlaveAddress(m_hSPI, 0)) { DEBUGMSG(ZONE_ERROR, (L"ACAudioHWContext::HWMapControllerRegs: " L"Failed to set the SPI slave address.\r\n" )); goto ErrExit; } return TRUE; ErrExit: // reset all mappings in case of error m_pMCBSPRegisters = NULL; m_pPRCMRegs = NULL; m_hSPI = NULL; return FALSE; }