drm_hwcomposer: Fix VTS failures
Couple of extra adjustments to pass VTS tests:
Ensure the ComposerClient is a singleton
Return unsupported for PowerMode::ON_SUSPEND
Check that brightness is a valid non-negative float number
Change-Id: Ib4704580f41ebbbc39487612efc2b27c0681b356
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc3/Composer.cpp b/hwc3/Composer.cpp
index 2494488..4977a14 100644
--- a/hwc3/Composer.cpp
+++ b/hwc3/Composer.cpp
@@ -32,6 +32,10 @@
std::shared_ptr<IComposerClient>* out_client) {
DEBUG_FUNC();
+ if (!client_.expired()) {
+ return ToBinderStatus(hwc3::Error::kNoResources);
+ }
+
auto client = ndk::SharedRefBase::make<ComposerClient>();
if (!client || !client->Init()) {
*out_client = nullptr;
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index 6c03722..e49698f 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -25,6 +25,7 @@
#include <hardware/hwcomposer2.h>
#include <cinttypes>
+#include <cmath>
#include <memory>
#include <unordered_map>
#include <vector>
@@ -881,6 +882,10 @@
return ToBinderStatus(hwc3::Error::kBadDisplay);
}
+ if (mode == PowerMode::ON_SUSPEND) {
+ return ToBinderStatus(hwc3::Error::kUnsupported);
+ }
+
auto error = display->SetPowerMode(Hwc3PowerModeToHwc2(mode));
return ToBinderStatus(Hwc2toHwc3Error(error));
}