commonsys-intf: display: Add support to query display wb capabilities

Change-Id: I2370df1cf4db99f353e047d2db50a5d416d7650b
diff --git a/libdisplayconfig/Android.mk b/libdisplayconfig/Android.mk
index ec9340d..5061886 100644
--- a/libdisplayconfig/Android.mk
+++ b/libdisplayconfig/Android.mk
@@ -1,5 +1,9 @@
 LOCAL_PATH := $(call my-dir)
 
+display_config_version := $(shell \
+    if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/config/1.4" ];\
+    then echo DISPLAY_CONFIG_1_4; fi)
+
 include $(CLEAR_VARS)
 LOCAL_MODULE                  := libdisplayconfig
 LOCAL_MODULE_TAGS             := optional
@@ -7,6 +11,12 @@
 LOCAL_SRC_FILES               := DisplayConfig.cpp
 LOCAL_SHARED_LIBRARIES        := libhidlbase libhidltransport libutils \
                                  vendor.display.config@1.0
+
+ifeq ($(display_config_version), DISPLAY_CONFIG_1_4)
+    LOCAL_SHARED_LIBRARIES        += vendor.display.config@1.4
+    LOCAL_CFLAGS                  += -DDISPLAY_CONFIG_1_4
+endif
+
 LOCAL_EXPORT_C_INCLUDE_DIRS   := $(LOCAL_PATH)
 
 ifeq ($(LLVM_SA), true)
diff --git a/libdisplayconfig/DisplayConfig.cpp b/libdisplayconfig/DisplayConfig.cpp
index 29fcc94..59d466a 100644
--- a/libdisplayconfig/DisplayConfig.cpp
+++ b/libdisplayconfig/DisplayConfig.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017 The Linux Foundation. All rights reserved.
+* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -27,13 +27,21 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#ifdef DISPLAY_CONFIG_1_4
+#include <vendor/display/config/1.4/IDisplayConfig.h>
+#else
 #include <vendor/display/config/1.0/IDisplayConfig.h>
+#endif
+
 
 #include "DisplayConfig.h"
 
 namespace display {
-
+#ifdef DISPLAY_CONFIG_1_4
+using vendor::display::config::V1_4::IDisplayConfig;
+#else
 using vendor::display::config::V1_0::IDisplayConfig;
+#endif
 
 //=============================================================================
 // The functions below run in the client process and wherever necessary
@@ -332,6 +340,27 @@
     return error;
 }
 
+#ifdef DISPLAY_CONFIG_1_4
+int32_t getWriteBackCapabilities( WriteBackCapabilities *caps) {
+    android::sp<IDisplayConfig> intf = IDisplayConfig::getService();
+    if (intf == NULL || caps == NULL) {
+        return -1;
+    }
+
+    int error = -1;
+    intf->getWriteBackCapabilities(
+        [&](const auto &tmpError, const auto &tmpCaps) {
+            error = tmpError;
+            if (error) {
+                return;
+            }
+            caps->isWbUbwcSupported = tmpCaps.isWbUbwcSupported;
+        });
+
+    return error;
+}
+#endif
+
 int setCameraLaunchStatus(uint32_t on) {
     android::sp<IDisplayConfig> intf = IDisplayConfig::getService();
     if (intf == NULL) {
diff --git a/libdisplayconfig/DisplayConfig.h b/libdisplayconfig/DisplayConfig.h
index 17b6421..5d54d3f 100644
--- a/libdisplayconfig/DisplayConfig.h
+++ b/libdisplayconfig/DisplayConfig.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2017 The Linux Foundation. All rights reserved.
+* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -83,6 +83,10 @@
     float min_luminance = 0.0f;
 };
 
+struct WriteBackCapabilities {
+    bool isWbUbwcSupported;
+};
+
 //=============================================================================
 // The functions below run in the client pocess and wherever necessary
 // do a binder call to HWC to get/set data.
@@ -104,6 +108,7 @@
 int getHDRCapabilities(int dpy, DisplayHDRCapabilities *caps);
 int setCameraLaunchStatus(uint32_t on);
 bool displayBWTransactionPending();
+int32_t getWriteBackCapabilities(WriteBackCapabilities *caps);
 
 } // namespace display