sdm: Add support for HDR

- Add LayerRequests to SDM Layer Interface, which will
  be used in informing any requests from SDM to client.
- Check for color metadata from client and handle
  HDR content.
- Include GPU Tonemapper to tonemap any requests
  coming from SDM

Change-Id: Idd1882ffab77fc3bff296114f36fb30bff4a4530
Crs-fixed: 1092142
diff --git a/sdm/include/core/layer_buffer.h b/sdm/include/core/layer_buffer.h
index 27a4f03..4b42e7b 100644
--- a/sdm/include/core/layer_buffer.h
+++ b/sdm/include/core/layer_buffer.h
@@ -203,6 +203,9 @@
       uint32_t secure_camera : 1;   //!< This flag shall be set by the client to indicate that the
                                     //!< buffer is associated with secure camera session. A secure
                                     //!< camera layer can co-exist with non-secure layer(s).
+
+      uint32_t hdr : 1;             //!< This flag shall be set by the client to indicate that the
+                                    //!< the content is HDR.
     };
 
     uint32_t flags = 0;             //!< For initialization purpose only.
diff --git a/sdm/include/core/layer_stack.h b/sdm/include/core/layer_stack.h
index 096e88f..701e3ca 100644
--- a/sdm/include/core/layer_stack.h
+++ b/sdm/include/core/layer_stack.h
@@ -179,6 +179,36 @@
   };
 };
 
+/*! @brief This structure defines flags associated with the layer requests. The 1-bit flag can be
+    set to ON(1) or OFF(0).
+
+  @sa Layer
+*/
+struct LayerRequestFlags {
+  union {
+    struct {
+      uint32_t tone_map : 1;  //!< This flag will be set by SDM when the layer needs tone map
+      uint32_t secure: 1;  //!< This flag will be set by SDM when the layer must be secure
+    };
+    uint32_t request_flags = 0;  //!< For initialization purpose only.
+                                 //!< Shall not be refered directly.
+  };
+};
+
+/*! @brief This structure defines LayerRequest.
+   Includes width/height/format of the LayerRequest.
+
+   SDM shall set the properties of LayerRequest to be used by the client
+
+  @sa LayerRequest
+*/
+struct LayerRequest {
+  LayerRequestFlags flags;  // Flags associated with this request
+  LayerBufferFormat format = kFormatRGBA8888;  // Requested format
+  uint32_t width = 0;
+  uint32_t height = 0;
+};
+
 /*! @brief This structure defines flags associated with a layer stack. The 1-bit flag can be set to
   ON(1) or OFF(0).
 
@@ -219,6 +249,8 @@
 
       uint32_t post_processed_output : 1;  // If output_buffer should contain post processed output
                                            // This applies only to primary displays currently
+
+      uint32_t hdr_present : 1;  //!< Set if stack has HDR content
     };
 
     uint32_t flags = 0;               //!< For initialization purpose only.
@@ -322,6 +354,11 @@
                                                    //!< no content is associated with the layer.
 
   LayerFlags flags;                                //!< Flags associated with this layer.
+
+  LayerRequest request = {};                       //!< o/p - request on this Layer by SDM.
+
+  Lut3d lut_3d = {};                               //!< o/p - Populated by SDM when tone mapping is
+                                                   //!< needed on this layer.
 };
 
 /*! @brief This structure defines a layer stack that contains layers which need to be composed and
diff --git a/sdm/include/private/strategy_interface.h b/sdm/include/private/strategy_interface.h
index 122a3c6..90e1064 100644
--- a/sdm/include/private/strategy_interface.h
+++ b/sdm/include/private/strategy_interface.h
@@ -53,6 +53,7 @@
                                    const HWMixerAttributes &mixer_attributes,
                                    const DisplayConfigVariableInfo &fb_config) = 0;
   virtual DisplayError SetCompositionState(LayerComposition composition_type, bool enable) = 0;
+  virtual DisplayError Purge() = 0;
 
  protected:
   virtual ~StrategyInterface() { }
diff --git a/sdm/include/utils/constants.h b/sdm/include/utils/constants.h
index 31129c1..72b1bed 100644
--- a/sdm/include/utils/constants.h
+++ b/sdm/include/utils/constants.h
@@ -71,6 +71,8 @@
   const int kMaxRotatePerLayer = 2;
   const uint32_t kMaxBlitTargetLayers = 2;
   const int kPageSize = 4096;
+  const uint32_t kGridSize = 129;  // size used for non-linear transformation before Tone-mapping
+  const uint32_t kLutDim = 17;  // Dim of the 3d LUT for tone-mapping.
 
   typedef void * Handle;