Loading services/surfaceflinger/SurfaceFlinger.cpp +25 −10 Original line number Original line Diff line number Diff line Loading @@ -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); Loading @@ -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, ¶m) != 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, ¶m) != 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); Loading Loading @@ -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, ¶m) != 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) { Loading services/surfaceflinger/SurfaceFlinger.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -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"; } } Loading services/surfaceflinger/main_surfaceflinger.cpp +3 −4 Original line number Original line Diff line number Diff line Loading @@ -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" Loading Loading @@ -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, ¶m) != 0) { ALOGE("Couldn't set SCHED_FIFO"); } } // run surface flinger in this thread // run surface flinger in this thread Loading Loading
services/surfaceflinger/SurfaceFlinger.cpp +25 −10 Original line number Original line Diff line number Diff line Loading @@ -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); Loading @@ -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, ¶m) != 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, ¶m) != 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); Loading Loading @@ -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, ¶m) != 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) { Loading
services/surfaceflinger/SurfaceFlinger.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -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"; } } Loading
services/surfaceflinger/main_surfaceflinger.cpp +3 −4 Original line number Original line Diff line number Diff line Loading @@ -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" Loading Loading @@ -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, ¶m) != 0) { ALOGE("Couldn't set SCHED_FIFO"); } } // run surface flinger in this thread // run surface flinger in this thread Loading