sdm: Add HIDL implementation to configure bit clocks.

Change-Id: I2ff291c6d0c27986bd207ffdc22c8b67431d632c
CRs-Fixed: 2476186
diff --git a/common.mk b/common.mk
index 5db3d16..f7c930e 100644
--- a/common.mk
+++ b/common.mk
@@ -3,8 +3,14 @@
 
 #Get the highest display config version available
 display_config_version := $(shell \
+    if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/config/1.10" ];\
+    then echo DISPLAY_CONFIG_1_10; fi)
+
+ifeq ($(display_config_version),)
+display_config_version := $(shell \
     if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/config/1.9" ];\
     then echo DISPLAY_CONFIG_1_9; fi)
+endif
 ifeq ($(display_config_version),)
 display_config_version := $(shell \
     if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/config/1.8" ];\
@@ -91,6 +97,12 @@
     common_flags += -DDISPLAY_CONFIG_1_4 -DDISPLAY_CONFIG_1_5 -DDISPLAY_CONFIG_1_6
     common_flags += -DDISPLAY_CONFIG_1_7 -DDISPLAY_CONFIG_1_8 -DDISPLAY_CONFIG_1_9
 endif
+ifeq ($(display_config_version), DISPLAY_CONFIG_1_10)
+    common_flags += -DDISPLAY_CONFIG_1_1 -DDISPLAY_CONFIG_1_2 -DDISPLAY_CONFIG_1_3
+    common_flags += -DDISPLAY_CONFIG_1_4 -DDISPLAY_CONFIG_1_5 -DDISPLAY_CONFIG_1_6
+    common_flags += -DDISPLAY_CONFIG_1_7 -DDISPLAY_CONFIG_1_8 -DDISPLAY_CONFIG_1_9
+    common_flags += -DDISPLAY_CONFIG_1_10
+endif
 
 ifeq ($(TARGET_USES_COLOR_METADATA), true)
     common_flags += -DUSE_COLOR_METADATA
diff --git a/composer/Android.mk b/composer/Android.mk
index 8ff86d6..62cbca6 100644
--- a/composer/Android.mk
+++ b/composer/Android.mk
@@ -92,6 +92,18 @@
 LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.8
 LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.9
 endif
+ifeq ($(display_config_version), DISPLAY_CONFIG_1_10)
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.1
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.2
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.3
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.4
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.5
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.6
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.7
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.8
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.9
+LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.10
+endif
 
 LOCAL_SRC_FILES               := hwc_session.cpp \
                                  hwc_session_services.cpp \
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index c304dde..d4c4308 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -843,15 +843,11 @@
 }
 
 DisplayError HWCDisplayBuiltIn::SetDynamicDSIClock(uint64_t bitclk) {
-  {
-    SEQUENCE_WAIT_SCOPE_LOCK(HWCSession::locker_[type_]);
-    DisablePartialUpdateOneFrame();
-
-    DisplayError error = display_intf_->SetDynamicDSIClock(bitclk);
-    if (error != kErrorNone) {
-      DLOGE(" failed: Clk: %llu Error: %d", bitclk, error);
-      return error;
-    }
+  DisablePartialUpdateOneFrame();
+  DisplayError error = display_intf_->SetDynamicDSIClock(bitclk);
+  if (error != kErrorNone) {
+    DLOGE(" failed: Clk: %llu Error: %d", bitclk, error);
+    return error;
   }
 
   callbacks_->Refresh(id_);
@@ -861,7 +857,6 @@
 }
 
 DisplayError HWCDisplayBuiltIn::GetDynamicDSIClock(uint64_t *bitclk) {
-  SEQUENCE_WAIT_SCOPE_LOCK(HWCSession::locker_[type_]);
   if (display_intf_) {
     return display_intf_->GetDynamicDSIClock(bitclk);
   }
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index 3a3cbfd..f3ea6d9 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -1974,7 +1974,12 @@
 android::status_t HWCSession::SetDsiClk(const android::Parcel *input_parcel) {
   int disp_id = input_parcel->readInt32();
   uint64_t clk = UINT64(input_parcel->readInt64());
-  if (disp_id < 0 || !hwc_display_[disp_id]) {
+  if (disp_id < 0) {
+    return -EINVAL;
+  }
+
+  SEQUENCE_WAIT_SCOPE_LOCK(locker_[disp_id]);
+  if (!hwc_display_[disp_id]) {
     return -EINVAL;
   }
 
@@ -1984,7 +1989,12 @@
 android::status_t HWCSession::GetDsiClk(const android::Parcel *input_parcel,
                                         android::Parcel *output_parcel) {
   int disp_id = input_parcel->readInt32();
-  if (disp_id < 0 || !hwc_display_[disp_id]) {
+  if (disp_id < 0) {
+    return -EINVAL;
+  }
+
+  SEQUENCE_WAIT_SCOPE_LOCK(locker_[disp_id]);
+  if (!hwc_display_[disp_id]) {
     return -EINVAL;
   }
 
@@ -1998,7 +2008,12 @@
 android::status_t HWCSession::GetSupportedDsiClk(const android::Parcel *input_parcel,
                                                  android::Parcel *output_parcel) {
   int disp_id = input_parcel->readInt32();
-  if (disp_id < 0 || !hwc_display_[disp_id]) {
+  if (disp_id < 0) {
+    return -EINVAL;
+  }
+
+  SCOPE_LOCK(locker_[disp_id]);
+  if (!hwc_display_[disp_id]) {
     return -EINVAL;
   }
 
diff --git a/composer/hwc_session.h b/composer/hwc_session.h
index 7a858fa..d95c75f 100644
--- a/composer/hwc_session.h
+++ b/composer/hwc_session.h
@@ -20,7 +20,9 @@
 #ifndef __HWC_SESSION_H__
 #define __HWC_SESSION_H__
 
-#ifdef DISPLAY_CONFIG_1_9
+#ifdef DISPLAY_CONFIG_1_10
+#include <vendor/display/config/1.10/IDisplayConfig.h>
+#elif DISPLAY_CONFIG_1_9
 #include <vendor/display/config/1.9/IDisplayConfig.h>
 #elif DISPLAY_CONFIG_1_8
 #include <vendor/display/config/1.8/IDisplayConfig.h>
@@ -63,7 +65,9 @@
 
 namespace sdm {
 
-#ifdef DISPLAY_CONFIG_1_9
+#ifdef DISPLAY_CONFIG_1_10
+using vendor::display::config::V1_10::IDisplayConfig;
+#elif DISPLAY_CONFIG_1_9
 using vendor::display::config::V1_9::IDisplayConfig;
 #elif DISPLAY_CONFIG_1_8
 using vendor::display::config::V1_8::IDisplayConfig;
@@ -84,8 +88,16 @@
 #else
 using vendor::display::config::V1_0::IDisplayConfig;
 #endif
+
+#ifdef DISPLAY_CONFIG_1_10
+// Need to be declarated for any version 10 or above.
+using vendor::display::config::V1_10::IDisplayCWBCallback;
+#endif
+
 using ::android::hardware::Return;
 using ::android::hardware::hidl_string;
+using android::hardware::hidl_handle;
+using ::android::hardware::hidl_vec;
 
 int32_t GetDataspaceFromColorMode(ColorMode mode);
 
@@ -384,6 +396,16 @@
   Return<bool> isBuiltInDisplay(uint32_t disp_id) override;
 #endif
 
+#ifdef DISPLAY_CONFIG_1_10
+  Return<void> getSupportedDSIBitClks(uint32_t disp_id,
+                                      getSupportedDSIBitClks_cb _hidl_cb) override;
+  Return<uint64_t> getDSIClk(uint32_t disp_id) override;
+  Return<int32_t> setDSIClk(uint32_t disp_id, uint64_t bit_clk) override;
+  Return<int32_t> setCWBOutputBuffer(const ::android::sp<IDisplayCWBCallback> &callback,
+                                     uint32_t disp_id, const Rect &rect, bool post_processed,
+                                     const hidl_handle& buffer) override;
+#endif
+
   // QClient methods
   virtual android::status_t notifyCallback(uint32_t command, const android::Parcel *input_parcel,
                                            android::Parcel *output_parcel);
diff --git a/composer/hwc_session_services.cpp b/composer/hwc_session_services.cpp
index 8232b94..d43d29f 100644
--- a/composer/hwc_session_services.cpp
+++ b/composer/hwc_session_services.cpp
@@ -831,4 +831,49 @@
 }
 #endif  // DISPLAY_CONFIG_1_9
 
+#ifdef DISPLAY_CONFIG_1_10
+Return<void> HWCSession::getSupportedDSIBitClks(uint32_t disp_id,
+                                                getSupportedDSIBitClks_cb _hidl_cb) {
+  SCOPE_LOCK(locker_[disp_id]);
+  if (!hwc_display_[disp_id]) {
+    return Void();
+  }
+
+  std::vector<uint64_t> bit_clks;
+  hwc_display_[disp_id]->GetSupportedDSIClock(&bit_clks);
+
+  hidl_vec<uint64_t> hidl_bit_clks = bit_clks;
+  _hidl_cb(hidl_bit_clks);
+
+  return Void();
+}
+
+Return<uint64_t> HWCSession::getDSIClk(uint32_t disp_id) {
+  SCOPE_LOCK(locker_[disp_id]);
+  if (!hwc_display_[disp_id]) {
+    return 0;
+  }
+
+  uint64_t bit_clk = 0;
+  hwc_display_[disp_id]->GetDynamicDSIClock(&bit_clk);
+
+  return bit_clk;
+}
+
+Return<int32_t> HWCSession::setDSIClk(uint32_t disp_id, uint64_t bit_clk) {
+  SCOPE_LOCK(locker_[disp_id]);
+  if (!hwc_display_[disp_id]) {
+    return -1;
+  }
+
+  return hwc_display_[disp_id]->SetDynamicDSIClock(bit_clk);
+}
+
+Return<int32_t> HWCSession::setCWBOutputBuffer(const ::android::sp<IDisplayCWBCallback> &callback,
+                                               uint32_t disp_id, const Rect &rect,
+                                               bool post_processed, const hidl_handle& buffer) {
+  return -1;
+}
+#endif  // DISPLAY_CONFIG_1_10
+
 }  // namespace sdm
diff --git a/config/display-product.mk b/config/display-product.mk
index 029e246..31dde0f 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -23,6 +23,7 @@
     vendor.display.config@1.7.vendor \
     vendor.display.config@1.8.vendor \
     vendor.display.config@1.9.vendor \
+    vendor.display.config@1.10.vendor \
     modetest
 
 #QDCM calibration xml file for 2k panel