Merge 6879d90872f8d5806bd01e649e87d26ee50e788a on remote branch

Change-Id: I400c38595f1427fc973654bbc83c2d65200e2998
diff --git a/include/display_extn_intf.h b/include/display_extn_intf.h
index ac79cd8..c3e0c83 100644
--- a/include/display_extn_intf.h
+++ b/include/display_extn_intf.h
@@ -30,6 +30,8 @@
 #ifndef __DISP_EXTN_INTF_H__
 #define __DISP_EXTN_INTF_H__
 
+#define EARLY_WAKEUP_FEATURE 1
+
 namespace composer {
 
 class DisplayExtnIntf {
diff --git a/services/config/config_defs.h b/services/config/config_defs.h
index 4f4ef92..0009ac8 100644
--- a/services/config/config_defs.h
+++ b/services/config/config_defs.h
@@ -296,6 +296,8 @@
   virtual int ControlQsyncCallback(bool enable) DEFAULT_RET
   virtual int SendTUIEvent(DisplayType dpy, TUIEventType event_type) DEFAULT_RET
   virtual int GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id) DEFAULT_RET
+  virtual int GetSupportedDisplayRefreshRates(
+      DisplayType dpy, std::vector<uint32_t> *supported_refresh_rates) DEFAULT_RET
 
   // deprecated APIs
   virtual int GetDebugProperty(const std::string prop_name, std::string value) DEFAULT_RET
diff --git a/services/config/src/client_impl.cpp b/services/config/src/client_impl.cpp
index d3c3075..9790f21 100644
--- a/services/config/src/client_impl.cpp
+++ b/services/config/src/client_impl.cpp
@@ -865,6 +865,32 @@
   return error;
 }
 
+int ClientImpl::GetSupportedDisplayRefreshRates(DisplayType dpy,
+                                                std::vector<uint32_t> *supported_refresh_rates) {
+  ByteStream input_params;
+  input_params.setToExternal(reinterpret_cast<uint8_t *>(&dpy), sizeof(DisplayType));
+  ByteStream output_params;
+  int error = 0;
+  auto hidl_cb = [&error, &output_params](int32_t err, ByteStream params, HandleStream handles) {
+    error = err;
+    output_params = params;
+  };
+
+  display_config_->perform(client_handle_, kGetSupportedDisplayRefreshRates, input_params, {},
+                           hidl_cb);
+
+  if (!error) {
+    const uint8_t *data = output_params.data();
+    const uint32_t *refresh_rates_data = reinterpret_cast<const uint32_t *>(data);
+    int num_refresh_rates = static_cast<int>(output_params.size() / sizeof(uint32_t));
+    for (int i = 0; i < num_refresh_rates; i++) {
+      supported_refresh_rates->push_back(refresh_rates_data[i]);
+    }
+  }
+
+  return error;
+}
+
 void ClientCallback::ParseNotifyCWBBufferDone(const ByteStream &input_params,
                                               const HandleStream &input_handles) {
   const int *error;
diff --git a/services/config/src/client_impl.h b/services/config/src/client_impl.h
index 677fedf..737ea19 100644
--- a/services/config/src/client_impl.h
+++ b/services/config/src/client_impl.h
@@ -116,6 +116,8 @@
   virtual int ControlQsyncCallback(bool enable);
   virtual int SendTUIEvent(DisplayType dpy, TUIEventType event_type);
   virtual int GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id);
+  virtual int GetSupportedDisplayRefreshRates(DisplayType dpy,
+                                              std::vector<uint32_t> *supported_refresh_rates);
 
  private:
   android::sp<IDisplayConfig> display_config_ = nullptr;
diff --git a/services/config/src/device_impl.cpp b/services/config/src/device_impl.cpp
index a6304cc..7480194 100644
--- a/services/config/src/device_impl.cpp
+++ b/services/config/src/device_impl.cpp
@@ -736,6 +736,25 @@
   _hidl_cb(error, output_params, {});
 }
 
+void DeviceImpl::DeviceClientContext::ParseGetSupportedDisplayRefreshRates(
+    const ByteStream &input_params, perform_cb _hidl_cb) {
+  ByteStream output_params;
+  std::vector<uint32_t> refresh_rates;
+
+  const uint8_t *data = input_params.data();
+  const DisplayType *dpy = reinterpret_cast<const DisplayType *>(data);
+  int32_t error = intf_->GetSupportedDisplayRefreshRates(*dpy, &refresh_rates);
+
+  uint32_t *refresh_rates_data =
+      reinterpret_cast<uint32_t *>(malloc(sizeof(uint32_t) * refresh_rates.size()));
+  for (int i = 0; i < refresh_rates.size(); i++) {
+    refresh_rates_data[i] = refresh_rates[i];
+  }
+  output_params.setToExternal(reinterpret_cast<uint8_t *>(refresh_rates_data),
+                              sizeof(uint32_t) * refresh_rates.size());
+  _hidl_cb(error, output_params, {});
+}
+
 Return<void> DeviceImpl::perform(uint64_t client_handle, uint32_t op_code,
                                  const ByteStream &input_params, const HandleStream &input_handles,
                                  perform_cb _hidl_cb) {
@@ -889,6 +908,9 @@
     case kGetDisplayHwId:
       client->ParseGetDisplayHwId(input_params, _hidl_cb);
       break;
+    case kGetSupportedDisplayRefreshRates:
+      client->ParseGetSupportedDisplayRefreshRates(input_params, _hidl_cb);
+      break;
     default:
       break;
   }
diff --git a/services/config/src/device_impl.h b/services/config/src/device_impl.h
index 85a31c5..a116f30 100644
--- a/services/config/src/device_impl.h
+++ b/services/config/src/device_impl.h
@@ -118,6 +118,7 @@
                                    perform_cb _hidl_cb);
     void ParseSendTUIEvent(const ByteStream &input_params, perform_cb _hidl_cb);
     void ParseGetDisplayHwId(const ByteStream &input_params, perform_cb _hidl_cb);
+    void ParseGetSupportedDisplayRefreshRates(const ByteStream &input_params, perform_cb _hidl_cb);
 
    private:
     ConfigInterface *intf_ = nullptr;
diff --git a/services/config/src/opcode_types.h b/services/config/src/opcode_types.h
index 6e0c5b7..6386cae 100644
--- a/services/config/src/opcode_types.h
+++ b/services/config/src/opcode_types.h
@@ -77,6 +77,7 @@
   kControlQsyncCallback = 41,
   kSendTUIEvent = 42,
   kGetDisplayHwId = 43,
+  kGetSupportedDisplayRefreshRates = 44,
 
   kDestroy = 0xFFFF, // Destroy sequence execution
 };