display: Add support to query Display HW Id

Add support to query Display HW Id from HWC HAL of a given display.

CRs-Fixed: 2710899
Change-Id: I96e9cfe4f8f75b0c1cd23adab23e7abd2707ff59
diff --git a/services/config/config_defs.h b/services/config/config_defs.h
index c4181b8..4f4ef92 100644
--- a/services/config/config_defs.h
+++ b/services/config/config_defs.h
@@ -295,6 +295,7 @@
   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
+  virtual int GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id) 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 0e1cdab..d3c3075 100644
--- a/services/config/src/client_impl.cpp
+++ b/services/config/src/client_impl.cpp
@@ -842,6 +842,29 @@
   return error;
 }
 
+int ClientImpl::GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id) {
+  ByteStream input_params;
+  input_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_id), sizeof(uint32_t));
+  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_, kGetDisplayHwId, input_params, {}, hidl_cb);
+
+  const uint8_t *data = output_params.data();
+  const uint32_t *output = reinterpret_cast<const uint32_t*>(data);
+
+  if (!error) {
+    *display_hw_id = *output;
+  }
+
+  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 a76d3de..677fedf 100644
--- a/services/config/src/client_impl.h
+++ b/services/config/src/client_impl.h
@@ -115,6 +115,7 @@
   virtual int IsRotatorSupportedFormat(int hal_format, bool ubwc, bool *supported);
   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);
 
  private:
   android::sp<IDisplayConfig> display_config_ = nullptr;
diff --git a/services/config/src/device_impl.cpp b/services/config/src/device_impl.cpp
index 5a590a8..a6304cc 100644
--- a/services/config/src/device_impl.cpp
+++ b/services/config/src/device_impl.cpp
@@ -723,6 +723,19 @@
   _hidl_cb(0, {}, {});
 }
 
+void DeviceImpl::DeviceClientContext::ParseGetDisplayHwId(const ByteStream &input_params,
+                                                          perform_cb _hidl_cb) {
+  uint32_t disp_hw_id = 0;
+  ByteStream output_params;
+
+  const uint8_t *data = input_params.data();
+  const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
+  int32_t error = intf_->GetDisplayHwId(*disp_id, &disp_hw_id);
+  output_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_hw_id), sizeof(uint32_t));
+
+  _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) {
@@ -873,6 +886,9 @@
     case kDestroy:
       ParseDestroy(client_handle, _hidl_cb);
       break;
+    case kGetDisplayHwId:
+      client->ParseGetDisplayHwId(input_params, _hidl_cb);
+      break;
     default:
       break;
   }
diff --git a/services/config/src/device_impl.h b/services/config/src/device_impl.h
index 39b7587..85a31c5 100644
--- a/services/config/src/device_impl.h
+++ b/services/config/src/device_impl.h
@@ -117,6 +117,7 @@
     void ParseControlQsyncCallback(uint64_t client_handle, const ByteStream &input_params,
                                    perform_cb _hidl_cb);
     void ParseSendTUIEvent(const ByteStream &input_params, perform_cb _hidl_cb);
+    void ParseGetDisplayHwId(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 b589d8a..6e0c5b7 100644
--- a/services/config/src/opcode_types.h
+++ b/services/config/src/opcode_types.h
@@ -76,6 +76,7 @@
   kIsRotatorSupportedFormat = 40,
   kControlQsyncCallback = 41,
   kSendTUIEvent = 42,
+  kGetDisplayHwId = 43,
 
   kDestroy = 0xFFFF, // Destroy sequence execution
 };