omni: Allow extension of valid gralloc 1.0 buffer usage bits

Author: Kevin F. Haggerty <haggertk@lineageos.org>
Date:   Sat Aug 25 20:23:19 2018 -0600

* fw/native change I7f4174581e24e361577640b9263514a168ed482d
  implemented validation of the buffer description info prior to
  creating the descriptor. Some of our legacy devices need to
  whitelist additional usage bits to support various functionality.
* The TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS variable can contain
  a singular roll-up value (e.g., 0x02000000U), a left-shifted bit
  (e.g., (1 << 25)), a bitwise OR of these things, or essentially
  anything that the compiler can choke down.

Change-Id: I2127d33b03426b5e0f981aae837e07d82163fa17

Author: Kevin F. Haggerty <haggertk@lineageos.org>
Date:   Sat Aug 25 20:23:19 2018 -0600

    soong_config: Allow extension of valid gralloc 1.0 buffer usage bits

    * fw/native change I7f4174581e24e361577640b9263514a168ed482d
      implemented validation of the buffer description info prior to
      creating the descriptor. Some of our legacy devices need to
      whitelist additional usage bits to support various functionality.
    * The TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS variable can contain
      a singular roll-up value (e.g., 0x02000000U), a left-shifted bit
      (e.g., (1 << 25)), a bitwise OR of these things, or essentially
      anything that the compiler can choke down.

    Change-Id: I2127d33b03426b5e0f981aae837e07d82163fa17

Author: Bruno Martins <bgcngm@gmail.com>
Date:   Fri Dec 28 21:34:03 2018 +0000

    qcom: Mark some gralloc bits as valid

     * Add GRALLOC_USAGE_PRIVATE_WFD as valid gralloc bits for all
       the platforms and GRALLOC_USAGE_PRIVATE_10BIT_TP only for the
       UM 4.9-based platforms. Both are defined in the respective
       display HALs (in gralloc/gralloc_priv.h) being the latter
       only available for sdm845.

     * This results in the same as applying https://goo.gl/SR7sFY,
       but it's preferable since it makes use of our own method of
       extending the valid gralloc 1.0 usage bits (see commit 59009f8).
       TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS is extended here on
       purpose and as a bitwise OR of all the values in order not to
       clear what might have been set in the device trees.

    Change-Id: I5536f341e75088cc72ac369065011388f0a6d3f1

Author: Bruno Martins <bgcngm@gmail.com>
Date:   Sat Oct 17 10:20:37 2020 +0100

    soong: Set a default for TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS

    Devices not setting BOARD_USES_QCOM_HARDWARE to true fail to build
    in case a default is not set.

    Change-Id: I6643aa08244a5c476a45336485362dd7876fc90c

Change-Id: If3697acbc92ab4bf9cc9f26e22c4f6ada14a04d5
diff --git a/config/Android.bp b/config/Android.bp
index ff47865..bc88a09 100644
--- a/config/Android.bp
+++ b/config/Android.bp
@@ -169,6 +169,23 @@
     },
 }
 
+soong_config_module_type {
+    name: "gralloc_10_usage_bits",
+    module_type: "cc_defaults",
+    config_namespace: "omniGlobalVars",
+    value_variables: ["additional_gralloc_10_usage_bits"],
+    properties: ["cppflags"],
+}
+
+gralloc_10_usage_bits {
+    name: "gralloc_10_usage_bits_defaults",
+    soong_config_variables: {
+        additional_gralloc_10_usage_bits: {
+            cppflags: ["-DADDNL_GRALLOC_10_USAGE_BITS=%s"],
+        },
+    },
+}
+
 // QCOM specific config modules
 soong_config_module_type {
     name: "metadata_fde_key",
diff --git a/config/BoardConfigSoong.mk b/config/BoardConfigSoong.mk
index 9d40986..f350d01 100644
--- a/config/BoardConfigSoong.mk
+++ b/config/BoardConfigSoong.mk
@@ -25,6 +25,7 @@
 
 SOONG_CONFIG_NAMESPACES += omniGlobalVars
 SOONG_CONFIG_omniGlobalVars += \
+    additional_gralloc_10_usage_bits \
     target_create_device_symlinks \
     target_init_vendor_lib \
     target_surfaceflinger_udfps_lib \
@@ -58,10 +59,12 @@
 SOONG_CONFIG_omniGlobalVars_target_create_device_symlinks := $(TARGET_CREATE_DEVICE_SYMLINKS)
 
 # Set default values
+TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS ?= 0
 TARGET_INIT_VENDOR_LIB ?= vendor_init
 TARGET_SURFACEFLINGER_UDFPS_LIB ?= surfaceflinger_udfps_lib
 TARGET_GRALLOC_HANDLE_HAS_RESERVED_SIZE ?= false
 
 # Soong value variables
+SOONG_CONFIG_omniGlobalVars_additional_gralloc_10_usage_bits := $(TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS)
 SOONG_CONFIG_omniGlobalVars_target_init_vendor_lib := $(TARGET_INIT_VENDOR_LIB)
 SOONG_CONFIG_omniGlobalVars_target_surfaceflinger_udfps_lib := $(TARGET_SURFACEFLINGER_UDFPS_LIB)