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

Commit a254e15d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "SurfaceFlinger: align init and resume mode priority" into rvc-dev am: 879095d2

Change-Id: Ib021d62333f17a6e6f53d40dbba5e8ab46b2b5ca
parents 0a08015c 879095d2
Loading
Loading
Loading
Loading
+25 −10
Original line number Original line Diff line number Diff line
@@ -4132,6 +4132,9 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, int
    }
    }


    if (currentMode == HWC_POWER_MODE_OFF) {
    if (currentMode == HWC_POWER_MODE_OFF) {
        if (SurfaceFlinger::setSchedFifo(true) != NO_ERROR) {
            ALOGW("Couldn't set SCHED_FIFO on display on: %s\n", strerror(errno));
        }
        getHwComposer().setPowerMode(*displayId, mode);
        getHwComposer().setPowerMode(*displayId, mode);
        if (display->isPrimary() && mode != HWC_POWER_MODE_DOZE_SUSPEND) {
        if (display->isPrimary() && mode != HWC_POWER_MODE_DOZE_SUSPEND) {
            setVsyncEnabledInHWC(*displayId, mHWCVsyncPendingState);
            setVsyncEnabledInHWC(*displayId, mHWCVsyncPendingState);
@@ -4142,19 +4145,11 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, int
        mVisibleRegionsDirty = true;
        mVisibleRegionsDirty = true;
        mHasPoweredOff = true;
        mHasPoweredOff = true;
        repaintEverything();
        repaintEverything();

        struct sched_param param = {0};
        param.sched_priority = 1;
        if (sched_setscheduler(0, SCHED_FIFO, &param) != 0) {
            ALOGW("Couldn't set SCHED_FIFO on display on");
        }
    } else if (mode == HWC_POWER_MODE_OFF) {
    } else if (mode == HWC_POWER_MODE_OFF) {
        // Turn off the display
        // Turn off the display
        struct sched_param param = {0};
        if (SurfaceFlinger::setSchedFifo(false) != NO_ERROR) {
        if (sched_setscheduler(0, SCHED_OTHER, &param) != 0) {
            ALOGW("Couldn't set SCHED_OTHER on display off: %s\n", strerror(errno));
            ALOGW("Couldn't set SCHED_OTHER on display off");
        }
        }

        if (display->isPrimary() && currentMode != HWC_POWER_MODE_DOZE_SUSPEND) {
        if (display->isPrimary() && currentMode != HWC_POWER_MODE_DOZE_SUSPEND) {
            mScheduler->disableHardwareVsync(true);
            mScheduler->disableHardwareVsync(true);
            mScheduler->onScreenReleased(mAppConnectionHandle);
            mScheduler->onScreenReleased(mAppConnectionHandle);
@@ -5341,6 +5336,26 @@ static Dataspace pickDataspaceFromColorMode(const ColorMode colorMode) {
    }
    }
}
}


status_t SurfaceFlinger::setSchedFifo(bool enabled) {
    static constexpr int kFifoPriority = 2;
    static constexpr int kOtherPriority = 0;

    struct sched_param param = {0};
    int sched_policy;
    if (enabled) {
        sched_policy = SCHED_FIFO;
        param.sched_priority = kFifoPriority;
    } else {
        sched_policy = SCHED_OTHER;
        param.sched_priority = kOtherPriority;
    }

    if (sched_setscheduler(0, sched_policy, &param) != 0) {
        return -errno;
    }
    return NO_ERROR;
}

const sp<DisplayDevice> SurfaceFlinger::getDisplayByIdOrLayerStack(uint64_t displayOrLayerStack) {
const sp<DisplayDevice> SurfaceFlinger::getDisplayByIdOrLayerStack(uint64_t displayOrLayerStack) {
    const sp<IBinder> displayToken = getPhysicalDisplayTokenLocked(DisplayId{displayOrLayerStack});
    const sp<IBinder> displayToken = getPhysicalDisplayTokenLocked(DisplayId{displayOrLayerStack});
    if (displayToken) {
    if (displayToken) {
+3 −0
Original line number Original line Diff line number Diff line
@@ -259,6 +259,9 @@ public:
    // overhead that is caused by reading from sysprop.
    // overhead that is caused by reading from sysprop.
    static bool useFrameRateApi;
    static bool useFrameRateApi;


    // set main thread scheduling policy
    static status_t setSchedFifo(bool enabled) ANDROID_API;

    static char const* getServiceName() ANDROID_API {
    static char const* getServiceName() ANDROID_API {
        return "SurfaceFlinger";
        return "SurfaceFlinger";
    }
    }
+3 −4
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@
#include <binder/ProcessState.h>
#include <binder/ProcessState.h>
#include <configstore/Utils.h>
#include <configstore/Utils.h>
#include <displayservice/DisplayService.h>
#include <displayservice/DisplayService.h>
#include <errno.h>
#include <hidl/LegacySupport.h>
#include <hidl/LegacySupport.h>
#include <processgroup/sched_policy.h>
#include <processgroup/sched_policy.h>
#include "SurfaceFlinger.h"
#include "SurfaceFlinger.h"
@@ -114,10 +115,8 @@ int main(int, char**) {


    startDisplayService(); // dependency on SF getting registered above
    startDisplayService(); // dependency on SF getting registered above


    struct sched_param param = {0};
    if (SurfaceFlinger::setSchedFifo(true) != NO_ERROR) {
    param.sched_priority = 2;
        ALOGW("Couldn't set to SCHED_FIFO: %s", strerror(errno));
    if (sched_setscheduler(0, SCHED_FIFO, &param) != 0) {
        ALOGE("Couldn't set SCHED_FIFO");
    }
    }


    // run surface flinger in this thread
    // run surface flinger in this thread