Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 152438d4 authored by Rheygine Medel's avatar Rheygine Medel Committed by Bruno Martins
Browse files

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
parent b38ec86d
Loading
Loading
Loading
Loading
+24 −21
Original line number Diff line number Diff line
@@ -853,9 +853,8 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) {

    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(),
@@ -3402,10 +3401,9 @@ void SurfaceFlinger::processDisplayAdded(const wp<IBinder>& displayToken,
        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) {
        // Check if VDS is allowed to use HWC
        size_t maxVirtualDisplaySize = getHwComposer().getMaxVirtualDisplayDimension();
            if (maxVirtualDisplaySize == 0 ||
                ((uint64_t)resolution.width <= maxVirtualDisplaySize &&
        if (maxVirtualDisplaySize == 0 || ((uint64_t)resolution.width <= maxVirtualDisplaySize &&
            (uint64_t)resolution.height <= maxVirtualDisplaySize)) {
            uint64_t usage = 0;
            // Replace with native_window_get_consumer_usage ?
@@ -3415,8 +3413,6 @@ void SurfaceFlinger::processDisplayAdded(const wp<IBinder>& displayToken,
                canAllocateHwcForVDS = true;
            }
        }
        }

    } else {
        // Virtual displays without a surface are dormant:
        // they have external state (layer stack, projection,
@@ -7766,15 +7762,22 @@ gui::DisplayModeSpecs::RefreshRateRanges translate(const FpsRanges& ranges) {
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,
+2 −0
Original line number Diff line number Diff line
@@ -1422,6 +1422,8 @@ private:
    const sp<WindowInfosListenerInvoker> mWindowInfosListenerInvoker;

    FlagManager mFlagManager;
    bool mAllowHwcForVDS = false;
    bool mAllowHwcForWFD = false;

    // returns the framerate of the layer with the given sequence ID
    float getLayerFramerate(nsecs_t now, int32_t id) const {