Merge "composer: Add 100ms delay upon releasing of large comp hint" into display.lnx.9.0
diff --git a/composer/hwc_layers.cpp b/composer/hwc_layers.cpp
index 842269f..497b219 100644
--- a/composer/hwc_layers.cpp
+++ b/composer/hwc_layers.cpp
@@ -24,7 +24,7 @@
 /*
 * Changes from Qualcomm Innovation Center are provided under the following license:
 *
-* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted (subject to the limitations in the
@@ -1261,6 +1261,7 @@
         layer_->update_mask.set(kMetadataUpdate);
       }
       if (new_metadata.dynamicMetaDataValid &&
+          new_metadata.dynamicMetaDataLen < HDR_DYNAMIC_META_DATA_SZ &&
           ((new_metadata.dynamicMetaDataLen != layer_buffer->color_metadata.dynamicMetaDataLen) ||
             !SameConfig(layer_buffer->color_metadata.dynamicMetaDataPayload,
                         new_metadata.dynamicMetaDataPayload, new_metadata.dynamicMetaDataLen))) {
diff --git a/sdm/libs/dal/hw_device_drm.cpp b/sdm/libs/dal/hw_device_drm.cpp
index 683f071..8ce6a1d 100644
--- a/sdm/libs/dal/hw_device_drm.cpp
+++ b/sdm/libs/dal/hw_device_drm.cpp
@@ -569,6 +569,12 @@
     DLOGI("aspect_ratio_threshold_: %f", aspect_ratio_threshold_);
   }
 
+  value = 0;
+  if (Debug::GetProperty(FORCE_TONEMAPPING, &value) == kErrorNone) {
+    force_tonemapping_ = (value == 1);
+    DLOGI("force_tonemapping_ %d", force_tonemapping_);
+  }
+
   return kErrorNone;
 }
 
@@ -1523,6 +1529,37 @@
 
           SetSsppTonemapFeatures(pipe_info);
         } else if (update_luts) {
+          if (force_tonemapping_) {
+            sde_drm::DRMFp16CscType fp16_csc_type = sde_drm::DRMFp16CscType::kFP16CscTypeMax;
+            int fp16_igc_en = 0;
+            int fp16_unmult_en = 0;
+            drm_msm_fp16_gc fp16_gc_config = {.flags = 0, .mode = FP16_GC_MODE_INVALID};
+            SelectFp16Config(layer.input_buffer, &fp16_igc_en, &fp16_unmult_en, &fp16_csc_type,
+                             &fp16_gc_config, layer.blending);
+
+            // Account for PMA block activation directly at translation time to preserve layer
+            // blending definition and avoid issues when a layer structure is reused.
+            DRMBlendType blending = DRMBlendType::UNDEFINED;
+            LayerBlending layer_blend = layer.blending;
+            if (layer_blend == kBlendingPremultiplied) {
+              // If blending type is premultiplied alpha and FP16 unmult is enabled,
+              // prevent performing alpha unmultiply twice
+              if (fp16_unmult_en) {
+                layer_blend = kBlendingCoverage;
+                pipe_info->inverse_pma_info.inverse_pma = false;
+                pipe_info->inverse_pma_info.op = kReset;
+                DLOGI_IF(kTagDriverConfig,
+                         "PMA handled by FP16 UNMULT block - Pipe id: %u", pipe_id);
+              } else if (pipe_info->inverse_pma_info.inverse_pma) {
+                layer_blend = kBlendingCoverage;
+                DLOGI_IF(kTagDriverConfig,
+                         "PMA handled by Inverse PMA block - Pipe id: %u", pipe_id);
+              }
+            }
+            SetBlending(layer_blend, &blending);
+            drm_atomic_intf_->Perform(DRMOps::PLANE_SET_BLEND_TYPE, pipe_id, blending);
+          }
+
           SetSsppTonemapFeatures(pipe_info);
         }
 
diff --git a/sdm/libs/dal/hw_device_drm.h b/sdm/libs/dal/hw_device_drm.h
index 93a209e..1653b6b 100644
--- a/sdm/libs/dal/hw_device_drm.h
+++ b/sdm/libs/dal/hw_device_drm.h
@@ -334,6 +334,7 @@
   static HWCwbConfig cwb_config_;
   static std::mutex cwb_state_lock_;  // cwb state lock. Set before accesing or updating cwb_config_
   uint32_t transfer_time_updated_ = 0;
+  bool force_tonemapping_ = false;
 
  private:
   void GetCWBCapabilities();