Skip to content

Instantly share code, notes, and snippets.

@liamwhite
Created December 8, 2020 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liamwhite/8f46f3de1b3c97df08834d386d5b2d85 to your computer and use it in GitHub Desktop.
Save liamwhite/8f46f3de1b3c97df08834d386d5b2d85 to your computer and use it in GitHub Desktop.
project android/
diff --git a/default.xml b/default.xml
index 0df4649..d240524 100644
--- a/default.xml
+++ b/default.xml
@@ -13,6 +13,10 @@
review="android-review.googlesource.com"
revision="refs/tags/android-11.0.0_r17" />
+ <remote name="codeaurora"
+ fetch="https://source.codeaurora.org/quic/la"
+ revision="LA.AU.0.1.1.r4" />
+
<default revision="refs/heads/lineage-18.0"
remote="github"
sync-c="true"
@@ -20,6 +24,7 @@
<!-- AOSP Projects -->
+ <project path="vendor/codeaurora/core-utils" name="vendor_codeaurora_core-utils" />
<project path="build/make" name="LineageOS/android_build" groups="pdk" >
<copyfile src="core/root.mk" dest="Makefile" />
<linkfile src="CleanSpec.mk" dest="build/CleanSpec.mk" />
project build/make/
diff --git a/target/product/mainline_system.mk b/target/product/mainline_system.mk
index a787707a0..e284793b5 100644
--- a/target/product/mainline_system.mk
+++ b/target/product/mainline_system.mk
@@ -139,5 +139,6 @@ _my_allowed_list := $(_base_mk_allowed_list)
_my_paths := \
$(TARGET_COPY_OUT_ROOT)/ \
$(TARGET_COPY_OUT_SYSTEM)/ \
+ $(TARGET_COPY_OUT_SYSTEM_EXT)/ \
$(call require-artifacts-in-path, $(_my_paths), $(_my_allowed_list))
project hardware/google/pixel-sepolicy/
diff --git a/common/attributes b/common/attributes
new file mode 100644
index 0000000..7e6def7
--- /dev/null
+++ b/common/attributes
@@ -0,0 +1 @@
+attribute vendor_persist_type;
diff --git a/pixelstats/attributes b/pixelstats/attributes
new file mode 100644
index 0000000..bb9de49
--- /dev/null
+++ b/pixelstats/attributes
@@ -0,0 +1,3 @@
+attribute pixelstats_vendor;
+attribute sysfs_scsi_devices_0000;
+attribute debugfs_wlan;
project hardware/qcom/sm8150/data/ipacfg-mgr/
diff --git a/ipacm/Android.bp b/ipacm/Android.bp
index 7c2a0c5..c04dada 100644
--- a/ipacm/Android.bp
+++ b/ipacm/Android.bp
@@ -3,7 +3,7 @@ cc_binary {
name: "ipacm",
local_include_dirs: ["src"] + ["inc"],
- header_libs: ["device_kernel_headers"],
+ header_libs: ["generated_kernel_headers"],
cflags: ["-DFEATURE_IPA_ANDROID"] + ["-DFEATURE_IPACM_RESTART"] + [
"-DFEATURE_IPACM_HAL",
"-Wall",
diff --git a/ipacm/inc/IPACM_Netlink.h b/ipacm/inc/IPACM_Netlink.h
index 7a1a939..81f1968 100644
--- a/ipacm/inc/IPACM_Netlink.h
+++ b/ipacm/inc/IPACM_Netlink.h
@@ -52,6 +52,8 @@ extern "C"
#include <sys/select.h>
#include <sys/socket.h>
#include <linux/socket.h>
+#include <inaddr.h>
+#define sockaddr_storage __kernel_sockaddr_storage
#include <linux/if.h>
#include <linux/if_addr.h>
#include <linux/rtnetlink.h>
diff --git a/ipanat/Android.bp b/ipanat/Android.bp
index eefd266..3165b4a 100644
--- a/ipanat/Android.bp
+++ b/ipanat/Android.bp
@@ -3,7 +3,7 @@
cc_library_shared {
name: "libipanat",
- header_libs: ["device_kernel_headers"],
+ header_libs: ["generated_kernel_headers"],
srcs: [
"src/ipa_nat_drv.c",
diff --git a/os_pickup.bp b/os_pickup.bp
index 4cfddc8..e1e14f2 100644
--- a/os_pickup.bp
+++ b/os_pickup.bp
@@ -1,17 +1,3 @@
//hardware/qcom/sm8150/Android.bp links to this file
-bootstrap_go_package {
- name: "soong-display_defaults",
- pkgPath: "android/soong/hardware/qcom/sm8150/display",
- deps: [
- "blueprint",
- "blueprint-pathtools",
- "soong",
- "soong-android",
- "soong-cc",
- "soong-genrule",
- ],
- srcs: [
- "display/display_defaults.go",
- ],
- pluginFor: ["soong_build"],
+soong_namespace {
}
project hardware/qcom/sm8150/display/
diff --git a/display-commonsys-intf/.clang-format b/display-commonsys-intf/.clang-format
new file mode 100644
index 00000000..26ce4fe4
--- /dev/null
+++ b/display-commonsys-intf/.clang-format
@@ -0,0 +1,14 @@
+---
+Language: Cpp
+BasedOnStyle: Google
+Standard : C++11
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortBlocksOnASingleLine: false
+ColumnLimit: 100
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 4
+DerivePointerAlignment: false
+PointerAlignment: Right
+#ReflowComments: false
diff --git a/display-commonsys-intf/.gitignore b/display-commonsys-intf/.gitignore
new file mode 100644
index 00000000..ad71dd6c
--- /dev/null
+++ b/display-commonsys-intf/.gitignore
@@ -0,0 +1,4 @@
+CMakeLists.txt
+.idea/
+.editorconfig
+.clang-complete
diff --git a/display-commonsys-intf/Android.bp b/display-commonsys-intf/Android.bp
new file mode 100644
index 00000000..408e9046
--- /dev/null
+++ b/display-commonsys-intf/Android.bp
@@ -0,0 +1,10 @@
+cc_library_headers {
+ name: "display_intf_headers",
+ vendor_available: true,
+ export_include_dirs: [
+ "gralloc",
+ "include",
+ "libqdmetadata",
+ "services",
+ ],
+}
diff --git a/display-commonsys-intf/Makefile.am b/display-commonsys-intf/Makefile.am
new file mode 100644
index 00000000..8009b422
--- /dev/null
+++ b/display-commonsys-intf/Makefile.am
@@ -0,0 +1,2 @@
+ACLOCAL_AMFLAGS = -I m4
+SUBDIRS = libqdmetadata
diff --git a/display-commonsys-intf/config/display-interfaces-product.mk b/display-commonsys-intf/config/display-interfaces-product.mk
new file mode 100644
index 00000000..8f2edc43
--- /dev/null
+++ b/display-commonsys-intf/config/display-interfaces-product.mk
@@ -0,0 +1,24 @@
+PRODUCT_PACKAGES += vendor.qti.hardware.display.allocator@1.0.vendor \
+ vendor.qti.hardware.display.allocator@3.0.vendor \
+ vendor.qti.hardware.display.composer@1.0.vendor \
+ vendor.qti.hardware.display.composer@2.0.vendor \
+ vendor.display.config@1.0.vendor \
+ vendor.display.config@1.1.vendor \
+ vendor.display.config@1.2.vendor \
+ vendor.display.config@1.3.vendor \
+ vendor.display.config@1.4.vendor \
+ vendor.display.config@1.5.vendor \
+ vendor.display.config@1.6.vendor \
+ vendor.display.config@1.7.vendor \
+ vendor.display.config@1.8.vendor \
+ vendor.display.config@1.9.vendor \
+ vendor.display.config@1.10.vendor \
+ vendor.display.config@1.11.vendor \
+ vendor.display.config@2.0.vendor \
+ vendor.qti.hardware.display.mapper@1.0.vendor \
+ vendor.qti.hardware.display.mapper@1.1.vendor \
+ vendor.qti.hardware.display.mapper@2.0.vendor \
+ vendor.qti.hardware.display.mapper@3.0.vendor \
+ vendor.qti.hardware.display.mapper@4.0.vendor \
+ vendor.qti.hardware.display.mapperextensions@1.0.vendor \
+ vendor.qti.hardware.display.mapperextensions@1.1.vendor
diff --git a/display-commonsys-intf/config/display-product-system.mk b/display-commonsys-intf/config/display-product-system.mk
new file mode 100644
index 00000000..65096487
--- /dev/null
+++ b/display-commonsys-intf/config/display-product-system.mk
@@ -0,0 +1,26 @@
+PRODUCT_PACKAGES += libdisplayconfig \
+ libqdMetaData \
+ libqdMetaData.system \
+ libgralloc.qti \
+ libdrm \
+ vendor.display.config@1.0 \
+ vendor.display.config@1.1 \
+ vendor.display.config@1.2 \
+ vendor.display.config@1.3 \
+ vendor.display.config@1.4 \
+ vendor.display.config@1.5 \
+ libsmomo.qti \
+ liblayerext.qti \
+ libsmomoconfig.qti \
+ libcomposerextn.qti \
+ libdisplayconfig.qti
+
+SOONG_CONFIG_NAMESPACES += qtidisplaycommonsys
+# Soong Keys
+SOONG_CONFIG_qtidisplaycommonsys := displayconfig_enabled
+# Soong Values
+SOONG_CONFIG_qtidisplaycommonsys_displayconfig_enabled := false
+
+ifeq ($(call is-vendor-board-platform,QCOM),true)
+ SOONG_CONFIG_qtidisplaycommonsys_displayconfig_enabled := true
+endif
diff --git a/display-commonsys-intf/configure.ac b/display-commonsys-intf/configure.ac
new file mode 100644
index 00000000..8950b21c
--- /dev/null
+++ b/display-commonsys-intf/configure.ac
@@ -0,0 +1,52 @@
+# -*- Autoconf -*-
+# configure.ac -- Autoconf script for display commonsys intf
+#
+
+# Process this file with autoconf to produce a configure script
+
+# Requires autoconf tool later than 2.61
+AC_PREREQ(2.61)
+# Initialize the display commonsys intf package version 1.0.0
+AC_INIT([disp-commonsys-intf],1.0.0)
+# Does not strictly follow GNU Coding standards
+AM_INIT_AUTOMAKE([foreign])
+# Disables auto rebuilding of configure, Makefile.ins
+AM_MAINTAINER_MODE
+# defines some macros variable to be included by source
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AC_SUBST([AM_CPPFLAGS], [--std=c++11])
+
+AC_ARG_WITH([core_includes],
+ AC_HELP_STRING([--with-core-includes=@<:@dir@:>@],
+ [Specify the location of the core headers]),
+ [core_incdir=$withval],
+ with_core_includes=no)
+
+if test "x$with_core_includes" != "xno"; then
+ CFLAGS="${CFLAGS} -I${core_incdir}"
+fi
+
+AC_ARG_WITH(sanitized-headers,
+ AS_HELP_STRING([--with-sanitized-headers=DIR],
+ [Specify the location of the sanitized Linux headers]),
+ [CPPFLAGS="$CPPFLAGS -I$withval"])
+
+# Checks for programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CXX
+AC_PROG_LIBTOOL
+AC_PROG_AWK
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+AC_SUBST([CFLAGS])
+AC_SUBST([CC])
+AC_CONFIG_FILES([ \
+ Makefile \
+ libqdmetadata/Makefile
+ ])
+AC_OUTPUT
diff --git a/display-commonsys-intf/gralloc/Android.bp b/display-commonsys-intf/gralloc/Android.bp
new file mode 100644
index 00000000..c7339c2f
--- /dev/null
+++ b/display-commonsys-intf/gralloc/Android.bp
@@ -0,0 +1,23 @@
+cc_library_shared {
+ name: "libgralloc.qti",
+ vendor_available: true,
+ system_ext_specific: true,
+ cflags: [
+ "-Wno-sign-conversion",
+ "-DLOG_TAG=\"qtigralloc\"",
+ ],
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libgralloctypes",
+ "libhidlbase",
+ "libhardware",
+ "android.hardware.graphics.mapper@4.0",
+ ],
+
+ srcs: ["QtiGralloc.cpp"],
+
+ header_libs: ["display_intf_headers"],
+}
+
diff --git a/display-commonsys-intf/gralloc/QtiGralloc.cpp b/display-commonsys-intf/gralloc/QtiGralloc.cpp
new file mode 100644
index 00000000..5172ad54
--- /dev/null
+++ b/display-commonsys-intf/gralloc/QtiGralloc.cpp
@@ -0,0 +1,397 @@
+/*
+ * Copyright (c) 2020, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "QtiGralloc.h"
+
+#include <log/log.h>
+namespace qtigralloc {
+
+using android::hardware::graphics::mapper::V4_0::IMapper;
+
+static sp<IMapper> getInstance() {
+ static sp<IMapper> mapper = IMapper::getService();
+ return mapper;
+}
+
+Error decodeMetadataState(hidl_vec<uint8_t> &in, bool *out) {
+ if (!in.size() || !out) {
+ return Error::BAD_VALUE;
+ }
+ memcpy(out, in.data(), METADATA_SET_SIZE);
+ return Error::NONE;
+}
+
+Error encodeMetadataState(bool *in, hidl_vec<uint8_t> *out) {
+ if (!in || !out) {
+ return Error::BAD_VALUE;
+ }
+ out->resize(sizeof(bool) * METADATA_SET_SIZE);
+ memcpy(out->data(), in, sizeof(bool) * METADATA_SET_SIZE);
+ return Error::NONE;
+}
+
+Error decodeColorMetadata(hidl_vec<uint8_t> &in, ColorMetaData *out) {
+ if (!in.size() || !out) {
+ return Error::BAD_VALUE;
+ }
+ memcpy(out, in.data(), sizeof(ColorMetaData));
+ return Error::NONE;
+}
+
+Error encodeColorMetadata(ColorMetaData &in, hidl_vec<uint8_t> *out) {
+ if (!out) {
+ return Error::BAD_VALUE;
+ }
+ out->resize(sizeof(ColorMetaData));
+ memcpy(out->data(), &in, sizeof(ColorMetaData));
+ return Error::NONE;
+}
+
+// decode the raw graphics metadata from bytestream and store it in 'data' member of
+// GraphicsMetadata struct during mapper->set call, 'size' member is unused.
+Error decodeGraphicsMetadata(hidl_vec<uint8_t> &in, GraphicsMetadata *out) {
+ if (!in.size() || !out) {
+ return Error::BAD_VALUE;
+ }
+ memcpy(&(out->data), in.data(), GRAPHICS_METADATA_SIZE_IN_BYTES);
+ return Error::NONE;
+}
+
+// encode only 'data' member of GraphicsMetadata struct for retrieval of
+// graphics metadata during mapper->get call
+Error encodeGraphicsMetadata(GraphicsMetadata &in, hidl_vec<uint8_t> *out) {
+ if (!out) {
+ return Error::BAD_VALUE;
+ }
+ out->resize(GRAPHICS_METADATA_SIZE_IN_BYTES);
+ memcpy(out->data(), &(in.data), GRAPHICS_METADATA_SIZE_IN_BYTES);
+ return Error::NONE;
+}
+
+// decode the raw graphics metadata from bytestream before presenting it to caller
+Error decodeGraphicsMetadataRaw(hidl_vec<uint8_t> &in, void *out) {
+ if (!in.size() || !out) {
+ return Error::BAD_VALUE;
+ }
+ memcpy(out, in.data(), GRAPHICS_METADATA_SIZE_IN_BYTES);
+ return Error::NONE;
+}
+
+// encode the raw graphics metadata in bytestream before calling mapper->set
+Error encodeGraphicsMetadataRaw(void *in, hidl_vec<uint8_t> *out) {
+ if (!in || !out) {
+ return Error::BAD_VALUE;
+ }
+ out->resize(GRAPHICS_METADATA_SIZE_IN_BYTES);
+ memcpy(out->data(), in, GRAPHICS_METADATA_SIZE_IN_BYTES);
+ return Error::NONE;
+}
+
+Error decodeUBWCStats(hidl_vec<uint8_t> &in, UBWCStats *out) {
+ if (!in.size() || !out) {
+ return Error::BAD_VALUE;
+ }
+ memcpy(out, in.data(), UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
+ return Error::NONE;
+}
+
+Error encodeUBWCStats(UBWCStats *in, hidl_vec<uint8_t> *out) {
+ if (!in || !out) {
+ return Error::BAD_VALUE;
+ }
+ out->resize(UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
+ memcpy(out->data(), in, UBWC_STATS_ARRAY_SIZE * sizeof(UBWCStats));
+ return Error::NONE;
+}
+
+Error decodeCVPMetadata(hidl_vec<uint8_t> &in, CVPMetadata *out) {
+ if (!in.size() || !out) {
+ return Error::BAD_VALUE;
+ }
+ memcpy(out, in.data(), sizeof(CVPMetadata));
+ return Error::NONE;
+}
+
+Error encodeCVPMetadata(CVPMetadata &in, hidl_vec<uint8_t> *out) {
+ if (!out) {
+ return Error::BAD_VALUE;
+ }
+ out->resize(sizeof(CVPMetadata));
+ memcpy(out->data(), &in, sizeof(CVPMetadata));
+ return Error::NONE;
+}
+
+Error decodeVideoHistogramMetadata(hidl_vec<uint8_t> &in, VideoHistogramMetadata *out) {
+ if (!in.size() || !out) {
+ return Error::BAD_VALUE;
+ }
+ memcpy(out, in.data(), sizeof(VideoHistogramMetadata));
+ return Error::NONE;
+}
+
+Error encodeVideoHistogramMetadata(VideoHistogramMetadata &in, hidl_vec<uint8_t> *out) {
+ if (!out) {
+ return Error::BAD_VALUE;
+ }
+ out->resize(sizeof(VideoHistogramMetadata));
+ memcpy(out->data(), &in, sizeof(VideoHistogramMetadata));
+ return Error::NONE;
+}
+
+MetadataType getMetadataType(uint32_t in) {
+ switch (in) {
+ case QTI_VT_TIMESTAMP:
+ return MetadataType_VTTimestamp;
+ case QTI_VIDEO_PERF_MODE:
+ return MetadataType_VideoPerfMode;
+ case QTI_LINEAR_FORMAT:
+ return MetadataType_LinearFormat;
+ case QTI_SINGLE_BUFFER_MODE:
+ return MetadataType_SingleBufferMode;
+ case QTI_PP_PARAM_INTERLACED:
+ return MetadataType_PPParamInterlaced;
+ case QTI_MAP_SECURE_BUFFER:
+ return MetadataType_MapSecureBuffer;
+ case QTI_COLOR_METADATA:
+ return MetadataType_ColorMetadata;
+ case QTI_GRAPHICS_METADATA:
+ return MetadataType_GraphicsMetadata;
+ case QTI_UBWC_CR_STATS_INFO:
+ return MetadataType_UBWCCRStatsInfo;
+ case QTI_REFRESH_RATE:
+ return MetadataType_RefreshRate;
+ case QTI_CVP_METADATA:
+ return MetadataType_CVPMetadata;
+ case QTI_VIDEO_HISTOGRAM_STATS:
+ return MetadataType_VideoHistogramStats;
+ case QTI_FD:
+ return MetadataType_FD;
+ case QTI_PRIVATE_FLAGS:
+ return MetadataType_PrivateFlags;
+ case QTI_ALIGNED_WIDTH_IN_PIXELS:
+ return MetadataType_AlignedWidthInPixels;
+ case QTI_ALIGNED_HEIGHT_IN_PIXELS:
+ return MetadataType_AlignedHeightInPixels;
+ case QTI_STANDARD_METADATA_STATUS:
+ return MetadataType_StandardMetadataStatus;
+ case QTI_VENDOR_METADATA_STATUS:
+ return MetadataType_VendorMetadataStatus;
+ case QTI_BUFFER_TYPE:
+ return MetadataType_BufferType;
+ default:
+ return MetadataType_Invalid;
+ }
+}
+
+Error get(void *buffer, uint32_t type, void *param) {
+ hidl_vec<uint8_t> bytestream;
+ sp<IMapper> mapper = getInstance();
+
+ MetadataType metadata_type = getMetadataType(type);
+ if (metadata_type == MetadataType_Invalid) {
+ param = nullptr;
+ return Error::UNSUPPORTED;
+ }
+
+ auto err = Error::UNSUPPORTED;
+ mapper->get(buffer, metadata_type, [&](const auto &tmpError, const auto &tmpByteStream) {
+ err = tmpError;
+ bytestream = tmpByteStream;
+ });
+
+ if (err != Error::NONE) {
+ return err;
+ }
+
+ switch (type) {
+ case QTI_VT_TIMESTAMP:
+ err = static_cast<Error>(android::gralloc4::decodeUint64(qtigralloc::MetadataType_VTTimestamp,
+ bytestream, (uint64_t *)param));
+ break;
+ case QTI_VIDEO_PERF_MODE:
+ err = static_cast<Error>(android::gralloc4::decodeUint32(
+ qtigralloc::MetadataType_VideoPerfMode, bytestream, (uint32_t *)param));
+ break;
+ case QTI_LINEAR_FORMAT:
+ err = static_cast<Error>(android::gralloc4::decodeUint32(
+ qtigralloc::MetadataType_LinearFormat, bytestream, (uint32_t *)param));
+ break;
+ case QTI_SINGLE_BUFFER_MODE:
+ err = static_cast<Error>(android::gralloc4::decodeUint32(
+ qtigralloc::MetadataType_SingleBufferMode, bytestream, (uint32_t *)param));
+ break;
+ case QTI_PP_PARAM_INTERLACED:
+ err = static_cast<Error>(android::gralloc4::decodeInt32(
+ qtigralloc::MetadataType_PPParamInterlaced, bytestream, (int32_t *)param));
+ break;
+ case QTI_MAP_SECURE_BUFFER:
+ err = static_cast<Error>(android::gralloc4::decodeInt32(
+ qtigralloc::MetadataType_MapSecureBuffer, bytestream, (int32_t *)param));
+ break;
+ case QTI_COLOR_METADATA:
+ err = decodeColorMetadata(bytestream, (ColorMetaData *)param);
+ break;
+ case QTI_GRAPHICS_METADATA:
+ err = decodeGraphicsMetadataRaw(bytestream, param);
+ break;
+ case QTI_UBWC_CR_STATS_INFO:
+ err = decodeUBWCStats(bytestream, (UBWCStats *)param);
+ break;
+ case QTI_REFRESH_RATE:
+ err = static_cast<Error>(android::gralloc4::decodeFloat(qtigralloc::MetadataType_RefreshRate,
+ bytestream, (float *)param));
+ break;
+ case QTI_CVP_METADATA:
+ err = decodeCVPMetadata(bytestream, (CVPMetadata *)param);
+ break;
+ case QTI_VIDEO_HISTOGRAM_STATS:
+ err = decodeVideoHistogramMetadata(bytestream, (VideoHistogramMetadata *)param);
+ break;
+ case QTI_FD:
+ err = static_cast<Error>(android::gralloc4::decodeInt32(qtigralloc::MetadataType_FD,
+ bytestream, (int32_t *)param));
+ break;
+ case QTI_PRIVATE_FLAGS:
+ err = static_cast<Error>(android::gralloc4::decodeInt32(qtigralloc::MetadataType_PrivateFlags,
+ bytestream, (int32_t *)param));
+ break;
+ case QTI_ALIGNED_WIDTH_IN_PIXELS:
+ err = static_cast<Error>(android::gralloc4::decodeUint32(
+ qtigralloc::MetadataType_AlignedWidthInPixels, bytestream, (uint32_t *)param));
+ break;
+ case QTI_ALIGNED_HEIGHT_IN_PIXELS:
+ err = static_cast<Error>(android::gralloc4::decodeUint32(
+ qtigralloc::MetadataType_AlignedHeightInPixels, bytestream, (uint32_t *)param));
+ break;
+ case QTI_STANDARD_METADATA_STATUS:
+ case QTI_VENDOR_METADATA_STATUS:
+ err = decodeMetadataState(bytestream, (bool *)param);
+ break;
+ case QTI_BUFFER_TYPE:
+ err = static_cast<Error>(android::gralloc4::decodeUint32(
+ qtigralloc::MetadataType_BufferType, bytestream, (uint32_t *)param));
+ break;
+ default:
+ param = nullptr;
+ return Error::UNSUPPORTED;
+ }
+
+ return err;
+}
+
+Error set(void *buffer, uint32_t type, void *param) {
+ hidl_vec<uint8_t> bytestream;
+ sp<IMapper> mapper = getInstance();
+
+ Error err = Error::UNSUPPORTED;
+ MetadataType metadata_type = getMetadataType(type);
+ if (metadata_type == MetadataType_Invalid) {
+ return err;
+ }
+
+ switch (type) {
+ case QTI_VT_TIMESTAMP:
+ err = static_cast<Error>(android::gralloc4::encodeUint64(qtigralloc::MetadataType_VTTimestamp,
+ *(uint64_t *)param, &bytestream));
+ break;
+ case QTI_VIDEO_PERF_MODE:
+ err = static_cast<Error>(android::gralloc4::encodeUint32(
+ qtigralloc::MetadataType_VideoPerfMode, *(uint32_t *)param, &bytestream));
+ break;
+ case QTI_LINEAR_FORMAT:
+ err = static_cast<Error>(android::gralloc4::encodeUint32(
+ qtigralloc::MetadataType_LinearFormat, *(uint32_t *)param, &bytestream));
+ break;
+ case QTI_SINGLE_BUFFER_MODE:
+ err = static_cast<Error>(android::gralloc4::encodeUint32(
+ qtigralloc::MetadataType_SingleBufferMode, *(uint32_t *)param, &bytestream));
+ break;
+ case QTI_PP_PARAM_INTERLACED:
+ err = static_cast<Error>(android::gralloc4::encodeInt32(
+ qtigralloc::MetadataType_PPParamInterlaced, *(int32_t *)param, &bytestream));
+ break;
+ case QTI_MAP_SECURE_BUFFER:
+ err = static_cast<Error>(android::gralloc4::encodeInt32(
+ qtigralloc::MetadataType_MapSecureBuffer, *(int32_t *)param, &bytestream));
+ break;
+ case QTI_COLOR_METADATA:
+ err = encodeColorMetadata(*(ColorMetaData *)param, &bytestream);
+ break;
+ case QTI_GRAPHICS_METADATA:
+ err = encodeGraphicsMetadataRaw(param, &bytestream);
+ break;
+ case QTI_UBWC_CR_STATS_INFO:
+ err = encodeUBWCStats((UBWCStats *)param, &bytestream);
+ break;
+ case QTI_REFRESH_RATE:
+ err = static_cast<Error>(android::gralloc4::encodeFloat(qtigralloc::MetadataType_RefreshRate,
+ *(float *)param, &bytestream));
+ break;
+ case QTI_CVP_METADATA:
+ err = encodeCVPMetadata(*(CVPMetadata *)param, &bytestream);
+ break;
+ case QTI_VIDEO_HISTOGRAM_STATS:
+ err = encodeVideoHistogramMetadata(*(VideoHistogramMetadata *)param, &bytestream);
+ break;
+ default:
+ param = nullptr;
+ return Error::UNSUPPORTED;
+ }
+
+ if (err != Error::NONE) {
+ return err;
+ }
+
+ return mapper->set((void *)buffer, metadata_type, bytestream);
+}
+
+int getMetadataState(void *buffer, uint32_t type) {
+ bool metadata_set[METADATA_SET_SIZE];
+ Error err;
+ if (IS_VENDOR_METADATA_TYPE(type)) {
+ err = get(buffer, QTI_VENDOR_METADATA_STATUS, &metadata_set);
+ } else {
+ err = get(buffer, QTI_STANDARD_METADATA_STATUS, &metadata_set);
+ }
+
+ if (err != Error::NONE) {
+ ALOGE("Unable to get metadata state");
+ return -1;
+ }
+
+ if (IS_VENDOR_METADATA_TYPE(type)) {
+ return metadata_set[GET_VENDOR_METADATA_STATUS_INDEX(type)];
+ } else if (GET_STANDARD_METADATA_STATUS_INDEX(type) < METADATA_SET_SIZE) {
+ return metadata_set[GET_STANDARD_METADATA_STATUS_INDEX(type)];
+ } else {
+ return -1;
+ }
+}
+
+} // namespace qtigralloc
diff --git a/display-commonsys-intf/gralloc/QtiGralloc.h b/display-commonsys-intf/gralloc/QtiGralloc.h
new file mode 100644
index 00000000..9ab8732e
--- /dev/null
+++ b/display-commonsys-intf/gralloc/QtiGralloc.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2020 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __QTIGRALLOC_H__
+#define __QTIGRALLOC_H__
+
+#include <android/hardware/graphics/mapper/4.0/IMapper.h>
+#include <gralloctypes/Gralloc4.h>
+#include <hidl/HidlSupport.h>
+#include <stdint.h>
+
+#include <string>
+
+#include "QtiGrallocDefs.h"
+#include "QtiGrallocMetadata.h"
+
+namespace qtigralloc {
+using android::sp;
+using android::hardware::hidl_vec;
+using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType;
+using android::hardware::graphics::mapper::V4_0::Error;
+// from gr_priv_handle.h
+enum {
+ PRIV_FLAGS_USES_ION = 0x00000008,
+ PRIV_FLAGS_NEEDS_FLUSH = 0x00000020,
+ PRIV_FLAGS_NON_CPU_WRITER = 0x00000080,
+ PRIV_FLAGS_CACHED = 0x00000200,
+ PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
+ PRIV_FLAGS_VIDEO_ENCODER = 0x00010000,
+ PRIV_FLAGS_CAMERA_WRITE = 0x00020000,
+ PRIV_FLAGS_CAMERA_READ = 0x00040000,
+ PRIV_FLAGS_HW_TEXTURE = 0x00100000,
+ PRIV_FLAGS_SECURE_DISPLAY = 0x01000000,
+ PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
+ PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format
+};
+
+// Metadata
+static const std::string VENDOR_QTI = "QTI";
+
+Error get(void *buffer, uint32_t type, void *param);
+Error set(void *buffer, uint32_t type, void *param);
+MetadataType getMetadataType(uint32_t in);
+int getMetadataState(void *buffer, uint32_t type);
+
+static const MetadataType MetadataType_VTTimestamp = {VENDOR_QTI, QTI_VT_TIMESTAMP};
+
+static const MetadataType MetadataType_ColorMetadata = {VENDOR_QTI, QTI_COLOR_METADATA};
+
+static const MetadataType MetadataType_PPParamInterlaced = {VENDOR_QTI, QTI_PP_PARAM_INTERLACED};
+
+static const MetadataType MetadataType_VideoPerfMode = {VENDOR_QTI, QTI_VIDEO_PERF_MODE};
+
+static const MetadataType MetadataType_GraphicsMetadata = {VENDOR_QTI, QTI_GRAPHICS_METADATA};
+
+static const MetadataType MetadataType_UBWCCRStatsInfo = {VENDOR_QTI, QTI_UBWC_CR_STATS_INFO};
+
+static const MetadataType MetadataType_RefreshRate = {VENDOR_QTI, QTI_REFRESH_RATE};
+static const MetadataType MetadataType_MapSecureBuffer = {VENDOR_QTI, QTI_MAP_SECURE_BUFFER};
+
+static const MetadataType MetadataType_LinearFormat = {VENDOR_QTI, QTI_LINEAR_FORMAT};
+
+static const MetadataType MetadataType_SingleBufferMode = {VENDOR_QTI, QTI_SINGLE_BUFFER_MODE};
+
+static const MetadataType MetadataType_CVPMetadata = {VENDOR_QTI, QTI_CVP_METADATA};
+
+static const MetadataType MetadataType_VideoHistogramStats = {VENDOR_QTI,
+ QTI_VIDEO_HISTOGRAM_STATS};
+
+static const MetadataType MetadataType_FD = {VENDOR_QTI, QTI_FD};
+
+static const MetadataType MetadataType_PrivateFlags = {VENDOR_QTI, QTI_PRIVATE_FLAGS};
+
+static const MetadataType MetadataType_AlignedWidthInPixels = {VENDOR_QTI,
+ QTI_ALIGNED_WIDTH_IN_PIXELS};
+
+static const MetadataType MetadataType_AlignedHeightInPixels = {VENDOR_QTI,
+ QTI_ALIGNED_HEIGHT_IN_PIXELS};
+
+static const MetadataType MetadataType_StandardMetadataStatus = {VENDOR_QTI,
+ QTI_STANDARD_METADATA_STATUS};
+
+static const MetadataType MetadataType_VendorMetadataStatus = {VENDOR_QTI,
+ QTI_VENDOR_METADATA_STATUS};
+
+static const MetadataType MetadataType_BufferType = {VENDOR_QTI,
+ QTI_BUFFER_TYPE};
+
+// 0 is also used as invalid value in standard metadata
+static const MetadataType MetadataType_Invalid = {VENDOR_QTI, 0};
+
+static const aidl::android::hardware::graphics::common::ExtendableType Compression_QtiUBWC = {
+ VENDOR_QTI, COMPRESSION_QTI_UBWC};
+static const aidl::android::hardware::graphics::common::ExtendableType Interlaced_Qti = {
+ VENDOR_QTI, INTERLACED_QTI};
+
+static const aidl::android::hardware::graphics::common::ExtendableType
+ PlaneLayoutComponentType_Raw = {VENDOR_QTI, PLANE_COMPONENT_TYPE_RAW};
+static const aidl::android::hardware::graphics::common::ExtendableType
+ PlaneLayoutComponentType_Meta = {VENDOR_QTI, PLANE_COMPONENT_TYPE_META};
+
+Error decodeMetadataState(hidl_vec<uint8_t> &in, bool *out);
+Error encodeMetadataState(bool *in, hidl_vec<uint8_t> *out);
+Error decodeColorMetadata(hidl_vec<uint8_t> &in, ColorMetaData *out);
+Error encodeColorMetadata(ColorMetaData &in, hidl_vec<uint8_t> *out);
+Error decodeGraphicsMetadata(hidl_vec<uint8_t> &in, GraphicsMetadata *out);
+Error encodeGraphicsMetadata(GraphicsMetadata &in, hidl_vec<uint8_t> *out);
+Error decodeGraphicsMetadataRaw(hidl_vec<uint8_t> &in, void *out);
+Error encodeGraphicsMetadataRaw(void *in, hidl_vec<uint8_t> *out);
+Error decodeUBWCStats(hidl_vec<uint8_t> &in, UBWCStats *out);
+Error encodeUBWCStats(UBWCStats *in, hidl_vec<uint8_t> *out);
+Error decodeCVPMetadata(hidl_vec<uint8_t> &in, CVPMetadata *out);
+Error encodeCVPMetadata(CVPMetadata &in, hidl_vec<uint8_t> *out);
+Error decodeVideoHistogramMetadata(hidl_vec<uint8_t> &in, VideoHistogramMetadata *out);
+Error encodeVideoHistogramMetadata(VideoHistogramMetadata &in, hidl_vec<uint8_t> *out);
+} // namespace qtigralloc
+
+#endif //__QTIGRALLOC_H__
diff --git a/display-commonsys-intf/gralloc/QtiGrallocDefs.h b/display-commonsys-intf/gralloc/QtiGrallocDefs.h
new file mode 100644
index 00000000..93272dd3
--- /dev/null
+++ b/display-commonsys-intf/gralloc/QtiGrallocDefs.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2020 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __QTIGRALLOCDEFS_H__
+#define __QTIGRALLOCDEFS_H__
+
+// From gralloc_priv.h
+
+/* Gralloc usage bits indicating the type of allocation that should be used */
+/* Refer to BufferUsage in hardware/interfaces/graphics/common/<ver>/types.hal */
+
+/* The bits below are in officially defined vendor space
+ * i.e bits 28-31 and 48-63*/
+/* Non linear, Universal Bandwidth Compression */
+#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC (UINT32_C(1) << 28)
+
+/* Set this for allocating uncached memory (using O_DSYNC),
+ * cannot be used with noncontiguous heaps */
+#define GRALLOC_USAGE_PRIVATE_UNCACHED (UINT32_C(1) << 29)
+
+/* This flag is used to indicate 10 bit format.
+ * When both GRALLOC_USAGE_PRIVATE_ALLOC_UBWC & GRALLOC_USAGE_PRIVATE_10BIT
+ * are set then it will indicate UBWC_TP10 format.
+ * When only GRALLOC_USAGE_PRIVATE_10BIT is set it will indicate linear P010 format.
+ */
+#define GRALLOC_USAGE_PRIVATE_10BIT (UINT32_C(1) << 30)
+
+/* This flag is used for SECURE display usecase */
+#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY (UINT32_C(1) << 31)
+
+/* This flag is used to indicate video NV21 format */
+#define GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER 1ULL << 48
+
+/* unused legacy flags */
+#define GRALLOC_USAGE_PRIVATE_MM_HEAP 0
+#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP 0
+
+/* This flag is set for WFD usecase */
+#define GRALLOC_USAGE_PRIVATE_WFD 1ULL << 51
+
+/* This flag is set for HEIF usecase */
+#define GRALLOC_USAGE_PRIVATE_HEIF (UINT32_C(1) << 27)
+
+/* TODO(user): Remove when clients stop referencing this flag */
+#define GRALLOC_USAGE_PRIVATE_10BIT_TP 0
+
+/* This flag indicates PI format is being used */
+#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI 1ULL << 49
+
+/* This flag is set while CDSP accesses the buffer */
+#define GRALLOC_USAGE_PRIVATE_CDSP 1ULL << 50
+
+// OEM specific HAL formats
+#define HAL_PIXEL_FORMAT_RGBA_5551 6
+#define HAL_PIXEL_FORMAT_RGBA_4444 7
+#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102
+#define HAL_PIXEL_FORMAT_NV21_ENCODEABLE 0x7FA30C00
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109
+#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01
+#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B
+#define HAL_PIXEL_FORMAT_R_8 0x10D
+#define HAL_PIXEL_FORMAT_RG_88 0x10E
+#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F
+#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110
+#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111
+#define HAL_PIXEL_FORMAT_BGRX_8888 0x112
+#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113
+#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114
+#define HAL_PIXEL_FORMAT_BGR_565 0x115
+#define HAL_PIXEL_FORMAT_RAW8 0x123
+#define HAL_PIXEL_FORMAT_NV12_HEIF 0x116
+
+// 10 bit
+#define HAL_PIXEL_FORMAT_ARGB_2101010 0x117
+#define HAL_PIXEL_FORMAT_RGBX_1010102 0x118
+#define HAL_PIXEL_FORMAT_XRGB_2101010 0x119
+#define HAL_PIXEL_FORMAT_BGRA_1010102 0x11A
+#define HAL_PIXEL_FORMAT_ABGR_2101010 0x11B
+#define HAL_PIXEL_FORMAT_BGRX_1010102 0x11C
+#define HAL_PIXEL_FORMAT_XBGR_2101010 0x11D
+#define HAL_PIXEL_FORMAT_YCbCr_420_P010 0x36 // HAL_PIXEL_FORMAT_YCBCR_P010
+#define HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC 0x124
+#define HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS 0x7FA30C0A
+
+#define HAL_PIXEL_FORMAT_CbYCrY_422_I 0x120
+#define HAL_PIXEL_FORMAT_BGR_888 0x121
+
+#define HAL_PIXEL_FORMAT_INTERLACE 0x180
+
+// Camera utils format
+#define HAL_PIXEL_FORMAT_NV12_LINEAR_FLEX 0x125
+#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX 0x126
+#define HAL_PIXEL_FORMAT_MULTIPLANAR_FLEX 0x127
+#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_2_BATCH 0x128
+#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_4_BATCH 0x129
+#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_8_BATCH 0x130
+
+// v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component
+#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559
+
+// v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed
+// format reduces the memory access bandwidth
+#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259
+
+// UBWC aligned Venus format
+#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06
+#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC 0x7FA30C09
+
+// Khronos ASTC formats
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
+#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
+#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+
+enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO };
+
+#endif //__QTIGRALLOCDEFS_H__
diff --git a/display-commonsys-intf/gralloc/QtiGrallocMetadata.h b/display-commonsys-intf/gralloc/QtiGrallocMetadata.h
new file mode 100644
index 00000000..35bf4a08
--- /dev/null
+++ b/display-commonsys-intf/gralloc/QtiGrallocMetadata.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2020 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __QTIGRALLOCMETADATA_H__
+#define __QTIGRALLOCMETADATA_H__
+
+#include <color_metadata.h>
+
+#define QTI_VT_TIMESTAMP 10000
+#define QTI_COLOR_METADATA 10001
+#define QTI_PP_PARAM_INTERLACED 10002
+#define QTI_VIDEO_PERF_MODE 10003
+#define QTI_GRAPHICS_METADATA 10004
+#define QTI_UBWC_CR_STATS_INFO 10005
+#define QTI_REFRESH_RATE 10006
+#define QTI_MAP_SECURE_BUFFER 10007
+#define QTI_LINEAR_FORMAT 10008
+#define QTI_SINGLE_BUFFER_MODE 10009
+#define QTI_CVP_METADATA 10010
+#define QTI_VIDEO_HISTOGRAM_STATS 10011
+// File descriptor for allocated buffer
+#define QTI_FD 10012
+// Flags from the private handle of the allocated buffer
+#define QTI_PRIVATE_FLAGS 10013
+// Width of the allocated buffer in pixels
+#define QTI_ALIGNED_WIDTH_IN_PIXELS 10014
+// Height of the allocated buffer in pixels
+#define QTI_ALIGNED_HEIGHT_IN_PIXELS 10015
+// Indicates whether metadata is using default value or has been set
+#define QTI_STANDARD_METADATA_STATUS 10016
+#define QTI_VENDOR_METADATA_STATUS 10017
+#define QTI_BUFFER_TYPE 10018
+
+// Used to indicate to framework that internal definitions are used instead
+#define COMPRESSION_QTI_UBWC 20001
+#define INTERLACED_QTI 20002
+
+#define PLANE_COMPONENT_TYPE_RAW 20003
+#define PLANE_COMPONENT_TYPE_META 20004
+
+#define MAX_NAME_LEN 256
+
+// GRAPHICS_METADATA
+#define GRAPHICS_METADATA_SIZE 4096
+#define GRAPHICS_METADATA_SIZE_IN_BYTES (GRAPHICS_METADATA_SIZE * sizeof(uint32_t))
+typedef struct GraphicsMetadata {
+ uint32_t size; //unused in Gralloc4, in Gralloc3 it was never returned on Get()
+ uint32_t data[GRAPHICS_METADATA_SIZE]; //Clients must set only raw data with Gralloc4
+} GraphicsMetadata;
+
+// UBWC_CR_STATS_INFO
+#define MAX_UBWC_STATS_LENGTH 32
+enum UBWC_Version {
+ UBWC_UNUSED = 0,
+ UBWC_1_0 = 0x1,
+ UBWC_2_0 = 0x2,
+ UBWC_3_0 = 0x3,
+ UBWC_4_0 = 0x4,
+ UBWC_MAX_VERSION = 0xFF,
+};
+
+struct UBWC_2_0_Stats {
+ uint32_t nCRStatsTile32; /**< UBWC Stats info for 32 Byte Tile */
+ uint32_t nCRStatsTile64; /**< UBWC Stats info for 64 Byte Tile */
+ uint32_t nCRStatsTile96; /**< UBWC Stats info for 96 Byte Tile */
+ uint32_t nCRStatsTile128; /**< UBWC Stats info for 128 Byte Tile */
+ uint32_t nCRStatsTile160; /**< UBWC Stats info for 160 Byte Tile */
+ uint32_t nCRStatsTile192; /**< UBWC Stats info for 192 Byte Tile */
+ uint32_t nCRStatsTile256; /**< UBWC Stats info for 256 Byte Tile */
+};
+
+struct UBWCStats {
+ enum UBWC_Version version; /* Union depends on this version. */
+ uint8_t bDataValid; /* If [non-zero], CR Stats data is valid.
+ * Consumers may use stats data.
+ * If [zero], CR Stats data is invalid.
+ * Consumers *Shall* not use stats data */
+ union {
+ struct UBWC_2_0_Stats ubwc_stats;
+ uint32_t reserved[MAX_UBWC_STATS_LENGTH]; /* This is for future */
+ };
+};
+
+#define UBWC_STATS_ARRAY_SIZE 2
+struct CropRectangle_t {
+ int32_t left;
+ int32_t top;
+ int32_t right;
+ int32_t bottom;
+};
+
+// CVP_METADATA
+#define CVP_METADATA_SIZE 1024
+enum CVPMetadataFlags {
+ /* bit wise flags */
+ CVP_METADATA_FLAG_NONE = 0x00000000,
+ CVP_METADATA_FLAG_REPEAT = 0x00000001,
+};
+
+typedef struct CVPMetadata {
+ uint32_t size; /* payload size in bytes */
+ uint8_t payload[CVP_METADATA_SIZE];
+ uint32_t capture_frame_rate;
+ /* Frame rate in Q16 format.
+ Eg: fps = 7.5, then
+ capture_frame_rate = 7 << 16 --> Upper 16 bits to represent 7
+ capture_frame_rate |= 5 -------> Lower 16 bits to represent 5
+
+ If size > 0, framerate is valid
+ If size = 0, invalid data, so ignore all parameters */
+ uint32_t cvp_frame_rate;
+ enum CVPMetadataFlags flags;
+ uint32_t reserved[8];
+} CVPMetadata;
+
+// VIDEO_HISTOGRAM_STATS
+
+#define VIDEO_HISTOGRAM_STATS_SIZE (4 * 1024)
+struct VideoHistogramMetadata {
+ uint32_t stats_info[1024]; /* video stats payload */
+ uint32_t stat_len; /* Payload size in bytes */
+ uint32_t frame_type; /* bit mask to indicate frame type */
+ uint32_t display_width;
+ uint32_t display_height;
+ uint32_t decode_width;
+ uint32_t decode_height;
+ uint32_t reserved[12];
+};
+
+#define RESERVED_REGION_SIZE 4096
+typedef struct ReservedRegion {
+ uint32_t size;
+ uint8_t data[RESERVED_REGION_SIZE];
+} ReservedRegion;
+
+#define METADATA_SET_SIZE 512
+
+#define IS_VENDOR_METADATA_TYPE(x) (x >= QTI_VT_TIMESTAMP)
+
+#define GET_STANDARD_METADATA_STATUS_INDEX(x) x
+#define GET_VENDOR_METADATA_STATUS_INDEX(x) x - QTI_VT_TIMESTAMP
+
+#endif //__QTIGRALLOCMETADATA_H__
diff --git a/display-commonsys-intf/gralloc/QtiGrallocPriv.h b/display-commonsys-intf/gralloc/QtiGrallocPriv.h
new file mode 100644
index 00000000..3874ecdd
--- /dev/null
+++ b/display-commonsys-intf/gralloc/QtiGrallocPriv.h
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2020 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __QTIGRALLOCPRIV_H__
+#define __QTIGRALLOCPRIV_H__
+
+#include <color_metadata.h>
+#include <cutils/native_handle.h>
+#include <log/log.h>
+
+#include <cinttypes>
+#include <string>
+
+#include "QtiGrallocMetadata.h"
+
+#ifndef __QTI_DISPLAY_GRALLOC__
+#pragma message "QtiGrallocPriv.h should not be included"
+#endif
+
+/*
+ *
+ * DISCLAIMER:
+ * INTERNAL GRALLOC USE ONLY - THIS FILE SHOULD NOT BE INCLUDED BY GRALLOC CLIENTS
+ * The location will be changed and this file will not be exposed
+ * once qdMetaData copy functions are deprecated
+ *
+ */
+
+#define METADATA_V2
+
+// TODO: MetaData_t should be in qtigralloc namespace
+struct MetaData_t {
+ int32_t operation;
+ int32_t interlaced;
+ float refreshrate;
+ int32_t mapSecureBuffer;
+ /* Deprecated */
+ uint32_t s3dFormat;
+ /* VENUS output buffer is linear for UBWC Interlaced video */
+ uint32_t linearFormat;
+ /* Set by graphics to indicate that this buffer will be written to but not
+ * swapped out */
+ uint32_t isSingleBufferMode;
+
+ /* Set by camera to program the VT Timestamp */
+ uint64_t vtTimeStamp;
+ /* Color Aspects + HDR info */
+ ColorMetaData color;
+ /* Consumer should read this data as follows based on
+ * Gralloc flag "interlaced" listed above.
+ * [0] : If it is progressive.
+ * [0] : Top field, if it is interlaced.
+ * [1] : Do not read, if it is progressive.
+ * [1] : Bottom field, if it is interlaced.
+ */
+ struct UBWCStats ubwcCRStats[UBWC_STATS_ARRAY_SIZE];
+ /* Set by camera to indicate that this buffer will be used for a High
+ * Performance Video Usecase */
+ uint32_t isVideoPerfMode;
+ /* Populated and used by adreno during buffer size calculation.
+ * Set only for RGB formats. */
+ GraphicsMetadata graphics_metadata;
+ /* Video hisogram stats populated by video decoder */
+ struct VideoHistogramMetadata video_histogram_stats;
+ /*
+ * Producer (camera) will set cvp metadata and consumer (video) will
+ * use it. The format of metadata is known to producer and consumer.
+ */
+ CVPMetadata cvpMetadata;
+ CropRectangle_t crop;
+ int32_t blendMode;
+ char name[MAX_NAME_LEN];
+ ReservedRegion reservedRegion;
+ bool isStandardMetadataSet[METADATA_SET_SIZE];
+ bool isVendorMetadataSet[METADATA_SET_SIZE];
+ uint64_t reservedSize;
+};
+
+namespace qtigralloc {
+#define QTI_HANDLE_CONST(exp) static_cast<const private_handle_t *>(exp)
+
+#pragma pack(push, 4)
+struct private_handle_t : public native_handle_t {
+ // file-descriptors dup'd over IPC
+ int fd;
+ int fd_metadata;
+
+ // values sent over IPC
+ int magic;
+ int flags;
+ int width; // holds width of the actual buffer allocated
+ int height; // holds height of the actual buffer allocated
+ int unaligned_width; // holds width client asked to allocate
+ int unaligned_height; // holds height client asked to allocate
+ int format;
+ int buffer_type;
+ unsigned int layer_count;
+ uint64_t id;
+ uint64_t usage;
+
+ unsigned int size;
+ unsigned int offset;
+ unsigned int offset_metadata;
+ uint64_t base;
+ uint64_t base_metadata;
+ uint64_t gpuaddr;
+ static const int kNumFds = 2;
+ static const int kMagic = 'gmsm';
+
+ static inline int NumInts() {
+ return ((sizeof(private_handle_t) - sizeof(native_handle_t)) / sizeof(int)) - kNumFds;
+ }
+
+ private_handle_t(int fd, int meta_fd, int flags, int width, int height, int uw, int uh,
+ int format, int buf_type, unsigned int size, uint64_t usage = 0)
+ : fd(fd),
+ fd_metadata(meta_fd),
+ magic(kMagic),
+ flags(flags),
+ width(width),
+ height(height),
+ unaligned_width(uw),
+ unaligned_height(uh),
+ format(format),
+ buffer_type(buf_type),
+ layer_count(1),
+ id(0),
+ usage(usage),
+ size(size),
+ offset(0),
+ offset_metadata(0),
+ base(0),
+ base_metadata(0),
+ gpuaddr(0) {
+ version = static_cast<int>(sizeof(native_handle));
+ numInts = NumInts();
+ numFds = kNumFds;
+ }
+
+ ~private_handle_t() { magic = 0; }
+
+ static int validate(const native_handle *h) {
+ auto *hnd = static_cast<const private_handle_t *>(h);
+ if (!h || h->version != sizeof(native_handle) || h->numInts != NumInts() ||
+ h->numFds != kNumFds) {
+ ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d)", h,
+ h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(),
+ h ? h->numFds : -1, kNumFds);
+ return -1;
+ }
+ if (hnd->magic != kMagic) {
+ ALOGE("handle = %p invalid magic(%c%c%c%c/%c%c%c%c)", hnd,
+ hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 0) & 0xFF) ? ((hnd->magic >> 0) & 0xFF) : '-') : '?',
+ (kMagic >> 24) & 0xFF, (kMagic >> 16) & 0xFF, (kMagic >> 8) & 0xFF,
+ (kMagic >> 0) & 0xFF);
+ return -1;
+ }
+
+ return 0;
+ }
+
+ static void Dump(const private_handle_t *hnd) {
+ ALOGD("handle id:%" PRIu64
+ " wxh:%dx%d uwxuh:%dx%d size: %d fd:%d fd_meta:%d flags:0x%x "
+ "usage:0x%" PRIx64 " format:0x%x layer_count: %d",
+ hnd->id, hnd->width, hnd->height, hnd->unaligned_width, hnd->unaligned_height, hnd->size,
+ hnd->fd, hnd->fd_metadata, hnd->flags, hnd->usage, hnd->format, hnd->layer_count);
+ }
+};
+#pragma pack(pop)
+
+} // namespace qtigralloc
+
+#endif //__QTIGRALLOCPRIV_H__
diff --git a/display-commonsys-intf/gralloc/gr_priv_handle.h b/display-commonsys-intf/gralloc/gr_priv_handle.h
new file mode 100644
index 00000000..98f9f694
--- /dev/null
+++ b/display-commonsys-intf/gralloc/gr_priv_handle.h
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2011-2019, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GR_PRIV_HANDLE_H__
+#define __GR_PRIV_HANDLE_H__
+
+#include <log/log.h>
+#include <hardware/gralloc.h>
+#include <hardware/gralloc1.h>
+#ifdef __cplusplus
+#include <cinttypes>
+#endif
+
+#define GRALLOC1_FUNCTION_PERFORM 0x00001000
+
+#define DBG_HANDLE false
+
+typedef gralloc1_error_t (*GRALLOC1_PFN_PERFORM)(gralloc1_device_t *device, int operation, ...);
+
+#define PRIV_HANDLE_CONST(exp) static_cast<const private_handle_t *>(exp)
+
+#pragma pack(push, 4)
+#ifdef __cplusplus
+struct private_handle_t : public native_handle_t {
+#else
+struct private_handle_t {
+ native_handle_t nativeHandle;
+#endif
+ enum {
+ PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
+ PRIV_FLAGS_USES_ION = 0x00000008,
+ PRIV_FLAGS_NEEDS_FLUSH = 0x00000020,
+ PRIV_FLAGS_INTERNAL_ONLY = 0x00000040,
+ PRIV_FLAGS_NON_CPU_WRITER = 0x00000080,
+ PRIV_FLAGS_CACHED = 0x00000200,
+ PRIV_FLAGS_SECURE_BUFFER = 0x00000400,
+ PRIV_FLAGS_EXTERNAL_ONLY = 0x00002000,
+ PRIV_FLAGS_PROTECTED_BUFFER = 0x00004000,
+ PRIV_FLAGS_VIDEO_ENCODER = 0x00010000,
+ PRIV_FLAGS_CAMERA_WRITE = 0x00020000,
+ PRIV_FLAGS_CAMERA_READ = 0x00040000,
+ PRIV_FLAGS_HW_COMPOSER = 0x00080000,
+ PRIV_FLAGS_HW_TEXTURE = 0x00100000,
+ PRIV_FLAGS_ITU_R_601 = 0x00200000, // Unused from display
+ PRIV_FLAGS_ITU_R_601_FR = 0x00400000, // Unused from display
+ PRIV_FLAGS_ITU_R_709 = 0x00800000, // Unused from display
+ PRIV_FLAGS_SECURE_DISPLAY = 0x01000000,
+ PRIV_FLAGS_TILE_RENDERED = 0x02000000,
+ PRIV_FLAGS_CPU_RENDERED = 0x04000000,
+ PRIV_FLAGS_UBWC_ALIGNED = 0x08000000,
+ PRIV_FLAGS_DISP_CONSUMER = 0x10000000,
+ PRIV_FLAGS_CLIENT_ALLOCATED = 0x20000000, // Ion buffer allocated outside of gralloc
+ PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format
+ };
+
+ // file-descriptors dup'd over IPC
+ int fd;
+ int fd_metadata;
+
+ // values sent over IPC
+ int magic;
+ int flags;
+ int width; // holds width of the actual buffer allocated
+ int height; // holds height of the actual buffer allocated
+ int unaligned_width; // holds width client asked to allocate
+ int unaligned_height; // holds height client asked to allocate
+ int format;
+ int buffer_type;
+ unsigned int layer_count;
+ uint64_t id;
+ uint64_t usage;
+
+ unsigned int size;
+ unsigned int offset;
+ unsigned int offset_metadata;
+ uint64_t base;
+ uint64_t base_metadata;
+ uint64_t gpuaddr;
+#ifdef __cplusplus
+ static const int kNumFds = 2;
+ static const int kMagic = 'gmsm';
+
+ static inline int NumInts() {
+ return ((sizeof(private_handle_t) - sizeof(native_handle_t)) / sizeof(int)) - kNumFds;
+ }
+
+ private_handle_t(int fd, int meta_fd, int flags, int width, int height, int uw, int uh,
+ int format, int buf_type, unsigned int size, uint64_t usage = 0)
+ : fd(fd),
+ fd_metadata(meta_fd),
+ magic(kMagic),
+ flags(flags),
+ width(width),
+ height(height),
+ unaligned_width(uw),
+ unaligned_height(uh),
+ format(format),
+ buffer_type(buf_type),
+ layer_count(1),
+ id(0),
+ usage(usage),
+ size(size),
+ offset(0),
+ offset_metadata(0),
+ base(0),
+ base_metadata(0),
+ gpuaddr(0) {
+ version = static_cast<int>(sizeof(native_handle));
+ numInts = NumInts();
+ numFds = kNumFds;
+ }
+
+ // Legacy constructor used by some clients
+ private_handle_t(int fd, unsigned int size, int usage, int buf_type, int format, int w, int h)
+ : private_handle_t(fd, -1, PRIV_FLAGS_CLIENT_ALLOCATED, w, h, 0, 0, format, buf_type, size,
+ static_cast<uint64_t>(usage)) {}
+
+ ~private_handle_t() {
+ magic = 0;
+ ALOGE_IF(DBG_HANDLE, "Deleting buffer handle %p", this);
+ }
+
+ static int validate(const native_handle *h) {
+ auto *hnd = static_cast<const private_handle_t *>(h);
+ if (!h || h->version != sizeof(native_handle) || h->numInts != NumInts() ||
+ h->numFds != kNumFds) {
+ ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d)",
+ h, h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(),
+ h ? h->numFds : -1, kNumFds);
+ return -EINVAL;
+ }
+ if (hnd->magic != kMagic) {
+ ALOGE("handle = %p invalid magic(%c%c%c%c/%c%c%c%c)",hnd,
+ hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?',
+ hnd ? (((hnd->magic >> 0) & 0xFF) ? ((hnd->magic >> 0) & 0xFF) : '-') : '?',
+ (kMagic >> 24) & 0xFF, (kMagic >> 16) & 0xFF, (kMagic >> 8) & 0xFF, (kMagic >> 0) & 0xFF);
+ return -EINVAL;
+ }
+
+ return 0;
+ }
+
+ static void Dump(const private_handle_t *hnd) {
+ ALOGD("handle id:%" PRIu64
+ " wxh:%dx%d uwxuh:%dx%d size: %d fd:%d fd_meta:%d flags:0x%x "
+ "usage:0x%" PRIx64 " format:0x%x layer_count: %d",
+ hnd->id, hnd->width, hnd->height, hnd->unaligned_width, hnd->unaligned_height, hnd->size,
+ hnd->fd, hnd->fd_metadata, hnd->flags, hnd->usage, hnd->format, hnd->layer_count);
+ }
+
+ int GetUnalignedWidth() const { return unaligned_width; }
+
+ int GetUnalignedHeight() const { return unaligned_height; }
+
+ int GetColorFormat() const { return format; }
+
+ unsigned int GetLayerCount() const { return layer_count; }
+
+ int GetStride() const {
+ // In handle we currently store aligned width after allocation.
+ return width;
+ }
+
+ uint64_t GetUsage() const { return usage; }
+
+ uint64_t GetBackingstore() const { return id; }
+#endif
+};
+#pragma pack(pop)
+
+#endif // __GR_PRIV_HANDLE_H__
diff --git a/display-commonsys-intf/gralloc/gralloc_priv.h b/display-commonsys-intf/gralloc/gralloc_priv.h
new file mode 100644
index 00000000..77c8787e
--- /dev/null
+++ b/display-commonsys-intf/gralloc/gralloc_priv.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
+ * Not a Contribution
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GRALLOC_PRIV_H__
+#define __GRALLOC_PRIV_H__
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "QtiGrallocDefs.h"
+#include "gr_priv_handle.h"
+
+#pragma message "Warning: gralloc_priv.h is deprecated"
+
+#define GRALLOC_PROP_PREFIX "vendor.gralloc."
+#define GRALLOC_PROP(prop_name) GRALLOC_PROP_PREFIX prop_name
+
+#define DISABLE_UBWC_PROP GRALLOC_PROP("disable_ubwc")
+#define DISABLE_AHARDWAREBUFFER_PROP GRALLOC_PROP("disable_ahardware_buffer")
+#define ENABLE_FB_UBWC_PROP GRALLOC_PROP("enable_fb_ubwc")
+#define MAP_FB_MEMORY_PROP GRALLOC_PROP("map_fb_memory")
+#define USE_SYSTEM_HEAP_FOR_SENSORS GRALLOC_PROP("use_system_heap_for_sensors")
+
+#define ROUND_UP_PAGESIZE(x) roundUpToPageSize(x)
+inline int roundUpToPageSize(int x) {
+ return (x + (getpagesize() - 1)) & ~(getpagesize() - 1);
+}
+
+/* Legacy gralloc1 definitions */
+/* Some clients may still be using the old flags */
+#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC_USAGE_PRIVATE_ADSP_HEAP
+#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_ALLOC_UBWC
+#define GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED GRALLOC_USAGE_PRIVATE_UNCACHED
+#define GRALLOC1_CONSUMER_USAGE_PRIVATE_SECURE_DISPLAY GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY
+#define GRALLOC1_PRODUCER_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_MM_HEAP
+#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT GRALLOC_USAGE_PRIVATE_10BIT
+#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP
+#define GRALLOC1_CONSUMER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP
+#define GRALLOC1_PRODUCER_USAGE_PRIVATE_VIDEO_NV21_ENCODER GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER
+
+// for PERFORM API :
+#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1
+#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2
+#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3
+#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4
+#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5
+#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6
+#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7
+#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8
+#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9
+#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10
+#define GRALLOC_MODULE_PERFORM_GET_IGC 11
+#define GRALLOC_MODULE_PERFORM_SET_IGC 12
+#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13
+#define GRALLOC1_MODULE_PERFORM_GET_BUFFER_SIZE_AND_DIMENSIONS 14
+#define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 15
+#define GRALLOC_MODULE_PERFORM_GET_GRAPHICS_METADATA 16
+
+/* possible values for inverse gamma correction */
+#define HAL_IGC_NOT_SPECIFIED 0
+#define HAL_IGC_s_RGB 1
+
+/* Color Space: Values maps to ColorSpace_t in qdMetadata.h */
+#define HAL_CSC_ITU_R_601 0
+#define HAL_CSC_ITU_R_601_FR 1
+#define HAL_CSC_ITU_R_709 2
+#define HAL_CSC_ITU_R_2020 3
+#define HAL_CSC_ITU_R_2020_FR 4
+
+/* possible formats for 3D content*/
+enum {
+ HAL_NO_3D = 0x0,
+ HAL_3D_SIDE_BY_SIDE_L_R = 0x1,
+ HAL_3D_SIDE_BY_SIDE_R_L = 0x2,
+ HAL_3D_TOP_BOTTOM = 0x4,
+ HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format
+};
+
+/* Flag to determine interlaced content
+ * Value maps to Flags presents in types.hal of QtiMapperextensions
+ */
+enum {
+ LAYOUT_INTERLACED_FLAG = 1 << 0,
+};
+
+#endif // __GRALLOC_PRIV_H__
diff --git a/display-commonsys-intf/include/color_metadata.h b/display-commonsys-intf/include/color_metadata.h
new file mode 100644
index 00000000..c8a5890b
--- /dev/null
+++ b/display-commonsys-intf/include/color_metadata.h
@@ -0,0 +1,198 @@
+/*
+* Copyright (c) 2016-2018, 2020 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __COLOR_METADATA_H__
+#define __COLOR_METADATA_H__
+
+#ifdef __cplusplus
+extern "C" {
+#else
+#include <stdbool.h>
+#endif
+#include <stdint.h>
+
+typedef enum ColorRange {
+ Range_Limited = 0,
+ Range_Full = 1,
+ Range_Extended = 2,
+ Range_Max = 0xff,
+} ColorRange;
+
+// The following values matches the HEVC spec
+typedef enum ColorPrimaries {
+ // Unused = 0;
+ ColorPrimaries_BT709_5 = 1, // ITU-R BT.709-5 or equivalent
+ /* Unspecified = 2, Reserved = 3*/
+ ColorPrimaries_BT470_6M = 4, // ITU-R BT.470-6 System M or equivalent
+ ColorPrimaries_BT601_6_625 = 5, // ITU-R BT.601-6 625 or equivalent
+ ColorPrimaries_BT601_6_525 = 6, // ITU-R BT.601-6 525 or equivalent
+ ColorPrimaries_SMPTE_240M = 7, // SMPTE_240M
+ ColorPrimaries_GenericFilm = 8, // Generic Film
+ ColorPrimaries_BT2020 = 9, // ITU-R BT.2020 or equivalent
+ ColorPrimaries_SMPTE_ST428 = 10, // SMPTE_240M
+ ColorPrimaries_AdobeRGB = 11,
+ ColorPrimaries_DCIP3 = 12,
+ ColorPrimaries_EBU3213 = 22,
+ ColorPrimaries_Max = 0xff,
+} ColorPrimaries;
+
+typedef enum GammaTransfer {
+ // Unused = 0;
+ Transfer_sRGB = 1, // ITR-BT.709-5
+ /* Unspecified = 2, Reserved = 3 */
+ Transfer_Gamma2_2 = 4,
+ Transfer_Gamma2_8 = 5,
+ Transfer_SMPTE_170M = 6, // BT.601-6 525 or 625
+ Transfer_SMPTE_240M = 7, // SMPTE_240M
+ Transfer_Linear = 8,
+ Transfer_Log = 9,
+ Transfer_Log_Sqrt = 10,
+ Transfer_XvYCC = 11, // IEC 61966-2-4
+ Transfer_BT1361 = 12, // Rec.ITU-R BT.1361 extended gamut
+ Transfer_sYCC = 13, // IEC 61966-2-1 sRGB or sYCC
+ Transfer_BT2020_2_1 = 14, // Rec. ITU-R BT.2020-2 (same as the values 1, 6, and 15)
+ Transfer_BT2020_2_2 = 15, // Rec. ITU-R BT.2020-2 (same as the values 1, 6, and 14)
+ Transfer_SMPTE_ST2084 = 16, // 2084
+ // transfers unlikely to be required by Android
+ Transfer_ST_428 = 17, // SMPTE ST 428-1
+ Transfer_HLG = 18, // ARIB STD-B67
+ Transfer_Max = 0xff,
+} GammaTransfer;
+
+typedef enum MatrixCoEfficients {
+ MatrixCoEff_Identity = 0,
+ MatrixCoEff_BT709_5 = 1,
+ /* Unspecified = 2, Reserved = 3 */
+ MatrixCoeff_FCC_73_682 = 4,
+ MatrixCoEff_BT601_6_625 = 5,
+ MatrixCoEff_BT601_6_525 = 6,
+ MatrixCoEff_SMPTE240M = 7, // used with 601_525_Unadjusted
+ MatrixCoEff_YCgCo = 8,
+ MatrixCoEff_BT2020 = 9,
+ MatrixCoEff_BT2020Constant = 10,
+ MatrixCoEff_BT601_6_Unadjusted = 11, // Used with BT601_625(KR=0.222, KB=0.071)
+ MatrixCoEff_DCIP3 = 12,
+ MatrixCoEff_Chroma_NonConstant = 13,
+ MatrixCoEff_Max = 0xff,
+} MatrixCoEfficients;
+
+typedef struct Primaries {
+ uint32_t rgbPrimaries[3][2]; // unit 1/50000;
+ uint32_t whitePoint[2]; // unit 1/50000;
+} Primaries;
+
+typedef struct MasteringDisplay {
+ bool colorVolumeSEIEnabled;
+ Primaries primaries;
+ uint32_t maxDisplayLuminance; // unit: cd/m^2.
+ uint32_t minDisplayLuminance; // unit: 1/10000 cd/m^2.
+} MasteringDisplay;
+
+typedef struct ContentLightLevel {
+ bool lightLevelSEIEnabled;
+ uint32_t maxContentLightLevel; // unit: cd/m^2.
+ uint32_t minPicAverageLightLevel; // unit: cd/m^2, will be DEPRECATED, use below
+ uint32_t maxPicAverageLightLevel; // unit: cd/m^2, its same as maxFrameAvgLightLevel(CTA-861-G)
+} ContentLightLevel;
+
+typedef struct ColorRemappingInfo {
+ bool criEnabled;
+ uint32_t crId;
+ uint32_t crCancelFlag;
+ uint32_t crPersistenceFlag;
+ uint32_t crVideoSignalInfoPresentFlag;
+ uint32_t crRange;
+ ColorPrimaries crPrimaries;
+ GammaTransfer crTransferFunction;
+ MatrixCoEfficients crMatrixCoefficients;
+ uint32_t crInputBitDepth;
+ uint32_t crOutputBitDepth;
+ uint32_t crPreLutNumValMinusOne[3];
+ uint32_t crPreLutCodedValue[3*33];
+ uint32_t crPreLutTargetValue[3*33];
+ uint32_t crMatrixPresentFlag;
+ uint32_t crLog2MatrixDenom;
+ int32_t crCoefficients[3*3];
+ uint32_t crPostLutNumValMinusOne[3];
+ uint32_t crPostLutCodedValue[3*33];
+ uint32_t crPostLutTargetValue[3*33];
+} ColorRemappingInfo;
+
+#define HDR_DYNAMIC_META_DATA_SZ 1024
+typedef struct ColorMetaData {
+ // Default values based on sRGB, needs to be overridden in gralloc
+ // based on the format and size.
+ ColorPrimaries colorPrimaries;
+ ColorRange range;
+ GammaTransfer transfer;
+ MatrixCoEfficients matrixCoefficients;
+
+ MasteringDisplay masteringDisplayInfo;
+ ContentLightLevel contentLightLevel;
+ ColorRemappingInfo cRI;
+
+ // Dynamic meta data elements
+ bool dynamicMetaDataValid;
+ uint32_t dynamicMetaDataLen;
+ uint8_t dynamicMetaDataPayload[HDR_DYNAMIC_META_DATA_SZ];
+} ColorMetaData;
+
+typedef struct Color10Bit {
+ uint32_t R: 10;
+ uint32_t G: 10;
+ uint32_t B: 10;
+ uint32_t A: 2;
+} Color10Bit;
+
+typedef struct Lut3d {
+ uint16_t dim; // dimension of each side of LUT cube (ex: 13, 17)in lutEntries
+ uint16_t gridSize; // number of elements in the gridEntries
+ /* Matrix ordering convension
+ for (b = 0; b < dim; b++) {
+ for (g = 0; g < dim; g++) {
+ for (r = 0; r < dim; r++) {
+ read/write [mR mG mB] associated w/ 3DLUT[r][g][b] to/from file
+ }
+ }
+ } */
+ Color10Bit *lutEntries;
+ bool validLutEntries; // Indicates if entries are valid and can be used.
+ /*
+ The grid is a 1D LUT for each of the R,G,B channels that can be
+ used to apply an independent nonlinear transformation to each
+ channel before it is used as a coordinate for addressing
+ the uniform 3D LUT. This effectively creates a non-uniformly
+ sampled 3D LUT. This is useful for having independent control
+ of the sampling grid density along each dimension for greater
+ precision in spite of having a relatively small number of samples.i
+ */
+ Color10Bit *gridEntries;
+ bool validGridEntries; // Indicates if entries are valid and can be used.
+} Lut3d;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __COLOR_METADATA_H__
diff --git a/display-commonsys-intf/include/composer_extn_intf.h b/display-commonsys-intf/include/composer_extn_intf.h
new file mode 100644
index 00000000..54796ef2
--- /dev/null
+++ b/display-commonsys-intf/include/composer_extn_intf.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2019-2020, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __COMPOSER_EXTN_INTF_H__
+#define __COMPOSER_EXTN_INTF_H__
+
+#include <dlfcn.h>
+#include "frame_scheduler_intf.h"
+#include "display_extn_intf.h"
+#include "phase_offset_extn_intf.h"
+
+#define COMPOSER_EXTN_REV_MAJOR (1)
+#define COMPOSER_EXTN_REV_MINOR (0)
+#define COMPOSER_EXTN_VERSION_TAG ((uint16_t) ((COMPOSER_EXTN_REV_MAJOR << 8) \
+ | COMPOSER_EXTN_REV_MINOR))
+
+namespace composer {
+
+class ComposerExtnIntf {
+ public:
+ virtual int CreateFrameScheduler(FrameSchedulerIntf **intf) = 0;
+ virtual void DestroyFrameScheduler(FrameSchedulerIntf *intf) = 0;
+ virtual int CreateDisplayExtn(DisplayExtnIntf **intf) = 0;
+ virtual void DestroyDisplayExtn(DisplayExtnIntf *intf) = 0;
+ virtual int CreatePhaseOffsetExtn(PhaseOffsetExtnIntf **intf) = 0;
+ virtual void DestroyPhaseOffsetExtn(PhaseOffsetExtnIntf *intf) = 0;
+ protected:
+ virtual ~ComposerExtnIntf() { }
+};
+
+class ComposerExtnLib {
+ public:
+ static ComposerExtnIntf * GetInstance() {
+ return g_composer_ext_lib_.composer_ext_intf_;
+ }
+
+ private:
+ const char *lib_name = "libcomposerextn.qti.so";
+
+ typedef int (*CreateComposerExtn)(uint16_t version, ComposerExtnIntf **intf);
+ typedef void (*DestroyComposerExtn)(ComposerExtnIntf *intf);
+
+ ComposerExtnLib() {
+ lib_obj_ = ::dlopen(lib_name, RTLD_NOW);
+ if (!lib_obj_) {
+ return;
+ }
+
+ create_composer_ext_fn_ = reinterpret_cast<CreateComposerExtn>(
+ ::dlsym(lib_obj_, "CreateComposerExtn"));
+ destroy_composer_ext_fn_ = reinterpret_cast<DestroyComposerExtn>(
+ ::dlsym(lib_obj_, "DestroyComposerExtn"));
+ if (create_composer_ext_fn_ && destroy_composer_ext_fn_) {
+ create_composer_ext_fn_(COMPOSER_EXTN_VERSION_TAG, &composer_ext_intf_);
+ }
+ }
+
+ ~ComposerExtnLib() {
+ if (composer_ext_intf_) {
+ destroy_composer_ext_fn_(composer_ext_intf_);
+ }
+
+ if (lib_obj_) {
+ ::dlclose(lib_obj_);
+ }
+ }
+
+ static ComposerExtnLib g_composer_ext_lib_;
+ void *lib_obj_ = nullptr;
+ CreateComposerExtn create_composer_ext_fn_ = nullptr;
+ DestroyComposerExtn destroy_composer_ext_fn_ = nullptr;
+ ComposerExtnIntf *composer_ext_intf_ = nullptr;
+};
+
+} // namespace composer
+
+#endif // __COMPOSER_EXTN_INTF_H__
diff --git a/display-commonsys-intf/include/display_color_processing.h b/display-commonsys-intf/include/display_color_processing.h
new file mode 100644
index 00000000..49cb5d7b
--- /dev/null
+++ b/display-commonsys-intf/include/display_color_processing.h
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2015-2020, 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __DISP_COLOR_PROCESSING_H__
+#define __DISP_COLOR_PROCESSING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LUT3D_ENTRIES_SIZE (17 * 17 * 17)
+#define LUT3D_GC_ENTRIES_SIZE 1024
+
+struct rgb {
+ uint32_t r;
+ uint32_t g;
+ uint32_t b;
+};
+
+struct rgb_entry {
+ struct rgb in;
+ struct rgb out;
+};
+
+/*
+struct lut3d_info
+ flags -- Reserved
+ lut3d_id -- Unique ID used to distinguish individual 3D Lut tables
+ uniform -- Identifies if coefficients are uniform (1) or non-uniform (0)
+ num_entries-- Identifies the number of lut values in the table
+ entries -- Table buffer holding the lut values.
+
+ All coefficients are expected to be tightly packed in the
+ structure, any unused buffer space shall exist at the end
+ of the buffer.
+*/
+struct lut3d_info {
+ uint32_t flags;
+ uint32_t lut3d_id;
+ uint32_t uniform;
+ uint32_t num_entries;
+ struct rgb_entry entries[LUT3D_ENTRIES_SIZE];
+};
+
+/*
+struct lut1d_info
+ flags -- Reserved
+ bit_width -- Bit width of each entry
+ num_entries -- Identifies the number of lut values in the table
+ entries -- Table buffer holding the lut values
+*/
+#define LUT1D_ENTRIES_SIZE (256)
+struct lut1d_info {
+ uint32_t flags;
+ uint32_t bit_width;
+ uint32_t strength;
+ uint32_t num_entries;
+ struct rgb entries[LUT1D_ENTRIES_SIZE];
+};
+
+static const uint32_t kDeTuningFlagSharpFactor = 0x01;
+static const uint32_t kDeTuningFlagClip = 0x02;
+static const uint32_t kDeTuningFlagThrQuiet = 0x04;
+static const uint32_t kDeTuningFlagThrDieout = 0x08;
+static const uint32_t kDeTuningFlagThrLow = 0x10;
+static const uint32_t kDeTuningFlagThrHigh = 0x20;
+static const uint32_t kDeTuningFlagContentQualLevel = 0x40;
+static const uint32_t kDeTuningFlagDeBlend = 0x80;
+
+typedef enum {
+ kDeContentQualUnknown,
+ kDeContentQualLow,
+ kDeContentQualMedium,
+ kDeContentQualHigh,
+ kDeContentQualMax,
+} PPDEContentQualLevel;
+
+typedef enum {
+ kDeContentTypeUnknown,
+ kDeContentTypeVideo,
+ kDeContentTypeGraphics,
+ kDeContentTypeMax,
+} PPDEContentType;
+
+/*
+struct PPDETuningCfg
+*/
+struct PPDETuningCfg {
+ uint32_t flags;
+ int32_t sharp_factor;
+ uint16_t thr_quiet;
+ uint16_t thr_dieout;
+ uint16_t thr_low;
+ uint16_t thr_high;
+ uint16_t clip;
+ PPDEContentQualLevel quality;
+ PPDEContentType content_type;
+ uint32_t de_blend;
+};
+
+struct PPDETuningCfgData {
+ uint32_t cfg_en;
+ struct PPDETuningCfg params;
+ bool cfg_pending;
+};
+
+#ifdef __cplusplus
+}
+#endif
+#endif // __DISP_COLOR_PROCESSING_H__
diff --git a/display-commonsys-intf/include/display_extn_intf.h b/display-commonsys-intf/include/display_extn_intf.h
new file mode 100644
index 00000000..c3e0c834
--- /dev/null
+++ b/display-commonsys-intf/include/display_extn_intf.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2020, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __DISP_EXTN_INTF_H__
+#define __DISP_EXTN_INTF_H__
+
+#define EARLY_WAKEUP_FEATURE 1
+
+namespace composer {
+
+class DisplayExtnIntf {
+ public:
+ virtual int SetContentFps(uint32_t fps) = 0;
+ virtual void RegisterDisplay(uint32_t display_id) = 0;
+ virtual void UnregisterDisplay(uint32_t display_id) = 0;
+ virtual int SetActiveConfig(uint32_t display_id, uint32_t config_id) = 0;
+ virtual int NotifyEarlyWakeUp(bool gpu, bool display) = 0;
+ virtual int NotifyDisplayEarlyWakeUp(uint32_t display_id) = 0;
+
+ protected:
+ virtual ~DisplayExtnIntf() { }
+};
+
+} // namespace composer
+
+#endif // __DISP_EXTN_INTF_H__
diff --git a/display-commonsys-intf/include/frame_extn_intf.h b/display-commonsys-intf/include/frame_extn_intf.h
new file mode 100644
index 00000000..b6bfe41f
--- /dev/null
+++ b/display-commonsys-intf/include/frame_extn_intf.h
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2019, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __FRAME_EXTN_INTF_H__
+#define __FRAME_EXTN_INTF_H__
+
+#include <utils/Timers.h>
+#include <sys/types.h>
+#include <string>
+
+#define EXTENSION_LIBRARY_NAME "libframeextension.so"
+#define CREATE_FRAME_EXTN_INTERFACE "CreateFrameExtnInterface"
+#define DESTROY_FRAME_EXTN_INTERFACE "DestroyFrameExtnInterface"
+
+namespace composer {
+
+class FrameExtnIntf;
+
+// Function addresses queried at runtime using ::dlsym()
+typedef bool (*CreateFrameExtnInterface)(FrameExtnIntf **interface);
+typedef bool (*DestroyFrameExtnInterface)(FrameExtnIntf *interface);
+
+/*! @brief This structure defines extension version.
+
+ @details It is used to avoid any mismatch of versions between frameextension library
+ implementation and its clients usage (like SurfaceFlinger).
+
+ @sa FrameInfo
+*/
+struct Version {
+ uint8_t minor;
+ uint8_t major;
+};
+
+/*! @brief This structure defines the Frame info required by FrameExtnIntf.
+
+ @sa FrameExtnIntf::SetFrameInfo
+*/
+struct FrameInfo {
+ Version version;
+ bool transparent_region;
+ int width;
+ int height;
+ int max_queued_frames;
+ int num_idle;
+ std::string max_queued_layer_name;
+ std::string layer_name;
+ nsecs_t current_timestamp;
+ nsecs_t previous_timestamp;
+ nsecs_t vsync_timestamp;
+ nsecs_t refresh_timestamp;
+ nsecs_t ref_latency;
+ nsecs_t vsync_period;
+};
+
+
+/*! @brief This interface shall be implemented by frameextension library.
+
+ @details This class declares prototype for frameextension public interfaces which must be
+ implemented by frameextension library.
+*/
+class FrameExtnIntf {
+ public:
+ /*! @brief Set the FrameInfo used by frameextension.
+
+ @details This function is called once per refresh cycle so that required frame info are
+ feed to frameextension.
+
+ @param[in] frameInfo \link FrameInfo \endlink
+
+ @return \link int \endlink
+ */
+ virtual int SetFrameInfo(FrameInfo &frameInfo) = 0;
+
+ protected:
+ virtual ~FrameExtnIntf() { };
+};
+
+} // namespace composer
+
+#endif // __FRAME_EXTN_INTF_H__
diff --git a/display-commonsys-intf/include/frame_scheduler_intf.h b/display-commonsys-intf/include/frame_scheduler_intf.h
new file mode 100644
index 00000000..2d706e1b
--- /dev/null
+++ b/display-commonsys-intf/include/frame_scheduler_intf.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __FRAME_SCHEDULER_INTF_H__
+#define __FRAME_SCHEDULER_INTF_H__
+
+#include <utils/Timers.h>
+
+namespace composer {
+
+class FrameSchedulerIntf {
+ public:
+ virtual int UpdateFrameScheduling(int fenceFd, nsecs_t *timeStamp) = 0;
+ protected:
+ virtual ~FrameSchedulerIntf() { }
+};
+
+} // namespace composer
+
+#endif // __FRAME_SCHEDULER_INTF_H__
diff --git a/display-commonsys-intf/include/layer_extn_intf.h b/display-commonsys-intf/include/layer_extn_intf.h
new file mode 100644
index 00000000..adf36bbe
--- /dev/null
+++ b/display-commonsys-intf/include/layer_extn_intf.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LAYER_EXTN_INTF_H__
+#define __LAYER_EXTN_INTF_H__
+
+#include <sys/types.h>
+
+#include <vector>
+#include <string>
+
+namespace composer {
+
+#define LAYER_EXTN_LIBRARY_NAME "liblayerext.qti.so"
+#define CREATE_LAYER_EXTN_INTERFACE "CreateLayerExtnInterface"
+#define DESTROY_LAYER_EXTN_INTERFACE "DestroyLayerExtnInterface"
+
+#define LAYER_EXTN_REVISION_MAJOR (1)
+#define LAYER_EXTN_REVISION_MINOR (0)
+#define LAYER_EXTN_VERSION_TAG ((uint16_t) ((LAYER_EXTN_REVISION_MAJOR << 8) \
+ | LAYER_EXTN_REVISION_MINOR))
+
+class LayerExtnIntf {
+ public:
+ virtual ~LayerExtnIntf() = default;
+ virtual int GetLayerClass(const std::string &name) = 0;
+ virtual void UpdateLayerState(const std::vector<std::string> &layers, int num_layers) = 0;
+};
+
+typedef bool (*CreateLayerExtnInterface)(uint16_t version, LayerExtnIntf **interface);
+typedef void (*DestroyLayerExtnInterface)(LayerExtnIntf *interface);
+
+} // namespace composer
+
+#endif // __LAYER_EXTN_INTF_H__
diff --git a/display-commonsys-intf/include/phase_offset_extn_intf.h b/display-commonsys-intf/include/phase_offset_extn_intf.h
new file mode 100644
index 00000000..84c5e066
--- /dev/null
+++ b/display-commonsys-intf/include/phase_offset_extn_intf.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2020, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __PHASE_OFFSET_EXTN_INTF_H__
+#define __PHASE_OFFSET_EXTN_INTF_H__
+
+#include <unordered_map>
+
+#define PHASE_OFFSET_EXTN 1
+
+namespace composer {
+
+class PhaseOffsetExtnIntf {
+ public:
+ virtual int GetAdvancedSfOffsets(std::unordered_map<float, int64_t> *advancedSfOffsets) = 0;
+
+ protected:
+ virtual ~PhaseOffsetExtnIntf() { }
+};
+
+} // namespace composer
+
+#endif // __PHASE_OFFSET_EXTN_INTF_H__
diff --git a/display-commonsys-intf/include/smomo_config.h b/display-commonsys-intf/include/smomo_config.h
new file mode 100644
index 00000000..ff409d6d
--- /dev/null
+++ b/display-commonsys-intf/include/smomo_config.h
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2019, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*! @file smomo_config.h
+ @brief Interface file for the client of Smomo service, which provides tuning parameters of Smomo
+
+ @details Smomo clients use these interfaces to enable or disable Smomo, tune parameters to
+ optimize the display performance.
+*/
+
+#ifndef __SMOMO_CONFIG_H__
+#define __SMOMO_CONFIG_H__
+
+#include <cstdint>
+
+namespace smomoconfig {
+
+int EnableSmomo(bool enable);
+
+int GetSmomoMode(uint32_t *mode_idx);
+
+int SetSmomoMode(uint32_t mode_idx);
+
+} // namespace smomoconfig
+
+#endif // __SMOMO_CONFIG_H__
+
diff --git a/display-commonsys-intf/include/smomo_interface.h b/display-commonsys-intf/include/smomo_interface.h
new file mode 100644
index 00000000..c16111e0
--- /dev/null
+++ b/display-commonsys-intf/include/smomo_interface.h
@@ -0,0 +1,165 @@
+/*
+* Copyright (c) 2019, 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 met:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*! @file smomo.h
+ @brief Interface file for SmoMo which defines the public interface exposed to SmoMo clients.
+
+ @details SmoMo clients use these interfaces to feed SmoMo required info like frame rate, refresh
+ rate, these info are used to update SmoMo internal state.
+*/
+
+#ifndef __SMOMO_INTERFACE_H__
+#define __SMOMO_INTERFACE_H__
+
+#include <sys/types.h>
+
+#include <vector>
+#include <string>
+
+namespace smomo {
+
+#define SMOMO_LIBRARY_NAME "libsmomo.qti.so"
+#define CREATE_SMOMO_INTERFACE_NAME "CreateSmomoInterface"
+#define DESTROY_SMOMO_INTERFACE_NAME "DestroySmomoInterface"
+
+#define SMOMO_REVISION_MAJOR (1)
+#define SMOMO_REVISION_MINOR (0)
+#define SMOMO_VERSION_TAG ((uint16_t) ((SMOMO_REVISION_MAJOR << 8) \
+ | SMOMO_REVISION_MINOR))
+
+typedef int64_t nsecs_t;
+
+/*! @brief This structure defines the layer stats required by SmoMo.
+
+ @sa SmomoIntf::updateSmomoState
+*/
+struct SmomoLayerStats {
+ std::string name; // layer full name
+ int32_t id; // layer ID
+};
+
+/*! @brief This structure defines the buffer stats required by SmoMo.
+
+ @sa SmomoIntf::CollectLayerStats
+ @sa SmomoIntf::ShouldPresentNow
+*/
+struct SmomoBufferStats {
+ int32_t id; // layer ID
+ int32_t queued_frames; // queued frame count of this layer
+ bool auto_timestamp; // whether timestamp was generated automatically
+ nsecs_t timestamp; // layer buffer's timestamp
+ nsecs_t dequeue_latency; // last dequeue duration
+};
+
+/*! @brief SmoMo interface implemented by SmoMo library.
+
+ @details This class declares prototype for SmoMo public interfaces which must be
+ implemented by SmoMo library. SmoMo clients will use these methods to feed required
+ info to SmoMo implementation.
+*/
+class SmomoIntf {
+ public:
+ virtual ~SmomoIntf() = default;
+
+ /*! @brief Update SmoMo internal state.
+
+ @details This function is called once per each composition so that required layer info are feed
+ to SmoMo, the SmoMo uses these info to update its internal state.
+
+ @param[in] layers \link SmomoLayerStats \endlink
+ @param[in] refresh_rate current display refresh rate
+
+ @return \link void \endlink
+ */
+ virtual void UpdateSmomoState(const std::vector<SmomoLayerStats> &layers,
+ float refresh_rate) = 0;
+
+ /*! @brief Collect layer buffer stats.
+
+ @details This function is called once new buffer is ready for this layer. It's used to collect
+ layer's buffer stats for SmoMo.
+
+ @param[in] \link SmomoBufferStats \endlink
+
+ @return \link void \endlink
+ */
+ virtual void CollectLayerStats(const SmomoBufferStats &buffer_stats) = 0;
+
+ /*! @brief Is this layer buffer ready to present.
+
+ @details This function is called by SmoMo clients used to check whether this layer buffer is
+ due to present.
+
+ @param[in] \link SmomoBufferStats \endlink
+ @param[in] next_vsync_time When next VSYNC arrives
+
+ @return \link bool \endlink
+ */
+ virtual bool ShouldPresentNow(const SmomoBufferStats &buffer_stats,
+ const nsecs_t next_vsync_time) = 0;
+
+ /*! @brief Change refresh rate callback type definition.
+ */
+ using ChangeRefreshRateCallback = std::function<void(int32_t)>;
+
+ /*! @brief Set the callback used by SmoMo to change display refresh rate.
+
+ @details This function is called by SmoMo clients used to set the refresh rate callback.
+
+ @param[in] callback \link ChangeRefreshRateCallback \endlink
+
+ @return \link void \endlink
+ */
+ virtual void SetChangeRefreshRateCallback(
+ const ChangeRefreshRateCallback& callback) = 0;
+
+ /*! @brief Set the refersh rates supported by display.
+
+ @details This function is called to tell SmoMo what refresh rates this display can suport.
+
+ @param[in] refresh_rates The refresh rates supported by the display
+
+ @return \link void \endlink
+ */
+ virtual void SetDisplayRefreshRates(const std::vector<float> &refresh_rates) = 0;
+
+ /*! @brief Get the current frame rate from SmoMo.
+
+ @details This function is called by SmoMo client to query the current frame rate, which is
+ based on the internal state of SmoMo. Client needs to call the UpdateSmomoState API before
+ calling this function. SmoMo only returns a valid frame rate when it's settled to a state.
+
+ @return > 0 if valid, -1 if invalid.
+
+ @return \link int \endlink
+ */
+ virtual int GetFrameRate() = 0;
+};
+
+typedef bool (*CreateSmomoInterface)(uint16_t version, SmomoIntf **interface);
+typedef void (*DestroySmomoInterface)(SmomoIntf *interface);
+
+} // namespace smomo
+
+#endif // __SMOMO_INTERFACE_H__
diff --git a/display-commonsys-intf/libqdmetadata/Android.bp b/display-commonsys-intf/libqdmetadata/Android.bp
new file mode 100644
index 00000000..3cd036bf
--- /dev/null
+++ b/display-commonsys-intf/libqdmetadata/Android.bp
@@ -0,0 +1,22 @@
+cc_library_shared {
+ name: "libqdMetaData",
+ vendor_available: true,
+ system_ext_specific: true,
+ cflags: [
+ "-Wno-sign-conversion",
+ "-DLOG_TAG=\"qdmetadata\"",
+ "-D__QTI_DISPLAY_GRALLOC__",
+ ],
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libhidlbase",
+ "libgralloc.qti",
+ "libgralloctypes",
+ ],
+ header_libs: ["libhardware_headers", "display_intf_headers"],
+ srcs: ["qdMetaData.cpp", "qd_utils.cpp"],
+ export_header_lib_headers: ["display_intf_headers"],
+}
+
diff --git a/display-commonsys-intf/libqdmetadata/Makefile.am b/display-commonsys-intf/libqdmetadata/Makefile.am
new file mode 100644
index 00000000..24b1c4a8
--- /dev/null
+++ b/display-commonsys-intf/libqdmetadata/Makefile.am
@@ -0,0 +1,14 @@
+h_sources = qdMetaData.h
+
+cpp_sources = qdMetaData.cpp
+
+qdMetaData_includedir = $(pkgincludedir)/display
+qdMetaData_include_HEADERS = $(h_sources)
+
+lib_LTLIBRARIES = libqdMetaData.la
+libqdMetaData_la_CC = @CC@
+libqdMetaData_la_SOURCES = $(cpp_sources)
+libqdMetaData_la_CFLAGS = $(AM_CFLAGS) -DLOG_TAG=\"DisplayMetaData\"
+libqdMetaData_la_CPPFLAGS = $(AM_CPPFLAGS)
+libqdMetaData_LDADD = -lcutils -llog
+libqdMetaData_la_LDFLAGS = -shared -avoid-version
diff --git a/display-commonsys-intf/libqdmetadata/qdMetaData.cpp b/display-commonsys-intf/libqdmetadata/qdMetaData.cpp
new file mode 100644
index 00000000..0fa24caa
--- /dev/null
+++ b/display-commonsys-intf/libqdmetadata/qdMetaData.cpp
@@ -0,0 +1,604 @@
+/*
+ * Copyright (c) 2012-2020, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "qdMetaData.h"
+
+#include <QtiGrallocPriv.h>
+#include <errno.h>
+#include <gralloc_priv.h>
+#include <gralloctypes/Gralloc4.h>
+#include <log/log.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#include <cinttypes>
+
+static int colorMetaDataToColorSpace(ColorMetaData in, ColorSpace_t *out) {
+ if (in.colorPrimaries == ColorPrimaries_BT601_6_525 ||
+ in.colorPrimaries == ColorPrimaries_BT601_6_625) {
+ if (in.range == Range_Full) {
+ *out = ITU_R_601_FR;
+ } else {
+ *out = ITU_R_601;
+ }
+ } else if (in.colorPrimaries == ColorPrimaries_BT2020) {
+ if (in.range == Range_Full) {
+ *out = ITU_R_2020_FR;
+ } else {
+ *out = ITU_R_2020;
+ }
+ } else if (in.colorPrimaries == ColorPrimaries_BT709_5) {
+ *out = ITU_R_709;
+ } else {
+ ALOGE(
+ "Cannot convert ColorMetaData to ColorSpace_t. "
+ "Primaries = %d, Range = %d",
+ in.colorPrimaries, in.range);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int colorSpaceToColorMetadata(ColorSpace_t in, ColorMetaData *out) {
+ out->transfer = Transfer_sRGB;
+ switch (in) {
+ case ITU_R_601:
+ out->colorPrimaries = ColorPrimaries_BT601_6_525;
+ out->range = Range_Limited;
+ break;
+ case ITU_R_601_FR:
+ out->colorPrimaries = ColorPrimaries_BT601_6_525;
+ out->range = Range_Full;
+ break;
+ case ITU_R_709:
+ out->colorPrimaries = ColorPrimaries_BT709_5;
+ out->range = Range_Limited;
+ break;
+ case ITU_R_2020:
+ out->colorPrimaries = ColorPrimaries_BT2020;
+ out->range = Range_Limited;
+ break;
+ case ITU_R_2020_FR:
+ out->colorPrimaries = ColorPrimaries_BT2020;
+ out->range = Range_Full;
+ break;
+ default:
+ ALOGE("Cannot convert ColorSpace_t %d to ColorMetaData", in);
+ return -1;
+ break;
+ }
+
+ return 0;
+}
+
+static bool getGralloc4Array(MetaData_t *metadata, int32_t paramType) {
+ switch (paramType) {
+ case SET_VT_TIMESTAMP:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_VT_TIMESTAMP)];
+ case COLOR_METADATA:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_COLOR_METADATA)];
+ case PP_PARAM_INTERLACED:
+ return metadata
+ ->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_PP_PARAM_INTERLACED)];
+ case SET_VIDEO_PERF_MODE:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_VIDEO_PERF_MODE)];
+ case SET_GRAPHICS_METADATA:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_GRAPHICS_METADATA)];
+ case SET_UBWC_CR_STATS_INFO:
+ return metadata
+ ->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_UBWC_CR_STATS_INFO)];
+ case UPDATE_BUFFER_GEOMETRY:
+ return metadata->isStandardMetadataSet[GET_STANDARD_METADATA_STATUS_INDEX(
+ ::android::gralloc4::MetadataType_Crop.value)];
+ case UPDATE_REFRESH_RATE:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_REFRESH_RATE)];
+ case UPDATE_COLOR_SPACE:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_COLOR_METADATA)];
+ case MAP_SECURE_BUFFER:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_MAP_SECURE_BUFFER)];
+ case LINEAR_FORMAT:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_LINEAR_FORMAT)];
+ case SET_SINGLE_BUFFER_MODE:
+ return metadata
+ ->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_SINGLE_BUFFER_MODE)];
+ case SET_CVP_METADATA:
+ return metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_CVP_METADATA)];
+ case SET_VIDEO_HISTOGRAM_STATS:
+ return metadata
+ ->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_VIDEO_HISTOGRAM_STATS)];
+ default:
+ ALOGE("paramType %d not supported", paramType);
+ return false;
+ }
+}
+
+static void setGralloc4Array(MetaData_t *metadata, int32_t paramType, bool isSet) {
+ switch (paramType) {
+ case SET_VT_TIMESTAMP:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_VT_TIMESTAMP)] = isSet;
+ break;
+ case COLOR_METADATA:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_COLOR_METADATA)] = isSet;
+ break;
+ case PP_PARAM_INTERLACED:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_PP_PARAM_INTERLACED)] =
+ isSet;
+ break;
+ case SET_VIDEO_PERF_MODE:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_VIDEO_PERF_MODE)] = isSet;
+ break;
+ case SET_GRAPHICS_METADATA:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_GRAPHICS_METADATA)] =
+ isSet;
+ break;
+ case SET_UBWC_CR_STATS_INFO:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_UBWC_CR_STATS_INFO)] =
+ isSet;
+ break;
+ case UPDATE_BUFFER_GEOMETRY:
+ metadata->isStandardMetadataSet[GET_STANDARD_METADATA_STATUS_INDEX(
+ ::android::gralloc4::MetadataType_Crop.value)] = isSet;
+ break;
+ case UPDATE_REFRESH_RATE:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_REFRESH_RATE)] = isSet;
+ break;
+ case UPDATE_COLOR_SPACE:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_COLOR_METADATA)] = isSet;
+ break;
+ case MAP_SECURE_BUFFER:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_MAP_SECURE_BUFFER)] =
+ isSet;
+ break;
+ case LINEAR_FORMAT:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_LINEAR_FORMAT)] = isSet;
+ break;
+ case SET_SINGLE_BUFFER_MODE:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_SINGLE_BUFFER_MODE)] =
+ isSet;
+ break;
+ case SET_CVP_METADATA:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_CVP_METADATA)] = isSet;
+ break;
+ case SET_VIDEO_HISTOGRAM_STATS:
+ metadata->isVendorMetadataSet[GET_VENDOR_METADATA_STATUS_INDEX(QTI_VIDEO_HISTOGRAM_STATS)] =
+ isSet;
+ break;
+ default:
+ ALOGE("paramType %d not supported in Gralloc4", paramType);
+ }
+}
+
+unsigned long getMetaDataSize() {
+ return static_cast<unsigned long>(ROUND_UP_PAGESIZE(sizeof(MetaData_t)));
+}
+
+// Cannot add default argument to existing function
+unsigned long getMetaDataSizeWithReservedRegion(uint64_t reserved_size) {
+ return static_cast<unsigned long>(ROUND_UP_PAGESIZE(sizeof(MetaData_t) + reserved_size));
+}
+
+static int validateAndMap(private_handle_t* handle) {
+ if (private_handle_t::validate(handle)) {
+ ALOGE("%s: Private handle is invalid - handle:%p", __func__, handle);
+ return -1;
+ }
+ if (handle->fd_metadata < 0) {
+ // Metadata cannot be used
+ return -1;
+ }
+
+ if (!handle->base_metadata) {
+ auto size = getMetaDataSize();
+ void *base = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED,
+ handle->fd_metadata, 0);
+ if (base == reinterpret_cast<void*>(MAP_FAILED)) {
+ ALOGE("%s: metadata mmap failed - handle:%p fd: %d err: %s",
+ __func__, handle, handle->fd_metadata, strerror(errno));
+ return -1;
+ }
+ handle->base_metadata = (uintptr_t) base;
+ auto metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
+ if (metadata->reservedSize) {
+ auto reserved_size = metadata->reservedSize;
+ munmap(reinterpret_cast<void *>(handle->base_metadata), getMetaDataSize());
+ handle->base_metadata = 0;
+ size = getMetaDataSizeWithReservedRegion(reserved_size);
+ void *new_base =
+ mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd_metadata, 0);
+ if (new_base == reinterpret_cast<void *>(MAP_FAILED)) {
+ ALOGE("%s: metadata mmap failed - handle:%p fd: %d err: %s", __func__, handle,
+ handle->fd_metadata, strerror(errno));
+ return -1;
+ }
+ handle->base_metadata = (uintptr_t)new_base;
+ }
+ }
+ return 0;
+}
+
+static void unmapAndReset(private_handle_t *handle) {
+ if (private_handle_t::validate(handle) == 0 && handle->base_metadata) {
+ // If reservedSize is 0, the return value will be the same as getMetaDataSize
+ auto metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
+ auto size = getMetaDataSizeWithReservedRegion(metadata->reservedSize);
+ munmap(reinterpret_cast<void *>(handle->base_metadata), size);
+ handle->base_metadata = 0;
+ }
+}
+
+int setMetaData(private_handle_t *handle, DispParamType paramType,
+ void *param) {
+ auto err = validateAndMap(handle);
+ if (err != 0)
+ return err;
+ return setMetaDataVa(reinterpret_cast<MetaData_t*>(handle->base_metadata),
+ paramType, param);
+}
+
+int setMetaDataVa(MetaData_t *data, DispParamType paramType,
+ void *param) {
+ if (data == nullptr)
+ return -EINVAL;
+ // If parameter is NULL reset the specific MetaData Key
+ if (!param) {
+ setGralloc4Array(data, paramType, false);
+ switch (paramType) {
+ case SET_VIDEO_PERF_MODE:
+ data->isVideoPerfMode = 0;
+ break;
+ case SET_CVP_METADATA:
+ data->cvpMetadata.size = 0;
+ break;
+ case SET_VIDEO_HISTOGRAM_STATS:
+ data->video_histogram_stats.stat_len = 0;
+ break;
+ default:
+ ALOGE("Unknown paramType %d", paramType);
+ break;
+ }
+ // param unset
+ return 0;
+ }
+
+ setGralloc4Array(data, paramType, true);
+ switch (paramType) {
+ case PP_PARAM_INTERLACED:
+ data->interlaced = *((int32_t *)param);
+ break;
+ case UPDATE_BUFFER_GEOMETRY: {
+ BufferDim_t in = *((BufferDim_t *)param);
+ data->crop = {0, 0, in.sliceWidth, in.sliceHeight};
+ break;
+ }
+ case UPDATE_REFRESH_RATE:
+ data->refreshrate = *((float *)param);
+ break;
+ case UPDATE_COLOR_SPACE: {
+ ColorMetaData color = {};
+ if (!colorSpaceToColorMetadata(*((ColorSpace_t *)param), &color)) {
+ data->color = color;
+ break;
+ }
+ return -EINVAL;
+ }
+ case MAP_SECURE_BUFFER:
+ data->mapSecureBuffer = *((int32_t *)param);
+ break;
+ case S3D_FORMAT:
+ data->s3dFormat = *((uint32_t *)param);
+ break;
+ case LINEAR_FORMAT:
+ data->linearFormat = *((uint32_t *)param);
+ break;
+ case SET_SINGLE_BUFFER_MODE:
+ data->isSingleBufferMode = *((uint32_t *)param);
+ break;
+ case SET_VT_TIMESTAMP:
+ data->vtTimeStamp = *((uint64_t *)param);
+ break;
+ case COLOR_METADATA:
+ data->color = *((ColorMetaData *)param);
+ break;
+ case SET_UBWC_CR_STATS_INFO: {
+ struct UBWCStats *stats = (struct UBWCStats *)param;
+ int numelems = sizeof(data->ubwcCRStats) / sizeof(struct UBWCStats);
+ for (int i = 0; i < numelems; i++) {
+ data->ubwcCRStats[i] = stats[i];
+ }
+ break;
+ }
+ case SET_VIDEO_PERF_MODE:
+ data->isVideoPerfMode = *((uint32_t *)param);
+ break;
+ case SET_GRAPHICS_METADATA: {
+ GraphicsMetadata payload = *((GraphicsMetadata*)(param));
+ data->graphics_metadata.size = payload.size;
+ memcpy(data->graphics_metadata.data, payload.data,
+ sizeof(data->graphics_metadata.data));
+ break;
+ }
+ case SET_CVP_METADATA: {
+ struct CVPMetadata *cvpMetadata = (struct CVPMetadata *)param;
+ if (cvpMetadata->size <= CVP_METADATA_SIZE) {
+ data->cvpMetadata.size = cvpMetadata->size;
+ memcpy(data->cvpMetadata.payload, cvpMetadata->payload,
+ cvpMetadata->size);
+ data->cvpMetadata.capture_frame_rate = cvpMetadata->capture_frame_rate;
+ data->cvpMetadata.cvp_frame_rate = cvpMetadata->cvp_frame_rate;
+ data->cvpMetadata.flags = cvpMetadata->flags;
+ memcpy(data->cvpMetadata.reserved, cvpMetadata->reserved,
+ (8 * sizeof(uint32_t)));
+ } else {
+ setGralloc4Array(data, paramType, false);
+ ALOGE("%s: cvp metadata length %d is more than max size %d", __func__,
+ cvpMetadata->size, CVP_METADATA_SIZE);
+ return -EINVAL;
+ }
+ break;
+ }
+ case SET_VIDEO_HISTOGRAM_STATS: {
+ struct VideoHistogramMetadata *vidstats = (struct VideoHistogramMetadata *)param;
+ if (vidstats->stat_len <= VIDEO_HISTOGRAM_STATS_SIZE) {
+ memcpy(data->video_histogram_stats.stats_info,
+ vidstats->stats_info, VIDEO_HISTOGRAM_STATS_SIZE);
+ data->video_histogram_stats.stat_len = vidstats->stat_len;
+ data->video_histogram_stats.frame_type = vidstats->frame_type;
+ data->video_histogram_stats.display_width = vidstats->display_width;
+ data->video_histogram_stats.display_height = vidstats->display_height;
+ data->video_histogram_stats.decode_width = vidstats->decode_width;
+ data->video_histogram_stats.decode_height = vidstats->decode_height;
+ } else {
+ setGralloc4Array(data, paramType, false);
+ ALOGE("%s: video stats length %u is more than max size %u", __func__,
+ vidstats->stat_len, VIDEO_HISTOGRAM_STATS_SIZE);
+ return -EINVAL;
+ }
+ break;
+ }
+ default:
+ ALOGE("Unknown paramType %d", paramType);
+ break;
+ }
+ return 0;
+}
+
+int clearMetaData(private_handle_t *handle, DispParamType paramType) {
+ auto err = validateAndMap(handle);
+ if (err != 0)
+ return err;
+ return clearMetaDataVa(reinterpret_cast<MetaData_t *>(handle->base_metadata),
+ paramType);
+}
+
+int clearMetaDataVa(MetaData_t *data, DispParamType paramType) {
+ if (data == nullptr)
+ return -EINVAL;
+ data->operation &= ~paramType;
+ switch (paramType) {
+ case SET_VIDEO_PERF_MODE:
+ data->isVideoPerfMode = 0;
+ break;
+ case SET_CVP_METADATA:
+ data->cvpMetadata.size = 0;
+ break;
+ case SET_VIDEO_HISTOGRAM_STATS:
+ data->video_histogram_stats.stat_len = 0;
+ break;
+ default:
+ ALOGE("Unknown paramType %d", paramType);
+ break;
+ }
+ return 0;
+}
+
+int getMetaData(private_handle_t *handle, DispFetchParamType paramType,
+ void *param) {
+ int ret = validateAndMap(handle);
+ if (ret != 0)
+ return ret;
+ return getMetaDataVa(reinterpret_cast<MetaData_t *>(handle->base_metadata),
+ paramType, param);
+}
+
+int getMetaDataVa(MetaData_t *data, DispFetchParamType paramType,
+ void *param) {
+ // Make sure we send 0 only if the operation queried is present
+ int ret = -EINVAL;
+ if (data == nullptr)
+ return ret;
+ if (param == nullptr)
+ return ret;
+
+ if (!getGralloc4Array(data, paramType)) {
+ return ret;
+ }
+
+ ret = 0;
+
+ switch (paramType) {
+ case GET_PP_PARAM_INTERLACED:
+ *((int32_t *)param) = data->interlaced;
+ break;
+ case GET_BUFFER_GEOMETRY:
+ *((BufferDim_t *)param) = {data->crop.right, data->crop.bottom};
+ break;
+ case GET_REFRESH_RATE:
+ *((float *)param) = data->refreshrate;
+ break;
+ case GET_COLOR_SPACE: {
+ ColorSpace_t color_space;
+ if (!colorMetaDataToColorSpace(data->color, &color_space)) {
+ *((ColorSpace_t *)param) = color_space;
+ } else {
+ ret = -EINVAL;
+ }
+ break;
+ }
+ case GET_MAP_SECURE_BUFFER:
+ *((int32_t *)param) = data->mapSecureBuffer;
+ break;
+ case GET_S3D_FORMAT:
+ *((uint32_t *)param) = data->s3dFormat;
+ break;
+ case GET_LINEAR_FORMAT:
+ *((uint32_t *)param) = data->linearFormat;
+ break;
+ case GET_SINGLE_BUFFER_MODE:
+ *((uint32_t *)param) = data->isSingleBufferMode;
+ break;
+ case GET_VT_TIMESTAMP:
+ *((uint64_t *)param) = data->vtTimeStamp;
+ break;
+ case GET_COLOR_METADATA:
+ *((ColorMetaData *)param) = data->color;
+ break;
+ case GET_UBWC_CR_STATS_INFO: {
+ struct UBWCStats *stats = (struct UBWCStats *)param;
+ int numelems = sizeof(data->ubwcCRStats) / sizeof(struct UBWCStats);
+ for (int i = 0; i < numelems; i++) {
+ stats[i] = data->ubwcCRStats[i];
+ }
+ break;
+ }
+ case GET_VIDEO_PERF_MODE:
+ *((uint32_t *)param) = data->isVideoPerfMode;
+ break;
+ case GET_GRAPHICS_METADATA:
+ memcpy(param, data->graphics_metadata.data, sizeof(data->graphics_metadata.data));
+ break;
+ case GET_CVP_METADATA: {
+ struct CVPMetadata *cvpMetadata = (struct CVPMetadata *)param;
+ cvpMetadata->size = 0;
+ if (data->cvpMetadata.size <= CVP_METADATA_SIZE) {
+ cvpMetadata->size = data->cvpMetadata.size;
+ memcpy(cvpMetadata->payload, data->cvpMetadata.payload, data->cvpMetadata.size);
+ cvpMetadata->capture_frame_rate = data->cvpMetadata.capture_frame_rate;
+ cvpMetadata->cvp_frame_rate = data->cvpMetadata.cvp_frame_rate;
+ cvpMetadata->flags = data->cvpMetadata.flags;
+ memcpy(cvpMetadata->reserved, data->cvpMetadata.reserved, (8 * sizeof(uint32_t)));
+ } else {
+ ret = -EINVAL;
+ }
+ break;
+ }
+ case GET_VIDEO_HISTOGRAM_STATS: {
+ struct VideoHistogramMetadata *vidstats = (struct VideoHistogramMetadata *)param;
+ vidstats->stat_len = 0;
+ if (data->video_histogram_stats.stat_len <= VIDEO_HISTOGRAM_STATS_SIZE) {
+ memcpy(vidstats->stats_info, data->video_histogram_stats.stats_info,
+ VIDEO_HISTOGRAM_STATS_SIZE);
+ vidstats->stat_len = data->video_histogram_stats.stat_len;
+ vidstats->frame_type = data->video_histogram_stats.frame_type;
+ vidstats->display_width = data->video_histogram_stats.display_width;
+ vidstats->display_height = data->video_histogram_stats.display_height;
+ vidstats->decode_width = data->video_histogram_stats.decode_width;
+ vidstats->decode_height = data->video_histogram_stats.decode_height;
+ } else {
+ ret = -EINVAL;
+ }
+ break;
+ }
+ default:
+ ALOGE("Unknown paramType %d", paramType);
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+
+int copyMetaData(struct private_handle_t *src, struct private_handle_t *dst) {
+ auto err = validateAndMap(src);
+ if (err != 0)
+ return err;
+
+ err = validateAndMap(dst);
+ if (err != 0)
+ return err;
+
+ MetaData_t *src_data = reinterpret_cast <MetaData_t *>(src->base_metadata);
+ MetaData_t *dst_data = reinterpret_cast <MetaData_t *>(dst->base_metadata);
+ *dst_data = *src_data;
+ return 0;
+}
+
+int copyMetaDataVaToHandle(MetaData_t *src_data, struct private_handle_t *dst) {
+ int err = -EINVAL;
+ if (src_data == nullptr)
+ return err;
+
+ err = validateAndMap(dst);
+ if (err != 0)
+ return err;
+
+ MetaData_t *dst_data = reinterpret_cast <MetaData_t *>(dst->base_metadata);
+ *dst_data = *src_data;
+ return 0;
+}
+
+int copyMetaDataHandleToVa(struct private_handle_t *src, MetaData_t *dst_data) {
+ int err = -EINVAL;
+ if (dst_data == nullptr)
+ return err;
+
+ err = validateAndMap(src);
+ if (err != 0)
+ return err;
+
+ MetaData_t *src_data = reinterpret_cast <MetaData_t *>(src->base_metadata);
+ *dst_data = *src_data;
+ return 0;
+}
+
+int copyMetaDataVaToVa(MetaData_t *src_data, MetaData_t *dst_data) {
+ int err = -EINVAL;
+ if (src_data == nullptr)
+ return err;
+
+ if (dst_data == nullptr)
+ return err;
+
+ *dst_data = *src_data;
+ return 0;
+}
+
+int setMetaDataAndUnmap(struct private_handle_t *handle, enum DispParamType paramType,
+ void *param) {
+ auto ret = setMetaData(handle, paramType, param);
+ unmapAndReset(handle);
+ return ret;
+}
+
+int getMetaDataAndUnmap(struct private_handle_t *handle,
+ enum DispFetchParamType paramType,
+ void *param) {
+ auto ret = getMetaData(handle, paramType, param);
+ unmapAndReset(handle);
+ return ret;
+}
diff --git a/display-commonsys-intf/libqdmetadata/qdMetaData.h b/display-commonsys-intf/libqdmetadata/qdMetaData.h
new file mode 100644
index 00000000..a36d6e7b
--- /dev/null
+++ b/display-commonsys-intf/libqdmetadata/qdMetaData.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2012-2020, 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _QDMETADATA_H
+#define _QDMETADATA_H
+
+#include <QtiGrallocMetadata.h>
+#include <color_metadata.h>
+
+/* TODO: This conditional include is to prevent breaking video and camera test cases using
+ * MetaData_t - camxchinodedewarp.cpp, vtest_EncoderFileSource.cpp
+ */
+
+#ifdef __cplusplus
+#include <QtiGrallocPriv.h>
+#endif
+
+#ifndef __QTI_DISPLAY_GRALLOC__
+#pragma message "qdMetaData.h is being deprecated"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct MetaData_t;
+
+enum ColorSpace_t {
+ ITU_R_601,
+ ITU_R_601_FR,
+ ITU_R_709,
+ ITU_R_2020,
+ ITU_R_2020_FR,
+};
+
+struct BufferDim_t {
+ int32_t sliceWidth;
+ int32_t sliceHeight;
+};
+
+enum DispParamType {
+ SET_VT_TIMESTAMP = 0x0001,
+ COLOR_METADATA = 0x0002,
+ PP_PARAM_INTERLACED = 0x0004,
+ SET_VIDEO_PERF_MODE = 0x0008,
+ SET_GRAPHICS_METADATA = 0x0010,
+ SET_UNUSED = 0x0020,
+ SET_UBWC_CR_STATS_INFO = 0x0040,
+ UPDATE_BUFFER_GEOMETRY = 0x0080,
+ UPDATE_REFRESH_RATE = 0x0100,
+ UPDATE_COLOR_SPACE = 0x0200,
+ MAP_SECURE_BUFFER = 0x0400,
+ S3D_FORMAT = 0x0800,
+ LINEAR_FORMAT = 0x1000,
+ SET_IGC = 0x2000,
+ SET_SINGLE_BUFFER_MODE = 0x4000,
+ SET_S3D_COMP = 0x8000,
+ SET_CVP_METADATA = 0x00010000,
+ SET_VIDEO_HISTOGRAM_STATS = 0x00020000
+};
+
+enum DispFetchParamType {
+ GET_VT_TIMESTAMP = 0x0001,
+ GET_COLOR_METADATA = 0x0002,
+ GET_PP_PARAM_INTERLACED = 0x0004,
+ GET_VIDEO_PERF_MODE = 0x0008,
+ GET_GRAPHICS_METADATA = 0x0010,
+ GET_UNUSED = 0X0020,
+ GET_UBWC_CR_STATS_INFO = 0x0040,
+ GET_BUFFER_GEOMETRY = 0x0080,
+ GET_REFRESH_RATE = 0x0100,
+ GET_COLOR_SPACE = 0x0200,
+ GET_MAP_SECURE_BUFFER = 0x0400,
+ GET_S3D_FORMAT = 0x0800,
+ GET_LINEAR_FORMAT = 0x1000,
+ GET_IGC = 0x2000,
+ GET_SINGLE_BUFFER_MODE = 0x4000,
+ GET_S3D_COMP = 0x8000,
+ GET_CVP_METADATA = 0x00010000,
+ GET_VIDEO_HISTOGRAM_STATS = 0x00020000
+};
+
+/* Frame type bit mask */
+#define QD_SYNC_FRAME (0x1 << 0)
+
+struct private_handle_t;
+int setMetaData(struct private_handle_t *handle, enum DispParamType paramType,
+ void *param);
+int setMetaDataVa(struct MetaData_t* data, enum DispParamType paramType,
+ void *param);
+
+int getMetaData(struct private_handle_t *handle,
+ enum DispFetchParamType paramType,
+ void *param);
+int getMetaDataVa(struct MetaData_t* data, enum DispFetchParamType paramType,
+ void *param);
+
+int copyMetaData(struct private_handle_t *src, struct private_handle_t *dst);
+int copyMetaDataVaToHandle(struct MetaData_t *src, struct private_handle_t *dst);
+int copyMetaDataHandleToVa(struct private_handle_t* src, struct MetaData_t *dst);
+int copyMetaDataVaToVa(struct MetaData_t *src, struct MetaData_t *dst);
+
+int clearMetaData(struct private_handle_t *handle, enum DispParamType paramType);
+int clearMetaDataVa(struct MetaData_t *data, enum DispParamType paramType);
+
+unsigned long getMetaDataSize();
+
+// Map, access metadata and unmap. Used by clients that do not import/free but
+// clone and delete native_handle
+int setMetaDataAndUnmap(struct private_handle_t *handle, enum DispParamType paramType,
+ void *param);
+int getMetaDataAndUnmap(struct private_handle_t *handle,
+ enum DispFetchParamType paramType,
+ void *param);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _QDMETADATA_H */
+
diff --git a/display-commonsys-intf/libqdmetadata/qd_utils.cpp b/display-commonsys-intf/libqdmetadata/qd_utils.cpp
new file mode 100644
index 00000000..ac5d094b
--- /dev/null
+++ b/display-commonsys-intf/libqdmetadata/qd_utils.cpp
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2013, 2018, 2020 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <gralloc_priv.h>
+#include "qd_utils.h"
+
+static const int kFBNodeMax = 4;
+namespace qdutils {
+
+static int parseLine(char *input, char *tokens[], const uint32_t maxToken, uint32_t *count) {
+ char *tmpToken = NULL;
+ char *tmpPtr;
+ uint32_t index = 0;
+ const char *delim = ", =\n";
+ if (!input) {
+ return -1;
+ }
+ tmpToken = strtok_r(input, delim, &tmpPtr);
+ while (tmpToken && index < maxToken) {
+ tokens[index++] = tmpToken;
+ tmpToken = strtok_r(NULL, delim, &tmpPtr);
+ }
+ *count = index;
+
+ return 0;
+}
+
+static int getExternalNode(const char *type) {
+ FILE *displayDeviceFP = NULL;
+ char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
+ char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE];
+ int j = 0;
+
+ for(j = 0; j < kFBNodeMax; j++) {
+ snprintf (msmFbTypePath, sizeof(msmFbTypePath),
+ "/sys/devices/virtual/graphics/fb%d/msm_fb_type", j);
+ displayDeviceFP = fopen(msmFbTypePath, "r");
+ if(displayDeviceFP) {
+ fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE,
+ displayDeviceFP);
+ if(strncmp(fbType, type, strlen(type)) == 0) {
+ ALOGD("%s: %s is at fb%d", __func__, type, j);
+ fclose(displayDeviceFP);
+ break;
+ }
+ fclose(displayDeviceFP);
+ } else {
+ ALOGE("%s: Failed to open fb node %s", __func__, msmFbTypePath);
+ }
+ }
+
+ if (j < kFBNodeMax)
+ return j;
+ else
+ ALOGE("%s: Failed to find %s node", __func__, type);
+
+ return -1;
+}
+
+int getHDMINode(void) {
+ return getExternalNode("dtv panel");
+}
+
+int getEdidRawData(char *buffer)
+{
+ int size;
+ int edidFile;
+ char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE];
+ int node_id = getHDMINode();
+
+ if (node_id < 0) {
+ ALOGE("%s no HDMI node found", __func__);
+ return 0;
+ }
+
+ snprintf(msmFbTypePath, sizeof(msmFbTypePath),
+ "/sys/devices/virtual/graphics/fb%d/edid_raw_data", node_id);
+
+ edidFile = open(msmFbTypePath, O_RDONLY, 0);
+
+ if (edidFile < 0) {
+ ALOGE("%s no edid raw data found %s", __func__,msmFbTypePath);
+ return 0;
+ }
+
+ size = (int)read(edidFile, (char*)buffer, EDID_RAW_DATA_SIZE);
+ close(edidFile);
+ return size;
+}
+
+bool isDPConnected() {
+ char connectPath[MAX_FRAME_BUFFER_NAME_SIZE];
+ FILE *connectFile = NULL;
+ size_t len = MAX_STRING_LENGTH;
+ char stringBuffer[MAX_STRING_LENGTH];
+ char *line = stringBuffer;
+
+ int nodeId = getExternalNode("dp panel");
+ if (nodeId < 0) {
+ ALOGE("%s no DP node found", __func__);
+ return false;
+ }
+
+ snprintf(connectPath, sizeof(connectPath),
+ "/sys/devices/virtual/graphics/fb%d/connected", nodeId);
+
+ connectFile = fopen(connectPath, "rb");
+ if (!connectFile) {
+ ALOGW("Failed to open connect node for device node %s", connectPath);
+ return false;
+ }
+
+ if (getline(&line, &len, connectFile) < 0) {
+ fclose(connectFile);
+ return false;
+ }
+
+ fclose(connectFile);
+
+ return atoi(line);
+}
+
+int getDPTestConfig(uint32_t *panelBpp, uint32_t *patternType) {
+ if (!panelBpp || !patternType) {
+ return -1;
+ }
+
+ char configPath[MAX_FRAME_BUFFER_NAME_SIZE];
+ FILE *configFile = NULL;
+ uint32_t tokenCount = 0;
+ const uint32_t maxCount = 10;
+ char *tokens[maxCount] = { NULL };
+ size_t len = MAX_STRING_LENGTH;
+ char stringBuffer[MAX_STRING_LENGTH];
+ char *line = stringBuffer;
+
+ int nodeId = getExternalNode("dp panel");
+ if (nodeId < 0) {
+ ALOGE("%s no DP node found", __func__);
+ return -EINVAL;
+ }
+
+ snprintf(configPath, sizeof(configPath),
+ "/sys/devices/virtual/graphics/fb%d/config", nodeId);
+
+ configFile = fopen(configPath, "rb");
+ if (!configFile) {
+ ALOGW("Failed to open config node for device node %s", configPath);
+ return -EINVAL;
+ }
+
+ while (getline(&line, &len, configFile) != -1) {
+ if (!parseLine(line, tokens, maxCount, &tokenCount)) {
+ if (tokens[0] != NULL) {
+ if (!strncmp(tokens[0], "bpp", strlen("bpp"))) {
+ *panelBpp = static_cast<uint32_t>(atoi(tokens[1]));
+ } else if (!strncmp(tokens[0], "pattern", strlen("pattern"))) {
+ *patternType = static_cast<uint32_t>(atoi(tokens[1]));
+ }
+ }
+ }
+ }
+
+ fclose(configFile);
+
+ return 0;
+}
+
+DriverType getDriverType() {
+ const char *fb_caps = "/sys/devices/virtual/graphics/fb0/mdp/caps";
+ // 0 - File exists
+ return access(fb_caps, F_OK) ? DriverType::DRM : DriverType::FB;
+}
+
+const char *GetHALPixelFormatString(int format) {
+ switch (format) {
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ return "RGBA_8888";
+ case HAL_PIXEL_FORMAT_RGBX_8888:
+ return "RGBX_8888";
+ case HAL_PIXEL_FORMAT_RGB_888:
+ return "RGB_888";
+ case HAL_PIXEL_FORMAT_RGB_565:
+ return "RGB_565";
+ case HAL_PIXEL_FORMAT_BGR_565:
+ return "BGR_565";
+ case HAL_PIXEL_FORMAT_BGRA_8888:
+ return "BGRA_8888";
+ case HAL_PIXEL_FORMAT_RGBA_5551:
+ return "RGBA_5551";
+ case HAL_PIXEL_FORMAT_RGBA_4444:
+ return "RGBA_4444";
+ case HAL_PIXEL_FORMAT_YV12:
+ return "YV12";
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ return "YCbCr_422_SP_NV16";
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ return "YCrCb_420_SP_NV21";
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ return "YCbCr_422_I_YUY2";
+ case HAL_PIXEL_FORMAT_YCrCb_422_I:
+ return "YCrCb_422_I_YVYU";
+ case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
+ return "NV12_ENCODEABLE";
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
+ return "YCbCr_420_SP_TILED_TILE_4x2";
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP:
+ return "YCbCr_420_SP";
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
+ return "YCrCb_420_SP_ADRENO";
+ case HAL_PIXEL_FORMAT_YCrCb_422_SP:
+ return "YCrCb_422_SP";
+ case HAL_PIXEL_FORMAT_R_8:
+ return "R_8";
+ case HAL_PIXEL_FORMAT_RG_88:
+ return "RG_88";
+ case HAL_PIXEL_FORMAT_INTERLACE:
+ return "INTERLACE";
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
+ return "YCbCr_420_SP_VENUS";
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
+ return "YCrCb_420_SP_VENUS";
+ case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
+ return "YCbCr_420_SP_VENUS_UBWC";
+ case HAL_PIXEL_FORMAT_RGBA_1010102:
+ return "RGBA_1010102";
+ case HAL_PIXEL_FORMAT_ARGB_2101010:
+ return "ARGB_2101010";
+ case HAL_PIXEL_FORMAT_RGBX_1010102:
+ return "RGBX_1010102";
+ case HAL_PIXEL_FORMAT_XRGB_2101010:
+ return "XRGB_2101010";
+ case HAL_PIXEL_FORMAT_BGRA_1010102:
+ return "BGRA_1010102";
+ case HAL_PIXEL_FORMAT_ABGR_2101010:
+ return "ABGR_2101010";
+ case HAL_PIXEL_FORMAT_BGRX_1010102:
+ return "BGRX_1010102";
+ case HAL_PIXEL_FORMAT_XBGR_2101010:
+ return "XBGR_2101010";
+ case HAL_PIXEL_FORMAT_YCbCr_420_P010:
+ return "YCbCr_420_P010";
+ case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC:
+ return "YCbCr_420_TP10_UBWC";
+ case HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS:
+ return "YCbCr_420_P010_VENUS";
+ default:
+ return "Unknown_format";
+ }
+}
+
+}; //namespace qdutils
diff --git a/display-commonsys-intf/libqdmetadata/qd_utils.h b/display-commonsys-intf/libqdmetadata/qd_utils.h
new file mode 100644
index 00000000..0b0816a0
--- /dev/null
+++ b/display-commonsys-intf/libqdmetadata/qd_utils.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013, 2017, 2020 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
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation or the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _QD_UTIL_MISC_H
+#define _QD_UTIL_MISC_H
+
+#include <utils/threads.h>
+#include <linux/fb.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <utils/Errors.h>
+#include <log/log.h>
+
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+#include <sys/poll.h>
+#include <sys/resource.h>
+#include <cutils/properties.h>
+#include <hardware/hwcomposer.h>
+
+namespace qdutils {
+
+enum HWQueryType {
+ HAS_UBWC = 1,
+ HAS_WB_UBWC = 2
+};
+
+enum {
+ EDID_RAW_DATA_SIZE = 640,
+ MAX_FRAME_BUFFER_NAME_SIZE = 128,
+ MAX_SYSFS_FILE_PATH = 255,
+ MAX_STRING_LENGTH = 1024,
+};
+
+int getEdidRawData(char *buffer);
+int getHDMINode(void);
+bool isDPConnected();
+int getDPTestConfig(uint32_t *panelBpp, uint32_t *patternType);
+
+enum class DriverType {
+ FB = 0,
+ DRM,
+};
+DriverType getDriverType();
+const char *GetHALPixelFormatString(int format);
+
+}; //namespace qdutils
+#endif
diff --git a/display-commonsys-intf/services/config/client_interface.h b/display-commonsys-intf/services/config/client_interface.h
new file mode 100644
index 00000000..faf772a5
--- /dev/null
+++ b/display-commonsys-intf/services/config/client_interface.h
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __CLIENT_INTERFACE_H__
+#define __CLIENT_INTERFACE_H__
+
+#include "config_defs.h"
+
+namespace DisplayConfig {
+
+class ClientInterface : public ConfigInterface {
+ public:
+ static int Create(std::string client_name, ConfigCallback *callback,
+ ClientInterface **intf);
+ static void Destroy(ClientInterface *intf);
+
+ protected:
+ virtual ~ClientInterface() { }
+};
+
+} // namespace DisplayConfig
+
+#endif // __CLIENT_INTERFACE_H__
diff --git a/display-commonsys-intf/services/config/config_defs.h b/display-commonsys-intf/services/config/config_defs.h
new file mode 100644
index 00000000..f25013b0
--- /dev/null
+++ b/display-commonsys-intf/services/config/config_defs.h
@@ -0,0 +1,313 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __CONFIG_DEFS_H__
+#define __CONFIG_DEFS_H__
+
+#include <vector>
+#include <string>
+
+// #defines specifying the API level supported
+// Client can use these API level #ifdefs in their implementation to call the
+// corresponding DisplayConfig API independent of the underlying DisplayConfig
+// implementation being present. When this ifdef gets enabled in this header, the
+// client code will automatically get compiled.
+#define DISPLAY_CONFIG_API_LEVEL_0
+
+namespace DisplayConfig {
+
+// enum definitions
+enum class DisplayType : int {
+ kInvalid,
+ kPrimary,
+ kExternal,
+ kVirtual,
+ kBuiltIn2,
+};
+
+enum class ExternalStatus : int {
+ kInvalid,
+ kOffline,
+ kOnline,
+ kPause,
+ kResume,
+};
+
+enum class DynRefreshRateOp : int {
+ kInvalid,
+ kDisableMetadata,
+ kEnableMetadata,
+ kSetBinder,
+};
+
+enum class DisplayPortType : int {
+ kInvalid,
+ kDefault,
+ kDsi,
+ kDtv,
+ kWriteback,
+ kLvds,
+ kEdp,
+ kDp,
+};
+
+enum class PowerMode : int {
+ kOff,
+ kDoze,
+ kOn,
+ kDozeSuspend,
+};
+
+enum class QsyncMode : int {
+ kNone,
+ kWaitForFencesOneFrame,
+ kWaitForFencesEachFrame,
+ kWaitForCommitEachFrame,
+};
+
+enum class TUIEventType : int {
+ kNone,
+ kPrepareTUITransition,
+ kStartTUITransition,
+ kEndTUITransition,
+};
+
+// Input and Output Params structures
+struct Attributes {
+ uint32_t vsync_period = 0;
+ uint32_t x_res = 0;
+ uint32_t y_res = 0;
+ float x_dpi = 0;
+ float y_dpi = 0;
+ DisplayPortType panel_type = DisplayPortType::kDefault;
+ bool is_yuv = 0;
+};
+
+struct HDRCapsParams {
+ std::vector<int> supported_hdr_types = {};
+ float max_luminance = 0;
+ float max_avg_luminance = 0;
+ float min_luminance = 0;
+};
+
+struct StatusParams {
+ DisplayType dpy = DisplayType::kInvalid;
+ ExternalStatus status = ExternalStatus::kInvalid;
+};
+
+struct DynRefreshRateParams {
+ DynRefreshRateOp op = DynRefreshRateOp::kInvalid;
+ uint32_t refresh_rate = 0;
+};
+
+struct ConfigParams {
+ DisplayType dpy = DisplayType::kInvalid;
+ uint32_t config = 0;
+};
+
+struct AttributesParams {
+ uint32_t config_index = 0;
+ DisplayType dpy = DisplayType::kInvalid;
+};
+
+struct MinHdcpEncLevelChangedParams {
+ DisplayType dpy = DisplayType::kInvalid;
+ uint32_t min_enc_level = 0;
+};
+
+struct PartialUpdateParams {
+ DisplayType dpy = DisplayType::kInvalid;
+ bool enable = 0;
+};
+
+struct AnimationParams {
+ uint64_t display_id = 0;
+ bool animating = 0;
+};
+
+struct IdlePcParams {
+ bool enable = 0;
+ bool synchronous = 0;
+};
+
+struct DppsAdRoiParams {
+ uint32_t display_id = 0;
+ uint32_t h_start = 0;
+ uint32_t h_end = 0;
+ uint32_t v_start = 0;
+ uint32_t v_end = 0;
+ uint32_t factor_in = 0;
+ uint32_t factor_out = 0;
+};
+
+struct PowerModeParams {
+ uint32_t disp_id = 0;
+ PowerMode power_mode = PowerMode::kOff;
+};
+
+struct LayerMaskParams {
+ uint32_t disp_id = 0;
+ uint64_t layer_id = 0;
+};
+
+struct PanelLumAttrParams {
+ uint32_t disp_id = 0;
+ float min_lum = 0;
+ float max_lum = 0;
+};
+
+struct Rect {
+ uint32_t left = 0;
+ uint32_t top = 0;
+ uint32_t right = 0;
+ uint32_t bottom = 0;
+};
+
+struct CwbBufferParams {
+ uint32_t disp_id = 0;
+ Rect rect;
+ bool post_processed = 0;
+};
+
+struct DsiClkParams {
+ uint32_t disp_id = 0;
+ uint64_t bit_clk = 0;
+};
+
+struct QsyncModeParams {
+ uint32_t disp_id = 0;
+ QsyncMode mode = QsyncMode::kNone;
+};
+
+struct SmartPanelCfgParams {
+ uint32_t disp_id = 0;
+ uint32_t config_id = 0;
+};
+
+struct VdsParams {
+ uint32_t width = 0;
+ uint32_t height = 0;
+ int format = 0;
+};
+
+struct RotatorFormatParams {
+ int hal_format = 0;
+ bool ubwc = 0;
+};
+
+struct QsyncCallbackParams {
+ bool qsync_enabled = 0;
+ int refresh_rate = 0;
+ int qsync_refresh_rate = 0;
+};
+
+struct TUIEventParams {
+ DisplayType dpy = DisplayType::kInvalid;
+ TUIEventType tui_event_type = TUIEventType::kNone;
+};
+
+/* Callback Interface */
+class ConfigCallback {
+ public:
+ virtual void NotifyCWBBufferDone(int error, const native_handle_t *buffer) { }
+ virtual void NotifyQsyncChange(bool qsync_enabled, int refresh_rate, int qsync_refresh_rate) { }
+
+ protected:
+ virtual ~ConfigCallback() { }
+};
+
+#define DEFAULT_RET { return -EINVAL; }
+
+/* Config Interface */
+class ConfigInterface {
+ public:
+ virtual int IsDisplayConnected(DisplayType dpy, bool *connected) DEFAULT_RET
+ virtual int SetDisplayStatus(DisplayType dpy, ExternalStatus status) DEFAULT_RET
+ virtual int ConfigureDynRefreshRate(DynRefreshRateOp op, uint32_t refresh_rate) DEFAULT_RET
+ virtual int GetConfigCount(DisplayType dpy, uint32_t *count) DEFAULT_RET
+ virtual int GetActiveConfig(DisplayType dpy, uint32_t *config) DEFAULT_RET
+ virtual int SetActiveConfig(DisplayType dpy, uint32_t config) DEFAULT_RET
+ virtual int GetDisplayAttributes(uint32_t config_index, DisplayType dpy,
+ Attributes *attributes) DEFAULT_RET
+ virtual int SetPanelBrightness(uint32_t level) DEFAULT_RET
+ virtual int GetPanelBrightness(uint32_t *level) DEFAULT_RET
+ virtual int MinHdcpEncryptionLevelChanged(DisplayType dpy, uint32_t min_enc_level) DEFAULT_RET
+ virtual int RefreshScreen() DEFAULT_RET
+ virtual int ControlPartialUpdate(DisplayType dpy, bool enable) DEFAULT_RET
+ virtual int ToggleScreenUpdate(bool on) DEFAULT_RET
+ virtual int SetIdleTimeout(uint32_t value) DEFAULT_RET
+ virtual int GetHDRCapabilities(DisplayType dpy, HDRCapsParams *caps) DEFAULT_RET
+ virtual int SetCameraLaunchStatus(uint32_t on) DEFAULT_RET
+ virtual int DisplayBWTransactionPending(bool *status) DEFAULT_RET
+ virtual int SetDisplayAnimating(uint64_t display_id, bool animating) DEFAULT_RET
+ virtual int ControlIdlePowerCollapse(bool enable, bool synchronous) DEFAULT_RET
+ virtual int GetWriteBackCapabilities(bool *is_wb_ubwc_supported) DEFAULT_RET
+ virtual int SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start, uint32_t h_end,
+ uint32_t v_start, uint32_t v_end, uint32_t factor_in,
+ uint32_t factor_out) DEFAULT_RET
+ virtual int UpdateVSyncSourceOnPowerModeOff() DEFAULT_RET
+ virtual int UpdateVSyncSourceOnPowerModeDoze() DEFAULT_RET
+ virtual int SetPowerMode(uint32_t disp_id, PowerMode power_mode) DEFAULT_RET
+ virtual int IsPowerModeOverrideSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
+ virtual int IsHDRSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
+ virtual int IsWCGSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
+ virtual int SetLayerAsMask(uint32_t disp_id, uint64_t layer_id) DEFAULT_RET
+ virtual int GetDebugProperty(const std::string prop_name, std::string *value) DEFAULT_RET
+ virtual int GetActiveBuiltinDisplayAttributes(Attributes *attr) DEFAULT_RET
+ virtual int SetPanelLuminanceAttributes(uint32_t disp_id, float min_lum,
+ float max_lum) DEFAULT_RET
+ virtual int IsBuiltInDisplay(uint32_t disp_id, bool *is_builtin) DEFAULT_RET
+ virtual int IsAsyncVDSCreationSupported(bool *supported) DEFAULT_RET
+ virtual int CreateVirtualDisplay(uint32_t width, uint32_t height, int format) DEFAULT_RET
+ virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> *bit_clks) DEFAULT_RET
+ virtual int GetDSIClk(uint32_t disp_id, uint64_t *bit_clk) DEFAULT_RET
+ virtual int SetDSIClk(uint32_t disp_id, uint64_t bit_clk) DEFAULT_RET
+ virtual int SetCWBOutputBuffer(uint32_t disp_id, const Rect rect, bool post_processed,
+ const native_handle_t *buffer) DEFAULT_RET
+ virtual int SetQsyncMode(uint32_t disp_id, QsyncMode mode) DEFAULT_RET
+ 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
+ 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
+ virtual int IsRCSupported(uint32_t disp_id, bool *supported) DEFAULT_RET
+
+ // deprecated APIs
+ virtual int GetDebugProperty(const std::string prop_name, std::string value) DEFAULT_RET
+ virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> bit_clks) DEFAULT_RET
+
+ protected:
+ virtual ~ConfigInterface() { }
+};
+
+} // namespace DisplayConfig
+
+#endif // __CONFIG_DEFS_H__
diff --git a/display-commonsys-intf/services/config/device_interface.h b/display-commonsys-intf/services/config/device_interface.h
new file mode 100644
index 00000000..7d859102
--- /dev/null
+++ b/display-commonsys-intf/services/config/device_interface.h
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __DEVICE_INTERFACE_H__
+#define __DEVICE_INTERFACE_H__
+
+#include "config_defs.h"
+
+namespace DisplayConfig {
+
+class ClientContext {
+ public:
+ virtual int RegisterClientContext(std::shared_ptr<ConfigCallback> callback,
+ ConfigInterface **intf) { return -EINVAL; }
+ virtual void UnRegisterClientContext(ConfigInterface *intf) { }
+
+ protected:
+ virtual ~ClientContext() { }
+};
+
+class DeviceInterface {
+ public:
+ static int RegisterDevice(ClientContext *intf);
+
+ protected:
+ virtual ~DeviceInterface() { }
+};
+
+} // namespace DisplayConfig
+
+#endif // __DEVICE_INTERFACE_H__
diff --git a/display-commonsys-intf/services/config/src/Android.bp b/display-commonsys-intf/services/config/src/Android.bp
new file mode 100644
index 00000000..27df5b86
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/Android.bp
@@ -0,0 +1,24 @@
+cc_library_shared {
+ name: "libdisplayconfig.qti",
+ vendor_available: true,
+ system_ext_specific: true,
+ cflags: [
+ "-Wno-sign-conversion",
+ "-Wno-unused-parameter",
+ "-DLOG_TAG=\"libdisplayconfigqti\"",
+ ],
+ shared_libs: [
+ "libhidlbase",
+ "libutils",
+ "vendor.display.config@2.0"
+ ],
+ header_libs: ["libhardware_headers", "display_intf_headers"],
+ srcs: [
+ "client_interface.cpp",
+ "client_impl.cpp",
+ "device_impl.cpp",
+ "device_interface.cpp",
+ ],
+ export_header_lib_headers: ["display_intf_headers"],
+}
+
diff --git a/display-commonsys-intf/services/config/src/client_impl.cpp b/display-commonsys-intf/services/config/src/client_impl.cpp
new file mode 100644
index 00000000..e6bc6129
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/client_impl.cpp
@@ -0,0 +1,959 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <string>
+#include <vector>
+
+#include "client_impl.h"
+
+namespace DisplayConfig {
+
+int ClientImpl::Init(std::string client_name, ConfigCallback *callback) {
+ display_config_ = IDisplayConfig::getService();
+ // Unable to find Display Config 2.0 service. Fail Init.
+ if (!display_config_) {
+ return -1;
+ }
+ int32_t error = 0;
+ uint64_t handle = 0;
+ auto hidl_callback = [&error, &handle] (int32_t err, uint64_t client_handle) {
+ error = err;
+ handle = client_handle;
+ };
+ int pid = getpid();
+ android::sp<ClientCallback> client_cb(new ClientCallback(callback));
+ display_config_->registerClient(client_name + std::to_string(pid), client_cb,
+ hidl_callback);
+ client_handle_ = handle;
+
+ return 0;
+}
+
+void ClientImpl::DeInit() {
+ int32_t error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kDestroy, {}, {}, hidl_cb);
+ display_config_.clear();
+ display_config_ = nullptr;
+}
+
+int ClientImpl::IsDisplayConnected(DisplayType dpy, bool *connected) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&dpy), sizeof(DisplayType));
+ const bool *output;
+ 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_, kIsDisplayConnected, input_params, {}, hidl_cb);
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *connected = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetDisplayStatus(DisplayType dpy, ExternalStatus status) {
+ struct StatusParams input = {dpy, status};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct StatusParams));
+ int error = 0;
+
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetDisplayStatus, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::ConfigureDynRefreshRate(DynRefreshRateOp op, uint32_t refresh_rate) {
+ struct DynRefreshRateParams input = {op, refresh_rate};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input),
+ sizeof(struct DynRefreshRateParams));
+ int error = 0;
+
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kConfigureDynRefreshRate, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::GetConfigCount(DisplayType dpy, uint32_t *count) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&dpy), sizeof(DisplayType));
+ const uint32_t *output;
+ 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_, kGetConfigCount, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const uint32_t*>(data);
+ *count = *output;
+
+ return error;
+}
+
+int ClientImpl::GetActiveConfig(DisplayType dpy, uint32_t *config) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&dpy), sizeof(DisplayType));
+ const uint32_t *output;
+ 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_, kGetActiveConfig, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const uint32_t*>(data);
+ *config = *output;
+
+ return error;
+}
+
+int ClientImpl::SetActiveConfig(DisplayType dpy, uint32_t config) {
+ struct ConfigParams input = {dpy, config};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct ConfigParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetActiveConfig, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::GetDisplayAttributes(uint32_t config_index, DisplayType dpy,
+ Attributes *attributes) {
+ struct AttributesParams input = {config_index, dpy};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct AttributesParams));
+ const struct Attributes *output;
+ 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_, kGetDisplayAttributes, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const Attributes*>(data);
+ if (!error) {
+ *attributes = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetPanelBrightness(uint32_t level) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&level), sizeof(uint32_t));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetPanelBrightness, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::GetPanelBrightness(uint32_t *level) {
+ const uint32_t *output;
+ 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_, kGetPanelBrightness, {}, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const uint32_t*>(data);
+ if (!error) {
+ *level = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::MinHdcpEncryptionLevelChanged(DisplayType dpy, uint32_t min_enc_level) {
+ struct MinHdcpEncLevelChangedParams input = {dpy, min_enc_level};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input),
+ sizeof(struct MinHdcpEncLevelChangedParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kMinHdcpEncryptionLevelChanged,
+ input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::RefreshScreen() {
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kRefreshScreen, {}, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::ControlPartialUpdate(DisplayType dpy, bool enable) {
+ struct PartialUpdateParams input = {dpy, enable};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input),
+ sizeof(struct PartialUpdateParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kControlPartialUpdate, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::ToggleScreenUpdate(bool on) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&on), sizeof(bool));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kToggleScreenUpdate, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::SetIdleTimeout(uint32_t value) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&value), sizeof(uint32_t));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetIdleTimeout, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::GetHDRCapabilities(DisplayType dpy, HDRCapsParams *caps) {
+ 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_, kGetHdrCapabilities, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+
+ if (!error) {
+ const int32_t *hdr_caps;
+ const float *lum;
+ size_t size = output_params.size();
+ size_t hdr_caps_size = size - 3 * sizeof(float);
+ hdr_caps_size /= sizeof(int32_t);
+ hdr_caps = reinterpret_cast<const int32_t*>(data);
+ for (size_t i = 0; i < hdr_caps_size; i++) {
+ caps->supported_hdr_types.push_back(*hdr_caps);
+ hdr_caps++;
+ }
+ lum = reinterpret_cast<const float *>(hdr_caps);
+ caps->max_luminance = lum[0];
+ caps->max_avg_luminance = lum[1];
+ caps->min_luminance = lum[2];
+ }
+
+ return error;
+}
+
+int ClientImpl::SetCameraLaunchStatus(uint32_t on) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&on), sizeof(uint32_t));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetCameraLaunchStatus, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::DisplayBWTransactionPending(bool *status) {
+ const bool *output;
+ 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_, kDisplayBwTransactionPending, {}, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+ if (!error) {
+ *status = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetDisplayAnimating(uint64_t display_id, bool animating) {
+ struct AnimationParams input = {display_id, animating};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct AnimationParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetDisplayAnimating, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::ControlIdlePowerCollapse(bool enable, bool synchronous) {
+ struct IdlePcParams input = {enable, synchronous};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct IdlePcParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kControlIdlePowerCollapse, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::GetWriteBackCapabilities(bool *is_wb_ubwc_supported) {
+ const bool *output;
+ 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_, kGetWritebackCapabilities, {}, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+ if (!error) {
+ *is_wb_ubwc_supported = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start,
+ uint32_t h_end, uint32_t v_start, uint32_t v_end,
+ uint32_t factor_in, uint32_t factor_out) {
+ struct DppsAdRoiParams input = {display_id, h_start, h_end, v_start, v_end,
+ factor_in, factor_out};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct DppsAdRoiParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetDisplayDppsAdRoi, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::UpdateVSyncSourceOnPowerModeOff() {
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kUpdateVsyncSourceOnPowerModeOff, {}, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::UpdateVSyncSourceOnPowerModeDoze() {
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kUpdateVsyncSourceOnPowerModeDoze, {}, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::SetPowerMode(uint32_t disp_id, PowerMode power_mode) {
+ struct PowerModeParams input = {disp_id, power_mode};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct PowerModeParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetPowerMode, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::IsPowerModeOverrideSupported(uint32_t disp_id, bool *supported) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_id), sizeof(uint32_t));
+ const bool *output;
+ 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_, kIsPowerModeOverrideSupported,
+ input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *supported = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::IsHDRSupported(uint32_t disp_id, bool *supported) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_id), sizeof(uint32_t));
+ const bool *output;
+ 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_, kIsHdrSupported, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *supported = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::IsWCGSupported(uint32_t disp_id, bool *supported) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_id), sizeof(int32_t));
+ const bool *output;
+ 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_, kIsWcgSupported, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *supported = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetLayerAsMask(uint32_t disp_id, uint64_t layer_id) {
+ struct LayerMaskParams input = {disp_id, layer_id};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct LayerMaskParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetLayerAsMask, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::GetDebugProperty(const std::string prop_name, std::string *value) {
+ ByteStream input_params;
+ std::string prop(prop_name);
+ prop += '\0';
+ uint8_t *data_input = reinterpret_cast<uint8_t*>(const_cast<char*>(prop.data()));
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(data_input),
+ prop.size() * sizeof(char));
+ 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_, kGetDebugProperty, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ const char *name = reinterpret_cast<const char *>(data);
+ if (!error) {
+ std::string output(name);
+ *value = output;
+ }
+
+ return error;
+}
+
+int ClientImpl::GetActiveBuiltinDisplayAttributes(Attributes *attr) {
+ const struct Attributes *output;
+ 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_, kGetActiveBuiltinDisplayAttributes, {}, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const Attributes*>(data);
+ if (!error) {
+ *attr = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetPanelLuminanceAttributes(uint32_t disp_id, float min_lum, float max_lum) {
+ struct PanelLumAttrParams input = {disp_id, min_lum, max_lum};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct PanelLumAttrParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetPanelLuminanceAttributes, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::IsBuiltInDisplay(uint32_t disp_id, bool *is_builtin) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_id), sizeof(uint32_t));
+ const bool *output;
+ 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_, kIsBuiltinDisplay, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *is_builtin = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetCWBOutputBuffer(uint32_t disp_id, const Rect rect, bool post_processed,
+ const native_handle_t *buffer) {
+ struct CwbBufferParams input = {disp_id, rect, post_processed};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct CwbBufferParams));
+
+ hidl_handle handle = buffer;
+ std::vector<hidl_handle> handle_vector;
+ handle_vector.push_back(buffer);
+ HandleStream input_handles = handle_vector;
+
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetCwbOutputBuffer, input_params,
+ input_handles, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> *bit_clks) {
+ 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_, kGetSupportedDsiBitclks, input_params, {}, hidl_cb);
+
+ if (!error) {
+ const uint8_t *data = output_params.data();
+ const uint64_t *bit_clks_data = reinterpret_cast<const uint64_t *>(data);
+ int num_bit_clks = static_cast<int>(output_params.size() / sizeof(uint64_t));
+ for (int i = 0; i < num_bit_clks; i++) {
+ bit_clks->push_back(bit_clks_data[i]);
+ }
+ }
+
+ return error;
+}
+
+int ClientImpl::GetDSIClk(uint32_t disp_id, uint64_t *bit_clk) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_id), sizeof(uint32_t));
+ const uint64_t *output;
+ 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_, kGetDsiClk, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const uint64_t*>(data);
+
+ if (!error) {
+ *bit_clk = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::SetDSIClk(uint32_t disp_id, uint64_t bit_clk) {
+ struct DsiClkParams input = {disp_id, bit_clk};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct DsiClkParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetDsiClk, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::SetQsyncMode(uint32_t disp_id, QsyncMode mode) {
+ struct QsyncModeParams input = {disp_id, mode};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct QsyncModeParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kSetQsyncMode, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::IsSmartPanelConfig(uint32_t disp_id, uint32_t config_id, bool *is_smart) {
+ struct SmartPanelCfgParams input = {disp_id, config_id};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input),
+ sizeof(struct SmartPanelCfgParams));
+ const bool *output;
+ 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_, kIsSmartPanelConfig, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *is_smart = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::IsAsyncVDSCreationSupported(bool *supported) {
+ const bool *output;
+ 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_, kIsAsyncVdsSupported, {}, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *supported = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::CreateVirtualDisplay(uint32_t width, uint32_t height, int32_t format) {
+ struct VdsParams input = {width, height, format};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input), sizeof(struct VdsParams));
+ int error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kCreateVirtualDisplay, input_params, {}, hidl_cb);
+
+ return error;
+}
+
+int ClientImpl::IsRotatorSupportedFormat(int hal_format, bool ubwc, bool *supported) {
+ struct RotatorFormatParams input = {hal_format, ubwc};
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&input),
+ sizeof(struct RotatorFormatParams));
+ const bool *output;
+ 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_, kIsRotatorSupportedFormat, input_params, {}, hidl_cb);
+
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+
+ if (!error) {
+ *supported = *output;
+ }
+
+ return error;
+}
+
+int ClientImpl::ControlQsyncCallback(bool enable) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&enable), sizeof(bool));
+ int32_t error = 0;
+ auto hidl_cb = [&error] (int32_t err, ByteStream params, HandleStream handles) {
+ error = err;
+ };
+
+ display_config_->perform(client_handle_, kControlQsyncCallback, input_params, {}, hidl_cb);
+
+ 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;
+}
+
+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;
+}
+
+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;
+}
+
+int ClientImpl::IsRCSupported(uint32_t disp_id, bool *supported) {
+ ByteStream input_params;
+ input_params.setToExternal(reinterpret_cast<uint8_t*>(&disp_id), sizeof(uint32_t));
+ const bool *output;
+ 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_, kIsRCSupported, input_params, {}, hidl_cb);
+
+ if (!error) {
+ const uint8_t *data = output_params.data();
+ output = reinterpret_cast<const bool*>(data);
+ *supported = *output;
+ }
+
+ return error;
+}
+
+void ClientCallback::ParseNotifyCWBBufferDone(const ByteStream &input_params,
+ const HandleStream &input_handles) {
+ const int *error;
+
+ if (callback_ == nullptr || input_params.size() == 0 || input_handles.size() == 0) {
+ return;
+ }
+
+ const uint8_t *data = input_params.data();
+ error = reinterpret_cast<const int*>(data);
+ hidl_handle buffer = input_handles[0];
+ callback_->NotifyCWBBufferDone(*error, buffer.getNativeHandle());
+}
+
+void ClientCallback::ParseNotifyQsyncChange(const ByteStream &input_params) {
+ const struct QsyncCallbackParams *qsync_data;
+
+ if (callback_ == nullptr || input_params.size() == 0) {
+ return;
+ }
+
+ const uint8_t *data = input_params.data();
+ qsync_data = reinterpret_cast<const QsyncCallbackParams*>(data);
+ callback_->NotifyQsyncChange(qsync_data->qsync_enabled, qsync_data->refresh_rate,
+ qsync_data->qsync_refresh_rate);
+}
+
+Return<void> ClientCallback::perform(uint32_t op_code, const ByteStream &input_params,
+ const HandleStream &input_handles) {
+ switch (op_code) {
+ case kSetCwbOutputBuffer:
+ ParseNotifyCWBBufferDone(input_params, input_handles);
+ break;
+ case kControlQsyncCallback:
+ ParseNotifyQsyncChange(input_params);
+ break;
+ default:
+ break;
+ }
+
+ return Void();
+}
+
+} // namespace DisplayConfig
diff --git a/display-commonsys-intf/services/config/src/client_impl.h b/display-commonsys-intf/services/config/src/client_impl.h
new file mode 100644
index 00000000..b944bb13
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/client_impl.h
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __CLIENT_IMPL_H__
+#define __CLIENT_IMPL_H__
+
+#include <vendor/display/config/2.0/IDisplayConfig.h>
+#include <hidl/HidlSupport.h>
+#include <config/client_interface.h>
+#include <string>
+#include <vector>
+
+#include "opcode_types.h"
+
+namespace DisplayConfig {
+
+using vendor::display::config::V2_0::IDisplayConfig;
+using vendor::display::config::V2_0::IDisplayConfigCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_vec;
+
+typedef hidl_vec<uint8_t> ByteStream;
+typedef hidl_vec<hidl_handle> HandleStream;
+
+class ClientCallback: public IDisplayConfigCallback {
+ public:
+ ClientCallback(ConfigCallback *cb) {
+ callback_ = cb;
+ }
+
+ private:
+ virtual Return<void> perform(uint32_t op_code, const ByteStream &input_params,
+ const HandleStream &input_handles);
+ void ParseNotifyCWBBufferDone(const ByteStream &input_params, const HandleStream &input_handles);
+ void ParseNotifyQsyncChange(const ByteStream &input_params);
+ ConfigCallback *callback_ = nullptr;
+};
+
+class ClientImpl : public ClientInterface {
+ public:
+ int Init(std::string client_name, ConfigCallback *callback);
+ void DeInit();
+
+ virtual int IsDisplayConnected(DisplayType dpy, bool *connected);
+ virtual int SetDisplayStatus(DisplayType dpy, ExternalStatus status);
+ virtual int ConfigureDynRefreshRate(DynRefreshRateOp op, uint32_t refresh_rate);
+ virtual int GetConfigCount(DisplayType dpy, uint32_t *count);
+ virtual int GetActiveConfig(DisplayType dpy, uint32_t *config);
+ virtual int SetActiveConfig(DisplayType dpy, uint32_t config);
+ virtual int GetDisplayAttributes(uint32_t config_index, DisplayType dpy, Attributes *attributes);
+ virtual int SetPanelBrightness(uint32_t level);
+ virtual int GetPanelBrightness(uint32_t *level);
+ virtual int MinHdcpEncryptionLevelChanged(DisplayType dpy, uint32_t min_enc_level);
+ virtual int RefreshScreen();
+ virtual int ControlPartialUpdate(DisplayType dpy, bool enable);
+ virtual int ToggleScreenUpdate(bool on);
+ virtual int SetIdleTimeout(uint32_t value);
+ virtual int GetHDRCapabilities(DisplayType dpy, HDRCapsParams *caps);
+ virtual int SetCameraLaunchStatus(uint32_t on);
+ virtual int DisplayBWTransactionPending(bool *status);
+ virtual int SetDisplayAnimating(uint64_t display_id, bool animating);
+ virtual int ControlIdlePowerCollapse(bool enable, bool synchronous);
+ virtual int GetWriteBackCapabilities(bool *is_wb_ubwc_supported);
+ virtual int SetDisplayDppsAdROI(uint32_t display_id, uint32_t h_start, uint32_t h_end,
+ uint32_t v_start, uint32_t v_end, uint32_t factor_in,
+ uint32_t factor_out);
+ virtual int UpdateVSyncSourceOnPowerModeOff();
+ virtual int UpdateVSyncSourceOnPowerModeDoze();
+ virtual int SetPowerMode(uint32_t disp_id, PowerMode power_mode);
+ virtual int IsPowerModeOverrideSupported(uint32_t disp_id, bool *supported);
+ virtual int IsHDRSupported(uint32_t disp_id, bool *supported);
+ virtual int IsWCGSupported(uint32_t disp_id, bool *supported);
+ virtual int SetLayerAsMask(uint32_t disp_id, uint64_t layer_id);
+ virtual int GetDebugProperty(const std::string prop_name, std::string *value);
+ virtual int GetActiveBuiltinDisplayAttributes(Attributes *attr);
+ virtual int SetPanelLuminanceAttributes(uint32_t disp_id, float min_lum, float max_lum);
+ virtual int IsBuiltInDisplay(uint32_t disp_id, bool *is_builtin);
+ virtual int IsAsyncVDSCreationSupported(bool *supported);
+ virtual int CreateVirtualDisplay(uint32_t width, uint32_t height, int format);
+ virtual int GetSupportedDSIBitClks(uint32_t disp_id, std::vector<uint64_t> *bit_clks);
+ virtual int GetDSIClk(uint32_t disp_id, uint64_t *bit_clk);
+ virtual int SetDSIClk(uint32_t disp_id, uint64_t bit_clk);
+ virtual int SetCWBOutputBuffer(uint32_t disp_id, const Rect rect, bool post_processed,
+ const native_handle_t *buffer);
+ virtual int SetQsyncMode(uint32_t disp_id, QsyncMode mode);
+ 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);
+ virtual int GetDisplayHwId(uint32_t disp_id, uint32_t *display_hw_id);
+ virtual int GetSupportedDisplayRefreshRates(DisplayType dpy,
+ std::vector<uint32_t> *supported_refresh_rates);
+ virtual int IsRCSupported(uint32_t disp_id, bool *supported);
+
+ private:
+ android::sp<IDisplayConfig> display_config_ = nullptr;
+ uint64_t client_handle_ = 0;
+};
+
+} // namespace DisplayConfig
+
+#endif // __CLIENT_IMPL_H__
diff --git a/display-commonsys-intf/services/config/src/client_interface.cpp b/display-commonsys-intf/services/config/src/client_interface.cpp
new file mode 100644
index 00000000..9c9ecd2b
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/client_interface.cpp
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <string>
+
+#include "client_impl.h"
+
+namespace DisplayConfig {
+
+int ClientInterface::Create(std::string client_name, ConfigCallback *callback,
+ ClientInterface **intf) {
+ if (!intf) {
+ return -1;
+ }
+
+ ClientImpl *impl = new ClientImpl();
+ if (!impl) {
+ return -1;
+ }
+
+ int ret = impl->Init(client_name, callback);
+ if (ret) {
+ delete impl;
+ return -1;
+ }
+
+ *intf = impl;
+ return 0;
+}
+
+void ClientInterface::Destroy(ClientInterface *intf) {
+ if (intf) {
+ ClientImpl *impl = static_cast<ClientImpl *>(intf);
+ impl->DeInit();
+ delete impl;
+ }
+}
+
+} // namespace DisplayConfig
diff --git a/display-commonsys-intf/services/config/src/device_impl.cpp b/display-commonsys-intf/services/config/src/device_impl.cpp
new file mode 100644
index 00000000..b097006f
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/device_impl.cpp
@@ -0,0 +1,945 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <string>
+#include <vector>
+
+#include "device_impl.h"
+
+namespace DisplayConfig {
+
+DeviceImpl *DeviceImpl::device_obj_ = nullptr;
+std::mutex DeviceImpl::device_lock_;
+
+int DeviceImpl::CreateInstance(ClientContext *intf) {
+ std::lock_guard<std::mutex> lock(device_lock_);
+ if (!device_obj_) {
+ device_obj_ = new DeviceImpl();
+ if (!device_obj_) {
+ return -1;
+ }
+
+ android::status_t status = device_obj_->IDisplayConfig::registerAsService();
+ // Unable to start Display Config 2.0 service. Fail Init.
+ if (status != android::OK) {
+ delete device_obj_;
+ device_obj_ = nullptr;
+ return -1;
+ }
+ device_obj_->intf_ = intf;
+ }
+
+ return 0;
+}
+
+Return<void> DeviceImpl::registerClient(const hidl_string &client_name,
+ const sp<IDisplayConfigCallback>& callback,
+ registerClient_cb _hidl_cb) {
+ int32_t error = 0;
+ std::string client_name_str = client_name.c_str();
+ if (client_name_str.empty()) {
+ error = -EINVAL;
+ _hidl_cb(error, 0);
+ return Void();
+ }
+
+ uint64_t client_handle = static_cast<uint64_t>(client_id_++);
+ std::shared_ptr<DeviceClientContext> device_client(new DeviceClientContext(callback));
+ if (callback) {
+ callback->linkToDeath(this, client_handle);
+ }
+ ConfigInterface *intf = nullptr;
+ error = intf_->RegisterClientContext(device_client, &intf);
+
+ if (error) {
+ callback->unlinkToDeath(this);
+ return Void();
+ }
+
+ device_client->SetDeviceConfigIntf(intf);
+
+ display_config_map_.emplace(std::make_pair(client_handle, device_client));
+ _hidl_cb(error, client_handle);
+ return Void();
+}
+
+void DeviceImpl::serviceDied(uint64_t client_handle,
+ const android::wp<::android::hidl::base::V1_0::IBase>& callback) {
+ std::lock_guard<std::mutex> lock(death_service_mutex_);
+ auto itr = display_config_map_.find(client_handle);
+ std::shared_ptr<DeviceClientContext> client = itr->second;
+ if (client != NULL) {
+ ConfigInterface *intf = client->GetDeviceConfigIntf();
+ intf_->UnRegisterClientContext(intf);
+ client.reset();
+ display_config_map_.erase(itr);
+ }
+}
+
+DeviceImpl::DeviceClientContext::DeviceClientContext(
+ const sp<IDisplayConfigCallback> callback) : callback_(callback) { }
+
+sp<IDisplayConfigCallback> DeviceImpl::DeviceClientContext::GetDeviceConfigCallback() {
+ return callback_;
+}
+
+void DeviceImpl::DeviceClientContext::SetDeviceConfigIntf(ConfigInterface *intf) {
+ intf_ = intf;
+}
+
+ConfigInterface* DeviceImpl::DeviceClientContext::GetDeviceConfigIntf() {
+ return intf_;
+}
+
+void DeviceImpl::DeviceClientContext::NotifyCWBBufferDone(int32_t error,
+ const native_handle_t *buffer) {
+ ByteStream output_params;
+ HandleStream output_handles;
+ std::vector<hidl_handle> handles;
+
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&error), sizeof(int));
+ handles.push_back(buffer);
+ output_handles = handles;
+
+ auto status = callback_->perform(kSetCwbOutputBuffer, output_params, output_handles);
+ if (status.isDeadObject()) {
+ return;
+ }
+}
+
+void DeviceImpl::DeviceClientContext::NotifyQsyncChange(bool qsync_enabled, int32_t refresh_rate,
+ int32_t qsync_refresh_rate) {
+ struct QsyncCallbackParams data = {qsync_enabled, refresh_rate, qsync_refresh_rate};
+ ByteStream output_params;
+
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&data), sizeof(data));
+
+ auto status = callback_->perform(kControlQsyncCallback, output_params, {});
+ if (status.isDeadObject()) {
+ return;
+ }
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsDisplayConnected(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const DisplayType *dpy;
+ bool connected = false;
+ ByteStream output_params;
+
+ const uint8_t *data = input_params.data();
+ dpy = reinterpret_cast<const DisplayType*>(data);
+ int32_t error = intf_->IsDisplayConnected(*dpy, &connected);
+
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&connected),
+ sizeof(connected));
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetDisplayStatus(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct StatusParams *display_status;
+ const uint8_t *data = input_params.data();
+ display_status = reinterpret_cast<const StatusParams*>(data);
+ int32_t error = intf_->SetDisplayStatus(display_status->dpy,
+ display_status->status);
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseConfigureDynRefreshRate(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct DynRefreshRateParams *dyn_refresh_data;
+ const uint8_t *data = input_params.data();
+ dyn_refresh_data = reinterpret_cast<const DynRefreshRateParams*>(data);
+ int32_t error = intf_->ConfigureDynRefreshRate(dyn_refresh_data->op,
+ dyn_refresh_data->refresh_rate);
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetConfigCount(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const DisplayType *dpy;
+ uint32_t count = 0;
+ ByteStream output_params;
+
+ if (input_params.size() == 0) {
+ _hidl_cb(-ENODATA, {}, {});
+ return;
+ }
+
+ const uint8_t *data = input_params.data();
+ dpy = reinterpret_cast<const DisplayType*>(data);
+ int32_t error = intf_->GetConfigCount(*dpy, &count);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&count),
+ sizeof(uint32_t));
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetActiveConfig(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const DisplayType *dpy;
+ uint32_t config = 0;
+ ByteStream output_params;
+
+ const uint8_t *data = input_params.data();
+ dpy = reinterpret_cast<const DisplayType*>(data);
+ int32_t error = intf_->GetActiveConfig(*dpy, &config);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&config),
+ sizeof(uint32_t));
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetActiveConfig(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct ConfigParams *set_active_cfg_data;
+
+ const uint8_t *data = input_params.data();
+ set_active_cfg_data = reinterpret_cast<const ConfigParams*>(data);
+ int32_t error = intf_->SetActiveConfig(set_active_cfg_data->dpy,
+ set_active_cfg_data->config);
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetDisplayAttributes(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct AttributesParams *get_disp_attr_data;
+ struct Attributes attributes = {};
+ ByteStream output_params;
+ int32_t error = -EINVAL;
+
+ const uint8_t *data = input_params.data();
+ get_disp_attr_data = reinterpret_cast<const AttributesParams*>(data);
+ error = intf_->GetDisplayAttributes(get_disp_attr_data->config_index, get_disp_attr_data->dpy,
+ &attributes);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&attributes),
+ sizeof(struct Attributes));
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetPanelBrightness(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint32_t *level;
+ int32_t error = 0;
+
+ const uint8_t *data = input_params.data();
+ level = reinterpret_cast<const uint32_t*>(data);
+ error = intf_->SetPanelBrightness(*level);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetPanelBrightness(perform_cb _hidl_cb) {
+ uint32_t level = 0;
+ ByteStream output_params;
+ int32_t error = -EINVAL;
+
+ error = intf_->GetPanelBrightness(&level);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&level),
+ sizeof(uint32_t));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseMinHdcpEncryptionLevelChanged(
+ const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct MinHdcpEncLevelChangedParams *min_hdcp_enc_level_data;
+ int32_t error = 0;
+
+ const uint8_t *data = input_params.data();
+ min_hdcp_enc_level_data = reinterpret_cast<const MinHdcpEncLevelChangedParams*>(data);
+ error = intf_->MinHdcpEncryptionLevelChanged(min_hdcp_enc_level_data->dpy,
+ min_hdcp_enc_level_data->min_enc_level);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseRefreshScreen(perform_cb _hidl_cb) {
+ int32_t error = intf_->RefreshScreen();
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseControlPartialUpdate(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct PartialUpdateParams *partial_update_data;
+ int32_t error = 0;
+
+ const uint8_t *data = input_params.data();
+ partial_update_data = reinterpret_cast<const PartialUpdateParams*>(data);
+ error = intf_->ControlPartialUpdate(partial_update_data->dpy, partial_update_data->enable);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseToggleScreenUpdate(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const bool *on;
+ int32_t error = 0;
+
+ const uint8_t *data = input_params.data();
+ on = reinterpret_cast<const bool*>(data);
+ error = intf_->ToggleScreenUpdate(on);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetIdleTimeout(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint32_t *timeout_value;
+
+ const uint8_t *data = input_params.data();
+ timeout_value = reinterpret_cast<const uint32_t*>(data);
+ int32_t error = intf_->SetIdleTimeout(*timeout_value);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetHdrCapabilities(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const DisplayType *dpy;
+ ByteStream output_params;
+ struct HDRCapsParams hdr_caps;
+ int32_t *data_output;
+ int32_t error = -EINVAL;
+
+ const uint8_t *data = input_params.data();
+ dpy = reinterpret_cast<const DisplayType*>(data);
+ error = intf_->GetHDRCapabilities(*dpy, &hdr_caps);
+
+ data_output = reinterpret_cast<int32_t *>(malloc(sizeof(int32_t) *
+ hdr_caps.supported_hdr_types.size() + 3 * sizeof(float)));
+ if (data_output != NULL) {
+ for (int i = 0; i < hdr_caps.supported_hdr_types.size(); i++) {
+ data_output[i] = hdr_caps.supported_hdr_types[i];
+ }
+ float *lum = reinterpret_cast<float *>(&data_output[hdr_caps.supported_hdr_types.size()]);
+ *lum = hdr_caps.max_luminance;
+ lum++;
+ *lum = hdr_caps.max_avg_luminance;
+ lum++;
+ *lum = hdr_caps.min_luminance;
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(data_output), sizeof(int32_t) *
+ hdr_caps.supported_hdr_types.size() + 3 * sizeof(float));
+ _hidl_cb(error, output_params, {});
+ }
+ else {
+ _hidl_cb(-EINVAL, {}, {});
+ }
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetCameraLaunchStatus(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint32_t *launch_status_data;
+
+ const uint8_t *data = input_params.data();
+ launch_status_data = reinterpret_cast<const uint32_t*>(data);
+
+ int32_t error = intf_->SetCameraLaunchStatus(*launch_status_data);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseDisplayBwTransactionPending(perform_cb _hidl_cb) {
+ bool status = true;
+ ByteStream output_params;
+
+ int32_t error = intf_->DisplayBWTransactionPending(&status);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&status),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetDisplayAnimating(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct AnimationParams *display_animating_data;
+
+ const uint8_t *data = input_params.data();
+ display_animating_data = reinterpret_cast<const AnimationParams*>(data);
+ int32_t error = intf_->SetDisplayAnimating(display_animating_data->display_id,
+ display_animating_data->animating);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseControlIdlePowerCollapse(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct IdlePcParams *idle_pc_data;
+
+ const uint8_t *data = input_params.data();
+ idle_pc_data = reinterpret_cast<const IdlePcParams*>(data);
+ int32_t error = intf_->ControlIdlePowerCollapse(idle_pc_data->enable, idle_pc_data->synchronous);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetWritebackCapabilities(perform_cb _hidl_cb) {
+ bool is_wb_ubwc_supported = false;
+ int32_t error = intf_->GetWriteBackCapabilities(&is_wb_ubwc_supported);
+ ByteStream output_params;
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&is_wb_ubwc_supported),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetDisplayDppsAdRoi(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct DppsAdRoiParams *ad_roi_data;
+
+ const uint8_t *data = input_params.data();
+ ad_roi_data = reinterpret_cast<const DppsAdRoiParams*>(data);
+
+ int32_t error = intf_->SetDisplayDppsAdROI(ad_roi_data->display_id, ad_roi_data->h_start,
+ ad_roi_data->h_end, ad_roi_data->v_start,
+ ad_roi_data->v_end, ad_roi_data->factor_in,
+ ad_roi_data->factor_out);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseUpdateVsyncSourceOnPowerModeOff(perform_cb _hidl_cb) {
+ int32_t error = intf_->UpdateVSyncSourceOnPowerModeOff();
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseUpdateVsyncSourceOnPowerModeDoze(perform_cb _hidl_cb) {
+ int32_t error = intf_->UpdateVSyncSourceOnPowerModeDoze();
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetPowerMode(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct PowerModeParams *set_power_mode_data;
+
+ const uint8_t *data = input_params.data();
+ set_power_mode_data = reinterpret_cast<const PowerModeParams*>(data);
+ int32_t error = intf_->SetPowerMode(set_power_mode_data->disp_id,
+ set_power_mode_data->power_mode);
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsPowerModeOverrideSupported(
+ const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint8_t *data = input_params.data();
+ const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
+ bool supported = false;
+ int32_t error = intf_->IsPowerModeOverrideSupported(*disp_id, &supported);
+ ByteStream output_params;
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&supported),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsHdrSupported(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint8_t *data = input_params.data();
+ const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
+ bool supported = false;
+ int32_t error = intf_->IsHDRSupported(*disp_id, &supported);
+ ByteStream output_params;
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&supported),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsWcgSupported(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint8_t *data = input_params.data();
+ const int32_t *disp_id = reinterpret_cast<const int32_t*>(data);
+ bool supported = false;
+ int32_t error = intf_->IsWCGSupported(*disp_id, &supported);
+ ByteStream output_params;
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&supported),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetLayerAsMask(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct LayerMaskParams *layer_mask_data;
+
+ const uint8_t *data = input_params.data();
+ layer_mask_data = reinterpret_cast<const LayerMaskParams*>(data);
+ int32_t error = intf_->SetLayerAsMask(layer_mask_data->disp_id, layer_mask_data->layer_id);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetDebugProperty(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ std::string value;
+ ByteStream output_params;
+
+ const uint8_t *data = input_params.data();
+ const char *name = reinterpret_cast<const char *>(data);
+ std::string prop_name(name);
+ int32_t error = intf_->GetDebugProperty(prop_name, &value);
+ value += '\0';
+ uint8_t *data_output = reinterpret_cast<uint8_t*>(value.data());
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(data_output),
+ value.size() * sizeof(char));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetActiveBuiltinDisplayAttributes(perform_cb _hidl_cb) {
+ struct Attributes attr;
+ ByteStream output_params;
+
+ int32_t error = intf_->GetActiveBuiltinDisplayAttributes(&attr);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&attr), sizeof(Attributes));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetPanelLuminanceAttributes(
+ const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct PanelLumAttrParams *panel_lum_attr_data;
+
+ const uint8_t *data = input_params.data();
+ panel_lum_attr_data = reinterpret_cast<const PanelLumAttrParams*>(data);
+ int32_t error = intf_->SetPanelLuminanceAttributes(panel_lum_attr_data->disp_id,
+ panel_lum_attr_data->min_lum,
+ panel_lum_attr_data->max_lum);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsBuiltinDisplay(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint32_t *disp_id;
+ bool is_builtin = false;
+ ByteStream output_params;
+
+ const uint8_t *data = input_params.data();
+ disp_id = reinterpret_cast<const uint32_t*>(data);
+ int32_t error = intf_->IsBuiltInDisplay(*disp_id, &is_builtin);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&is_builtin),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetCwbOutputBuffer(uint64_t clientHandle,
+ const ByteStream &input_params,
+ const HandleStream &input_handles,
+ perform_cb _hidl_cb) {
+ const struct CwbBufferParams *cwb_buffer_data;
+
+ const uint8_t *data = input_params.data();
+ cwb_buffer_data = reinterpret_cast<const CwbBufferParams*>(data);
+ hidl_handle buffer = input_handles[0];
+
+ if (!callback_ || !buffer.getNativeHandle()) {
+ _hidl_cb(-1, {}, {});
+ return;
+ }
+
+ int32_t error = intf_->SetCWBOutputBuffer(cwb_buffer_data->disp_id , cwb_buffer_data->rect,
+ cwb_buffer_data->post_processed,
+ buffer.getNativeHandle());
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetSupportedDsiBitclks(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint32_t *disp_id;
+ ByteStream output_params;
+ std::vector<uint64_t> bit_clks;
+ uint64_t *bit_clks_data;
+
+ const uint8_t *data = input_params.data();
+ disp_id = reinterpret_cast<const uint32_t*>(data);
+ int32_t error = intf_->GetSupportedDSIBitClks(*disp_id, &bit_clks);
+
+ bit_clks_data = reinterpret_cast<uint64_t *>(malloc(sizeof(uint64_t) * bit_clks.size()));
+ if (bit_clks_data == NULL) {
+ _hidl_cb(-EINVAL, {}, {});
+ return;
+ }
+ for (int i = 0; i < bit_clks.size(); i++) {
+ bit_clks_data[i] = bit_clks[i];
+ }
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(bit_clks_data),
+ sizeof(uint64_t) * bit_clks.size());
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseGetDsiClk(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint32_t *disp_id;
+ uint64_t bit_clk = 0;
+ ByteStream output_params;
+
+ const uint8_t *data = input_params.data();
+ disp_id = reinterpret_cast<const uint32_t*>(data);
+ int32_t error = intf_->GetDSIClk(*disp_id, &bit_clk);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&bit_clk),
+ sizeof(uint64_t));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetDsiClk(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct DsiClkParams *set_dsi_clk_data;
+
+ const uint8_t *data = input_params.data();
+ set_dsi_clk_data = reinterpret_cast<const DsiClkParams*>(data);
+ int32_t error = intf_->SetDSIClk(set_dsi_clk_data->disp_id, set_dsi_clk_data->bit_clk);
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseSetQsyncMode(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct QsyncModeParams *set_qsync_mode_data;
+
+ const uint8_t *data = input_params.data();
+ set_qsync_mode_data = reinterpret_cast<const QsyncModeParams*>(data);
+ int32_t error = intf_->SetQsyncMode(set_qsync_mode_data->disp_id, set_qsync_mode_data->mode);
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsSmartPanelConfig(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct SmartPanelCfgParams *smart_panel_cfg_data;
+ bool is_smart = false;
+ ByteStream output_params;
+
+ const uint8_t *data = input_params.data();
+ smart_panel_cfg_data = reinterpret_cast<const SmartPanelCfgParams*>(data);
+ int32_t error = intf_->IsSmartPanelConfig(smart_panel_cfg_data->disp_id,
+ smart_panel_cfg_data->config_id, &is_smart);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&is_smart),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsAsyncVdsSupported(perform_cb _hidl_cb) {
+ bool is_supported = false;
+ int32_t error = intf_->IsAsyncVDSCreationSupported(&is_supported);
+ ByteStream output_params;
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&is_supported),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseCreateVirtualDisplay(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct VdsParams *vds_input_data;
+
+ const uint8_t *data = input_params.data();
+ vds_input_data = reinterpret_cast<const VdsParams*>(data);
+
+ int32_t error = intf_->CreateVirtualDisplay(vds_input_data->width, vds_input_data->height,
+ vds_input_data->format);
+
+ _hidl_cb(error, {}, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsRotatorSupportedFormat(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const struct RotatorFormatParams *input_data;
+ bool supported = false;
+ ByteStream output_params;
+
+ const uint8_t *data = input_params.data();
+ input_data = reinterpret_cast<const RotatorFormatParams*>(data);
+ int32_t error = intf_->IsRotatorSupportedFormat(input_data->hal_format, input_data->ubwc,
+ &supported);
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&supported),
+ sizeof(bool));
+
+ _hidl_cb(error, output_params, {});
+}
+
+void DeviceImpl::DeviceClientContext::ParseControlQsyncCallback(uint64_t client_handle,
+ const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const bool *enable;
+
+ const uint8_t *data = input_params.data();
+ enable = reinterpret_cast<const bool*>(data);
+
+ int32_t error = intf_->ControlQsyncCallback(*enable);
+
+ _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, {}, {});
+}
+
+void DeviceImpl::ParseDestroy(uint64_t client_handle, perform_cb _hidl_cb) {
+ auto itr = display_config_map_.find(client_handle);
+ if (itr == display_config_map_.end()) {
+ _hidl_cb(-EINVAL, {}, {});
+ return;
+ }
+
+ std::shared_ptr<DeviceClientContext> client = itr->second;
+ if (client != NULL) {
+ sp<IDisplayConfigCallback> callback = client->GetDeviceConfigCallback();
+ callback->unlinkToDeath(this);
+ ConfigInterface *intf = client->GetDeviceConfigIntf();
+ intf_->UnRegisterClientContext(intf);
+ client.reset();
+ display_config_map_.erase(itr);
+ }
+
+ _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, {});
+}
+
+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()));
+ if (refresh_rates_data) {
+ 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, {});
+ } else {
+ _hidl_cb(-EINVAL, {}, {});
+ }
+}
+
+void DeviceImpl::DeviceClientContext::ParseIsRCSupported(const ByteStream &input_params,
+ perform_cb _hidl_cb) {
+ const uint8_t *data = input_params.data();
+ const uint32_t *disp_id = reinterpret_cast<const uint32_t*>(data);
+ bool supported = false;
+ int32_t error = intf_->IsRCSupported(*disp_id, &supported);
+ ByteStream output_params;
+ output_params.setToExternal(reinterpret_cast<uint8_t*>(&supported), sizeof(bool));
+
+ _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) {
+ int32_t error = 0;
+ auto itr = display_config_map_.find(client_handle);
+ if (itr == display_config_map_.end()) {
+ error = -EINVAL;
+ _hidl_cb(error, {}, {});
+ return Void();
+ }
+
+ std::shared_ptr<DeviceClientContext> client = itr->second;
+ if (!client) {
+ error = -EINVAL;
+ _hidl_cb(error, {}, {});
+ return Void();
+ }
+ switch (op_code) {
+ case kIsDisplayConnected:
+ client->ParseIsDisplayConnected(input_params, _hidl_cb);
+ break;
+ case kSetDisplayStatus:
+ client->ParseSetDisplayStatus(input_params, _hidl_cb);
+ break;
+ case kConfigureDynRefreshRate:
+ client->ParseConfigureDynRefreshRate(input_params, _hidl_cb);
+ break;
+ case kGetConfigCount:
+ client->ParseGetConfigCount(input_params, _hidl_cb);
+ break;
+ case kGetActiveConfig:
+ client->ParseGetActiveConfig(input_params, _hidl_cb);
+ break;
+ case kSetActiveConfig:
+ client->ParseSetActiveConfig(input_params, _hidl_cb);
+ break;
+ case kGetDisplayAttributes:
+ client->ParseGetDisplayAttributes(input_params, _hidl_cb);
+ break;
+ case kSetPanelBrightness:
+ client->ParseSetPanelBrightness(input_params, _hidl_cb);
+ break;
+ case kGetPanelBrightness:
+ client->ParseGetPanelBrightness(_hidl_cb);
+ break;
+ case kMinHdcpEncryptionLevelChanged:
+ client->ParseMinHdcpEncryptionLevelChanged(input_params, _hidl_cb);
+ break;
+ case kRefreshScreen:
+ client->ParseRefreshScreen(_hidl_cb);
+ break;
+ case kControlPartialUpdate:
+ client->ParseControlPartialUpdate(input_params, _hidl_cb);
+ break;
+ case kToggleScreenUpdate:
+ client->ParseToggleScreenUpdate(input_params, _hidl_cb);
+ break;
+ case kSetIdleTimeout:
+ client->ParseSetIdleTimeout(input_params, _hidl_cb);
+ break;
+ case kGetHdrCapabilities:
+ client->ParseGetHdrCapabilities(input_params, _hidl_cb);
+ break;
+ case kSetCameraLaunchStatus:
+ client->ParseSetCameraLaunchStatus(input_params, _hidl_cb);
+ break;
+ case kDisplayBwTransactionPending:
+ client->ParseDisplayBwTransactionPending(_hidl_cb);
+ break;
+ case kSetDisplayAnimating:
+ client->ParseSetDisplayAnimating(input_params, _hidl_cb);
+ break;
+ case kControlIdlePowerCollapse:
+ client->ParseControlIdlePowerCollapse(input_params, _hidl_cb);
+ break;
+ case kGetWritebackCapabilities:
+ client->ParseGetWritebackCapabilities(_hidl_cb);
+ break;
+ case kSetDisplayDppsAdRoi:
+ client->ParseSetDisplayDppsAdRoi(input_params, _hidl_cb);
+ break;
+ case kUpdateVsyncSourceOnPowerModeOff:
+ client->ParseUpdateVsyncSourceOnPowerModeOff(_hidl_cb);
+ break;
+ case kUpdateVsyncSourceOnPowerModeDoze:
+ client->ParseUpdateVsyncSourceOnPowerModeDoze(_hidl_cb);
+ break;
+ case kSetPowerMode:
+ client->ParseSetPowerMode(input_params, _hidl_cb);
+ break;
+ case kIsPowerModeOverrideSupported:
+ client->ParseIsPowerModeOverrideSupported(input_params, _hidl_cb);
+ break;
+ case kIsHdrSupported:
+ client->ParseIsHdrSupported(input_params, _hidl_cb);
+ break;
+ case kIsWcgSupported:
+ client->ParseIsWcgSupported(input_params, _hidl_cb);
+ break;
+ case kSetLayerAsMask:
+ client->ParseSetLayerAsMask(input_params, _hidl_cb);
+ break;
+ case kGetDebugProperty:
+ client->ParseGetDebugProperty(input_params, _hidl_cb);
+ break;
+ case kGetActiveBuiltinDisplayAttributes:
+ client->ParseGetActiveBuiltinDisplayAttributes(_hidl_cb);
+ break;
+ case kSetPanelLuminanceAttributes:
+ client->ParseSetPanelLuminanceAttributes(input_params, _hidl_cb);
+ break;
+ case kIsBuiltinDisplay:
+ client->ParseIsBuiltinDisplay(input_params, _hidl_cb);
+ break;
+ case kSetCwbOutputBuffer:
+ client->ParseSetCwbOutputBuffer(client_handle, input_params, input_handles, _hidl_cb);
+ break;
+ case kGetSupportedDsiBitclks:
+ client->ParseGetSupportedDsiBitclks(input_params, _hidl_cb);
+ break;
+ case kGetDsiClk:
+ client->ParseGetDsiClk(input_params, _hidl_cb);
+ break;
+ case kSetDsiClk:
+ client->ParseSetDsiClk(input_params, _hidl_cb);
+ break;
+ case kSetQsyncMode:
+ client->ParseSetQsyncMode(input_params, _hidl_cb);
+ break;
+ case kIsSmartPanelConfig:
+ client->ParseIsSmartPanelConfig(input_params, _hidl_cb);
+ break;
+ case kIsAsyncVdsSupported:
+ client->ParseIsAsyncVdsSupported(_hidl_cb);
+ break;
+ case kCreateVirtualDisplay:
+ client->ParseCreateVirtualDisplay(input_params, _hidl_cb);
+ break;
+ case kIsRotatorSupportedFormat:
+ client->ParseIsRotatorSupportedFormat(input_params, _hidl_cb);
+ break;
+ case kControlQsyncCallback:
+ client->ParseControlQsyncCallback(client_handle, input_params, _hidl_cb);
+ break;
+ case kSendTUIEvent:
+ client->ParseSendTUIEvent(input_params, _hidl_cb);
+ break;
+ case kDestroy:
+ ParseDestroy(client_handle, _hidl_cb);
+ break;
+ case kGetDisplayHwId:
+ client->ParseGetDisplayHwId(input_params, _hidl_cb);
+ break;
+ case kGetSupportedDisplayRefreshRates:
+ client->ParseGetSupportedDisplayRefreshRates(input_params, _hidl_cb);
+ break;
+ case kIsRCSupported:
+ client->ParseIsRCSupported(input_params, _hidl_cb);
+ break;
+ default:
+ break;
+ }
+ return Void();
+}
+
+} // namespace DisplayConfig
diff --git a/display-commonsys-intf/services/config/src/device_impl.h b/display-commonsys-intf/services/config/src/device_impl.h
new file mode 100644
index 00000000..a2435995
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/device_impl.h
@@ -0,0 +1,147 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __DEVICE_IMPL_H__
+#define __DEVICE_IMPL_H__
+
+#include <vendor/display/config/2.0/IDisplayConfig.h>
+#include <hidl/HidlSupport.h>
+
+#include <config/device_interface.h>
+#include <map>
+#include <utility>
+#include <string>
+#include <vector>
+
+#include "opcode_types.h"
+
+namespace DisplayConfig {
+
+using vendor::display::config::V2_0::IDisplayConfig;
+using vendor::display::config::V2_0::IDisplayConfigCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_handle;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::sp;
+
+typedef hidl_vec<uint8_t> ByteStream;
+typedef hidl_vec<hidl_handle> HandleStream;
+
+class DeviceImpl : public IDisplayConfig, public android::hardware::hidl_death_recipient {
+ public:
+ static int CreateInstance(ClientContext *intf);
+
+ private:
+ class DeviceClientContext : public ConfigCallback {
+ public:
+ explicit DeviceClientContext(const sp<IDisplayConfigCallback> callback);
+
+ void SetDeviceConfigIntf(ConfigInterface *intf);
+ ConfigInterface* GetDeviceConfigIntf();
+ sp<IDisplayConfigCallback> GetDeviceConfigCallback();
+
+ virtual void NotifyCWBBufferDone(int32_t error, const native_handle_t *buffer);
+ virtual void NotifyQsyncChange(bool qsync_enabled, int32_t refresh_rate,
+ int32_t qsync_refresh_rate);
+
+ void ParseIsDisplayConnected(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetDisplayStatus(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseConfigureDynRefreshRate(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetConfigCount(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetActiveConfig(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetActiveConfig(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetDisplayAttributes(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetPanelBrightness(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetPanelBrightness(perform_cb _hidl_cb);
+ void ParseMinHdcpEncryptionLevelChanged(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseRefreshScreen(perform_cb _hidl_cb);
+ void ParseControlPartialUpdate(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseToggleScreenUpdate(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetIdleTimeout(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetHdrCapabilities(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetCameraLaunchStatus(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseDisplayBwTransactionPending(perform_cb _hidl_cb);
+ void ParseSetDisplayAnimating(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseControlIdlePowerCollapse(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetWritebackCapabilities(perform_cb _hidl_cb);
+ void ParseSetDisplayDppsAdRoi(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseUpdateVsyncSourceOnPowerModeOff(perform_cb _hidl_cb);
+ void ParseUpdateVsyncSourceOnPowerModeDoze(perform_cb _hidl_cb);
+ void ParseSetPowerMode(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseIsPowerModeOverrideSupported(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseIsHdrSupported(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseIsWcgSupported(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetLayerAsMask(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetDebugProperty(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetActiveBuiltinDisplayAttributes(perform_cb _hidl_cb);
+ void ParseSetPanelLuminanceAttributes(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseIsBuiltinDisplay(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetCwbOutputBuffer(uint64_t clientHandle, const ByteStream &input_params,
+ const HandleStream &inputHandles, perform_cb _hidl_cb);
+ void ParseGetSupportedDsiBitclks(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetDsiClk(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetDsiClk(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseSetQsyncMode(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseIsSmartPanelConfig(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseIsAsyncVdsSupported(perform_cb _hidl_cb);
+ void ParseCreateVirtualDisplay(const ByteStream &input_params, perform_cb _hidl_cb);
+ 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);
+ void ParseGetDisplayHwId(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseGetSupportedDisplayRefreshRates(const ByteStream &input_params, perform_cb _hidl_cb);
+ void ParseIsRCSupported(const ByteStream &input_params, perform_cb _hidl_cb);
+
+ private:
+ ConfigInterface *intf_ = nullptr;
+ const sp<IDisplayConfigCallback> callback_;
+ };
+
+ Return<void> registerClient(const hidl_string &client_name, const sp<IDisplayConfigCallback>& cb,
+ registerClient_cb _hidl_cb) override;
+ Return<void> perform(uint64_t client_handle, uint32_t op_code, const ByteStream &input_params,
+ const HandleStream &input_handles, perform_cb _hidl_cb) override;
+ void serviceDied(uint64_t client_handle,
+ const android::wp<::android::hidl::base::V1_0::IBase>& callback);
+ void ParseDestroy(uint64_t client_handle, perform_cb _hidl_cb);
+
+ ClientContext *intf_ = nullptr;
+ std::map<uint64_t, std::shared_ptr<DeviceClientContext>> display_config_map_;
+ uint64_t client_id_ = 0;
+ std::mutex death_service_mutex_;
+ static DeviceImpl *device_obj_;
+ static std::mutex device_lock_;
+};
+
+} // namespace DisplayConfig
+
+#endif // __DEVICE_IMPL_H__
diff --git a/display-commonsys-intf/services/config/src/device_interface.cpp b/display-commonsys-intf/services/config/src/device_interface.cpp
new file mode 100644
index 00000000..0c2d6b73
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/device_interface.cpp
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "device_impl.h"
+
+namespace DisplayConfig {
+
+int DeviceInterface::RegisterDevice(ClientContext *intf) {
+ if (!intf) {
+ return -1;
+ }
+
+ return DeviceImpl::CreateInstance(intf);
+}
+
+} // namespace DisplayConfig
diff --git a/display-commonsys-intf/services/config/src/opcode_types.h b/display-commonsys-intf/services/config/src/opcode_types.h
new file mode 100644
index 00000000..84f9747a
--- /dev/null
+++ b/display-commonsys-intf/services/config/src/opcode_types.h
@@ -0,0 +1,88 @@
+/*
+* Copyright (c) 2020 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
+* met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __OPCODE_TYPES_H__
+#define __OPCODE_TYPES_H__
+
+namespace DisplayConfig {
+
+enum OpCode {
+ kIsDisplayConnected = 0,
+ kSetDisplayStatus = 1,
+ kConfigureDynRefreshRate = 2,
+ kGetConfigCount = 3,
+ kGetActiveConfig = 4,
+ kSetActiveConfig = 5,
+ kGetDisplayAttributes = 6,
+ kSetPanelBrightness = 7,
+ kGetPanelBrightness = 8,
+ kMinHdcpEncryptionLevelChanged = 9,
+ kRefreshScreen = 10,
+ kControlPartialUpdate = 11,
+ kToggleScreenUpdate = 12,
+ kSetIdleTimeout = 13,
+ kGetHdrCapabilities = 14,
+ kSetCameraLaunchStatus = 15,
+ kDisplayBwTransactionPending = 16,
+ kSetDisplayAnimating = 17,
+ kControlIdlePowerCollapse = 18,
+ kGetWritebackCapabilities = 19,
+ kSetDisplayDppsAdRoi = 20,
+ kUpdateVsyncSourceOnPowerModeOff = 21,
+ kUpdateVsyncSourceOnPowerModeDoze = 22,
+ kSetPowerMode = 23,
+ kIsPowerModeOverrideSupported = 24,
+ kIsHdrSupported = 25,
+ kIsWcgSupported = 26,
+ kSetLayerAsMask = 27,
+ kGetDebugProperty = 28,
+ kGetActiveBuiltinDisplayAttributes = 29,
+ kSetPanelLuminanceAttributes = 30,
+ kIsBuiltinDisplay = 31,
+ kSetCwbOutputBuffer = 32,
+ kGetSupportedDsiBitclks = 33,
+ kGetDsiClk = 34,
+ kSetDsiClk = 35,
+ kSetQsyncMode = 36,
+ kIsSmartPanelConfig = 37,
+ kIsAsyncVdsSupported = 38,
+ kCreateVirtualDisplay = 39,
+ kIsRotatorSupportedFormat = 40,
+ kControlQsyncCallback = 41,
+ kSendTUIEvent = 42,
+ kGetDisplayHwId = 43,
+ kGetSupportedDisplayRefreshRates = 44,
+ kIsRCSupported = 45,
+
+ kDestroy = 0xFFFF, // Destroy sequence execution
+};
+
+} // namespace DisplayConfig
+
+#endif // __OPCODE_TYPES_H__
diff --git a/libcopybit/c2d2.h b/libcopybit/c2d2.h
index 315a3ba5..2ee71b1a 100644
--- a/libcopybit/c2d2.h
+++ b/libcopybit/c2d2.h
@@ -72,6 +72,7 @@ typedef enum {
C2D_FORMAT_MACROTILED = (1 << 16), /* tiled in macro level */
C2D_FORMAT_TILED_4x4 = (1 << 17), /* 4x4 tiled format */
C2D_FORMAT_SWAP_RB = (1 << 18), /* Swap R & B color components */
+ C2D_FORMAT_BT601_FULLRANGE = (1 << 20), /* YUV format is full range following BT 601 */
C2D_FORMAT_UBWC_COMPRESSED = (1 << 23), /* UBWC compressed format */
} C2D_FORMAT_MODE;
@@ -207,6 +208,7 @@ typedef enum {
C2D_COLOR_FORMAT_422_Y42B = 174,
C2D_COLOR_FORMAT_800_Y800 = 190,
+ C2D_COLOR_FORMAT_420_TP10 = 191,
} C2D_YUV_FORMAT;
project hardware/qcom/sm8150/media/
diff --git a/libc2dcolorconvert/Android.mk b/libc2dcolorconvert/Android.mk
index f6158fc0..fdc20e52 100644
--- a/libc2dcolorconvert/Android.mk
+++ b/libc2dcolorconvert/Android.mk
@@ -14,7 +14,7 @@ LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_HEADER_LIBRARIES := \
libutils_headers \
libhardware_headers \
- display_intf_headers
+ display_headers
LOCAL_SHARED_LIBRARIES := liblog libdl
diff --git a/mm-video-v4l2/vidc/common/Android.mk b/mm-video-v4l2/vidc/common/Android.mk
index 0013278f..e1e5a746 100644
--- a/mm-video-v4l2/vidc/common/Android.mk
+++ b/mm-video-v4l2/vidc/common/Android.mk
@@ -1,5 +1,5 @@
ROOT_DIR := $(call my-dir)
-LIBION_HEADER_PATH_WRAPPER := $(QC_OPEN_PATH)/core-utils/build/libion_header_paths/libion_path.mk
+LIBION_HEADER_PATH_WRAPPER := $(TOP)/vendor/qcom/opensource/core-utils/build/libion_header_paths/libion_path.mk
include $(CLEAR_VARS)
include $(LIBION_HEADER_PATH_WRAPPER)
@@ -39,7 +39,7 @@ LOCAL_PRELINK_MODULE := false
LOCAL_SHARED_LIBRARIES := liblog libcutils libdl
LOCAL_HEADER_LIBRARIES := \
- libutils_headers display_intf_headers
+ libutils_headers display_headers
LOCAL_SRC_FILES += src/vidc_common.cpp
LOCAL_SRC_FILES += src/vidc_vendor_extensions.cpp
diff --git a/mm-video-v4l2/vidc/vdec/Android.mk b/mm-video-v4l2/vidc/vdec/Android.mk
index 323eba21..1db8c6bb 100644
--- a/mm-video-v4l2/vidc/vdec/Android.mk
+++ b/mm-video-v4l2/vidc/vdec/Android.mk
@@ -1,5 +1,5 @@
LOCAL_PATH := $(call my-dir)
-LIBION_HEADER_PATH_WRAPPER := $(QC_OPEN_PATH)/core-utils/build/libion_header_paths/libion_path.mk
+LIBION_HEADER_PATH_WRAPPER := $(TOP)/vendor/qcom/opensource/core-utils/build/libion_header_paths/libion_path.mk
include $(CLEAR_VARS)
include $(LIBION_HEADER_PATH_WRAPPER)
@@ -110,7 +110,7 @@ LOCAL_HEADER_LIBRARIES := \
libnativebase_headers \
libutils_headers \
libhardware_headers \
- display_intf_headers
+ display_headers
LOCAL_C_INCLUDES += $(libmm-vdec-inc)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libmm-vdec-add-dep)
diff --git a/mm-video-v4l2/vidc/venc/Android.mk b/mm-video-v4l2/vidc/venc/Android.mk
index de46005b..c0752879 100644
--- a/mm-video-v4l2/vidc/venc/Android.mk
+++ b/mm-video-v4l2/vidc/venc/Android.mk
@@ -1,5 +1,5 @@
LOCAL_PATH := $(call my-dir)
-LIBION_HEADER_PATH_WRAPPER := $(QC_OPEN_PATH)/core-utils/build/libion_header_paths/libion_path.mk
+LIBION_HEADER_PATH_WRAPPER := $(TOP)/vendor/qcom/opensource/core-utils/build/libion_header_paths/libion_path.mk
include $(CLEAR_VARS)
include $(LIBION_HEADER_PATH_WRAPPER)
@@ -108,7 +108,7 @@ LOCAL_HEADER_LIBRARIES := \
libcutils_headers \
libutils_headers \
libhardware_headers \
- display_intf_headers
+ display_headers
LOCAL_C_INCLUDES := $(libmm-venc-inc)
LOCAL_ADDITIONAL_DEPENDENCIES := $(libmm-venc-add-dep)
project vendor/qcom/opensource/core-utils/
diff --git a/fwk-detect/Android.bp b/fwk-detect/Android.bp
deleted file mode 100644
index 08d3aba..0000000
--- a/fwk-detect/Android.bp
+++ /dev/null
@@ -1,56 +0,0 @@
-cc_library_shared {
- name: "libqti_vndfwk_detect",
- srcs: ["vndfwk-detect.c"],
- shared_libs: ["libcutils"],
- system_ext_specific: true,
- vendor_available: true,
- export_include_dirs: ["."],
-
- compile_multilib: "both",
- cflags: [
- "-Wall",
- "-Werror",
- ],
-}
-
-cc_test {
- name: "vndfwk-test",
- srcs: ["vndfwk-test.c"],
- shared_libs: ["libqti_vndfwk_detect"],
- vendor_available: true,
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-}
-
-cc_library_shared {
- name: "libvndfwk_detect_jni.qti",
- srcs: ["jni/com_qualcomm_qti_VndFwkDetect.cpp"],
- shared_libs: [
- "libqti_vndfwk_detect",
- "libcutils",
- "libutils",
- "liblog",
- ],
- include_dirs: [
- ".",
- ],
- header_libs: [
- "jni_headers",
- ],
- system_ext_specific: true,
- vendor_available: true,
- compile_multilib: "both",
-
- cflags: [
- "-Wno-unused-parameter",
- ],
-}
-
-java_library_static {
- name: "vndfwk.detect",
- srcs: ["src/**/*.java"],
- sdk_version: "current",
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment