Merge ebb5dddd63fe0befc1582504a403af4388cea94c on remote branch

Change-Id: I41f1267a41e42518d2868780b7659648a44c3253
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp
index 9204192..bd67a46 100644
--- a/composer/hwc_session.cpp
+++ b/composer/hwc_session.cpp
@@ -1320,6 +1320,23 @@
 
     virtual_display_list_.push_back(info);
   }
+
+  if (virtual_display_list_.empty() && virtual_display_factory_.IsGPUColorConvertSupported()) {
+    AddGpuBasedVirtualDisplay(&hw_displays_info);
+  }
+}
+
+void HWCSession::AddGpuBasedVirtualDisplay(const HWDisplaysInfo* const hw_displays_info) {
+  HWDisplayInfo hw_info = {};
+  hw_info.display_type = kVirtual;
+  hw_info.is_connected = true;
+  hw_info.is_primary = false;
+  hw_info.is_wb_ubwc_supported = true;
+  hw_info.display_id = 0;
+  while (hw_displays_info->find(hw_info.display_id) != hw_displays_info->end()) {
+    hw_info.display_id++;
+  }
+  virtual_display_list_.push_back(hw_info);
 }
 
 HWC2::Error HWCSession::CheckWbAvailability() {
diff --git a/composer/hwc_session.h b/composer/hwc_session.h
index 283da9d..8c32a01 100644
--- a/composer/hwc_session.h
+++ b/composer/hwc_session.h
@@ -610,6 +610,7 @@
   void GetVirtualDisplayList();
   HWC2::Error CheckWbAvailability();
   bool IsHWDisplayConnected(hwc2_display_t client_id);
+  void AddGpuBasedVirtualDisplay(const HWDisplaysInfo* const hw_displays_info);
 
   CoreInterface *core_intf_ = nullptr;
   HWCDisplay *hwc_display_[HWCCallbacks::kNumDisplays] = {nullptr};
diff --git a/composer/hwc_session_services.cpp b/composer/hwc_session_services.cpp
index a069d81..b61c3b5 100644
--- a/composer/hwc_session_services.cpp
+++ b/composer/hwc_session_services.cpp
@@ -570,8 +570,8 @@
 int HWCSession::ControlIdlePowerCollapse(bool enable, bool synchronous) {
   hwc2_display_t active_builtin_disp_id = GetActiveBuiltinDisplay();
   if (active_builtin_disp_id >= HWCCallbacks::kNumDisplays) {
-    DLOGE("No active displays");
-    return -EINVAL;
+    DLOGW("No active displays");
+    return 0;
   }
   bool needs_refresh = false;
   {
diff --git a/gpu_tonemapper/EGLImageWrapper.cpp b/gpu_tonemapper/EGLImageWrapper.cpp
index 5b3d1e0..75b3512 100644
--- a/gpu_tonemapper/EGLImageWrapper.cpp
+++ b/gpu_tonemapper/EGLImageWrapper.cpp
@@ -4,8 +4,6 @@
  *
  * Copyright 2015 The Android Open Source Project
  *
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -19,6 +17,13 @@
  * limitations under the 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
+ */
+
 #include "EGLImageWrapper.h"
 #include <cutils/native_handle.h>
 #include <QtiGralloc.h>
@@ -128,7 +133,7 @@
   CropRectangle_t crop;
   if (gralloc::GetMetaDataValue(const_cast<private_handle_t *>(src),
                                 (int64_t)StandardMetadataType::CROP,
-                                &crop) != gralloc::Error::NONE) {
+                                &crop) == gralloc::Error::NONE) {
     unaligned_width = crop.right;
     unaligned_height = crop.bottom;
     uint32_t aligned_height = 0;
diff --git a/sdm/libs/core/hw_info_default.cpp b/sdm/libs/core/hw_info_default.cpp
index 9f8d69f..6b78bcc 100644
--- a/sdm/libs/core/hw_info_default.cpp
+++ b/sdm/libs/core/hw_info_default.cpp
@@ -30,11 +30,12 @@
 
 DisplayError HWInfoDefault::GetDisplaysStatus(HWDisplaysInfo *hw_displays_info) {
   HWDisplayInfo hw_info = {};
+
   hw_info.display_type = kBuiltIn;
-  hw_info.is_connected = 1;
-  hw_info.is_primary = 1;
-  hw_info.is_wb_ubwc_supported = 0;
-  hw_info.display_id = 1;
+  hw_info.is_connected = true;
+  hw_info.is_primary = true;
+  hw_info.is_wb_ubwc_supported = false;
+  hw_info.display_id = 0;
   (*hw_displays_info)[hw_info.display_id] = hw_info;
   DLOGI("display: %4d-%d, connected: %s, primary: %s", hw_info.display_id, hw_info.display_type,
         hw_info.is_connected ? "true" : "false", hw_info.is_primary ? "true" : "false");