displayconfig: Add support to notify TUI transition events

Add support to notify TUI transition events to hwcomposer.

Change-Id: I56f8fa8c3432ebf4fff44b9cbf8c2ac5252b799a
diff --git a/services/config/config_defs.h b/services/config/config_defs.h
index 7b4838a..c4181b8 100644
--- a/services/config/config_defs.h
+++ b/services/config/config_defs.h
@@ -48,6 +48,7 @@
   kPrimary,
   kExternal,
   kVirtual,
+  kBuiltIn2,
 };
 
 enum class ExternalStatus : int {
@@ -90,6 +91,13 @@
   kWaitForCommitEachFrame,
 };
 
+enum class TUIEventType : int {
+  kNone,
+  kPrepareTUITransition,
+  kStartTUITransition,
+  kEndTUITransition,
+};
+
 // Input and Output Params structures
 struct Attributes {
   uint32_t vsync_period = 0;
@@ -219,6 +227,11 @@
   int qsync_refresh_rate = 0;
 };
 
+struct TUIEventParams {
+  DisplayType dpy = DisplayType::kInvalid;
+  TUIEventType tui_event_type = TUIEventType::kNone;
+};
+
 /* Callback Interface */
 class ConfigCallback {
  public:
@@ -281,6 +294,7 @@
   virtual int IsSmartPanelConfig(uint32_t disp_id, uint32_t config_id, bool *is_smart) DEFAULT_RET
   virtual int IsRotatorSupportedFormat(int hal_format, bool ubwc, bool *supported) DEFAULT_RET
   virtual int ControlQsyncCallback(bool enable) DEFAULT_RET
+  virtual int SendTUIEvent(DisplayType dpy, TUIEventType event_type) 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 c11fa3c..483ad29 100644
--- a/services/config/src/client_impl.cpp
+++ b/services/config/src/client_impl.cpp
@@ -820,6 +820,20 @@
   return error;
 }
 
+int ClientImpl::SendTUIEvent(DisplayType dpy, TUIEventType event_type) {
+  struct TUIEventParams input = {dpy, event_type};
+  ByteStream input_params;
+  input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct TUIEventParams));
+  int32_t error = 0;
+  auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+    error = err;
+  };
+
+  display_config_->perform(client_handle_, kSendTUIEvent, input_params, {}, hidl_cb);
+
+  return error;
+}
+
 void ClientImpl::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 085fc22..ebcfa85 100644
--- a/services/config/src/client_impl.h
+++ b/services/config/src/client_impl.h
@@ -99,6 +99,7 @@
   virtual int IsSmartPanelConfig(uint32_t disp_id, uint32_t config_id, bool *is_smart);
   virtual int IsRotatorSupportedFormat(int hal_format, bool ubwc, bool *supported);
   virtual int ControlQsyncCallback(bool enable);
+  virtual int SendTUIEvent(DisplayType dpy, TUIEventType event_type);
 
  private:
   virtual Return<void> perform(uint32_t op_code, const ByteStream &input_params,
diff --git a/services/config/src/device_impl.cpp b/services/config/src/device_impl.cpp
index 6cbdb18..37a0778 100644
--- a/services/config/src/device_impl.cpp
+++ b/services/config/src/device_impl.cpp
@@ -690,6 +690,16 @@
   _hidl_cb(error, {}, {});
 }
 
+void DeviceImpl::DeviceClientContext::ParseSendTUIEvent(const ByteStream &input_params,
+                                                        perform_cb _hidl_cb) {
+  const struct TUIEventParams *input_data =
+               reinterpret_cast<const TUIEventParams*>(input_params.data());
+
+  int32_t error = intf_->SendTUIEvent(input_data->dpy, input_data->tui_event_type);
+
+  _hidl_cb(error, {}, {});
+}
+
 Return<void> DeviceImpl::perform(uint64_t client_handle, uint32_t op_code,
                                  const ByteStream &input_params, const HandleStream &input_handles,
                                  perform_cb _hidl_cb) {
@@ -834,6 +844,9 @@
     case kControlQsyncCallback:
       client->ParseControlQsyncCallback(client_handle, input_params, _hidl_cb);
       break;
+    case kSendTUIEvent:
+      client->ParseSendTUIEvent(input_params, _hidl_cb);
+      break;
     default:
       break;
   }
diff --git a/services/config/src/device_impl.h b/services/config/src/device_impl.h
index 96e9351..bc0c4a1 100644
--- a/services/config/src/device_impl.h
+++ b/services/config/src/device_impl.h
@@ -115,6 +115,7 @@
     void ParseIsRotatorSupportedFormat(const ByteStream &input_params, perform_cb _hidl_cb);
     void ParseControlQsyncCallback(uint64_t client_handle, const ByteStream &input_params,
                                    perform_cb _hidl_cb);
+    void ParseSendTUIEvent(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 1b28105..6f49b6f 100644
--- a/services/config/src/opcode_types.h
+++ b/services/config/src/opcode_types.h
@@ -75,6 +75,7 @@
   kCreateVirtualDisplay = 39,
   kIsRotatorSupportedFormat = 40,
   kControlQsyncCallback = 41,
+  kSendTUIEvent = 42,
 };
 
 }  // namespace DisplayConfig