Merge "composer: Fix HandlePluggableDisplays scope call" into display.lnx.9.0
diff --git a/composer/QtiComposerClient.cpp b/composer/QtiComposerClient.cpp
index a8e4a9c..2d37d74 100644
--- a/composer/QtiComposerClient.cpp
+++ b/composer/QtiComposerClient.cpp
@@ -17,6 +17,13 @@
  * limitations under the License.
  */
 
+/*
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
 #include <vector>
 #include <string>
 
@@ -2105,15 +2112,14 @@
 Error QtiComposerClient::CommandReader::lookupBuffer(BufferCache cache, uint32_t slot,
                                                      bool useCache, buffer_handle_t handle,
                                                      buffer_handle_t* outHandle) {
+  std::lock_guard<std::mutex> lock(mClient.mDisplayDataMutex);
+  BufferCacheEntry* entry;
+  Error error = lookupBufferCacheEntryLocked(cache, slot, &entry);
+  if (error != Error::NONE) {
+    return error;
+  }
+
   if (useCache) {
-    std::lock_guard<std::mutex> lock(mClient.mDisplayDataMutex);
-
-    BufferCacheEntry* entry;
-    Error error = lookupBufferCacheEntryLocked(cache, slot, &entry);
-    if (error != Error::NONE) {
-      return error;
-    }
-
     // input handle is ignored
     *outHandle = entry->getHandle();
   } else if (cache == BufferCache::LAYER_SIDEBAND_STREAMS) {
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index 35051f6..a8e559b 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -1386,10 +1386,6 @@
   HandleFrameOutput();
   PostCommitStitchLayers();
 
-  if (flush_ && layer_stack_.output_buffer == nullptr) {
-    display_intf_->FlushConcurrentWriteback();
-  }
-
   auto status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
 /*  display_intf_->GetConfig(&fixed_info);
   is_cmd_mode_ = fixed_info.is_cmdmode;
diff --git a/composer/hwc_display_pluggable.cpp b/composer/hwc_display_pluggable.cpp
index 53efc3c..5c970c6 100644
--- a/composer/hwc_display_pluggable.cpp
+++ b/composer/hwc_display_pluggable.cpp
@@ -181,10 +181,6 @@
   auto status = HWC2::Error::None;
 
   HandleFrameOutput();
-
-  if (flush_ && layer_stack_.output_buffer == nullptr) {
-    display_intf_->FlushConcurrentWriteback();
-  }
   status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
 
   return status;
diff --git a/composer/hwc_display_virtual.cpp b/composer/hwc_display_virtual.cpp
index 94d7ccf..b1c1a1f 100644
--- a/composer/hwc_display_virtual.cpp
+++ b/composer/hwc_display_virtual.cpp
@@ -1,8 +1,6 @@
 /*
 * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
 *
-* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
-*
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
@@ -29,41 +27,11 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*
-* Changes from Qualcomm Innovation Center are provided under the following license:
-*
-* Copyright (c) 2022 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
-* disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
-*      contributors may be used to endorse or promote products derived
-*      from this software without specific prior written permission.
-*
-* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
-* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
-* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
-*/
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
 
 #include <utils/constants.h>
 #include <utils/debug.h>
@@ -123,7 +91,7 @@
     if (output_handle_) {
       BufferInfo buffer_info;
       const native_handle_t *output_handle =
-          reinterpret_cast<const native_handle_t *>(output_buffer_.buffer_id);
+          reinterpret_cast<const native_handle_t *>(output_buffer_->buffer_id);
       void *base_ptr = NULL;
       int error = buffer_allocator_->MapBuffer(output_handle, nullptr, &base_ptr);
       if (error != 0) {
@@ -183,16 +151,16 @@
       return HWC2::Error::BadParameter;
     }
 
-    output_buffer_.flags.secure = 0;
-    output_buffer_.flags.video = 0;
-    output_buffer_.buffer_id = reinterpret_cast<uint64_t>(output_handle);
-    output_buffer_.format = new_sdm_format;
-    output_buffer_.color_metadata = color_metadata;
+    output_buffer_->flags.secure = 0;
+    output_buffer_->flags.video = 0;
+    output_buffer_->buffer_id = reinterpret_cast<uint64_t>(output_handle);
+    output_buffer_->format = new_sdm_format;
+    output_buffer_->color_metadata = color_metadata;
     output_handle_ = output_handle;
 
     // TZ Protected Buffer - L1
     if (output_handle_flags & qtigralloc::PRIV_FLAGS_SECURE_BUFFER) {
-      output_buffer_.flags.secure = 1;
+      output_buffer_->flags.secure = 1;
     }
 
     // ToDo: Need to extend for non-RGB formats
@@ -200,12 +168,12 @@
     uint32_t width = 0;
     buffer_allocator_->GetFd((void *)output_handle, fd);
     buffer_allocator_->GetWidth((void *)output_handle, width);
-    output_buffer_.planes[0].fd = fd;
-    output_buffer_.planes[0].offset = 0;
-    output_buffer_.planes[0].stride = width;
+    output_buffer_->planes[0].fd = fd;
+    output_buffer_->planes[0].offset = 0;
+    output_buffer_->planes[0].stride = width;
   }
 
-  output_buffer_.acquire_fence = release_fence;
+  output_buffer_->acquire_fence = release_fence;
 
   return HWC2::Error::None;
 }
diff --git a/composer/hwc_display_virtual.h b/composer/hwc_display_virtual.h
index fb15e41..b75e263 100644
--- a/composer/hwc_display_virtual.h
+++ b/composer/hwc_display_virtual.h
@@ -27,41 +27,11 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
-* Changes from Qualcomm Innovation Center are provided under the following license:
-*
-* Copyright (c) 2022 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
-* disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
-*      contributors may be used to endorse or promote products derived
-*      from this software without specific prior written permission.
-*
-* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
-* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
-* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
-*/
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
 
 #ifndef __HWC_DISPLAY_VIRTUAL_H__
 #define __HWC_DISPLAY_VIRTUAL_H__
@@ -95,7 +65,7 @@
  protected:
   uint32_t width_ = 0;
   uint32_t height_ = 0;
-  LayerBuffer output_buffer_ = {};
+  std::shared_ptr<LayerBuffer> output_buffer_ = std::make_shared<LayerBuffer>();
   const native_handle_t *output_handle_ = nullptr;
 
  private:
diff --git a/composer/hwc_display_virtual_dpu.cpp b/composer/hwc_display_virtual_dpu.cpp
index de3e4ed..681df00 100644
--- a/composer/hwc_display_virtual_dpu.cpp
+++ b/composer/hwc_display_virtual_dpu.cpp
@@ -27,6 +27,12 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
 #include <hwc_display_virtual_dpu.h>
 
 #define __CLASS__ "HWCDisplayVirtualDPU"
@@ -121,10 +127,10 @@
       }
     }
 
-    output_buffer_.width = UINT32(new_aligned_w);
-    output_buffer_.height = UINT32(new_aligned_h);
-    output_buffer_.unaligned_width = UINT32(new_width);
-    output_buffer_.unaligned_height = UINT32(new_height);
+    output_buffer_->width = UINT32(new_aligned_w);
+    output_buffer_->height = UINT32(new_aligned_h);
+    output_buffer_->unaligned_width = UINT32(new_width);
+    output_buffer_->unaligned_height = UINT32(new_height);
   }
 
   return HWC2::Error::None;
@@ -148,9 +154,9 @@
     layer->flags.updating = true;
   }
 
-  layer_stack_.output_buffer = &output_buffer_;
+  layer_stack_.output_buffer = output_buffer_;
   // If Output buffer of Virtual Display is not secure, set SKIP flag on the secure layers.
-  if (!output_buffer_.flags.secure && layer_stack_.flags.secure_present) {
+  if (!output_buffer_->flags.secure && layer_stack_.flags.secure_present) {
     for (auto hwc_layer : layer_set_) {
       Layer *layer = hwc_layer->GetSDMLayer();
       if (layer->input_buffer.flags.secure) {
@@ -178,7 +184,7 @@
 HWC2::Error HWCDisplayVirtualDPU::Present(shared_ptr<Fence> *out_retire_fence) {
   auto status = HWC2::Error::None;
 
-  if (!output_buffer_.buffer_id) {
+  if (!output_buffer_->buffer_id) {
     return HWC2::Error::NoResources;
   }
 
@@ -186,7 +192,7 @@
     return HWC2::Error::None;
   }
 
-  layer_stack_.output_buffer = &output_buffer_;
+  layer_stack_.output_buffer = output_buffer_;
 
   status = HWCDisplay::CommitLayerStack();
   if (status != HWC2::Error::None) {
@@ -217,7 +223,7 @@
                                                   uint32_t *out_num_requests, bool *needs_commit) {
   DTRACE_SCOPED();
 
-  layer_stack_.output_buffer = &output_buffer_;
+  layer_stack_.output_buffer = output_buffer_;
   auto status = HWCDisplay::CommitOrPrepare(validate_only, out_retire_fence, out_num_types,
                                             out_num_requests, needs_commit);
   return status;
diff --git a/composer/hwc_display_virtual_gpu.cpp b/composer/hwc_display_virtual_gpu.cpp
index e8b897f..89e5182 100644
--- a/composer/hwc_display_virtual_gpu.cpp
+++ b/composer/hwc_display_virtual_gpu.cpp
@@ -27,8 +27,7 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * Changes from Qualcomm Innovation Center are provided under the following license:
+/* Changes from Qualcomm Innovation Center are provided under the following license:
  *
  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * SPDX-License-Identifier: BSD-3-Clause-Clear
@@ -144,17 +143,17 @@
   }
 
   native_handle_t *hnd = const_cast<native_handle_t *>(buf);
-  buffer_allocator_->GetWidth(hnd, output_buffer_.width);
-  buffer_allocator_->GetHeight(hnd, output_buffer_.height);
-  buffer_allocator_->GetUnalignedWidth(hnd, output_buffer_.unaligned_width);
-  buffer_allocator_->GetUnalignedHeight(hnd, output_buffer_.unaligned_height);
+  buffer_allocator_->GetWidth(hnd, output_buffer_->width);
+  buffer_allocator_->GetHeight(hnd, output_buffer_->height);
+  buffer_allocator_->GetUnalignedWidth(hnd, output_buffer_->unaligned_width);
+  buffer_allocator_->GetUnalignedHeight(hnd, output_buffer_->unaligned_height);
 
   // Update active dimensions.
   if (qtigralloc::getMetadataState(hnd, android::gralloc4::MetadataType_Crop.value)) {
     int32_t slice_width = 0, slice_height = 0;
     if (!buffer_allocator_->GetBufferGeometry(hnd, slice_width, slice_height)) {
-      output_buffer_.unaligned_width = slice_width;
-      output_buffer_.unaligned_height = slice_height;
+      output_buffer_->unaligned_width = slice_width;
+      output_buffer_->unaligned_height = slice_height;
       // Update buffer width and height.
       int new_aligned_w = 0;
       int new_aligned_h = 0;
@@ -163,8 +162,8 @@
       buffer_allocator_->GetAlignedWidthAndHeight(INT(slice_width), INT(slice_height),
                                                   output_handle_format, 0, &new_aligned_w,
                                                   &new_aligned_h);
-      output_buffer_.width = UINT32(new_aligned_w);
-      output_buffer_.height = UINT32(new_aligned_h);
+      output_buffer_->width = UINT32(new_aligned_w);
+      output_buffer_->height = UINT32(new_aligned_h);
       color_convert_task_.PerformTask(ColorConvertTaskCode::kCodeReset, nullptr);
     }
   }
@@ -177,7 +176,7 @@
 
   auto status = HWC2::Error::None;
 
-  if (!output_buffer_.buffer_id) {
+  if (!output_buffer_->buffer_id) {
     return HWC2::Error::NoResources;
   }
 
@@ -185,7 +184,7 @@
     return status;
   }
 
-  layer_stack_.output_buffer = &output_buffer_;
+  layer_stack_.output_buffer = output_buffer_;
 
   // Ensure that blit is initialized.
   // GPU context gets in secure or non-secure mode depending on output buffer provided.
@@ -206,10 +205,10 @@
   LayerBuffer &input_buffer = sdm_layer->input_buffer;
   ctx.src_hnd = reinterpret_cast<const native_handle_t *>(input_buffer.buffer_id);
   ctx.dst_hnd = reinterpret_cast<const native_handle_t *>(output_handle_);
-  ctx.dst_rect = {0, 0, FLOAT(output_buffer_.unaligned_width),
-                  FLOAT(output_buffer_.unaligned_height)};
+  ctx.dst_rect = {0, 0, FLOAT(output_buffer_->unaligned_width),
+                  FLOAT(output_buffer_->unaligned_height)};
   ctx.src_acquire_fence = input_buffer.acquire_fence;
-  ctx.dst_acquire_fence = output_buffer_.acquire_fence;
+  ctx.dst_acquire_fence = output_buffer_->acquire_fence;
 
   color_convert_task_.PerformTask(ColorConvertTaskCode::kCodeBlit, &ctx);
 
@@ -225,7 +224,7 @@
                                   SyncTask<ColorConvertTaskCode>::TaskContext *task_context) {
   switch (task_code) {
     case ColorConvertTaskCode::kCodeGetInstance: {
-        gl_color_convert_ = GLColorConvert::GetInstance(kTargetYUV, output_buffer_.flags.secure);
+        gl_color_convert_ = GLColorConvert::GetInstance(kTargetYUV, output_buffer_->flags.secure);
       }
       break;
     case ColorConvertTaskCode::kCodeBlit: {
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index 959d03e..4f2b3dd 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -4159,10 +4159,12 @@
   }
 
   std::bitset<kSecureMax> secure_sessions = 0;
+  HWC2::PowerMode current_power_mode = HWC2::PowerMode::Off;
   {
     SEQUENCE_WAIT_SCOPE_LOCK(locker_[target_display]);
     if (hwc_display_[target_display]) {
       hwc_display_[target_display]->GetActiveSecureSession(&secure_sessions);
+      current_power_mode = hwc_display_[target_display]->GetCurrentPowerMode();
     }
   }
 
@@ -4171,6 +4173,11 @@
     return -ENOTSUP;
   }
 
+  if (current_power_mode != HWC2::PowerMode::On) {
+    DLOGW("TUI session not allowed as target display is not powered On");
+    return -ENOTSUP;
+  }
+
   std::vector<DisplayMapInfo> map_info = {map_info_primary_};
   std::copy(map_info_builtin_.begin(), map_info_builtin_.end(), std::back_inserter(map_info));
   std::copy(map_info_pluggable_.begin(), map_info_pluggable_.end(), std::back_inserter(map_info));
diff --git a/config/display-product.mk b/config/display-product.mk
index 4990265..41df82f 100644
--- a/config/display-product.mk
+++ b/config/display-product.mk
@@ -54,6 +54,7 @@
     debug.sf.hw=0 \
     debug.egl.hw=0 \
     debug.sf.latch_unsignaled=1 \
+    debug.sf.auto_latch_unsignaled=0 \
     debug.mdpcomp.logs=0 \
     vendor.gralloc.disable_ubwc=0 \
     vendor.gralloc.enable_logs=0 \
diff --git a/init/init.qti.display_boot.sh b/init/init.qti.display_boot.sh
index ca8be18..ba0a9f7 100644
--- a/init/init.qti.display_boot.sh
+++ b/init/init.qti.display_boot.sh
@@ -63,8 +63,9 @@
     #SOC ID for Kalama is 519
     #SOC ID for Kalama SG36 is 600
     #SOC ID for Kalama SG p is 601
+    #SOC ID for Kalama APQ 536
     case "$soc_hwid" in
-       519|600|601|603|604)
+       519|600|601|603|604|536)
         #Set property for kalama
         #SOC ID for QCS Kalama is 603
         #SOC ID for QCM Kalama is 604
@@ -89,6 +90,28 @@
         ;;
     esac
     ;;
+    "crow")
+    #SOC ID for Crow is 608
+    case "$soc_hwid" in
+       608)
+        #SOC ID for Crow is 608
+        setprop vendor.display.enable_fb_scaling 0
+        setprop vendor.display.target.version 4
+        setprop vendor.gralloc.use_dma_buf_heaps 1
+        setprop vendor.display.enable_posted_start_dyn 2
+        setprop vendor.display.enable_allow_idle_fallback 1
+        setprop vendor.display.enable_perf_hint_large_comp_cycle 1
+        setprop vendor.display.enable_rotator_ui 1
+        setprop vendor.display.enable_spec_fence 1
+        setprop vendor.display.thermal.version 1
+        setprop vendor.display.enable_rc_support 1
+        setprop vendor.display.enable_latch_media_content 1
+        setprop vendor.display.enable_inline_writeback 0
+        setprop vendor.display.timed_render_enable 1
+        setprop debug.sf.disable_client_composition_cache 0
+        ;;
+    esac
+    ;;
     "taro")
     #Set property to differentiate Waipio
     #SOC ID for Waipio is 457
diff --git a/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index a987365..ce31f82 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -30,37 +30,8 @@
 /*
 * Changes from Qualcomm Innovation Center are provided under the following license:
 *
-* Copyright (c) 2022 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
-* disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
-*      contributors may be used to endorse or promote products derived
-*      from this software without specific prior written permission.
-*
-* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
-* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
-* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
+* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+* SPDX-License-Identifier: BSD-3-Clause-Clear
 */
 
 #ifndef __DRM_INTERFACE_H__
@@ -680,6 +651,12 @@
   kInlineRotationV2,
 };
 
+/* DDR Version */
+enum struct DDRVersion {
+  kDDRVersion4,
+  kDDRVersion5,
+};
+
 /* Type for panel feature resource reservation info */
 typedef std::tuple<std::string, int32_t, int8_t> FetchResource;
 typedef std::vector<FetchResource> FetchResourceList;
@@ -734,6 +711,7 @@
   bool skip_inline_rot_threshold = false;
   bool has_noise_layer = false;
   uint32_t dsc_block_count = 0;
+  DDRVersion ddr_version = DDRVersion::kDDRVersion5;
 };
 
 enum struct DRMPlaneType {
diff --git a/sde-drm/drm_crtc.cpp b/sde-drm/drm_crtc.cpp
index 57eeeb9..3b53532 100755
--- a/sde-drm/drm_crtc.cpp
+++ b/sde-drm/drm_crtc.cpp
@@ -27,6 +27,13 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+/*
+* Changes from Qualcomm Innovation Center are provided under the following license:
+*
+* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+* SPDX-License-Identifier: BSD-3-Clause-Clear
+*/
+
 #include <stdint.h>
 #include <stdlib.h>
 #include <drm.h>
@@ -454,6 +461,7 @@
   string dspp_count = "dspp_count=";
   string skip_inline_rot_threshold="skip_inline_rot_threshold=";
   string dsc_block_count = "dsc_block_count=";
+  string ddr_version = "DDR version=";
 
   while (std::getline(stream, line)) {
     if (line.find(max_blendstages) != string::npos) {
@@ -584,6 +592,12 @@
         std::stoi(string(line, skip_inline_rot_threshold.length()));
     } else if (line.find(dsc_block_count) != string::npos) {
       crtc_info_.dsc_block_count = std::stoi(string(line, dsc_block_count.length()));
+    } else if (line.find(ddr_version) != string::npos) {
+      if (string(line, ddr_version.length()) == "DDR4") {
+        crtc_info_.ddr_version = DDRVersion::kDDRVersion4;
+      } else if(string(line, ddr_version.length()) == "DDR5") {
+        crtc_info_.ddr_version = DDRVersion::kDDRVersion5;
+        }
     }
   }
   drmModeFreePropertyBlob(blob);
diff --git a/sdm/include/core/dpps_interface.h b/sdm/include/core/dpps_interface.h
index af5dc81..2d68f08 100644
--- a/sdm/include/core/dpps_interface.h
+++ b/sdm/include/core/dpps_interface.h
@@ -27,13 +27,18 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+/*
+* Changes from Qualcomm Innovation Center are provided under the following license:
+*
+* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+* SPDX-License-Identifier: BSD-3-Clause-Clear
+*/
+
 #ifndef __DPPS_INTERFACE_H__
 #define __DPPS_INTERFACE_H__
 
 #include <core/sdm_types.h>
-#if !defined(LINUX_COMPILE) && !defined(WIN32) && !defined(_WIN64) && !defined(__APPLE__)
 #include <core/display_interface.h>
-#endif
 #include <color_metadata.h>
 
 #include <string>
@@ -95,7 +100,8 @@
 
 class DppsInterface {
  public:
-  virtual int Init(DppsPropIntf* intf, const std::string &panel_name) = 0;
+  virtual int Init(DppsPropIntf *intf, const std::string &panel_name,
+                   DisplayInterface *display_intf) = 0;
   virtual int Deinit() = 0;
   virtual int DppsNotifyOps(enum DppsNotifyOps op, void *payload, size_t size) = 0;
 
@@ -105,9 +111,11 @@
 
 class DppsDummyImpl : public DppsInterface {
  public:
-  int Init(DppsPropIntf* intf, const std::string &panel_name) {
+  int Init(DppsPropIntf *intf, const std::string &panel_name,
+           DisplayInterface *display_intf = nullptr) {
     (void)intf;
     (void)panel_name;
+    (void)display_intf;
     return 0;
   }
   int Deinit() {
diff --git a/sdm/include/core/layer_stack.h b/sdm/include/core/layer_stack.h
index 5995739..71452ed 100644
--- a/sdm/include/core/layer_stack.h
+++ b/sdm/include/core/layer_stack.h
@@ -22,41 +22,11 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*
-* Changes from Qualcomm Innovation Center are provided under the following license:
-*
-* Copyright (c) 2022 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
-* disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
-*      contributors may be used to endorse or promote products derived
-*      from this software without specific prior written permission.
-*
-* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
-* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
-* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
-*/
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
 
 /*! @file layer_stack.h
   @brief File for display layer stack structure which represents a drawing buffer.
@@ -571,7 +541,8 @@
                                        //!< descriptor.
                                        //!< NOTE: This field applies to a physical display only.
 
-  LayerBuffer *output_buffer = NULL;   //!< Pointer to the buffer where composed buffer would be
+  std::shared_ptr<LayerBuffer> output_buffer = nullptr;
+                                       //!< Pointer to the buffer where composed buffer would be
                                        //!< rendered for virtual displays.
                                        //!< NOTE: This field applies to a virtual display only.
 
diff --git a/sdm/include/private/hw_info_types.h b/sdm/include/private/hw_info_types.h
index cc4b47a..4376199 100644
--- a/sdm/include/private/hw_info_types.h
+++ b/sdm/include/private/hw_info_types.h
@@ -22,41 +22,11 @@
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*
-* Changes from Qualcomm Innovation Center are provided under the following license:
-*
-* Copyright (c) 2022 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
-* disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
-*      contributors may be used to endorse or promote products derived
-*      from this software without specific prior written permission.
-*
-* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
-* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
-* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
-*/
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
 
 #ifndef __HW_INFO_TYPES_H__
 #define __HW_INFO_TYPES_H__
@@ -337,6 +307,11 @@
   kInlineRotationV2,
 };
 
+enum DDRVersion {
+  kDDRVersion4,
+  kDDRVersion5,
+};
+
 struct InlineRotationInfo {
   InlineRotationVersion inrot_version = kInlineRotationNone;
   std::vector<LayerBufferFormat> inrot_fmts_supported;
@@ -423,6 +398,7 @@
   bool skip_inline_rot_threshold = false;
   bool has_noise_layer = false;
   uint32_t dsc_block_count = 0;
+  DDRVersion ddr_version = kDDRVersion5;
 };
 
 struct HWSplitInfo {
@@ -908,7 +884,8 @@
   shared_ptr<Fence> retire_fence = nullptr;  // Retire fence for current draw cycle.
   LayerStackFlags flags;               //!< Flags associated with this layer set.
   PrimariesTransfer blend_cs = {};     //!< o/p - Blending color space of the frame, updated by SDM
-  LayerBuffer *output_buffer = NULL;   //!< Pointer to the buffer where composed buffer would be
+  std::shared_ptr<LayerBuffer> output_buffer = nullptr;
+                                       //!< Pointer to the buffer where composed buffer would be
                                        //!< rendered for virtual displays.
                                        //!< NOTE: This field applies to a virtual display only.
   uint32_t output_fb_id = 0;           //!< FB ID of the output buffer of virtual display
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 6642ca8..45fc72c 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -2111,7 +2111,7 @@
     return os.str();
   }
 
-  LayerBuffer *out_buffer = disp_layer_stack_.info.output_buffer;
+  std::shared_ptr<LayerBuffer> out_buffer = disp_layer_stack_.info.output_buffer;
   if (out_buffer) {
     os << "\n Output buffer res: " << out_buffer->width << "x" << out_buffer->height
        << " format: " << GetFormatString(out_buffer->format);
@@ -3893,7 +3893,7 @@
 
 DisplayError DisplayBase::GetOutputBufferAcquireFence(shared_ptr<Fence> *out_fence) {
   ClientLock lock(disp_mutex_);
-  LayerBuffer *out_buffer = disp_layer_stack_.info.output_buffer;
+  std::shared_ptr<LayerBuffer> out_buffer = disp_layer_stack_.info.output_buffer;
   if (out_buffer == nullptr) {
     return kErrorNotSupported;
   }
@@ -4215,9 +4215,11 @@
 
 /* this func is called by DC dimming feature only after PCC updates */
 void DisplayBase::ScreenRefresh() {
-  ClientLock lock(disp_mutex_);
-  /* do not skip validate */
-  validated_ = false;
+  {
+    ClientLock lock(disp_mutex_);
+    /* do not skip validate */
+    validated_ = false;
+  }
   event_handler_->Refresh();
 }
 
diff --git a/sdm/libs/core/display_builtin.cpp b/sdm/libs/core/display_builtin.cpp
index 6a074a9..13fa618 100644
--- a/sdm/libs/core/display_builtin.cpp
+++ b/sdm/libs/core/display_builtin.cpp
@@ -990,7 +990,7 @@
     dpps_pu_nofiy_pending_ = false;
     dpps_pu_lock_.Broadcast();
   }
-  dpps_info_.Init(this, hw_panel_info_.panel_name);
+  dpps_info_.Init(this, hw_panel_info_.panel_name, this);
 
   if (demuratn_)
     EnableDemuraTn(true);
@@ -1776,7 +1776,7 @@
     return os.str();
   }
 
-  LayerBuffer *out_buffer = disp_layer_stack_.info.output_buffer;
+  std::shared_ptr<LayerBuffer> out_buffer = disp_layer_stack_.info.output_buffer;
   if (out_buffer) {
     os << "\n Output buffer res: " << out_buffer->width << "x" << out_buffer->height
        << " format: " << GetFormatString(out_buffer->format);
@@ -1927,12 +1927,13 @@
 DppsInterface* DppsInfo::dpps_intf_ = NULL;
 std::vector<int32_t> DppsInfo::display_id_ = {};
 
-void DppsInfo::Init(DppsPropIntf *intf, const std::string &panel_name) {
+void DppsInfo::Init(DppsPropIntf *intf, const std::string &panel_name,
+                    DisplayInterface *display_intf) {
   std::lock_guard<std::mutex> guard(lock_);
   int error = 0;
 
-  if (!intf) {
-    DLOGE("Invalid intf is null");
+  if (!intf || !display_intf) {
+    DLOGE("Invalid intf %pK display_intf %pK", intf, display_intf);
     return;
   }
 
@@ -1967,7 +1968,7 @@
       goto exit;
     }
   }
-  error = dpps_intf_->Init(intf, panel_name);
+  error = dpps_intf_->Init(intf, panel_name, display_intf);
   if (error) {
     DLOGE("DPPS Interface init failure with err %d", error);
     goto exit;
diff --git a/sdm/libs/core/display_builtin.h b/sdm/libs/core/display_builtin.h
index 758e8db..b2fe25c 100644
--- a/sdm/libs/core/display_builtin.h
+++ b/sdm/libs/core/display_builtin.h
@@ -94,7 +94,7 @@
 
 class DppsInfo {
  public:
-  void Init(DppsPropIntf *intf, const std::string &panel_name);
+  void Init(DppsPropIntf *intf, const std::string &panel_name, DisplayInterface *display_intf);
   void Deinit();
   void DppsNotifyOps(enum DppsNotifyOps op, void *payload, size_t size);
   bool disable_pu_ = false;
diff --git a/sdm/libs/dal/hw_device_drm.cpp b/sdm/libs/dal/hw_device_drm.cpp
index 5f04967..d93e006 100644
--- a/sdm/libs/dal/hw_device_drm.cpp
+++ b/sdm/libs/dal/hw_device_drm.cpp
@@ -27,8 +27,7 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*
- * Changes from Qualcomm Innovation Center are provided under the following license:
+/* Changes from Qualcomm Innovation Center are provided under the following license:
  *
  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * SPDX-License-Identifier: BSD-3-Clause-Clear
@@ -429,7 +428,7 @@
   }
 }
 
-void HWDeviceDRM::Registry::MapOutputBufferToFbId(LayerBuffer *output_buffer) {
+void HWDeviceDRM::Registry::MapOutputBufferToFbId(std::shared_ptr<LayerBuffer> output_buffer) {
   if (output_buffer->planes[0].fd < 0) {
     return;
   }
@@ -1950,11 +1949,25 @@
   // dpps commit feature ops doesn't use the obj id, set it as -1
   drm_atomic_intf_->Perform(DRMOps::DPPS_COMMIT_FEATURE, -1);
 
+  if (cwb_config_.cwb_disp_id == display_id_ && cwb_config_.enabled) {
+    drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, cwb_config_.token.conn_id, 0);
+    DLOGI("Tearing down the CWB topology");
+  }
+
   int ret = NullCommit(sync_commit /* synchronous */, false /* retain_planes*/);
   if (ret) {
     DLOGE("failed with error %d", ret);
     return kErrorHardware;
   }
+
+  if (cwb_config_.cwb_disp_id == display_id_) {
+    if (cwb_config_.enabled) {
+      FlushConcurrentWriteback();
+    } else {
+      cwb_config_.cwb_disp_id = -1;
+    }
+  }
+
   return kErrorNone;
 }
 
@@ -2996,7 +3009,7 @@
 
 void HWDeviceDRM::ConfigureConcurrentWriteback(const HWLayersInfo &hw_layer_info) {
   CwbConfig *cwb_config = hw_layer_info.hw_cwb_config;
-  LayerBuffer *output_buffer = hw_layer_info.output_buffer;
+  std::shared_ptr<LayerBuffer> output_buffer = hw_layer_info.output_buffer;
   registry_.MapOutputBufferToFbId(output_buffer);
   uint32_t &vitual_conn_id = cwb_config_.token.conn_id;
 
@@ -3091,7 +3104,7 @@
   return kErrorNone;
 }
 
-void HWDeviceDRM::PostCommitConcurrentWriteback(LayerBuffer *output_buffer) {
+void HWDeviceDRM::PostCommitConcurrentWriteback(std::shared_ptr<LayerBuffer> output_buffer) {
   if (hw_resource_.has_concurrent_writeback && output_buffer) {
     return;
   }
diff --git a/sdm/libs/dal/hw_device_drm.h b/sdm/libs/dal/hw_device_drm.h
index 18506f3..93a209e 100644
--- a/sdm/libs/dal/hw_device_drm.h
+++ b/sdm/libs/dal/hw_device_drm.h
@@ -27,8 +27,7 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*
- * Changes from Qualcomm Innovation Center are provided under the following license:
+/* Changes from Qualcomm Innovation Center are provided under the following license:
  *
  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * SPDX-License-Identifier: BSD-3-Clause-Clear
@@ -114,7 +113,7 @@
                                 int64_t *release_fence_fd);
   DisplayError TeardownConcurrentWriteback(void);
   void ConfigureConcurrentWriteback(const HWLayersInfo &hw_layer_info);
-  void PostCommitConcurrentWriteback(LayerBuffer *output_buffer);
+  void PostCommitConcurrentWriteback(std::shared_ptr<LayerBuffer> output_buffer);
   virtual DisplayError GetPPFeaturesVersion(PPFeatureVersion *vers);
   virtual DisplayError SetPPFeature(PPFeatureInfo *feature);
   // This API is no longer supported, expectation is to call the correct API on HWEvents
@@ -262,7 +261,7 @@
     // Find handle_id in the layer map. Else create fb_id and add <handle_id,fb_id> in map.
     void MapBufferToFbId(Layer* layer, const LayerBuffer &buffer);
     // Find handle_id in output buffer map. Else create fb_id and add <handle_id,fb_id> in map.
-    void MapOutputBufferToFbId(LayerBuffer* buffer);
+    void MapOutputBufferToFbId(std::shared_ptr<LayerBuffer> buffer);
     // Find fb_id for given handle_id in the layer map.
     uint32_t GetFbId(Layer *layer, uint64_t handle_id);
     // Find fb_id for given handle_id in output buffer map.
diff --git a/sdm/libs/dal/hw_info_drm.cpp b/sdm/libs/dal/hw_info_drm.cpp
index 573b0b7..fd46ad5 100644
--- a/sdm/libs/dal/hw_info_drm.cpp
+++ b/sdm/libs/dal/hw_info_drm.cpp
@@ -368,6 +368,12 @@
   hw_resource->skip_inline_rot_threshold = info.skip_inline_rot_threshold;
   hw_resource->has_noise_layer = info.has_noise_layer;
 
+  if (info.ddr_version == sde_drm::DDRVersion::kDDRVersion4) {
+    hw_resource->ddr_version = kDDRVersion4;
+  } else if (info.ddr_version == sde_drm::DDRVersion::kDDRVersion5) {
+    hw_resource->ddr_version = kDDRVersion5;
+  }
+
   for (int index = 0; index < kBwModeMax; index++) {
     if (index == kBwVFEOn) {
       hw_resource->dyn_bw_info.total_bw_limit[index] = info.max_bandwidth_low / kKiloUnit;
diff --git a/sdm/libs/dal/hw_virtual_drm.cpp b/sdm/libs/dal/hw_virtual_drm.cpp
index 37d323f..9cc4a2d 100644
--- a/sdm/libs/dal/hw_virtual_drm.cpp
+++ b/sdm/libs/dal/hw_virtual_drm.cpp
@@ -27,41 +27,11 @@
 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-/*
-* Changes from Qualcomm Innovation Center are provided under the following license:
-*
-* Copyright (c) 2022 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
-* disclaimer below) 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 Qualcomm Innovation Center, Inc. nor the names of its
-*      contributors may be used to endorse or promote products derived
-*      from this software without specific prior written permission.
-*
-* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
-* GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
-* HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
-* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-* IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
-*/
+/* Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
 
 #include <stdio.h>
 #include <ctype.h>
@@ -223,7 +193,7 @@
 }
 
 DisplayError HWVirtualDRM::Commit(HWLayersInfo *hw_layers_info) {
-  LayerBuffer *output_buffer = hw_layers_info->output_buffer;
+  std::shared_ptr<LayerBuffer> output_buffer = hw_layers_info->output_buffer;
   DisplayError err = kErrorNone;
 
   registry_.Register(hw_layers_info);
@@ -259,7 +229,7 @@
 }
 
 DisplayError HWVirtualDRM::Validate(HWLayersInfo *hw_layers_info) {
-  LayerBuffer *output_buffer = hw_layers_info->output_buffer;
+  std::shared_ptr<LayerBuffer> output_buffer = hw_layers_info->output_buffer;
 
   registry_.MapOutputBufferToFbId(output_buffer);
   uint32_t fb_id = registry_.GetOutputFbId(output_buffer->handle_id);