Merge "sdm: remove vsync enable as part of commit cycle" into display.lnx.9.0
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index a8e559b..0047b1d 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -1581,11 +1581,15 @@
       }
     }
 
-    // For long term large composition hint, release the acquired handle after a consecutive number
-    // of basic frames to avoid resending hints in animation launch use cases and others.
-    num_basic_frames_++;
+    // For long term large composition hint, release the acquired handle after 100 milliseconds
+    // to avoid resending hints in animation launch use cases and others.
+    if (hint_release_start_time_ == 0) {
+      hint_release_start_time_ = systemTime(SYSTEM_TIME_MONOTONIC);
+    }
 
-    if (num_basic_frames_ >= active_refresh_rate_) {
+    nsecs_t current_time = systemTime(SYSTEM_TIME_MONOTONIC);
+    if (nanoseconds_to_milliseconds(current_time - hint_release_start_time_) >=
+        elapse_time_threshold_) {
       cpu_hint_->ReqHintRelease();
     }
     return;
@@ -1600,7 +1604,8 @@
     cpu_hint_->ReqHintsOffload(kPerfHintLargeCompCycle, 0);
   }
 
-  num_basic_frames_ = 0;
+  // Reset time when large composition hint is active
+  hint_release_start_time_ = 0;
 }
 
 void HWCDisplayBuiltIn::ReqPerfHintRelease() {
diff --git a/composer/hwc_display_builtin.h b/composer/hwc_display_builtin.h
index 1ddbb5a..5cd318b 100644
--- a/composer/hwc_display_builtin.h
+++ b/composer/hwc_display_builtin.h
@@ -228,8 +228,9 @@
 
   // Long term large composition hint
   int hwc_tid_ = 0;
-  uint32_t num_basic_frames_ = 0;
   uint32_t large_comp_hint_threshold_ = 0;
+  nsecs_t hint_release_start_time_ = 0;
+  nsecs_t elapse_time_threshold_ = 100;  // Time is in milliseconds
 };
 
 }  // namespace sdm
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/config/display-product.mk b/config/display-product.mk
index 41df82f..9c59bbc 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -123,7 +123,13 @@
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.surface_flinger.force_hwc_copy_for_virtual_displays=true
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.surface_flinger.max_frame_buffer_acquired_buffers=3
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.surface_flinger.max_virtual_display_dimension=4096
+
+#BG blur support
+ifeq ($(TARGET_BOARD_PLATFORM),kalama)
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.surface_flinger.supports_background_blur=1
+else
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.surface_flinger.supports_background_blur=0
+endif
 
 ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
 # Recovery is enabled, logging is enabled
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();