summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/DisplayHardware
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger/DisplayHardware')
-rw-r--r--services/surfaceflinger/DisplayHardware/PowerHAL.cpp40
-rw-r--r--services/surfaceflinger/DisplayHardware/PowerHAL.h10
2 files changed, 20 insertions, 30 deletions
diff --git a/services/surfaceflinger/DisplayHardware/PowerHAL.cpp b/services/surfaceflinger/DisplayHardware/PowerHAL.cpp
index e41fbbc..bd50b4a 100644
--- a/services/surfaceflinger/DisplayHardware/PowerHAL.cpp
+++ b/services/surfaceflinger/DisplayHardware/PowerHAL.cpp
@@ -20,38 +20,30 @@
#include <cutils/log.h>
#include <utils/Errors.h>
+#include <binder/IServiceManager.h>
+#include <powermanager/IPowerManager.h>
+#include <powermanager/PowerManager.h>
+
#include "PowerHAL.h"
namespace android {
// ---------------------------------------------------------------------------
-PowerHAL::PowerHAL() : mPowerModule(0), mVSyncHintEnabled(false) {
- int err = hw_get_module(POWER_HARDWARE_MODULE_ID,
- (const hw_module_t **)&mPowerModule);
- ALOGW_IF(err, "%s module not found", POWER_HARDWARE_MODULE_ID);
-}
-
-PowerHAL::~PowerHAL() {
-}
-
-status_t PowerHAL::initCheck() const {
- return mPowerModule ? NO_ERROR : NO_INIT;
-}
-
status_t PowerHAL::vsyncHint(bool enabled) {
- if (!mPowerModule) {
- return NO_INIT;
- }
- if (mPowerModule->common.module_api_version >= POWER_MODULE_API_VERSION_0_2) {
- if (mPowerModule->powerHint) {
- if (mVSyncHintEnabled != bool(enabled)) {
- mPowerModule->powerHint(mPowerModule,
- POWER_HINT_VSYNC, (void*)enabled);
- mVSyncHintEnabled = bool(enabled);
- }
+ Mutex::Autolock _l(mlock);
+ if (mPowerManager == NULL) {
+ const String16 serviceName("power");
+ sp<IBinder> bs = defaultServiceManager()->checkService(serviceName);
+ if (bs == NULL) {
+ return NAME_NOT_FOUND;
}
+ mPowerManager = interface_cast<IPowerManager>(bs);
+ }
+ status_t status = mPowerManager->powerHint(POWER_HINT_VSYNC, enabled ? 1 : 0);
+ if(status == DEAD_OBJECT) {
+ mPowerManager = NULL;
}
- return NO_ERROR;
+ return status;
}
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/DisplayHardware/PowerHAL.h b/services/surfaceflinger/DisplayHardware/PowerHAL.h
index ef67b8f..e5f82a9 100644
--- a/services/surfaceflinger/DisplayHardware/PowerHAL.h
+++ b/services/surfaceflinger/DisplayHardware/PowerHAL.h
@@ -19,7 +19,9 @@
#include <stdint.h>
#include <sys/types.h>
+#include <utils/Mutex.h>
+#include <powermanager/IPowerManager.h>
#include <hardware/power.h>
namespace android {
@@ -28,15 +30,11 @@ namespace android {
class PowerHAL
{
public:
- PowerHAL();
- ~PowerHAL();
-
- status_t initCheck() const;
status_t vsyncHint(bool enabled);
private:
- power_module_t* mPowerModule;
- bool mVSyncHintEnabled;
+ sp<IPowerManager> mPowerManager;
+ Mutex mlock;
};
// ---------------------------------------------------------------------------