| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright 2018 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  */ | 
 | 16 |  | 
| Ana Krulec | 7ab5603 | 2018-11-02 20:51:06 +0100 | [diff] [blame] | 17 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS | 
 | 18 |  | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 19 | #include "Scheduler.h" | 
 | 20 |  | 
| Ana Krulec | 434c22d | 2018-11-28 13:48:36 +0100 | [diff] [blame] | 21 | #include <algorithm> | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 22 | #include <cinttypes> | 
 | 23 | #include <cstdint> | 
 | 24 | #include <memory> | 
| Ana Krulec | 7ab5603 | 2018-11-02 20:51:06 +0100 | [diff] [blame] | 25 | #include <numeric> | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 26 |  | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 27 | #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> | 
 | 28 | #include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h> | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 29 | #include <configstore/Utils.h> | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 30 | #include <cutils/properties.h> | 
| Ady Abraham | 8f1ee7f | 2019-04-05 10:32:50 -0700 | [diff] [blame] | 31 | #include <input/InputWindow.h> | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 32 | #include <system/window.h> | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 33 | #include <ui/DisplayStatInfo.h> | 
| Ana Krulec | 3084c05 | 2018-11-21 20:27:17 +0100 | [diff] [blame] | 34 | #include <utils/Timers.h> | 
| Ana Krulec | 7ab5603 | 2018-11-02 20:51:06 +0100 | [diff] [blame] | 35 | #include <utils/Trace.h> | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 36 |  | 
 | 37 | #include "DispSync.h" | 
 | 38 | #include "DispSyncSource.h" | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 39 | #include "EventControlThread.h" | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 40 | #include "EventThread.h" | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 41 | #include "IdleTimer.h" | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 42 | #include "InjectVSyncSource.h" | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 43 | #include "LayerInfo.h" | 
| Ana Krulec | 434c22d | 2018-11-28 13:48:36 +0100 | [diff] [blame] | 44 | #include "SchedulerUtils.h" | 
| Sundong Ahn | d5e08f6 | 2018-12-12 20:27:28 +0900 | [diff] [blame] | 45 | #include "SurfaceFlingerProperties.h" | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 46 |  | 
 | 47 | namespace android { | 
 | 48 |  | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 49 | using namespace android::hardware::configstore; | 
 | 50 | using namespace android::hardware::configstore::V1_0; | 
| Sundong Ahn | d5e08f6 | 2018-12-12 20:27:28 +0900 | [diff] [blame] | 51 | using namespace android::sysprop; | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 52 |  | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 53 | #define RETURN_VALUE_IF_INVALID(value) \ | 
 | 54 |     if (handle == nullptr || mConnections.count(handle->id) == 0) return value | 
 | 55 | #define RETURN_IF_INVALID() \ | 
 | 56 |     if (handle == nullptr || mConnections.count(handle->id) == 0) return | 
 | 57 |  | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 58 | std::atomic<int64_t> Scheduler::sNextId = 0; | 
 | 59 |  | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 60 | Scheduler::Scheduler(impl::EventControlThread::SetVSyncEnabledFunction function, | 
 | 61 |                      const scheduler::RefreshRateConfigs& refreshRateConfig) | 
| Sundong Ahn | d5e08f6 | 2018-12-12 20:27:28 +0900 | [diff] [blame] | 62 |       : mHasSyncFramework(running_without_sync_framework(true)), | 
 | 63 |         mDispSyncPresentTimeOffset(present_time_offset_from_vsync_ns(0)), | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 64 |         mPrimaryHWVsyncEnabled(false), | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 65 |         mHWVsyncAvailable(false), | 
 | 66 |         mRefreshRateConfigs(refreshRateConfig) { | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 67 |     // Note: We create a local temporary with the real DispSync implementation | 
 | 68 |     // type temporarily so we can initialize it with the configured values, | 
 | 69 |     // before storing it for more generic use using the interface type. | 
 | 70 |     auto primaryDispSync = std::make_unique<impl::DispSync>("SchedulerDispSync"); | 
 | 71 |     primaryDispSync->init(mHasSyncFramework, mDispSyncPresentTimeOffset); | 
 | 72 |     mPrimaryDispSync = std::move(primaryDispSync); | 
 | 73 |     mEventControlThread = std::make_unique<impl::EventControlThread>(function); | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 74 |  | 
| Ady Abraham | be59c0d | 2019-03-05 13:01:13 -0800 | [diff] [blame] | 75 |     mSetIdleTimerMs = set_idle_timer_ms(0); | 
| Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 76 |     mSupportKernelTimer = support_kernel_idle_timer(false); | 
| Ady Abraham | be59c0d | 2019-03-05 13:01:13 -0800 | [diff] [blame] | 77 |  | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 78 |     mSetTouchTimerMs = set_touch_timer_ms(0); | 
 | 79 |  | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 80 |     char value[PROPERTY_VALUE_MAX]; | 
| Ana Krulec | a5bdd9d | 2019-01-29 19:00:58 -0800 | [diff] [blame] | 81 |     property_get("debug.sf.set_idle_timer_ms", value, "0"); | 
| Ady Abraham | be59c0d | 2019-03-05 13:01:13 -0800 | [diff] [blame] | 82 |     int int_value = atoi(value); | 
 | 83 |     if (int_value) { | 
 | 84 |         mSetIdleTimerMs = atoi(value); | 
 | 85 |     } | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 86 |  | 
 | 87 |     if (mSetIdleTimerMs > 0) { | 
| Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 88 |         if (mSupportKernelTimer) { | 
 | 89 |             mIdleTimer = | 
 | 90 |                     std::make_unique<scheduler::IdleTimer>(std::chrono::milliseconds( | 
 | 91 |                                                                    mSetIdleTimerMs), | 
 | 92 |                                                            [this] { resetKernelTimerCallback(); }, | 
 | 93 |                                                            [this] { | 
 | 94 |                                                                expiredKernelTimerCallback(); | 
 | 95 |                                                            }); | 
 | 96 |         } else { | 
 | 97 |             mIdleTimer = std::make_unique<scheduler::IdleTimer>(std::chrono::milliseconds( | 
 | 98 |                                                                         mSetIdleTimerMs), | 
 | 99 |                                                                 [this] { resetTimerCallback(); }, | 
 | 100 |                                                                 [this] { expiredTimerCallback(); }); | 
 | 101 |         } | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 102 |         mIdleTimer->start(); | 
 | 103 |     } | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 104 |  | 
 | 105 |     if (mSetTouchTimerMs > 0) { | 
 | 106 |         // Touch events are coming to SF every 100ms, so the timer needs to be higher than that | 
 | 107 |         mTouchTimer = | 
 | 108 |                 std::make_unique<scheduler::IdleTimer>(std::chrono::milliseconds(mSetTouchTimerMs), | 
 | 109 |                                                        [this] { resetTouchTimerCallback(); }, | 
 | 110 |                                                        [this] { expiredTouchTimerCallback(); }); | 
 | 111 |         mTouchTimer->start(); | 
 | 112 |     } | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 113 | } | 
 | 114 |  | 
| Lloyd Pique | 1f9f1a4 | 2019-01-31 13:04:00 -0800 | [diff] [blame] | 115 | Scheduler::~Scheduler() { | 
 | 116 |     // Ensure the IdleTimer thread is joined before we start destroying state. | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 117 |     mTouchTimer.reset(); | 
| Lloyd Pique | 1f9f1a4 | 2019-01-31 13:04:00 -0800 | [diff] [blame] | 118 |     mIdleTimer.reset(); | 
 | 119 | } | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 120 |  | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 121 | sp<Scheduler::ConnectionHandle> Scheduler::createConnection( | 
| Dominik Laskowski | bd52c84 | 2019-01-28 18:11:23 -0800 | [diff] [blame] | 122 |         const char* connectionName, int64_t phaseOffsetNs, ResyncCallback resyncCallback, | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 123 |         impl::EventThread::InterceptVSyncsCallback interceptCallback) { | 
 | 124 |     const int64_t id = sNextId++; | 
 | 125 |     ALOGV("Creating a connection handle with ID: %" PRId64 "\n", id); | 
 | 126 |  | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 127 |     std::unique_ptr<EventThread> eventThread = | 
| Dominik Laskowski | f654d57 | 2018-12-20 11:03:06 -0800 | [diff] [blame] | 128 |             makeEventThread(connectionName, mPrimaryDispSync.get(), phaseOffsetNs, | 
| Dominik Laskowski | bd52c84 | 2019-01-28 18:11:23 -0800 | [diff] [blame] | 129 |                             std::move(interceptCallback)); | 
| Dominik Laskowski | f654d57 | 2018-12-20 11:03:06 -0800 | [diff] [blame] | 130 |  | 
| Dominik Laskowski | ccf37d7 | 2019-02-01 16:47:58 -0800 | [diff] [blame] | 131 |     auto eventThreadConnection = | 
| Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 132 |             createConnectionInternal(eventThread.get(), std::move(resyncCallback)); | 
| Dominik Laskowski | ccf37d7 | 2019-02-01 16:47:58 -0800 | [diff] [blame] | 133 |     mConnections.emplace(id, | 
 | 134 |                          std::make_unique<Connection>(new ConnectionHandle(id), | 
 | 135 |                                                       eventThreadConnection, | 
 | 136 |                                                       std::move(eventThread))); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 137 |     return mConnections[id]->handle; | 
 | 138 | } | 
 | 139 |  | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 140 | std::unique_ptr<EventThread> Scheduler::makeEventThread( | 
| Dominik Laskowski | bd52c84 | 2019-01-28 18:11:23 -0800 | [diff] [blame] | 141 |         const char* connectionName, DispSync* dispSync, int64_t phaseOffsetNs, | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 142 |         impl::EventThread::InterceptVSyncsCallback interceptCallback) { | 
 | 143 |     std::unique_ptr<VSyncSource> eventThreadSource = | 
| Dominik Laskowski | bd52c84 | 2019-01-28 18:11:23 -0800 | [diff] [blame] | 144 |             std::make_unique<DispSyncSource>(dispSync, phaseOffsetNs, true, connectionName); | 
 | 145 |     return std::make_unique<impl::EventThread>(std::move(eventThreadSource), | 
| Dominik Laskowski | ccf37d7 | 2019-02-01 16:47:58 -0800 | [diff] [blame] | 146 |                                                std::move(interceptCallback), connectionName); | 
 | 147 | } | 
 | 148 |  | 
| Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 149 | sp<EventThreadConnection> Scheduler::createConnectionInternal(EventThread* eventThread, | 
 | 150 |                                                               ResyncCallback&& resyncCallback) { | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 151 |     return eventThread->createEventConnection(std::move(resyncCallback)); | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 152 | } | 
 | 153 |  | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 154 | sp<IDisplayEventConnection> Scheduler::createDisplayEventConnection( | 
| Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 155 |         const sp<Scheduler::ConnectionHandle>& handle, ResyncCallback resyncCallback) { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 156 |     RETURN_VALUE_IF_INVALID(nullptr); | 
| Dominik Laskowski | ccf37d7 | 2019-02-01 16:47:58 -0800 | [diff] [blame] | 157 |     return createConnectionInternal(mConnections[handle->id]->thread.get(), | 
| Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 158 |                                     std::move(resyncCallback)); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 159 | } | 
 | 160 |  | 
 | 161 | EventThread* Scheduler::getEventThread(const sp<Scheduler::ConnectionHandle>& handle) { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 162 |     RETURN_VALUE_IF_INVALID(nullptr); | 
 | 163 |     return mConnections[handle->id]->thread.get(); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 164 | } | 
 | 165 |  | 
| Ana Krulec | 85c39af | 2018-12-26 17:29:57 -0800 | [diff] [blame] | 166 | sp<EventThreadConnection> Scheduler::getEventConnection(const sp<ConnectionHandle>& handle) { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 167 |     RETURN_VALUE_IF_INVALID(nullptr); | 
 | 168 |     return mConnections[handle->id]->eventConnection; | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 169 | } | 
 | 170 |  | 
 | 171 | void Scheduler::hotplugReceived(const sp<Scheduler::ConnectionHandle>& handle, | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 172 |                                 PhysicalDisplayId displayId, bool connected) { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 173 |     RETURN_IF_INVALID(); | 
| Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 174 |     mConnections[handle->id]->thread->onHotplugReceived(displayId, connected); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 175 | } | 
 | 176 |  | 
 | 177 | void Scheduler::onScreenAcquired(const sp<Scheduler::ConnectionHandle>& handle) { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 178 |     RETURN_IF_INVALID(); | 
 | 179 |     mConnections[handle->id]->thread->onScreenAcquired(); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 180 | } | 
 | 181 |  | 
 | 182 | void Scheduler::onScreenReleased(const sp<Scheduler::ConnectionHandle>& handle) { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 183 |     RETURN_IF_INVALID(); | 
 | 184 |     mConnections[handle->id]->thread->onScreenReleased(); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 185 | } | 
 | 186 |  | 
| Ady Abraham | 447052e | 2019-02-13 16:07:27 -0800 | [diff] [blame] | 187 | void Scheduler::onConfigChanged(const sp<ConnectionHandle>& handle, PhysicalDisplayId displayId, | 
 | 188 |                                 int32_t configId) { | 
 | 189 |     RETURN_IF_INVALID(); | 
 | 190 |     mConnections[handle->id]->thread->onConfigChanged(displayId, configId); | 
 | 191 | } | 
 | 192 |  | 
| Yiwei Zhang | 5434a78 | 2018-12-05 18:06:32 -0800 | [diff] [blame] | 193 | void Scheduler::dump(const sp<Scheduler::ConnectionHandle>& handle, std::string& result) const { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 194 |     RETURN_IF_INVALID(); | 
 | 195 |     mConnections.at(handle->id)->thread->dump(result); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 196 | } | 
 | 197 |  | 
 | 198 | void Scheduler::setPhaseOffset(const sp<Scheduler::ConnectionHandle>& handle, nsecs_t phaseOffset) { | 
| Ana Krulec | 0c8cd52 | 2018-08-31 12:27:28 -0700 | [diff] [blame] | 199 |     RETURN_IF_INVALID(); | 
 | 200 |     mConnections[handle->id]->thread->setPhaseOffset(phaseOffset); | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 201 | } | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 202 |  | 
 | 203 | void Scheduler::getDisplayStatInfo(DisplayStatInfo* stats) { | 
 | 204 |     stats->vsyncTime = mPrimaryDispSync->computeNextRefresh(0); | 
 | 205 |     stats->vsyncPeriod = mPrimaryDispSync->getPeriod(); | 
 | 206 | } | 
 | 207 |  | 
 | 208 | void Scheduler::enableHardwareVsync() { | 
 | 209 |     std::lock_guard<std::mutex> lock(mHWVsyncLock); | 
 | 210 |     if (!mPrimaryHWVsyncEnabled && mHWVsyncAvailable) { | 
 | 211 |         mPrimaryDispSync->beginResync(); | 
 | 212 |         mEventControlThread->setVsyncEnabled(true); | 
 | 213 |         mPrimaryHWVsyncEnabled = true; | 
 | 214 |     } | 
 | 215 | } | 
 | 216 |  | 
 | 217 | void Scheduler::disableHardwareVsync(bool makeUnavailable) { | 
 | 218 |     std::lock_guard<std::mutex> lock(mHWVsyncLock); | 
 | 219 |     if (mPrimaryHWVsyncEnabled) { | 
 | 220 |         mEventControlThread->setVsyncEnabled(false); | 
 | 221 |         mPrimaryDispSync->endResync(); | 
 | 222 |         mPrimaryHWVsyncEnabled = false; | 
 | 223 |     } | 
 | 224 |     if (makeUnavailable) { | 
 | 225 |         mHWVsyncAvailable = false; | 
 | 226 |     } | 
 | 227 | } | 
 | 228 |  | 
| Ana Krulec | c287042 | 2019-01-29 19:00:58 -0800 | [diff] [blame] | 229 | void Scheduler::resyncToHardwareVsync(bool makeAvailable, nsecs_t period) { | 
 | 230 |     { | 
 | 231 |         std::lock_guard<std::mutex> lock(mHWVsyncLock); | 
 | 232 |         if (makeAvailable) { | 
 | 233 |             mHWVsyncAvailable = makeAvailable; | 
 | 234 |         } else if (!mHWVsyncAvailable) { | 
 | 235 |             // Hardware vsync is not currently available, so abort the resync | 
 | 236 |             // attempt for now | 
 | 237 |             return; | 
 | 238 |         } | 
 | 239 |     } | 
 | 240 |  | 
 | 241 |     if (period <= 0) { | 
 | 242 |         return; | 
 | 243 |     } | 
 | 244 |  | 
 | 245 |     setVsyncPeriod(period); | 
 | 246 | } | 
 | 247 |  | 
 | 248 | ResyncCallback Scheduler::makeResyncCallback(GetVsyncPeriod&& getVsyncPeriod) { | 
 | 249 |     std::weak_ptr<VsyncState> ptr = mPrimaryVsyncState; | 
 | 250 |     return [ptr, getVsyncPeriod = std::move(getVsyncPeriod)]() { | 
 | 251 |         if (const auto vsync = ptr.lock()) { | 
 | 252 |             vsync->resync(getVsyncPeriod); | 
 | 253 |         } | 
 | 254 |     }; | 
 | 255 | } | 
 | 256 |  | 
 | 257 | void Scheduler::VsyncState::resync(const GetVsyncPeriod& getVsyncPeriod) { | 
 | 258 |     static constexpr nsecs_t kIgnoreDelay = ms2ns(500); | 
 | 259 |  | 
 | 260 |     const nsecs_t now = systemTime(); | 
 | 261 |     const nsecs_t last = lastResyncTime.exchange(now); | 
 | 262 |  | 
 | 263 |     if (now - last > kIgnoreDelay) { | 
 | 264 |         scheduler.resyncToHardwareVsync(false, getVsyncPeriod()); | 
 | 265 |     } | 
 | 266 | } | 
 | 267 |  | 
 | 268 | void Scheduler::setRefreshSkipCount(int count) { | 
 | 269 |     mPrimaryDispSync->setRefreshSkipCount(count); | 
 | 270 | } | 
 | 271 |  | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 272 | void Scheduler::setVsyncPeriod(const nsecs_t period) { | 
| Ady Abraham | 3aff917 | 2019-02-07 19:10:26 -0800 | [diff] [blame] | 273 |     std::lock_guard<std::mutex> lock(mHWVsyncLock); | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 274 |     mPrimaryDispSync->setPeriod(period); | 
| Ady Abraham | 3aff917 | 2019-02-07 19:10:26 -0800 | [diff] [blame] | 275 |  | 
 | 276 |     if (!mPrimaryHWVsyncEnabled) { | 
 | 277 |         mPrimaryDispSync->beginResync(); | 
 | 278 |         mEventControlThread->setVsyncEnabled(true); | 
 | 279 |         mPrimaryHWVsyncEnabled = true; | 
 | 280 |     } | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 281 | } | 
 | 282 |  | 
| Alec Mouri | 754c98a | 2019-03-18 18:53:42 -0700 | [diff] [blame] | 283 | void Scheduler::addResyncSample(const nsecs_t timestamp, bool* periodChanged) { | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 284 |     bool needsHwVsync = false; | 
| Alec Mouri | 754c98a | 2019-03-18 18:53:42 -0700 | [diff] [blame] | 285 |     *periodChanged = false; | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 286 |     { // Scope for the lock | 
 | 287 |         std::lock_guard<std::mutex> lock(mHWVsyncLock); | 
 | 288 |         if (mPrimaryHWVsyncEnabled) { | 
| Alec Mouri | 754c98a | 2019-03-18 18:53:42 -0700 | [diff] [blame] | 289 |             needsHwVsync = mPrimaryDispSync->addResyncSample(timestamp, periodChanged); | 
| Ana Krulec | e588e31 | 2018-09-18 12:32:24 -0700 | [diff] [blame] | 290 |         } | 
 | 291 |     } | 
 | 292 |  | 
 | 293 |     if (needsHwVsync) { | 
 | 294 |         enableHardwareVsync(); | 
 | 295 |     } else { | 
 | 296 |         disableHardwareVsync(false); | 
 | 297 |     } | 
 | 298 | } | 
 | 299 |  | 
 | 300 | void Scheduler::addPresentFence(const std::shared_ptr<FenceTime>& fenceTime) { | 
 | 301 |     if (mPrimaryDispSync->addPresentFence(fenceTime)) { | 
 | 302 |         enableHardwareVsync(); | 
 | 303 |     } else { | 
 | 304 |         disableHardwareVsync(false); | 
 | 305 |     } | 
 | 306 | } | 
 | 307 |  | 
 | 308 | void Scheduler::setIgnorePresentFences(bool ignore) { | 
 | 309 |     mPrimaryDispSync->setIgnorePresentFences(ignore); | 
 | 310 | } | 
 | 311 |  | 
| Ady Abraham | c3e2131 | 2019-02-07 14:30:23 -0800 | [diff] [blame] | 312 | nsecs_t Scheduler::expectedPresentTime() { | 
 | 313 |     return mPrimaryDispSync->expectedPresentTime(); | 
 | 314 | } | 
 | 315 |  | 
| Ady Abraham | 3aff917 | 2019-02-07 19:10:26 -0800 | [diff] [blame] | 316 | void Scheduler::dumpPrimaryDispSync(std::string& result) const { | 
 | 317 |     mPrimaryDispSync->dump(result); | 
 | 318 | } | 
 | 319 |  | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 320 | std::unique_ptr<scheduler::LayerHistory::LayerHandle> Scheduler::registerLayer( | 
| Ady Abraham | 8f1ee7f | 2019-04-05 10:32:50 -0700 | [diff] [blame] | 321 |         std::string const& name, int windowType) { | 
 | 322 |     RefreshRateType refreshRateType = (windowType == InputWindowInfo::TYPE_WALLPAPER) | 
 | 323 |             ? RefreshRateType::DEFAULT | 
 | 324 |             : RefreshRateType::PERFORMANCE; | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 325 |  | 
 | 326 |     const auto refreshRate = mRefreshRateConfigs.getRefreshRate(refreshRateType); | 
 | 327 |     const uint32_t fps = (refreshRate) ? refreshRate->fps : 0; | 
 | 328 |     return mLayerHistory.createLayer(name, fps); | 
 | 329 | } | 
 | 330 |  | 
| Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 331 | void Scheduler::addLayerPresentTimeAndHDR( | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 332 |         const std::unique_ptr<scheduler::LayerHistory::LayerHandle>& layerHandle, | 
| Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 333 |         nsecs_t presentTime, bool isHDR) { | 
 | 334 |     mLayerHistory.insert(layerHandle, presentTime, isHDR); | 
 | 335 | } | 
 | 336 |  | 
 | 337 | void Scheduler::setLayerVisibility( | 
 | 338 |         const std::unique_ptr<scheduler::LayerHistory::LayerHandle>& layerHandle, bool visible) { | 
 | 339 |     mLayerHistory.setVisibility(layerHandle, visible); | 
| Ana Krulec | 3084c05 | 2018-11-21 20:27:17 +0100 | [diff] [blame] | 340 | } | 
 | 341 |  | 
| Kevin DuBois | 413287f | 2019-02-25 08:46:47 -0800 | [diff] [blame] | 342 | void Scheduler::withPrimaryDispSync(std::function<void(DispSync&)> const& fn) { | 
 | 343 |     fn(*mPrimaryDispSync); | 
 | 344 | } | 
 | 345 |  | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 346 | void Scheduler::updateFpsBasedOnContent() { | 
| Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 347 |     auto [refreshRate, isHDR] = mLayerHistory.getDesiredRefreshRateAndHDR(); | 
 | 348 |     const uint32_t refreshRateRound = std::round(refreshRate); | 
| Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 349 |     RefreshRateType newRefreshRateType; | 
 | 350 |     { | 
 | 351 |         std::lock_guard<std::mutex> lock(mFeatureStateLock); | 
| Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 352 |         if (mContentRefreshRate == refreshRateRound && mIsHDRContent == isHDR) { | 
| Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 353 |             return; | 
 | 354 |         } | 
| Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 355 |         mContentRefreshRate = refreshRateRound; | 
| Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 356 |         ATRACE_INT("ContentFPS", mContentRefreshRate); | 
 | 357 |  | 
| Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 358 |         mIsHDRContent = isHDR; | 
 | 359 |         ATRACE_INT("ContentHDR", mIsHDRContent); | 
 | 360 |  | 
 | 361 |         mCurrentContentFeatureState = refreshRateRound > 0 | 
 | 362 |                 ? ContentFeatureState::CONTENT_DETECTION_ON | 
 | 363 |                 : ContentFeatureState::CONTENT_DETECTION_OFF; | 
| Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 364 |         newRefreshRateType = calculateRefreshRateType(); | 
 | 365 |         if (mRefreshRateType == newRefreshRateType) { | 
 | 366 |             return; | 
 | 367 |         } | 
 | 368 |         mRefreshRateType = newRefreshRateType; | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 369 |     } | 
| Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 370 |     changeRefreshRate(newRefreshRateType, ConfigEvent::Changed); | 
| Ana Krulec | 3084c05 | 2018-11-21 20:27:17 +0100 | [diff] [blame] | 371 | } | 
 | 372 |  | 
| Ana Krulec | 8d3e4f3 | 2019-03-05 10:40:33 -0800 | [diff] [blame] | 373 | void Scheduler::setChangeRefreshRateCallback( | 
 | 374 |         const ChangeRefreshRateCallback& changeRefreshRateCallback) { | 
| Ana Krulec | 7d1d683 | 2018-12-27 11:10:09 -0800 | [diff] [blame] | 375 |     std::lock_guard<std::mutex> lock(mCallbackLock); | 
| Ana Krulec | 8d3e4f3 | 2019-03-05 10:40:33 -0800 | [diff] [blame] | 376 |     mChangeRefreshRateCallback = changeRefreshRateCallback; | 
| Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 377 | } | 
 | 378 |  | 
| Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 379 | void Scheduler::setGetVsyncPeriodCallback(const GetVsyncPeriod&& getVsyncPeriod) { | 
 | 380 |     std::lock_guard<std::mutex> lock(mCallbackLock); | 
 | 381 |     mGetVsyncPeriod = getVsyncPeriod; | 
 | 382 | } | 
 | 383 |  | 
| Ana Krulec | 3084c05 | 2018-11-21 20:27:17 +0100 | [diff] [blame] | 384 | void Scheduler::updateFrameSkipping(const int64_t skipCount) { | 
 | 385 |     ATRACE_INT("FrameSkipCount", skipCount); | 
 | 386 |     if (mSkipCount != skipCount) { | 
 | 387 |         // Only update DispSync if it hasn't been updated yet. | 
 | 388 |         mPrimaryDispSync->setRefreshSkipCount(skipCount); | 
 | 389 |         mSkipCount = skipCount; | 
 | 390 |     } | 
 | 391 | } | 
 | 392 |  | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 393 | void Scheduler::resetIdleTimer() { | 
 | 394 |     if (mIdleTimer) { | 
 | 395 |         mIdleTimer->reset(); | 
| Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 396 |     } | 
 | 397 | } | 
 | 398 |  | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 399 | void Scheduler::notifyTouchEvent() { | 
 | 400 |     if (mTouchTimer) { | 
 | 401 |         mTouchTimer->reset(); | 
 | 402 |     } | 
 | 403 |  | 
 | 404 |     if (mSupportKernelTimer) { | 
 | 405 |         resetIdleTimer(); | 
 | 406 |     } | 
 | 407 | } | 
 | 408 |  | 
| Ady Abraham | a1a49af | 2019-02-07 14:36:55 -0800 | [diff] [blame] | 409 | void Scheduler::resetTimerCallback() { | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 410 |     timerChangeRefreshRate(IdleTimerState::RESET); | 
 | 411 |     ATRACE_INT("ExpiredIdleTimer", 0); | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 412 | } | 
 | 413 |  | 
| Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 414 | void Scheduler::resetKernelTimerCallback() { | 
 | 415 |     ATRACE_INT("ExpiredKernelIdleTimer", 0); | 
 | 416 |     std::lock_guard<std::mutex> lock(mCallbackLock); | 
 | 417 |     if (mGetVsyncPeriod) { | 
 | 418 |         resyncToHardwareVsync(false, mGetVsyncPeriod()); | 
 | 419 |     } | 
 | 420 | } | 
 | 421 |  | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 422 | void Scheduler::expiredTimerCallback() { | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 423 |     timerChangeRefreshRate(IdleTimerState::EXPIRED); | 
 | 424 |     ATRACE_INT("ExpiredIdleTimer", 1); | 
| Ana Krulec | fb77282 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 425 | } | 
 | 426 |  | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 427 | void Scheduler::resetTouchTimerCallback() { | 
 | 428 |     // We do not notify the applications about config changes when idle timer is reset. | 
 | 429 |     touchChangeRefreshRate(TouchState::ACTIVE); | 
 | 430 |     ATRACE_INT("TouchState", 1); | 
 | 431 | } | 
 | 432 |  | 
 | 433 | void Scheduler::expiredTouchTimerCallback() { | 
 | 434 |     // We do not notify the applications about config changes when idle timer expires. | 
 | 435 |     touchChangeRefreshRate(TouchState::INACTIVE); | 
 | 436 |     ATRACE_INT("TouchState", 0); | 
 | 437 | } | 
 | 438 |  | 
| Alec Mouri | dc28b37 | 2019-04-18 21:17:13 -0700 | [diff] [blame] | 439 | void Scheduler::expiredKernelTimerCallback() { | 
 | 440 |     ATRACE_INT("ExpiredKernelIdleTimer", 1); | 
 | 441 |     // Disable HW Vsync if the timer expired, as we don't need it | 
 | 442 |     // enabled if we're not pushing frames. | 
 | 443 |     disableHardwareVsync(false); | 
 | 444 | } | 
 | 445 |  | 
| Ana Krulec | b43429d | 2019-01-09 14:28:51 -0800 | [diff] [blame] | 446 | std::string Scheduler::doDump() { | 
 | 447 |     std::ostringstream stream; | 
 | 448 |     stream << "+  Idle timer interval: " << mSetIdleTimerMs << " ms" << std::endl; | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 449 |     stream << "+  Touch timer interval: " << mSetTouchTimerMs << " ms" << std::endl; | 
| Ana Krulec | b43429d | 2019-01-09 14:28:51 -0800 | [diff] [blame] | 450 |     return stream.str(); | 
 | 451 | } | 
 | 452 |  | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 453 | void Scheduler::timerChangeRefreshRate(IdleTimerState idleTimerState) { | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 454 |     RefreshRateType newRefreshRateType; | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 455 |     { | 
 | 456 |         std::lock_guard<std::mutex> lock(mFeatureStateLock); | 
| Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 457 |         if (mCurrentIdleTimerState == idleTimerState) { | 
 | 458 |             return; | 
 | 459 |         } | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 460 |         mCurrentIdleTimerState = idleTimerState; | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 461 |         newRefreshRateType = calculateRefreshRateType(); | 
| Ady Abraham | 6398a0a | 2019-04-18 19:30:44 -0700 | [diff] [blame] | 462 |         if (mRefreshRateType == newRefreshRateType) { | 
 | 463 |             return; | 
 | 464 |         } | 
 | 465 |         mRefreshRateType = newRefreshRateType; | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 466 |     } | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 467 |     changeRefreshRate(newRefreshRateType, ConfigEvent::None); | 
 | 468 | } | 
 | 469 |  | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 470 | void Scheduler::touchChangeRefreshRate(TouchState touchState) { | 
 | 471 |     ConfigEvent event = ConfigEvent::None; | 
 | 472 |     RefreshRateType newRefreshRateType; | 
 | 473 |     { | 
 | 474 |         std::lock_guard<std::mutex> lock(mFeatureStateLock); | 
 | 475 |         if (mCurrentTouchState == touchState) { | 
 | 476 |             return; | 
 | 477 |         } | 
 | 478 |         mCurrentTouchState = touchState; | 
 | 479 |         newRefreshRateType = calculateRefreshRateType(); | 
 | 480 |         if (mRefreshRateType == newRefreshRateType) { | 
 | 481 |             return; | 
 | 482 |         } | 
 | 483 |         mRefreshRateType = newRefreshRateType; | 
 | 484 |         // Send an event in case that content detection is on as touch has a higher priority | 
 | 485 |         if (mCurrentContentFeatureState == ContentFeatureState::CONTENT_DETECTION_ON) { | 
 | 486 |             event = ConfigEvent::Changed; | 
 | 487 |         } | 
 | 488 |     } | 
 | 489 |     changeRefreshRate(newRefreshRateType, event); | 
 | 490 | } | 
 | 491 |  | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 492 | Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() { | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 493 |     // HDR content is not supported on PERFORMANCE mode | 
 | 494 |     if (mForceHDRContentToDefaultRefreshRate && mIsHDRContent) { | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 495 |         return RefreshRateType::DEFAULT; | 
 | 496 |     } | 
 | 497 |  | 
| Ady Abraham | 8532d01 | 2019-05-08 14:50:56 -0700 | [diff] [blame] | 498 |     // As long as touch is active we want to be in performance mode | 
 | 499 |     if (mCurrentTouchState == TouchState::ACTIVE) { | 
 | 500 |         return RefreshRateType::PERFORMANCE; | 
 | 501 |     } | 
 | 502 |  | 
 | 503 |     // If timer has expired as it means there is no new content on the screen | 
 | 504 |     if (mCurrentIdleTimerState == IdleTimerState::EXPIRED) { | 
| Ady Abraham | a315ce7 | 2019-04-24 14:35:20 -0700 | [diff] [blame] | 505 |         return RefreshRateType::DEFAULT; | 
 | 506 |     } | 
 | 507 |  | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 508 |     // If content detection is off we choose performance as we don't know the content fps | 
 | 509 |     if (mCurrentContentFeatureState == ContentFeatureState::CONTENT_DETECTION_OFF) { | 
 | 510 |         return RefreshRateType::PERFORMANCE; | 
 | 511 |     } | 
 | 512 |  | 
 | 513 |     // Content detection is on, find the appropriate refresh rate | 
| Ady Abraham | 85b3f01 | 2019-04-08 11:04:14 -0700 | [diff] [blame] | 514 |     // Start with the smallest refresh rate which is within a margin of the content | 
 | 515 |     RefreshRateType currRefreshRateType = RefreshRateType::PERFORMANCE; | 
 | 516 |     constexpr float MARGIN = 0.05f; | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 517 |     auto iter = mRefreshRateConfigs.getRefreshRates().cbegin(); | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 518 |     while (iter != mRefreshRateConfigs.getRefreshRates().cend()) { | 
| Ady Abraham | 85b3f01 | 2019-04-08 11:04:14 -0700 | [diff] [blame] | 519 |         if (iter->second->fps >= mContentRefreshRate * (1 - MARGIN)) { | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 520 |             currRefreshRateType = iter->first; | 
 | 521 |             break; | 
 | 522 |         } | 
 | 523 |         ++iter; | 
 | 524 |     } | 
 | 525 |  | 
| Ady Abraham | 85b3f01 | 2019-04-08 11:04:14 -0700 | [diff] [blame] | 526 |     // Some content aligns better on higher refresh rate. For example for 45fps we should choose | 
 | 527 |     // 90Hz config. However we should still prefer a lower refresh rate if the content doesn't | 
 | 528 |     // align well with both | 
 | 529 |     float ratio = mRefreshRateConfigs.getRefreshRate(currRefreshRateType)->fps / | 
 | 530 |             float(mContentRefreshRate); | 
 | 531 |     if (std::abs(std::round(ratio) - ratio) > MARGIN) { | 
 | 532 |         while (iter != mRefreshRateConfigs.getRefreshRates().cend()) { | 
 | 533 |             ratio = iter->second->fps / float(mContentRefreshRate); | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 534 |  | 
| Ady Abraham | 85b3f01 | 2019-04-08 11:04:14 -0700 | [diff] [blame] | 535 |             if (std::abs(std::round(ratio) - ratio) <= MARGIN) { | 
 | 536 |                 currRefreshRateType = iter->first; | 
 | 537 |                 break; | 
 | 538 |             } | 
 | 539 |             ++iter; | 
 | 540 |         } | 
 | 541 |     } | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 542 |  | 
 | 543 |     return currRefreshRateType; | 
| Ana Krulec | fefd6ae | 2019-02-13 17:53:08 -0800 | [diff] [blame] | 544 | } | 
 | 545 |  | 
 | 546 | void Scheduler::changeRefreshRate(RefreshRateType refreshRateType, ConfigEvent configEvent) { | 
 | 547 |     std::lock_guard<std::mutex> lock(mCallbackLock); | 
 | 548 |     if (mChangeRefreshRateCallback) { | 
 | 549 |         mChangeRefreshRateCallback(refreshRateType, configEvent); | 
 | 550 |     } | 
 | 551 | } | 
 | 552 |  | 
| Ana Krulec | 98b5b24 | 2018-08-10 15:03:23 -0700 | [diff] [blame] | 553 | } // namespace android |