blob: c4cfdc3482f20bd9e1ad12682d536b5b56e04ff6 [file] [log] [blame]
Michael Wright5d22d4f2018-06-21 02:50:34 +01001/*
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
17#pragma once
18
Dan Stoza030fbc12020-02-19 15:32:01 -080019#include <atomic>
Matt Buckleyef51fba2021-10-12 19:30:12 +000020#include <chrono>
Matt Buckley50c44062022-01-17 20:48:10 +000021#include <unordered_map>
Peiyong Lin74ca2f42019-01-14 19:36:57 -080022#include <unordered_set>
23
Matt Buckley50c44062022-01-17 20:48:10 +000024#include <ui/DisplayId.h>
25#include <ui/FenceTime.h>
Dan Stoza20950002020-06-18 14:56:58 -070026#include <utils/Mutex.h>
27
Xiang Wange12b4fa2022-03-25 23:48:40 +000028#include <android/hardware/power/IPower.h>
Matt Buckley50c44062022-01-17 20:48:10 +000029#include <compositionengine/impl/OutputCompositionState.h>
Matt Buckley2fa85012022-08-30 22:38:45 +000030#include <scheduler/Time.h>
Alec Mouriff793872022-01-13 17:45:06 -080031#include <ui/DisplayIdentification.h>
Dan Stoza030fbc12020-02-19 15:32:01 -080032#include "../Scheduler/OneShotTimer.h"
Michael Wright5d22d4f2018-06-21 02:50:34 +010033
Matt Buckleyef51fba2021-10-12 19:30:12 +000034using namespace std::chrono_literals;
35
Michael Wright5d22d4f2018-06-21 02:50:34 +010036namespace android {
Alec Mouridea1ac52021-06-23 18:12:18 -070037
38class SurfaceFlinger;
39
Michael Wright5d22d4f2018-06-21 02:50:34 +010040namespace Hwc2 {
41
42class PowerAdvisor {
43public:
44 virtual ~PowerAdvisor();
45
Alec Mouridea1ac52021-06-23 18:12:18 -070046 // Initializes resources that cannot be initialized on construction
47 virtual void init() = 0;
Dan Stoza29e7bdf2020-03-23 14:43:09 -070048 virtual void onBootFinished() = 0;
Peiyong Lin74ca2f42019-01-14 19:36:57 -080049 virtual void setExpensiveRenderingExpected(DisplayId displayId, bool expected) = 0;
Alec Mouridea1ac52021-06-23 18:12:18 -070050 virtual bool isUsingExpensiveRendering() = 0;
Matt Buckley15ecd1c2022-11-01 21:57:16 +000051 virtual void notifyDisplayUpdateImminentAndCpuReset() = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000052 // Checks both if it supports and if it's enabled
Matt Buckley06f299a2021-09-24 19:43:51 +000053 virtual bool usePowerHintSession() = 0;
54 virtual bool supportsPowerHintSession() = 0;
55 virtual bool isPowerHintSessionRunning() = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000056 // Sends a power hint that updates to the target work duration for the frame
Matt Buckley2fa85012022-08-30 22:38:45 +000057 virtual void setTargetWorkDuration(Duration targetDuration) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000058 // Sends a power hint for the actual known work duration at the end of the frame
59 virtual void sendActualWorkDuration() = 0;
60 // Sends a power hint for the upcoming frame predicted from previous frame timing
61 virtual void sendPredictedWorkDuration() = 0;
62 // Sets whether the power hint session is enabled
Matt Buckley06f299a2021-09-24 19:43:51 +000063 virtual void enablePowerHint(bool enabled) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000064 // Initializes the power hint session
Matt Buckleyef51fba2021-10-12 19:30:12 +000065 virtual bool startPowerHintSession(const std::vector<int32_t>& threadIds) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000066 // Provides PowerAdvisor with a copy of the gpu fence so it can determine the gpu end time
67 virtual void setGpuFenceTime(DisplayId displayId, std::unique_ptr<FenceTime>&& fenceTime) = 0;
Matt Buckley16dec1f2022-06-07 21:46:20 +000068 // Reports the start and end times of a hwc validate call this frame for a given display
Matt Buckley2fa85012022-08-30 22:38:45 +000069 virtual void setHwcValidateTiming(DisplayId displayId, TimePoint validateStartTime,
70 TimePoint validateEndTime) = 0;
Matt Buckley16dec1f2022-06-07 21:46:20 +000071 // Reports the start and end times of a hwc present call this frame for a given display
Matt Buckley2fa85012022-08-30 22:38:45 +000072 virtual void setHwcPresentTiming(DisplayId displayId, TimePoint presentStartTime,
73 TimePoint presentEndTime) = 0;
Matt Buckleyc6b9d382022-06-17 15:28:07 -070074 // Reports the expected time that the current frame will present to the display
Matt Buckley2fa85012022-08-30 22:38:45 +000075 virtual void setExpectedPresentTime(TimePoint expectedPresentTime) = 0;
Matt Buckley1809d902022-08-05 06:51:43 +000076 // Reports the most recent present fence time and end time once known
Matt Buckley2fa85012022-08-30 22:38:45 +000077 virtual void setSfPresentTiming(TimePoint presentFenceTime, TimePoint presentEndTime) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000078 // Reports whether a display used client composition this frame
79 virtual void setRequiresClientComposition(DisplayId displayId,
80 bool requiresClientComposition) = 0;
81 // Reports whether a given display skipped validation this frame
82 virtual void setSkippedValidate(DisplayId displayId, bool skipped) = 0;
Matt Buckley16dec1f2022-06-07 21:46:20 +000083 // Reports when a hwc present is delayed, and the time that it will resume
Matt Buckley2fa85012022-08-30 22:38:45 +000084 virtual void setHwcPresentDelayedTime(DisplayId displayId,
85 TimePoint earliestFrameStartTime) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000086 // Reports the start delay for SurfaceFlinger this frame
Matt Buckley2fa85012022-08-30 22:38:45 +000087 virtual void setFrameDelay(Duration frameDelayDuration) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000088 // Reports the SurfaceFlinger commit start time this frame
Matt Buckley2fa85012022-08-30 22:38:45 +000089 virtual void setCommitStart(TimePoint commitStartTime) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000090 // Reports the SurfaceFlinger composite end time this frame
Matt Buckley2fa85012022-08-30 22:38:45 +000091 virtual void setCompositeEnd(TimePoint compositeEndTime) = 0;
Matt Buckley50c44062022-01-17 20:48:10 +000092 // Reports the list of the currently active displays
93 virtual void setDisplays(std::vector<DisplayId>& displayIds) = 0;
94 // Sets the target duration for the entire pipeline including the gpu
Matt Buckley2fa85012022-08-30 22:38:45 +000095 virtual void setTotalFrameTargetWorkDuration(Duration targetDuration) = 0;
Michael Wright5d22d4f2018-06-21 02:50:34 +010096};
97
98namespace impl {
99
Michael Wright5d22d4f2018-06-21 02:50:34 +0100100// PowerAdvisor is a wrapper around IPower HAL which takes into account the
101// full state of the system when sending out power hints to things like the GPU.
102class PowerAdvisor final : public Hwc2::PowerAdvisor {
103public:
Dan Stoza030fbc12020-02-19 15:32:01 -0800104 class HalWrapper {
105 public:
106 virtual ~HalWrapper() = default;
107
108 virtual bool setExpensiveRendering(bool enabled) = 0;
Matt Buckley15ecd1c2022-11-01 21:57:16 +0000109 virtual bool notifyDisplayUpdateImminentAndCpuReset() = 0;
Matt Buckley06f299a2021-09-24 19:43:51 +0000110 virtual bool supportsPowerHintSession() = 0;
111 virtual bool isPowerHintSessionRunning() = 0;
112 virtual void restartPowerHintSession() = 0;
113 virtual void setPowerHintSessionThreadIds(const std::vector<int32_t>& threadIds) = 0;
114 virtual bool startPowerHintSession() = 0;
Matt Buckley2fa85012022-08-30 22:38:45 +0000115 virtual void setTargetWorkDuration(Duration targetDuration) = 0;
116 virtual void sendActualWorkDuration(Duration actualDuration, TimePoint timestamp) = 0;
Matt Buckley06f299a2021-09-24 19:43:51 +0000117 virtual bool shouldReconnectHAL() = 0;
118 virtual std::vector<int32_t> getPowerHintSessionThreadIds() = 0;
Matt Buckley2fa85012022-08-30 22:38:45 +0000119 virtual std::optional<Duration> getTargetWorkDuration() = 0;
Dan Stoza030fbc12020-02-19 15:32:01 -0800120 };
121
Alec Mouridea1ac52021-06-23 18:12:18 -0700122 PowerAdvisor(SurfaceFlinger& flinger);
Michael Wright5d22d4f2018-06-21 02:50:34 +0100123 ~PowerAdvisor() override;
124
Alec Mouridea1ac52021-06-23 18:12:18 -0700125 void init() override;
Dan Stoza29e7bdf2020-03-23 14:43:09 -0700126 void onBootFinished() override;
Peiyong Lin74ca2f42019-01-14 19:36:57 -0800127 void setExpensiveRenderingExpected(DisplayId displayId, bool expected) override;
Matt Buckley06f299a2021-09-24 19:43:51 +0000128 bool isUsingExpensiveRendering() override { return mNotifiedExpensiveRendering; };
Matt Buckley15ecd1c2022-11-01 21:57:16 +0000129 void notifyDisplayUpdateImminentAndCpuReset() override;
Matt Buckley06f299a2021-09-24 19:43:51 +0000130 bool usePowerHintSession() override;
131 bool supportsPowerHintSession() override;
132 bool isPowerHintSessionRunning() override;
Matt Buckley2fa85012022-08-30 22:38:45 +0000133 void setTargetWorkDuration(Duration targetDuration) override;
Matt Buckley50c44062022-01-17 20:48:10 +0000134 void sendActualWorkDuration() override;
135 void sendPredictedWorkDuration() override;
Matt Buckley06f299a2021-09-24 19:43:51 +0000136 void enablePowerHint(bool enabled) override;
Matt Buckleyef51fba2021-10-12 19:30:12 +0000137 bool startPowerHintSession(const std::vector<int32_t>& threadIds) override;
Matt Buckley50c44062022-01-17 20:48:10 +0000138 void setGpuFenceTime(DisplayId displayId, std::unique_ptr<FenceTime>&& fenceTime);
Matt Buckley2fa85012022-08-30 22:38:45 +0000139 void setHwcValidateTiming(DisplayId displayId, TimePoint validateStartTime,
140 TimePoint validateEndTime) override;
141 void setHwcPresentTiming(DisplayId displayId, TimePoint presentStartTime,
142 TimePoint presentEndTime) override;
Matt Buckley50c44062022-01-17 20:48:10 +0000143 void setSkippedValidate(DisplayId displayId, bool skipped) override;
144 void setRequiresClientComposition(DisplayId displayId, bool requiresClientComposition) override;
Matt Buckley2fa85012022-08-30 22:38:45 +0000145 void setExpectedPresentTime(TimePoint expectedPresentTime) override;
146 void setSfPresentTiming(TimePoint presentFenceTime, TimePoint presentEndTime) override;
147 void setHwcPresentDelayedTime(DisplayId displayId, TimePoint earliestFrameStartTime) override;
Matt Buckley50c44062022-01-17 20:48:10 +0000148
Matt Buckley2fa85012022-08-30 22:38:45 +0000149 void setFrameDelay(Duration frameDelayDuration) override;
150 void setCommitStart(TimePoint commitStartTime) override;
151 void setCompositeEnd(TimePoint compositeEndTime) override;
Matt Buckley50c44062022-01-17 20:48:10 +0000152 void setDisplays(std::vector<DisplayId>& displayIds) override;
Matt Buckley2fa85012022-08-30 22:38:45 +0000153 void setTotalFrameTargetWorkDuration(Duration targetDuration) override;
Michael Wright5d22d4f2018-06-21 02:50:34 +0100154
155private:
Matt Buckley57274052022-08-12 21:54:23 +0000156 friend class PowerAdvisorTest;
157
158 // Tracks if powerhal exists
159 bool mHasHal = true;
160 // Holds the hal wrapper for getPowerHal
161 std::unique_ptr<HalWrapper> mHalWrapper GUARDED_BY(mPowerHalMutex) = nullptr;
162
Dan Stoza20950002020-06-18 14:56:58 -0700163 HalWrapper* getPowerHal() REQUIRES(mPowerHalMutex);
164 bool mReconnectPowerHal GUARDED_BY(mPowerHalMutex) = false;
165 std::mutex mPowerHalMutex;
Dan Stoza030fbc12020-02-19 15:32:01 -0800166
Dan Stoza29e7bdf2020-03-23 14:43:09 -0700167 std::atomic_bool mBootFinished = false;
Matt Buckleyef51fba2021-10-12 19:30:12 +0000168
Peiyong Lin74ca2f42019-01-14 19:36:57 -0800169 std::unordered_set<DisplayId> mExpensiveDisplays;
Michael Wright5d22d4f2018-06-21 02:50:34 +0100170 bool mNotifiedExpensiveRendering = false;
Dan Stoza030fbc12020-02-19 15:32:01 -0800171
Alec Mouridea1ac52021-06-23 18:12:18 -0700172 SurfaceFlinger& mFlinger;
Dan Stoza030fbc12020-02-19 15:32:01 -0800173 std::atomic_bool mSendUpdateImminent = true;
Alec Mouric059dcf2022-05-05 23:40:07 +0000174 std::atomic<nsecs_t> mLastScreenUpdatedTime = 0;
175 std::optional<scheduler::OneShotTimer> mScreenUpdateTimer;
Matt Buckley50c44062022-01-17 20:48:10 +0000176
177 // Higher-level timing data used for estimation
178 struct DisplayTimeline {
Matt Buckley16dec1f2022-06-07 21:46:20 +0000179 // The start of hwc present, or the start of validate if it happened there instead
Matt Buckley2fa85012022-08-30 22:38:45 +0000180 TimePoint hwcPresentStartTime;
Matt Buckley16dec1f2022-06-07 21:46:20 +0000181 // The end of hwc present or validate, whichever one actually presented
Matt Buckley2fa85012022-08-30 22:38:45 +0000182 TimePoint hwcPresentEndTime;
Matt Buckley16dec1f2022-06-07 21:46:20 +0000183 // How long the actual hwc present was delayed after hwcPresentStartTime
Matt Buckley2fa85012022-08-30 22:38:45 +0000184 Duration hwcPresentDelayDuration{0ns};
Matt Buckleyc6b9d382022-06-17 15:28:07 -0700185 // When we think we started waiting for the present fence after calling into hwc present and
Matt Buckley50c44062022-01-17 20:48:10 +0000186 // after potentially waiting for the earliest present time
Matt Buckley2fa85012022-08-30 22:38:45 +0000187 TimePoint presentFenceWaitStartTime;
Matt Buckley16dec1f2022-06-07 21:46:20 +0000188 // How long we ran after we finished waiting for the fence but before hwc present finished
Matt Buckley2fa85012022-08-30 22:38:45 +0000189 Duration postPresentFenceHwcPresentDuration{0ns};
Matt Buckley50c44062022-01-17 20:48:10 +0000190 // Are we likely to have waited for the present fence during composition
Matt Buckleyc6b9d382022-06-17 15:28:07 -0700191 bool probablyWaitsForPresentFence = false;
Matt Buckley50c44062022-01-17 20:48:10 +0000192 // Estimate one frame's timeline from that of a previous frame
Matt Buckley2fa85012022-08-30 22:38:45 +0000193 DisplayTimeline estimateTimelineFromReference(TimePoint fenceTime,
194 TimePoint displayStartTime);
Matt Buckley50c44062022-01-17 20:48:10 +0000195 };
196
197 struct GpuTimeline {
Matt Buckley2fa85012022-08-30 22:38:45 +0000198 Duration duration{0ns};
199 TimePoint startTime;
Matt Buckley50c44062022-01-17 20:48:10 +0000200 };
201
202 // Power hint session data recorded from the pipeline
203 struct DisplayTimingData {
204 std::unique_ptr<FenceTime> gpuEndFenceTime;
Matt Buckley2fa85012022-08-30 22:38:45 +0000205 std::optional<TimePoint> gpuStartTime;
206 std::optional<TimePoint> lastValidGpuEndTime;
207 std::optional<TimePoint> lastValidGpuStartTime;
208 std::optional<TimePoint> hwcPresentStartTime;
209 std::optional<TimePoint> hwcPresentEndTime;
210 std::optional<TimePoint> hwcValidateStartTime;
211 std::optional<TimePoint> hwcValidateEndTime;
212 std::optional<TimePoint> hwcPresentDelayedTime;
Matt Buckley50c44062022-01-17 20:48:10 +0000213 bool usedClientComposition = false;
214 bool skippedValidate = false;
215 // Calculate high-level timing milestones from more granular display timing data
Matt Buckley2fa85012022-08-30 22:38:45 +0000216 DisplayTimeline calculateDisplayTimeline(TimePoint fenceTime);
Matt Buckley50c44062022-01-17 20:48:10 +0000217 // Estimate the gpu duration for a given display from previous gpu timing data
Matt Buckley2fa85012022-08-30 22:38:45 +0000218 std::optional<GpuTimeline> estimateGpuTiming(std::optional<TimePoint> previousEndTime);
Matt Buckley50c44062022-01-17 20:48:10 +0000219 };
220
221 template <class T, size_t N>
222 class RingBuffer {
223 std::array<T, N> elements = {};
224 size_t mIndex = 0;
225 size_t numElements = 0;
226
227 public:
228 void append(T item) {
229 mIndex = (mIndex + 1) % N;
230 numElements = std::min(N, numElements + 1);
231 elements[mIndex] = item;
232 }
233 bool isFull() const { return numElements == N; }
234 // Allows access like [0] == current, [-1] = previous, etc..
235 T& operator[](int offset) {
236 size_t positiveOffset =
237 static_cast<size_t>((offset % static_cast<int>(N)) + static_cast<int>(N));
238 return elements[(mIndex + positiveOffset) % N];
239 }
240 };
241
242 // Filter and sort the display ids by a given property
Matt Buckley2fa85012022-08-30 22:38:45 +0000243 std::vector<DisplayId> getOrderedDisplayIds(
244 std::optional<TimePoint> DisplayTimingData::*sortBy);
Matt Buckley50c44062022-01-17 20:48:10 +0000245 // Estimates a frame's total work duration including gpu time.
246 // Runs either at the beginning or end of a frame, using the most recent data available
Matt Buckley2fa85012022-08-30 22:38:45 +0000247 std::optional<Duration> estimateWorkDuration(bool earlyHint);
Matt Buckley50c44062022-01-17 20:48:10 +0000248 // There are two different targets and actual work durations we care about,
249 // this normalizes them together and takes the max of the two
Matt Buckley2fa85012022-08-30 22:38:45 +0000250 Duration combineTimingEstimates(Duration totalDuration, Duration flingerDuration);
Matt Buckley50c44062022-01-17 20:48:10 +0000251
252 std::unordered_map<DisplayId, DisplayTimingData> mDisplayTimingData;
253
254 // Current frame's delay
Matt Buckley2fa85012022-08-30 22:38:45 +0000255 Duration mFrameDelayDuration{0ns};
Matt Buckley50c44062022-01-17 20:48:10 +0000256 // Last frame's post-composition duration
Matt Buckley2fa85012022-08-30 22:38:45 +0000257 Duration mLastPostcompDuration{0ns};
Matt Buckley50c44062022-01-17 20:48:10 +0000258 // Buffer of recent commit start times
Matt Buckley2fa85012022-08-30 22:38:45 +0000259 RingBuffer<TimePoint, 2> mCommitStartTimes;
Matt Buckley50c44062022-01-17 20:48:10 +0000260 // Buffer of recent expected present times
Matt Buckley2fa85012022-08-30 22:38:45 +0000261 RingBuffer<TimePoint, 2> mExpectedPresentTimes;
Matt Buckleya2ad1dc2022-08-16 20:07:26 +0000262 // Most recent present fence time, provided by SF after composition engine finishes presenting
Matt Buckley2fa85012022-08-30 22:38:45 +0000263 TimePoint mLastPresentFenceTime;
Matt Buckleya2ad1dc2022-08-16 20:07:26 +0000264 // Most recent composition engine present end time, returned with the present fence from SF
Matt Buckley2fa85012022-08-30 22:38:45 +0000265 TimePoint mLastSfPresentEndTime;
Matt Buckleya2ad1dc2022-08-16 20:07:26 +0000266 // Target duration for the entire pipeline including gpu
Matt Buckley2fa85012022-08-30 22:38:45 +0000267 std::optional<Duration> mTotalFrameTargetDuration;
Matt Buckley50c44062022-01-17 20:48:10 +0000268 // Updated list of display IDs
269 std::vector<DisplayId> mDisplayIds;
270
271 std::optional<bool> mPowerHintEnabled;
272 std::optional<bool> mSupportsPowerHint;
273 bool mPowerHintSessionRunning = false;
274
Matt Buckleyc6b9d382022-06-17 15:28:07 -0700275 // An adjustable safety margin which pads the "actual" value sent to PowerHAL,
276 // encouraging more aggressive boosting to give SurfaceFlinger a larger margin for error
Matt Buckleyac15a1b2023-02-28 06:51:28 +0000277 static const Duration sTargetSafetyMargin;
278 static constexpr const Duration kDefaultTargetSafetyMargin{1ms};
Matt Buckley50c44062022-01-17 20:48:10 +0000279
280 // How long we expect hwc to run after the present call until it waits for the fence
Matt Buckley2fa85012022-08-30 22:38:45 +0000281 static constexpr const Duration kFenceWaitStartDelayValidated{150us};
282 static constexpr const Duration kFenceWaitStartDelaySkippedValidate{250us};
Michael Wright5d22d4f2018-06-21 02:50:34 +0100283};
284
Xiang Wange12b4fa2022-03-25 23:48:40 +0000285class AidlPowerHalWrapper : public PowerAdvisor::HalWrapper {
286public:
287 explicit AidlPowerHalWrapper(sp<hardware::power::IPower> powerHal);
288 ~AidlPowerHalWrapper() override;
289
290 static std::unique_ptr<HalWrapper> connect();
291
292 bool setExpensiveRendering(bool enabled) override;
Matt Buckley15ecd1c2022-11-01 21:57:16 +0000293 bool notifyDisplayUpdateImminentAndCpuReset() override;
Xiang Wange12b4fa2022-03-25 23:48:40 +0000294 bool supportsPowerHintSession() override;
295 bool isPowerHintSessionRunning() override;
296 void restartPowerHintSession() override;
297 void setPowerHintSessionThreadIds(const std::vector<int32_t>& threadIds) override;
298 bool startPowerHintSession() override;
Matt Buckley2fa85012022-08-30 22:38:45 +0000299 void setTargetWorkDuration(Duration targetDuration) override;
300 void sendActualWorkDuration(Duration actualDuration, TimePoint timestamp) override;
Xiang Wange12b4fa2022-03-25 23:48:40 +0000301 bool shouldReconnectHAL() override;
302 std::vector<int32_t> getPowerHintSessionThreadIds() override;
Matt Buckley2fa85012022-08-30 22:38:45 +0000303 std::optional<Duration> getTargetWorkDuration() override;
Xiang Wange12b4fa2022-03-25 23:48:40 +0000304
305private:
Matt Buckley50c44062022-01-17 20:48:10 +0000306 friend class AidlPowerHalWrapperTest;
307
Xiang Wange12b4fa2022-03-25 23:48:40 +0000308 bool checkPowerHintSessionSupported();
309 void closePowerHintSession();
Xiang Wange12b4fa2022-03-25 23:48:40 +0000310
311 const sp<hardware::power::IPower> mPowerHal = nullptr;
312 bool mHasExpensiveRendering = false;
313 bool mHasDisplayUpdateImminent = false;
314 // Used to indicate an error state and need for reconstruction
315 bool mShouldReconnectHal = false;
Matt Buckley50c44062022-01-17 20:48:10 +0000316
317 // Power hint session data
318
319 // Concurrent access for this is protected by mPowerHalMutex
Xiang Wange12b4fa2022-03-25 23:48:40 +0000320 sp<hardware::power::IPowerHintSession> mPowerHintSession = nullptr;
321 // Queue of actual durations saved to report
322 std::vector<hardware::power::WorkDuration> mPowerHintQueue;
Matt Buckley50c44062022-01-17 20:48:10 +0000323 // The latest values we have received for target and actual
Matt Buckley2fa85012022-08-30 22:38:45 +0000324 Duration mTargetDuration = kDefaultTargetDuration;
325 std::optional<Duration> mActualDuration;
Xiang Wange12b4fa2022-03-25 23:48:40 +0000326 // The list of thread ids, stored so we can restart the session from this class if needed
327 std::vector<int32_t> mPowerHintThreadIds;
Matt Buckley50c44062022-01-17 20:48:10 +0000328 bool mSupportsPowerHint = false;
Matt Buckley2fa85012022-08-30 22:38:45 +0000329 Duration mLastTargetDurationSent = kDefaultTargetDuration;
Xiang Wange12b4fa2022-03-25 23:48:40 +0000330 // Whether we should emit ATRACE_INT data for hint sessions
331 static const bool sTraceHintSessionData;
Matt Buckley2fa85012022-08-30 22:38:45 +0000332 static constexpr Duration kDefaultTargetDuration{16ms};
Xiang Wange12b4fa2022-03-25 23:48:40 +0000333};
334
Michael Wright5d22d4f2018-06-21 02:50:34 +0100335} // namespace impl
336} // namespace Hwc2
337} // namespace android