Merge "composer: Resume non target displays incase of TUI failure"
diff --git a/sdm/include/private/feature_license_intf.h b/sdm/include/private/feature_license_intf.h
new file mode 100644
index 0000000..ce93ace
--- /dev/null
+++ b/sdm/include/private/feature_license_intf.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ */
+
+#ifndef __FEATURE_LICENSE_INTF_H__
+#define __FEATURE_LICENSE_INTF_H__
+
+#include <private/generic_intf.h>
+#include <private/generic_payload.h>
+
+namespace sdm {
+
+enum FeatureLicenseId {
+ kDemura,
+ kAntiAging,
+ kFeatureLicenseIdMax = 255,
+};
+
+// Feature license intf params as enum
+enum FeatureLicenseParams {
+ kFeatureLicenseParamMax = 255,
+};
+
+// Feature license intf ops as enum
+enum FeatureLicenseOps {
+ kValidatePermission,
+ kFeatureLicenseOpsMax = 255,
+};
+
+struct FeatureValidatePermissionInput {
+ FeatureLicenseId id;
+};
+
+struct DemuraValidatePermissionInput : public FeatureValidatePermissionInput {
+ uint64_t panel_id;
+};
+
+struct AntiAgingValidatePermissionInput : public FeatureValidatePermissionInput {
+};
+
+using FeatureLicenseIntf = GenericIntf<FeatureLicenseParams, FeatureLicenseOps, GenericPayload>;
+
+class FeatureLicenseFactoryIntf {
+ public:
+ virtual ~FeatureLicenseFactoryIntf() {}
+ virtual std::shared_ptr<FeatureLicenseIntf> CreateFeatureLicenseIntf() = 0;
+};
+
+extern "C" FeatureLicenseFactoryIntf *GetFeatureLicenseFactoryIntf();
+
+} // namespace sdm
+
+#endif // __FEATURE_LICENSE_INTF_H__
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index edcc64a..fcacad6 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -25,7 +25,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.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
@@ -418,6 +418,19 @@
}
}
+ GetFeatureLicenseFactory get_feature_license_factory_ptr = nullptr;
+ if (!feature_impl_lib.Sym(GET_FEATURE_LICENSE_FACTORY,
+ reinterpret_cast<void **>(&get_feature_license_factory_ptr))) {
+ DLOGW("Unable to load symbols, error = %s", feature_impl_lib.Error());
+ return kErrorUndefined;
+ }
+
+ feature_license_factory_ = get_feature_license_factory_ptr();
+ if (!feature_license_factory_) {
+ DLOGE("Failed to create FeatureLicenseFactory");
+ return kErrorResources;
+ }
+
DLOGI("Setup pf factory and prop intf for Panel Features");
return kErrorNone;
}
diff --git a/sdm/libs/core/display_base.h b/sdm/libs/core/display_base.h
index 85acf94..2ba9c94 100644
--- a/sdm/libs/core/display_base.h
+++ b/sdm/libs/core/display_base.h
@@ -27,7 +27,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.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
@@ -41,6 +41,7 @@
#include <private/panel_feature_property_intf.h>
#include <private/panel_feature_factory_intf.h>
#include <private/demuratn_core_uvm_fact_intf.h>
+#include <private/feature_license_intf.h>
#include <private/noise_plugin_intf.h>
#include <private/noise_plugin_dbg.h>
#include <private/hw_interface.h>
@@ -59,6 +60,7 @@
#define GET_PANEL_FEATURE_FACTORY "GetPanelFeatureFactoryIntf"
#define GET_DEMURATN_FACTORY "GetDemuraTnCoreUvmFactoryIntf"
+#define GET_FEATURE_LICENSE_FACTORY "GetFeatureLicenseFactoryIntf"
namespace sdm {
@@ -70,6 +72,7 @@
typedef PanelFeatureFactoryIntf* (*GetPanelFeatureFactory)();
typedef DemuraTnCoreUvmFactoryIntf* (*GetDemuraTnFactory)();
+typedef FeatureLicenseFactoryIntf* (*GetFeatureLicenseFactory)();
class DisplayBase : public DisplayInterface, public CompManagerEventHandler {
public:
@@ -415,6 +418,7 @@
PanelFeatureFactoryIntf *pf_factory_ = nullptr;
PanelFeaturePropertyIntf *prop_intf_ = nullptr;
DemuraTnCoreUvmFactoryIntf *demuratn_factory_ = nullptr;
+ FeatureLicenseFactoryIntf *feature_license_factory_ = nullptr;
bool first_cycle_ = true;
bool registered_hw_events_ = false;
bool unified_draw_supported_ = true; // By default supported, unless disabled by property.
diff --git a/sdm/libs/core/display_builtin.cpp b/sdm/libs/core/display_builtin.cpp
index da704f5..5f5cf38 100644
--- a/sdm/libs/core/display_builtin.cpp
+++ b/sdm/libs/core/display_builtin.cpp
@@ -25,7 +25,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.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
@@ -169,21 +169,7 @@
return error;
}
- DisplayError tmp = kErrorNone;
- if ((tmp = SetupDemura()) != kErrorNone) {
- // Non-fatal but not expected, log error
- DLOGE("Demura failed to initialize on display %d-%d, Error = %d", display_id_,
- display_type_, tmp);
- comp_manager_->FreeDemuraFetchResources(display_id_);
- comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
- if (demura_) {
- SetDemuraIntfStatus(false);
- }
- } else if (demuratn_factory_) {
- if ((tmp = SetupDemuraTn()) != kErrorNone) {
- DLOGW("Failed to setup DemuraTn, Error = %d", tmp);
- }
- }
+ SetupDemuraT0AndTn();
} else {
DLOGW("Skipping Panel Feature Setups!");
}
@@ -509,128 +495,96 @@
}
DisplayError DisplayBuiltIn::SetupDemura() {
- if (!comp_manager_->GetDemuraStatus()) {
- comp_manager_->FreeDemuraFetchResources(display_id_);
- comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
- return kErrorNone;
+ DemuraInputConfig input_cfg;
+ input_cfg.secure_session = false; // TODO(user): Integrate with secure solution
+ std::string brightness_base;
+ hw_intf_->GetPanelBrightnessBasePath(&brightness_base);
+ input_cfg.brightness_path = brightness_base+"brightness";
+
+ FetchResourceList frl;
+ comp_manager_->GetDemuraFetchResources(display_comp_ctx_, &frl);
+ for (auto &fr : frl) {
+ int i = std::get<1>(fr); // fetch resource index
+ input_cfg.resources.set(i);
}
- int value = 0;
- uint64_t panel_id = 0;
- int panel_id_w = 0;
- if (IsPrimaryDisplay()) {
- Debug::Get()->GetProperty(DEMURA_PRIMARY_PANEL_OVERRIDE_LOW, &panel_id_w);
- panel_id = static_cast<uint32_t>(panel_id_w);
- Debug::Get()->GetProperty(DEMURA_PRIMARY_PANEL_OVERRIDE_HIGH, &panel_id_w);
- panel_id |= ((static_cast<uint64_t>(panel_id_w)) << 32);
- DLOGI("panel overide total value %lx\n", panel_id);
- Debug::Get()->GetProperty(DISABLE_DEMURA_PRIMARY, &value);
- } else {
- Debug::Get()->GetProperty(DEMURA_SECONDARY_PANEL_OVERRIDE_LOW, &panel_id_w);
- panel_id = static_cast<uint32_t>(panel_id_w);
- Debug::Get()->GetProperty(DEMURA_SECONDARY_PANEL_OVERRIDE_HIGH, &panel_id_w);
- panel_id |= ((static_cast<uint64_t>(panel_id_w)) << 32);
- DLOGI("panel overide total value %lx\n", panel_id);
- Debug::Get()->GetProperty(DISABLE_DEMURA_SECONDARY, &value);
- }
-
- if (value > 0) {
- comp_manager_->FreeDemuraFetchResources(display_id_);
- comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
- return kErrorNone;
- } else if (value == 0) {
- DemuraInputConfig input_cfg;
- input_cfg.secure_session = false; // TODO(user): Integrate with secure solution
- std::string brightness_base;
- hw_intf_->GetPanelBrightnessBasePath(&brightness_base);
- input_cfg.brightness_path = brightness_base+"brightness";
-
- FetchResourceList frl;
- comp_manager_->GetDemuraFetchResources(display_comp_ctx_, &frl);
- for (auto &fr : frl) {
- int i = std::get<1>(fr); // fetch resource index
- input_cfg.resources.set(i);
- }
-
#ifdef TRUSTED_VM
- int ret = 0;
- GenericPayload out;
- IPCImportBufOutParams *buf_out_params = nullptr;
- if ((ret = out.CreatePayload<IPCImportBufOutParams>(buf_out_params))) {
- DLOGE("Failed to create output payload error = %d", ret);
- return kErrorUndefined;
- }
+ int ret = 0;
+ GenericPayload out;
+ IPCImportBufOutParams *buf_out_params = nullptr;
+ if ((ret = out.CreatePayload<IPCImportBufOutParams>(buf_out_params))) {
+ DLOGE("Failed to create output payload error = %d", ret);
+ return kErrorUndefined;
+ }
- GenericPayload in;
- IPCImportBufInParams *buf_in_params = nullptr;
- if ((ret = in.CreatePayload<IPCImportBufInParams>(buf_in_params))) {
- DLOGE("Failed to create input payload error = %d", ret);
- return kErrorUndefined;
- }
- buf_in_params->req_buf_type = kIpcBufferTypeDemuraHFC;
+ GenericPayload in;
+ IPCImportBufInParams *buf_in_params = nullptr;
+ if ((ret = in.CreatePayload<IPCImportBufInParams>(buf_in_params))) {
+ DLOGE("Failed to create input payload error = %d", ret);
+ return kErrorUndefined;
+ }
+ buf_in_params->req_buf_type = kIpcBufferTypeDemuraHFC;
- if ((ret = ipc_intf_->ProcessOps(kIpcOpsImportBuffers, in, &out))) {
- DLOGE("Failed to kIpcOpsImportBuffers payload error = %d", ret);
- return kErrorUndefined;
- }
- DLOGI("DemuraHFC buffer fd %d size %d", buf_out_params->buffers[0].fd,
- buf_out_params->buffers[0].size);
+ if ((ret = ipc_intf_->ProcessOps(kIpcOpsImportBuffers, in, &out))) {
+ DLOGE("Failed to kIpcOpsImportBuffers payload error = %d", ret);
+ return kErrorUndefined;
+ }
+ DLOGI("DemuraHFC buffer fd %d size %d", buf_out_params->buffers[0].fd,
+ buf_out_params->buffers[0].size);
- if (buf_out_params->buffers[0].fd < 0) {
- DLOGE("HFC buffer import error fd :%d ", buf_out_params->buffers[0].fd);
- return kErrorUndefined;
- }
+ if (buf_out_params->buffers[0].fd < 0) {
+ DLOGE("HFC buffer import error fd :%d ", buf_out_params->buffers[0].fd);
+ return kErrorUndefined;
+ }
- input_cfg.secure_hfc_fd = buf_out_params->buffers[0].fd;
- input_cfg.secure_hfc_size = buf_out_params->buffers[0].size;
- input_cfg.panel_id = buf_out_params->buffers[0].panel_id;
- input_cfg.secure_session = true;
- hfc_buffer_fd_ = buf_out_params->buffers[0].fd;
- hfc_buffer_size_ = buf_out_params->buffers[0].size;
+ input_cfg.secure_hfc_fd = buf_out_params->buffers[0].fd;
+ input_cfg.secure_hfc_size = buf_out_params->buffers[0].size;
+ input_cfg.panel_id = buf_out_params->buffers[0].panel_id;
+ input_cfg.secure_session = true;
+ hfc_buffer_fd_ = buf_out_params->buffers[0].fd;
+ hfc_buffer_size_ = buf_out_params->buffers[0].size;
#endif
- DLOGI("panel id %lx\n", input_cfg.panel_id);
- input_cfg.panel_id = panel_id;
- std::unique_ptr<DemuraIntf> demura =
- pf_factory_->CreateDemuraIntf(input_cfg, prop_intf_, buffer_allocator_, spr_);
- if (!demura) {
- DLOGE("Unable to create Demura on Display %d-%d", display_id_, display_type_);
- return kErrorMemory;
- }
+ input_cfg.panel_id = panel_id_;
+ DLOGI("panel id %lx\n", input_cfg.panel_id);
+ std::unique_ptr<DemuraIntf> demura =
+ pf_factory_->CreateDemuraIntf(input_cfg, prop_intf_, buffer_allocator_, spr_);
+ if (!demura) {
+ DLOGE("Unable to create Demura on Display %d-%d", display_id_, display_type_);
+ return kErrorMemory;
+ }
- demura_ = std::move(demura);
- if (demura_->Init() != 0) {
- DLOGE("Unable to initialize Demura on Display %d-%d", display_id_, display_type_);
- return kErrorUndefined;
- }
+ demura_ = std::move(demura);
+ if (demura_->Init() != 0) {
+ DLOGE("Unable to initialize Demura on Display %d-%d", display_id_, display_type_);
+ return kErrorUndefined;
+ }
- if (SetupDemuraLayer() != kErrorNone) {
- DLOGE("Unable to setup Demura layer on Display %d-%d", display_id_, display_type_);
- return kErrorUndefined;
- }
+ if (SetupDemuraLayer() != kErrorNone) {
+ DLOGE("Unable to setup Demura layer on Display %d-%d", display_id_, display_type_);
+ return kErrorUndefined;
+ }
- if (SetDemuraIntfStatus(true)) {
- return kErrorUndefined;
- }
+ if (SetDemuraIntfStatus(true)) {
+ return kErrorUndefined;
+ }
- comp_manager_->SetDemuraStatusForDisplay(display_id_, true);
- demura_intended_ = true;
- DLOGI("Enabled Demura Core!");
+ comp_manager_->SetDemuraStatusForDisplay(display_id_, true);
+ demura_intended_ = true;
+ DLOGI("Enabled Demura Core!");
#ifndef TRUSTED_VM
- GenericPayload pl;
- uint64_t *panel_id_ptr = nullptr;
- int rc = 0;
- if ((rc = pl.CreatePayload<uint64_t>(panel_id_ptr))) {
- DLOGE("Failed to create payload for Paneld, error = %d", rc);
- }
- demura_->GetParameter(kDemuraFeatureParamPanelId, &pl);
- vm_cb_intf_ = new DisplayIPCVmCallbackImpl(buffer_allocator_, ipc_intf_,
- *panel_id_ptr, hfc_buffer_width_, hfc_buffer_height_);
- vm_cb_intf_->Init();
-#endif
- return kErrorNone;
+ GenericPayload pl;
+ uint64_t *panel_id_ptr = nullptr;
+ int rc = 0;
+ if ((rc = pl.CreatePayload<uint64_t>(panel_id_ptr))) {
+ DLOGE("Failed to create payload for Paneld, error = %d", rc);
}
- return kErrorUndefined;
+ demura_->GetParameter(kDemuraFeatureParamPanelId, &pl);
+ vm_cb_intf_ = new DisplayIPCVmCallbackImpl(buffer_allocator_, ipc_intf_,
+ *panel_id_ptr, hfc_buffer_width_, hfc_buffer_height_);
+ vm_cb_intf_->Init();
+#endif
+ return kErrorNone;
}
DisplayError DisplayBuiltIn::SetupDemuraLayer() {
@@ -730,6 +684,139 @@
}
}
+DisplayError DisplayBuiltIn::SetupDemuraT0AndTn() {
+ DisplayError error = kErrorNone;
+ int ret = 0, value = 0, panel_id_w = 0;
+ uint64_t panel_id = 0;
+ bool demura_allowed = false, demuratn_allowed = false;
+
+ if (!comp_manager_->GetDemuraStatus()) {
+ comp_manager_->FreeDemuraFetchResources(display_id_);
+ comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
+ return kErrorNone;
+ }
+
+ if (IsPrimaryDisplay()) {
+ Debug::Get()->GetProperty(DEMURA_PRIMARY_PANEL_OVERRIDE_LOW, &panel_id_w);
+ panel_id = static_cast<uint32_t>(panel_id_w);
+ Debug::Get()->GetProperty(DEMURA_PRIMARY_PANEL_OVERRIDE_HIGH, &panel_id_w);
+ panel_id |= ((static_cast<uint64_t>(panel_id_w)) << 32);
+ Debug::Get()->GetProperty(DISABLE_DEMURA_PRIMARY, &value);
+ DLOGI("panel overide total value %lx\n", panel_id);
+ } else {
+ Debug::Get()->GetProperty(DEMURA_SECONDARY_PANEL_OVERRIDE_LOW, &panel_id_w);
+ panel_id = static_cast<uint32_t>(panel_id_w);
+ Debug::Get()->GetProperty(DEMURA_SECONDARY_PANEL_OVERRIDE_HIGH, &panel_id_w);
+ panel_id |= ((static_cast<uint64_t>(panel_id_w)) << 32);
+ Debug::Get()->GetProperty(DISABLE_DEMURA_SECONDARY, &value);
+ DLOGI("panel overide total value %lx\n", panel_id);
+ }
+
+ if (value > 0) {
+ comp_manager_->FreeDemuraFetchResources(display_id_);
+ comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
+ return kErrorNone;
+ } else if (value < 0) {
+ return kErrorUndefined;
+ }
+
+ PanelFeaturePropertyInfo info;
+ if (!panel_id) {
+ info.prop_ptr = reinterpret_cast<uint64_t>(&panel_id);
+ info.prop_id = kPanelFeatureDemuraPanelId;
+ ret = prop_intf_->GetPanelFeature(&info);
+ if (ret) {
+ DLOGE("Failed to get panel id, error = %d", ret);
+ return kErrorUndefined;
+ }
+ }
+ panel_id_ = panel_id;
+ DLOGI("panel_id 0x%lx", panel_id_);
+
+#ifndef SDM_UNIT_TESTING
+ if (!feature_license_factory_) {
+ DLOGI("Feature license factory is not available");
+ return kErrorNone;
+ }
+
+ std::shared_ptr<FeatureLicenseIntf> feat_license_intf =
+ feature_license_factory_->CreateFeatureLicenseIntf();
+ if (!feat_license_intf) {
+ feature_license_factory_ = nullptr;
+ DLOGE("Failed to create FeatureLicenseIntf");
+ return kErrorUndefined;
+ }
+ ret = feat_license_intf->Init();
+ if (ret) {
+ DLOGE("Failed to init FeatureLicenseIntf");
+ return kErrorUndefined;
+ }
+
+ GenericPayload demura_pl, aa_pl, out_pl;
+ DemuraValidatePermissionInput *demura_input = nullptr;
+ ret = demura_pl.CreatePayload<DemuraValidatePermissionInput>(demura_input);
+ if (ret) {
+ DLOGE("Failed to create the payload. Error:%d", ret);
+ return kErrorUndefined;
+ }
+
+ bool *allowed = nullptr;
+ ret = out_pl.CreatePayload<bool>(allowed);
+ if (ret) {
+ DLOGE("Failed to create the payload. Error:%d", ret);
+ return kErrorUndefined;
+ }
+
+ demura_input->id = kDemura;
+ demura_input->panel_id = panel_id_;
+ ret = feat_license_intf->ProcessOps(kValidatePermission, demura_pl, &out_pl);
+ if (ret) {
+ DLOGE("Failed to get the license permission for Demura. Error:%d", ret);
+ return kErrorUndefined;
+ }
+ demura_allowed = *allowed;
+
+ AntiAgingValidatePermissionInput *aa_input = nullptr;
+ ret = aa_pl.CreatePayload<AntiAgingValidatePermissionInput>(aa_input);
+ if (ret) {
+ DLOGE("Failed to create the payload. Error:%d", ret);
+ return kErrorUndefined;
+ }
+
+ aa_input->id = kAntiAging;
+ ret = feat_license_intf->ProcessOps(kValidatePermission, aa_pl, &out_pl);
+ if (ret) {
+ DLOGE("Failed to get the license permission for Anti-aging. Error:%d", ret);
+ return kErrorUndefined;
+ }
+ demuratn_allowed = *allowed;
+#else
+ demura_allowed = true;
+ demuratn_allowed = true;
+#endif
+
+ DLOGI("Demura enable allowed %d, Anti-aging enable allowed %d", demura_allowed, demuratn_allowed);
+ if (demura_allowed) {
+ error = SetupDemura();
+ if (error != kErrorNone) {
+ // Non-fatal but not expected, log error
+ DLOGE("Demura failed to initialize on display %d-%d, Error = %d", display_id_, display_type_,
+ error);
+ comp_manager_->FreeDemuraFetchResources(display_id_);
+ comp_manager_->SetDemuraStatusForDisplay(display_id_, false);
+ if (demura_) {
+ SetDemuraIntfStatus(false);
+ }
+ } else if (demuratn_allowed && demuratn_factory_) {
+ error = SetupDemuraTn();
+ if (error != kErrorNone) {
+ DLOGW("Failed to setup DemuraTn, Error = %d", error);
+ }
+ }
+ }
+ return kErrorNone;
+}
+
DisplayError DisplayBuiltIn::SetupDemuraTn() {
int ret = 0;
diff --git a/sdm/libs/core/display_builtin.h b/sdm/libs/core/display_builtin.h
index 9ca3395..758e8db 100644
--- a/sdm/libs/core/display_builtin.h
+++ b/sdm/libs/core/display_builtin.h
@@ -25,7 +25,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.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*/
@@ -40,6 +40,7 @@
#include <private/extension_interface.h>
#include <private/spr_intf.h>
#include <private/demuratn_core_uvm_fact_intf.h>
+#include <private/feature_license_intf.h>
#include <private/panel_feature_property_intf.h>
#include <private/panel_feature_factory_intf.h>
#include <private/hw_events_interface.h>
@@ -235,6 +236,7 @@
DisplayError SetupDemuraLayer();
DisplayError SetupDemuraTn();
DisplayError EnableDemuraTn(bool enable);
+ DisplayError SetupDemuraT0AndTn();
DisplayError BuildLayerStackStats(LayerStack *layer_stack) override;
void UpdateDisplayModeParams();
void HandleQsyncPostCommit();
@@ -295,6 +297,7 @@
std::shared_ptr<DemuraIntf> demura_ = nullptr;
bool demuratn_enabled_ = false;
std::shared_ptr<DemuraTnCoreUvmIntf> demuratn_ = nullptr;
+ uint64_t panel_id_;
Layer demura_layer_ = {};
bool demura_intended_ = false;
bool demura_dynamic_enabled_ = true;