Bug 1122850 - Use setPowerMode interface for HWC 1.4 and above. r=dwilson
authorSushil Chauhan <sushilchauhan@codeaurora.org>
Thu, 05 Feb 2015 12:30:54 -0800
changeset 242019 3d85bc28eaad1537b7bf12bf0a7593bf67c21100
parent 242018 2ca4450d6a33c7247802f43a34432911b5169a2a
child 242020 8599349898e74f705b422dbe45e1f64b507030cb
push id629
push userjlal@mozilla.com
push dateTue, 10 Feb 2015 18:55:13 +0000
reviewersdwilson
bugs1122850
milestone38.0a1
Bug 1122850 - Use setPowerMode interface for HWC 1.4 and above. r=dwilson
widget/gonk/libdisplay/GonkDisplayJB.cpp
--- a/widget/gonk/libdisplay/GonkDisplayJB.cpp
+++ b/widget/gonk/libdisplay/GonkDisplayJB.cpp
@@ -131,18 +131,28 @@ GonkDisplayJB::GonkDisplayJB()
     mSTClient = stc;
     mSTClient->perform(mSTClient.get(), NATIVE_WINDOW_SET_BUFFER_COUNT, 2);
     mSTClient->perform(mSTClient.get(), NATIVE_WINDOW_SET_USAGE,
                                         GRALLOC_USAGE_HW_FB |
                                         GRALLOC_USAGE_HW_RENDER |
                                         GRALLOC_USAGE_HW_COMPOSER);
 
     mList = (hwc_display_contents_1_t *)malloc(sizeof(*mList) + (sizeof(hwc_layer_1_t)*2));
-    if (mHwc)
+    if (mHwc) {
+#if ANDROID_VERSION >= 21
+        if (mHwc->common.version >= HWC_DEVICE_API_VERSION_1_4) {
+            mHwc->setPowerMode(mHwc, HWC_DISPLAY_PRIMARY, HWC_POWER_MODE_NORMAL);
+        } else {
+            mHwc->blank(mHwc, HWC_DISPLAY_PRIMARY, 0);
+        }
+#else
         mHwc->blank(mHwc, HWC_DISPLAY_PRIMARY, 0);
+#endif
+    }
+
 
     ALOGI("Starting bootanimation with (%d) format framebuffer", surfaceformat);
     StartBootAnimation();
 }
 
 GonkDisplayJB::~GonkDisplayJB()
 {
     if (mHwc)
@@ -166,21 +176,34 @@ GonkDisplayJB::SetEnabled(bool enabled)
         autosuspend_disable();
         mPowerModule->setInteractive(mPowerModule, true);
     }
 
     if (!enabled && mEnabledCallback) {
         mEnabledCallback(enabled);
     }
 
+#if ANDROID_VERSION >= 21
+    if (mHwc) {
+        if (mHwc->common.version >= HWC_DEVICE_API_VERSION_1_4) {
+            mHwc->setPowerMode(mHwc, HWC_DISPLAY_PRIMARY,
+                (enabled ? HWC_POWER_MODE_NORMAL : HWC_POWER_MODE_OFF));
+        } else {
+            mHwc->blank(mHwc, HWC_DISPLAY_PRIMARY, !enabled);
+        }
+    } else if (mFBDevice && mFBDevice->enableScreen) {
+        mFBDevice->enableScreen(mFBDevice, enabled);
+    }
+#else
     if (mHwc && mHwc->blank) {
         mHwc->blank(mHwc, HWC_DISPLAY_PRIMARY, !enabled);
     } else if (mFBDevice && mFBDevice->enableScreen) {
         mFBDevice->enableScreen(mFBDevice, enabled);
     }
+#endif
 
     if (enabled && mEnabledCallback) {
         mEnabledCallback(enabled);
     }
 
     if (!enabled) {
         autosuspend_enable();
         mPowerModule->setInteractive(mPowerModule, false);