summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/DisplayHardware
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2014-04-02 12:50:06 -0700
committerRuchi Kandoi <kandoiruchi@google.com>2014-06-18 18:51:24 -0700
commitef472ec40a0fbb0ef96b79bef846f20b73da4971 (patch)
treede71052452705788c1d0d9a5fd4781d8f7629e47 /services/surfaceflinger/DisplayHardware
parenta317f27b7bf49e2e7b2b443223c07fb8c7c3ac3f (diff)
downloadframeworks_native-ef472ec40a0fbb0ef96b79bef846f20b73da4971.zip
frameworks_native-ef472ec40a0fbb0ef96b79bef846f20b73da4971.tar.gz
frameworks_native-ef472ec40a0fbb0ef96b79bef846f20b73da4971.tar.bz2
SurfaceFlinger: send VSYNC power hints to IPowerManager
VSYNC power hints are now sent via binder to IPowerManager. SurfaceFlinger no longer loads a second copy of the PowerHAL. VSYNC power hints are sent in batches and not on per frame basis. Change-Id: Ia5a839ab3c857cffae7089f810b4315d4ed23fcf
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;
};
// ---------------------------------------------------------------------------