Support external display rendering in vr flinger
Add support for external displays to vr flinger, hidden behind a system
property until we're ready to use it. To turn it on for testing:
$ adb shell setprop persist.vr.use_external_display 1
With external display support turned on and an external display
connected, all output is redirected to the external display, and we
switch to the external display's vsync.
Bug: 75047963
Test: Most of the testing was done on a Polaris, which now supports
external display hotplugging.
- Tested external display connect/disconnect while the device was
donned.
- Tested external display connect/disconnect while doffed.
- Verified booting with the external display connected doesn't cause the
device to crash, although we don't seem to get a hotplug event for the
external display until the cable is disconnected and reconnected, so
we output to the primary display at first.
- Did some basic testing on a Walleye to confirm vr behavior there is
unchanged.
- Verified the external display is ignored when the sysprop is unset.
Change-Id: I3d3f40e276d354551fc1c577b9392709398ad96e
diff --git a/libs/vr/libvrflinger/display_service.cpp b/libs/vr/libvrflinger/display_service.cpp
index a18ff1a..87162c0 100644
--- a/libs/vr/libvrflinger/display_service.cpp
+++ b/libs/vr/libvrflinger/display_service.cpp
@@ -177,12 +177,12 @@
Status<display::Metrics> DisplayService::OnGetMetrics(
pdx::Message& /*message*/) {
- return {{static_cast<uint32_t>(GetDisplayMetrics().width),
- static_cast<uint32_t>(GetDisplayMetrics().height),
- static_cast<uint32_t>(GetDisplayMetrics().dpi.x),
- static_cast<uint32_t>(GetDisplayMetrics().dpi.y),
- static_cast<uint32_t>(
- hardware_composer_.native_display_metrics().vsync_period_ns),
+ const auto& params = hardware_composer_.GetPrimaryDisplayParams();
+ return {{static_cast<uint32_t>(params.width),
+ static_cast<uint32_t>(params.height),
+ static_cast<uint32_t>(params.dpi.x),
+ static_cast<uint32_t>(params.dpi.y),
+ static_cast<uint32_t>(params.vsync_period_ns),
0,
0,
0,