sf: Clean up properties for virtual display
Currently, the properties are used as follows:
1. debug.sf.enable_hwc_vds - allows IDs to be generated for VDs
2. vendor.display.vds_allow_hwc - allows WFD to use HWC path
With this change, HWC path is enabled for WFD with only the vendor
property set. All other virtual displays require both of the
properties enabled.
Change-Id: Iab2c8d15d2c1cf24be0d371af8892c346634507f
CRs-Fixed: 3204941
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 6321883..f3c807b 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -912,9 +912,8 @@
enableLatchUnsignaledConfig = getLatchUnsignaledConfig();
- if (base::GetBoolProperty("debug.sf.enable_hwc_vds"s, false)) {
- enableHalVirtualDisplays(true);
- }
+ mAllowHwcForWFD = base::GetBoolProperty("vendor.display.vds_allow_hwc"s, false);
+ mAllowHwcForVDS = mAllowHwcForWFD && base::GetBoolProperty("debug.sf.enable_hwc_vds"s, false);
// Process hotplug for displays connected at boot.
LOG_ALWAYS_FATAL_IF(!configureLocked(),
@@ -3819,21 +3818,18 @@
status = state.surface->query(NATIVE_WINDOW_FORMAT, &format);
ALOGE_IF(status != NO_ERROR, "Unable to query format (%d)", status);
pixelFormat = static_cast<ui::PixelFormat>(format);
- if (mVirtualDisplayIdGenerators.hal) {
- size_t maxVirtualDisplaySize = getHwComposer().getMaxVirtualDisplayDimension();
- if (maxVirtualDisplaySize == 0 ||
- ((uint64_t)resolution.width <= maxVirtualDisplaySize &&
- (uint64_t)resolution.height <= maxVirtualDisplaySize)) {
- uint64_t usage = 0;
- // Replace with native_window_get_consumer_usage ?
- status = state .surface->getConsumerUsage(&usage);
- ALOGW_IF(status != NO_ERROR, "Unable to query usage (%d)", status);
- if ((status == NO_ERROR) && canAllocateHwcDisplayIdForVDS(usage)) {
- canAllocateHwcForVDS = true;
- }
+ // Check if VDS is allowed to use HWC
+ size_t maxVirtualDisplaySize = getHwComposer().getMaxVirtualDisplayDimension();
+ if (maxVirtualDisplaySize == 0 || ((uint64_t)resolution.width <= maxVirtualDisplaySize &&
+ (uint64_t)resolution.height <= maxVirtualDisplaySize)) {
+ uint64_t usage = 0;
+ // Replace with native_window_get_consumer_usage ?
+ status = state .surface->getConsumerUsage(&usage);
+ ALOGW_IF(status != NO_ERROR, "Unable to query usage (%d)", status);
+ if ((status == NO_ERROR) && canAllocateHwcDisplayIdForVDS(usage)) {
+ canAllocateHwcForVDS = true;
}
}
-
} else {
// Virtual displays without a surface are dormant:
// they have external state (layer stack, projection,
@@ -8829,15 +8825,22 @@
bool SurfaceFlinger::canAllocateHwcDisplayIdForVDS(uint64_t usage) {
uint64_t flag_mask_pvt_wfd = ~0;
uint64_t flag_mask_hw_video = ~0;
- char value[PROPERTY_VALUE_MAX] = {};
- property_get("vendor.display.vds_allow_hwc", value, "0");
- int allowHwcForVDS = atoi(value);
// Reserve hardware acceleration for WFD use-case
// GRALLOC_USAGE_PRIVATE_WFD + GRALLOC_USAGE_HW_VIDEO_ENCODER = WFD using HW composer.
flag_mask_pvt_wfd = GRALLOC_USAGE_PRIVATE_WFD;
flag_mask_hw_video = GRALLOC_USAGE_HW_VIDEO_ENCODER;
- return (allowHwcForVDS || ((usage & flag_mask_pvt_wfd) &&
- (usage & flag_mask_hw_video)));
+ // Enabling only the vendor property would allow WFD to use HWC
+ // Enabling both the aosp and vendor properties would allow all other VDS to use HWC
+ // Disabling both would set all virtual displays to fall back to GPU
+ bool canAllocate = mAllowHwcForVDS || (mAllowHwcForWFD && (usage & flag_mask_pvt_wfd) &&
+ (usage & flag_mask_hw_video));
+
+ if (canAllocate) {
+ enableHalVirtualDisplays(true);
+ }
+
+ return canAllocate;
+
}
status_t SurfaceFlinger::setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken,