composer 2.4: add api to control vsync period
Add new functions to improve vsync period switching by the platform:
- Adding a list of supported vsync periods to Config to avoid the need to expose
separate Configs for each vsync period.
- Adding an API to set the vsync period with timeline constraints to allow better
synchronization with vsync period change.
- Extending onVsync() callback to provide the current vsync period.
Test: rev up composer to 2.4 and test refresh rate switching
Bug: 141329414
Change-Id: I1a6f395d9634edadc68649d02f624f00173ec519
diff --git a/graphics/composer/2.4/utils/vts/ComposerVts.cpp b/graphics/composer/2.4/utils/vts/ComposerVts.cpp
index 937b50e..b02a59a 100644
--- a/graphics/composer/2.4/utils/vts/ComposerVts.cpp
+++ b/graphics/composer/2.4/utils/vts/ComposerVts.cpp
@@ -25,7 +25,7 @@
namespace V2_4 {
namespace vts {
-using V2_1::Error;
+using V2_4::Error;
Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {}
@@ -70,6 +70,40 @@
return error;
}
+Error ComposerClient::getSupportedDisplayVsyncPeriods(
+ Display display, Config config, std::vector<VsyncPeriodNanos>* outSupportedVsyncPeriods) {
+ Error error = Error::NONE;
+ mClient->getSupportedDisplayVsyncPeriods(
+ display, config, [&](const auto& tmpError, const auto& tmpSupportedVsyncPeriods) {
+ error = tmpError;
+ *outSupportedVsyncPeriods = tmpSupportedVsyncPeriods;
+ });
+ return error;
+}
+
+Error ComposerClient::getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) {
+ Error error = Error::NONE;
+ mClient->getDisplayVsyncPeriod(display, [&](const auto& tmpError, const auto& tmpVsyncPeriod) {
+ error = tmpError;
+ *outVsyncPeriod = tmpVsyncPeriod;
+ });
+ return error;
+}
+
+Error ComposerClient::setActiveConfigAndVsyncPeriod(
+ Display display, Config config, VsyncPeriodNanos vsyncPeriodNanos,
+ const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
+ int64_t* outNewVsyncAppliedTime) {
+ Error error = Error::NONE;
+ mClient->setActiveConfigAndVsyncPeriod(
+ display, config, vsyncPeriodNanos, vsyncPeriodChangeConstraints,
+ [&](const auto& tmpError, const auto& tmpNewVsyncAppliedTime) {
+ error = tmpError;
+ *outNewVsyncAppliedTime = tmpNewVsyncAppliedTime;
+ });
+ return error;
+}
+
} // namespace vts
} // namespace V2_4
} // namespace composer
diff --git a/graphics/composer/2.4/utils/vts/include/composer-vts/2.4/ComposerVts.h b/graphics/composer/2.4/utils/vts/include/composer-vts/2.4/ComposerVts.h
index a7d7f86..e8a3905 100644
--- a/graphics/composer/2.4/utils/vts/include/composer-vts/2.4/ComposerVts.h
+++ b/graphics/composer/2.4/utils/vts/include/composer-vts/2.4/ComposerVts.h
@@ -37,10 +37,12 @@
using common::V1_2::Dataspace;
using common::V1_2::Hdr;
using common::V1_2::PixelFormat;
+using V2_1::Config;
using V2_1::Display;
-using V2_1::Error;
+using V2_4::Error;
using V2_4::IComposer;
using V2_4::IComposerClient;
+using V2_4::VsyncPeriodNanos;
class ComposerClient;
@@ -74,6 +76,16 @@
Error getDisplayConnectionType(Display display,
IComposerClient::DisplayConnectionType* outType);
+ Error getSupportedDisplayVsyncPeriods(Display display, Config config,
+ std::vector<VsyncPeriodNanos>* outSupportedVsyncPeriods);
+
+ Error getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriods);
+
+ Error setActiveConfigAndVsyncPeriod(
+ Display display, Config config, VsyncPeriodNanos vsyncPeriodNanos,
+ const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
+ int64_t* outNewVsyncAppliedTime);
+
private:
const sp<IComposerClient> mClient;
};