blob: 333857ebab453e7df4a4caaa80ebb24326614399 [file] [log] [blame]
Roman Stratiienko3627beb2022-01-04 16:02:55 +02001/*
2 * Copyright (C) 2022 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#define LOG_TAG "hwc-display"
18#define ATRACE_TAG ATRACE_TAG_GRAPHICS
19
20#include "HwcDisplay.h"
21
22#include "DrmHwcTwo.h"
Roman Stratiienkobb594ba2022-02-18 16:52:03 +020023#include "backend/Backend.h"
Roman Stratiienko3627beb2022-01-04 16:02:55 +020024#include "backend/BackendManager.h"
25#include "bufferinfo/BufferInfoGetter.h"
26#include "utils/log.h"
27#include "utils/properties.h"
28
29namespace android {
30
31std::string HwcDisplay::DumpDelta(HwcDisplay::Stats delta) {
32 if (delta.total_pixops_ == 0)
33 return "No stats yet";
Roman Stratiienkoa7913de2022-10-20 13:18:57 +030034 auto ratio = 1.0 - double(delta.gpu_pixops_) / double(delta.total_pixops_);
Roman Stratiienko3627beb2022-01-04 16:02:55 +020035
36 std::stringstream ss;
37 ss << " Total frames count: " << delta.total_frames_ << "\n"
38 << " Failed to test commit frames: " << delta.failed_kms_validate_ << "\n"
39 << " Failed to commit frames: " << delta.failed_kms_present_ << "\n"
40 << ((delta.failed_kms_present_ > 0)
41 ? " !!! Internal failure, FIX it please\n"
42 : "")
43 << " Flattened frames: " << delta.frames_flattened_ << "\n"
44 << " Pixel operations (free units)"
45 << " : [TOTAL: " << delta.total_pixops_ << " / GPU: " << delta.gpu_pixops_
46 << "]\n"
47 << " Composition efficiency: " << ratio;
48
49 return ss.str();
50}
51
52std::string HwcDisplay::Dump() {
53 std::string flattening_state_str;
54 switch (flattenning_state_) {
55 case ClientFlattenningState::Disabled:
56 flattening_state_str = "Disabled";
57 break;
58 case ClientFlattenningState::NotRequired:
59 flattening_state_str = "Not needed";
60 break;
61 case ClientFlattenningState::Flattened:
62 flattening_state_str = "Active";
63 break;
64 case ClientFlattenningState::ClientRefreshRequested:
65 flattening_state_str = "Refresh requested";
66 break;
67 default:
68 flattening_state_str = std::to_string(flattenning_state_) +
69 " VSync remains";
70 }
71
Roman Stratiienkoa7913de2022-10-20 13:18:57 +030072 auto connector_name = IsInHeadlessMode()
73 ? std::string("NULL-DISPLAY")
74 : GetPipe().connector->Get()->GetName();
Roman Stratiienko19c162f2022-02-01 09:35:08 +020075
Roman Stratiienko3627beb2022-01-04 16:02:55 +020076 std::stringstream ss;
Roman Stratiienko19c162f2022-02-01 09:35:08 +020077 ss << "- Display on: " << connector_name << "\n"
Roman Stratiienko3627beb2022-01-04 16:02:55 +020078 << " Flattening state: " << flattening_state_str << "\n"
79 << "Statistics since system boot:\n"
80 << DumpDelta(total_stats_) << "\n\n"
81 << "Statistics since last dumpsys request:\n"
82 << DumpDelta(total_stats_.minus(prev_stats_)) << "\n\n";
83
84 memcpy(&prev_stats_, &total_stats_, sizeof(Stats));
85 return ss.str();
86}
87
Roman Stratiienkobb594ba2022-02-18 16:52:03 +020088HwcDisplay::HwcDisplay(hwc2_display_t handle, HWC2::DisplayType type,
89 DrmHwcTwo *hwc2)
Roman Stratiienko3627beb2022-01-04 16:02:55 +020090 : hwc2_(hwc2),
Roman Stratiienko3627beb2022-01-04 16:02:55 +020091 handle_(handle),
92 type_(type),
Roman Stratiienko4b2cc482022-02-21 14:53:58 +020093 client_layer_(this),
Roman Stratiienko3627beb2022-01-04 16:02:55 +020094 color_transform_hint_(HAL_COLOR_TRANSFORM_IDENTITY) {
95 // clang-format off
96 color_transform_matrix_ = {1.0, 0.0, 0.0, 0.0,
97 0.0, 1.0, 0.0, 0.0,
98 0.0, 0.0, 1.0, 0.0,
99 0.0, 0.0, 0.0, 1.0};
100 // clang-format on
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200101}
102
Roman Stratiienkobb594ba2022-02-18 16:52:03 +0200103HwcDisplay::~HwcDisplay() = default;
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200104
Roman Stratiienkobb594ba2022-02-18 16:52:03 +0200105void HwcDisplay::SetPipeline(DrmDisplayPipeline *pipeline) {
Roman Stratiienkod0494d92022-03-15 18:02:04 +0200106 Deinit();
107
Roman Stratiienkobb594ba2022-02-18 16:52:03 +0200108 pipeline_ = pipeline;
109
Roman Stratiienkod0494d92022-03-15 18:02:04 +0200110 if (pipeline != nullptr || handle_ == kPrimaryDisplay) {
Roman Stratiienkobb594ba2022-02-18 16:52:03 +0200111 Init();
Roman Stratiienkobb594ba2022-02-18 16:52:03 +0200112 hwc2_->ScheduleHotplugEvent(handle_, /*connected = */ true);
113 } else {
Roman Stratiienkod0494d92022-03-15 18:02:04 +0200114 hwc2_->ScheduleHotplugEvent(handle_, /*connected = */ false);
Roman Stratiienkobb594ba2022-02-18 16:52:03 +0200115 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200116}
117
Roman Stratiienkod0494d92022-03-15 18:02:04 +0200118void HwcDisplay::Deinit() {
119 if (pipeline_ != nullptr) {
120 AtomicCommitArgs a_args{};
Roman Stratiienkod0494d92022-03-15 18:02:04 +0200121 a_args.composition = std::make_shared<DrmKmsPlan>();
122 GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
John Stultz799e8c72022-06-30 19:49:42 +0000123/*
124 * TODO:
125 * Unfortunately the following causes regressions on db845c
126 * with VtsHalGraphicsComposerV2_3TargetTest due to the display
127 * never coming back. Patches to avoiding that issue on the
128 * the kernel side unfortunately causes further crashes in
129 * drm_hwcomposer, because the client detach takes longer then the
130 * 1 second max VTS expects. So for now as a workaround, lets skip
131 * deactivating the display on deinit, which matches previous
132 * behavior prior to commit d0494d9b8097
133 */
134#if 0
Roman Stratiienkoaf862a52022-06-22 12:14:22 +0300135 a_args.composition = {};
136 a_args.active = false;
137 GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
John Stultz799e8c72022-06-30 19:49:42 +0000138#endif
Roman Stratiienkod0494d92022-03-15 18:02:04 +0200139
140 vsync_worker_.Init(nullptr, [](int64_t) {});
141 current_plan_.reset();
142 backend_.reset();
143 }
144
145 SetClientTarget(nullptr, -1, 0, {});
146}
147
Roman Stratiienko19c162f2022-02-01 09:35:08 +0200148HWC2::Error HwcDisplay::Init() {
Roman Stratiienkod0494d92022-03-15 18:02:04 +0200149 ChosePreferredConfig();
150
Roman Stratiienko19c162f2022-02-01 09:35:08 +0200151 int ret = vsync_worker_.Init(pipeline_, [this](int64_t timestamp) {
Roman Stratiienko74923582022-01-17 11:24:21 +0200152 const std::lock_guard<std::mutex> lock(hwc2_->GetResMan().GetMainLock());
Roman Stratiienko099c3112022-01-20 11:50:54 +0200153 if (vsync_event_en_) {
154 uint32_t period_ns{};
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200155 GetDisplayVsyncPeriod(&period_ns);
Roman Stratiienko099c3112022-01-20 11:50:54 +0200156 hwc2_->SendVsyncEventToClient(handle_, timestamp, period_ns);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200157 }
Roman Stratiienko099c3112022-01-20 11:50:54 +0200158 if (vsync_flattening_en_) {
159 ProcessFlatenningVsyncInternal();
160 }
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200161 if (vsync_tracking_en_) {
162 last_vsync_ts_ = timestamp;
163 }
164 if (!vsync_event_en_ && !vsync_flattening_en_ && !vsync_tracking_en_) {
Roman Stratiienko099c3112022-01-20 11:50:54 +0200165 vsync_worker_.VSyncControl(false);
Roman Stratiienko19c162f2022-02-01 09:35:08 +0200166 }
167 });
Roman Stratiienkobb594ba2022-02-18 16:52:03 +0200168 if (ret && ret != -EALREADY) {
Roman Stratiienko19c162f2022-02-01 09:35:08 +0200169 ALOGE("Failed to create event worker for d=%d %d\n", int(handle_), ret);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200170 return HWC2::Error::BadDisplay;
171 }
172
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200173 if (!IsInHeadlessMode()) {
174 ret = BackendManager::GetInstance().SetBackendForDisplay(this);
175 if (ret) {
176 ALOGE("Failed to set backend for d=%d %d\n", int(handle_), ret);
177 return HWC2::Error::BadDisplay;
178 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200179 }
180
181 client_layer_.SetLayerBlendMode(HWC2_BLEND_MODE_PREMULTIPLIED);
182
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200183 return HWC2::Error::None;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200184}
185
186HWC2::Error HwcDisplay::ChosePreferredConfig() {
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200187 HWC2::Error err{};
188 if (!IsInHeadlessMode()) {
189 err = configs_.Update(*pipeline_->connector->Get());
190 } else {
191 configs_.FillHeadless();
192 }
193 if (!IsInHeadlessMode() && err != HWC2::Error::None) {
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200194 return HWC2::Error::BadDisplay;
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200195 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200196
Roman Stratiienko0137f862022-01-04 18:27:40 +0200197 return SetActiveConfig(configs_.preferred_config_id);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200198}
199
200HWC2::Error HwcDisplay::AcceptDisplayChanges() {
201 for (std::pair<const hwc2_layer_t, HwcLayer> &l : layers_)
202 l.second.AcceptTypeChange();
203 return HWC2::Error::None;
204}
205
206HWC2::Error HwcDisplay::CreateLayer(hwc2_layer_t *layer) {
Roman Stratiienko4b2cc482022-02-21 14:53:58 +0200207 layers_.emplace(static_cast<hwc2_layer_t>(layer_idx_), HwcLayer(this));
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200208 *layer = static_cast<hwc2_layer_t>(layer_idx_);
209 ++layer_idx_;
210 return HWC2::Error::None;
211}
212
213HWC2::Error HwcDisplay::DestroyLayer(hwc2_layer_t layer) {
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200214 if (!get_layer(layer)) {
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200215 return HWC2::Error::BadLayer;
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200216 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200217
218 layers_.erase(layer);
219 return HWC2::Error::None;
220}
221
222HWC2::Error HwcDisplay::GetActiveConfig(hwc2_config_t *config) const {
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200223 if (configs_.hwc_configs.count(staged_mode_config_id_) == 0)
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200224 return HWC2::Error::BadConfig;
225
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200226 *config = staged_mode_config_id_;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200227 return HWC2::Error::None;
228}
229
230HWC2::Error HwcDisplay::GetChangedCompositionTypes(uint32_t *num_elements,
231 hwc2_layer_t *layers,
232 int32_t *types) {
Roman Stratiienkof0c507f2022-01-17 18:29:24 +0200233 if (IsInHeadlessMode()) {
234 *num_elements = 0;
235 return HWC2::Error::None;
236 }
237
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200238 uint32_t num_changes = 0;
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300239 for (auto &l : layers_) {
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200240 if (l.second.IsTypeChanged()) {
241 if (layers && num_changes < *num_elements)
242 layers[num_changes] = l.first;
243 if (types && num_changes < *num_elements)
244 types[num_changes] = static_cast<int32_t>(l.second.GetValidatedType());
245 ++num_changes;
246 }
247 }
248 if (!layers && !types)
249 *num_elements = num_changes;
250 return HWC2::Error::None;
251}
252
253HWC2::Error HwcDisplay::GetClientTargetSupport(uint32_t width, uint32_t height,
254 int32_t /*format*/,
255 int32_t dataspace) {
Roman Stratiienkof0c507f2022-01-17 18:29:24 +0200256 if (IsInHeadlessMode()) {
257 return HWC2::Error::None;
258 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200259
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300260 auto min = pipeline_->device->GetMinResolution();
261 auto max = pipeline_->device->GetMaxResolution();
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200262
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200263 if (width < min.first || height < min.second)
264 return HWC2::Error::Unsupported;
265
266 if (width > max.first || height > max.second)
267 return HWC2::Error::Unsupported;
268
269 if (dataspace != HAL_DATASPACE_UNKNOWN)
270 return HWC2::Error::Unsupported;
271
272 // TODO(nobody): Validate format can be handled by either GL or planes
273 return HWC2::Error::None;
274}
275
276HWC2::Error HwcDisplay::GetColorModes(uint32_t *num_modes, int32_t *modes) {
277 if (!modes)
278 *num_modes = 1;
279
280 if (modes)
281 *modes = HAL_COLOR_MODE_NATIVE;
282
283 return HWC2::Error::None;
284}
285
286HWC2::Error HwcDisplay::GetDisplayAttribute(hwc2_config_t config,
287 int32_t attribute_in,
288 int32_t *value) {
289 int conf = static_cast<int>(config);
290
Roman Stratiienko0137f862022-01-04 18:27:40 +0200291 if (configs_.hwc_configs.count(conf) == 0) {
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200292 ALOGE("Could not find mode #%d", conf);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200293 return HWC2::Error::BadConfig;
294 }
295
Roman Stratiienko0137f862022-01-04 18:27:40 +0200296 auto &hwc_config = configs_.hwc_configs[conf];
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200297
298 static const int32_t kUmPerInch = 25400;
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300299 auto mm_width = configs_.mm_width;
300 auto mm_height = configs_.mm_height;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200301 auto attribute = static_cast<HWC2::Attribute>(attribute_in);
302 switch (attribute) {
303 case HWC2::Attribute::Width:
304 *value = static_cast<int>(hwc_config.mode.h_display());
305 break;
306 case HWC2::Attribute::Height:
307 *value = static_cast<int>(hwc_config.mode.v_display());
308 break;
309 case HWC2::Attribute::VsyncPeriod:
310 // in nanoseconds
311 *value = static_cast<int>(1E9 / hwc_config.mode.v_refresh());
312 break;
313 case HWC2::Attribute::DpiX:
314 // Dots per 1000 inches
315 *value = mm_width ? static_cast<int>(hwc_config.mode.h_display() *
316 kUmPerInch / mm_width)
317 : -1;
318 break;
319 case HWC2::Attribute::DpiY:
320 // Dots per 1000 inches
321 *value = mm_height ? static_cast<int>(hwc_config.mode.v_display() *
322 kUmPerInch / mm_height)
323 : -1;
324 break;
325#if PLATFORM_SDK_VERSION > 29
326 case HWC2::Attribute::ConfigGroup:
327 /* Dispite ConfigGroup is a part of HWC2.4 API, framework
328 * able to request it even if service @2.1 is used */
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200329 *value = int(hwc_config.group_id);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200330 break;
331#endif
332 default:
333 *value = -1;
334 return HWC2::Error::BadConfig;
335 }
336 return HWC2::Error::None;
337}
338
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200339HWC2::Error HwcDisplay::GetDisplayConfigs(uint32_t *num_configs,
340 hwc2_config_t *configs) {
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200341 uint32_t idx = 0;
Roman Stratiienko0137f862022-01-04 18:27:40 +0200342 for (auto &hwc_config : configs_.hwc_configs) {
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200343 if (hwc_config.second.disabled) {
344 continue;
345 }
346
347 if (configs != nullptr) {
348 if (idx >= *num_configs) {
349 break;
350 }
351 configs[idx] = hwc_config.second.id;
352 }
353
354 idx++;
355 }
356 *num_configs = idx;
357 return HWC2::Error::None;
358}
359
360HWC2::Error HwcDisplay::GetDisplayName(uint32_t *size, char *name) {
361 std::ostringstream stream;
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200362 if (IsInHeadlessMode()) {
363 stream << "null-display";
364 } else {
365 stream << "display-" << GetPipe().connector->Get()->GetId();
366 }
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300367 auto string = stream.str();
368 auto length = string.length();
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200369 if (!name) {
370 *size = length;
371 return HWC2::Error::None;
372 }
373
374 *size = std::min<uint32_t>(static_cast<uint32_t>(length - 1), *size);
375 strncpy(name, string.c_str(), *size);
376 return HWC2::Error::None;
377}
378
379HWC2::Error HwcDisplay::GetDisplayRequests(int32_t * /*display_requests*/,
380 uint32_t *num_elements,
381 hwc2_layer_t * /*layers*/,
382 int32_t * /*layer_requests*/) {
383 // TODO(nobody): I think virtual display should request
384 // HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT here
385 *num_elements = 0;
386 return HWC2::Error::None;
387}
388
389HWC2::Error HwcDisplay::GetDisplayType(int32_t *type) {
390 *type = static_cast<int32_t>(type_);
391 return HWC2::Error::None;
392}
393
394HWC2::Error HwcDisplay::GetDozeSupport(int32_t *support) {
395 *support = 0;
396 return HWC2::Error::None;
397}
398
399HWC2::Error HwcDisplay::GetHdrCapabilities(uint32_t *num_types,
400 int32_t * /*types*/,
401 float * /*max_luminance*/,
402 float * /*max_average_luminance*/,
403 float * /*min_luminance*/) {
404 *num_types = 0;
405 return HWC2::Error::None;
406}
407
408/* Find API details at:
409 * https://cs.android.com/android/platform/superproject/+/android-11.0.0_r3:hardware/libhardware/include/hardware/hwcomposer2.h;l=1767
Roman Stratiienkodd214942022-05-03 18:24:49 +0300410 *
411 * Called after PresentDisplay(), CLIENT is expecting release fence for the
412 * prior buffer (not the one assigned to the layer at the moment).
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200413 */
414HWC2::Error HwcDisplay::GetReleaseFences(uint32_t *num_elements,
415 hwc2_layer_t *layers,
416 int32_t *fences) {
Roman Stratiienkof0c507f2022-01-17 18:29:24 +0200417 if (IsInHeadlessMode()) {
418 *num_elements = 0;
419 return HWC2::Error::None;
420 }
421
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200422 uint32_t num_layers = 0;
423
Roman Stratiienkodd214942022-05-03 18:24:49 +0300424 for (auto &l : layers_) {
425 if (!l.second.GetPriorBufferScanOutFlag() || !present_fence_) {
426 continue;
427 }
428
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200429 ++num_layers;
Roman Stratiienkodd214942022-05-03 18:24:49 +0300430
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200431 if (layers == nullptr || fences == nullptr)
432 continue;
433
434 if (num_layers > *num_elements) {
435 ALOGW("Overflow num_elements %d/%d", num_layers, *num_elements);
436 return HWC2::Error::None;
437 }
438
439 layers[num_layers - 1] = l.first;
Roman Stratiienkodd214942022-05-03 18:24:49 +0300440 fences[num_layers - 1] = UniqueFd::Dup(present_fence_.Get()).Release();
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200441 }
442 *num_elements = num_layers;
Roman Stratiienkodd214942022-05-03 18:24:49 +0300443
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200444 return HWC2::Error::None;
445}
446
447HWC2::Error HwcDisplay::CreateComposition(AtomicCommitArgs &a_args) {
Roman Stratiienkof0c507f2022-01-17 18:29:24 +0200448 if (IsInHeadlessMode()) {
449 ALOGE("%s: Display is in headless mode, should never reach here", __func__);
450 return HWC2::Error::None;
451 }
452
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300453 auto PrevModeVsyncPeriodNs = static_cast<int>(
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200454 1E9 / GetPipe().connector->Get()->GetActiveMode().v_refresh());
455
456 auto mode_update_commited_ = false;
457 if (staged_mode_ &&
458 staged_mode_change_time_ <= ResourceManager::GetTimeMonotonicNs()) {
459 client_layer_.SetLayerDisplayFrame(
460 (hwc_rect_t){.left = 0,
461 .top = 0,
462 .right = static_cast<int>(staged_mode_->h_display()),
463 .bottom = static_cast<int>(staged_mode_->v_display())});
464
465 configs_.active_config_id = staged_mode_config_id_;
466
467 a_args.display_mode = *staged_mode_;
468 if (!a_args.test_only) {
469 mode_update_commited_ = true;
470 }
471 }
472
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200473 // order the layers by z-order
474 bool use_client_layer = false;
475 uint32_t client_z_order = UINT32_MAX;
476 std::map<uint32_t, HwcLayer *> z_map;
477 for (std::pair<const hwc2_layer_t, HwcLayer> &l : layers_) {
478 switch (l.second.GetValidatedType()) {
479 case HWC2::Composition::Device:
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300480 z_map.emplace(l.second.GetZOrder(), &l.second);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200481 break;
482 case HWC2::Composition::Client:
483 // Place it at the z_order of the lowest client layer
484 use_client_layer = true;
485 client_z_order = std::min(client_z_order, l.second.GetZOrder());
486 break;
487 default:
488 continue;
489 }
490 }
491 if (use_client_layer)
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300492 z_map.emplace(client_z_order, &client_layer_);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200493
494 if (z_map.empty())
495 return HWC2::Error::BadLayer;
496
Roman Stratiienko4b2cc482022-02-21 14:53:58 +0200497 std::vector<LayerData> composition_layers;
498
499 /* Import & populate */
500 for (std::pair<const uint32_t, HwcLayer *> &l : z_map) {
501 l.second->PopulateLayerData(a_args.test_only);
502 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200503
504 // now that they're ordered by z, add them to the composition
505 for (std::pair<const uint32_t, HwcLayer *> &l : z_map) {
Roman Stratiienko4b2cc482022-02-21 14:53:58 +0200506 if (!l.second->IsLayerUsableAsDevice()) {
507 /* This will be normally triggered on validation of the first frame
508 * containing CLIENT layer. At this moment client buffer is not yet
509 * provided by the CLIENT.
510 * This may be triggered once in HwcLayer lifecycle in case FB can't be
511 * imported. For example when non-contiguous buffer is imported into
512 * contiguous-only DRM/KMS driver.
513 */
514 return HWC2::Error::BadLayer;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200515 }
Roman Stratiienko4b2cc482022-02-21 14:53:58 +0200516 composition_layers.emplace_back(l.second->GetLayerData().Clone());
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200517 }
518
Roman Stratiienko9362cef2022-02-02 09:53:50 +0200519 /* Store plan to ensure shared planes won't be stolen by other display
520 * in between of ValidateDisplay() and PresentDisplay() calls
521 */
522 current_plan_ = DrmKmsPlan::CreateDrmKmsPlan(GetPipe(),
523 std::move(composition_layers));
524 if (!current_plan_) {
525 if (!a_args.test_only) {
526 ALOGE("Failed to create DrmKmsPlan");
527 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200528 return HWC2::Error::BadConfig;
529 }
530
Roman Stratiienko9362cef2022-02-02 09:53:50 +0200531 a_args.composition = current_plan_;
532
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300533 auto ret = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200534
535 if (ret) {
536 if (!a_args.test_only)
537 ALOGE("Failed to apply the frame composition ret=%d", ret);
538 return HWC2::Error::BadParameter;
539 }
540
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200541 if (mode_update_commited_) {
542 staged_mode_.reset();
543 vsync_tracking_en_ = false;
544 if (last_vsync_ts_ != 0) {
545 hwc2_->SendVsyncPeriodTimingChangedEventToClient(
546 handle_, last_vsync_ts_ + PrevModeVsyncPeriodNs);
547 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200548 }
549
550 return HWC2::Error::None;
551}
552
553/* Find API details at:
554 * https://cs.android.com/android/platform/superproject/+/android-11.0.0_r3:hardware/libhardware/include/hardware/hwcomposer2.h;l=1805
555 */
Roman Stratiienkodd214942022-05-03 18:24:49 +0300556HWC2::Error HwcDisplay::PresentDisplay(int32_t *out_present_fence) {
Roman Stratiienkof0c507f2022-01-17 18:29:24 +0200557 if (IsInHeadlessMode()) {
Roman Stratiienkodd214942022-05-03 18:24:49 +0300558 *out_present_fence = -1;
Roman Stratiienkof0c507f2022-01-17 18:29:24 +0200559 return HWC2::Error::None;
560 }
Roman Stratiienko780f7da2022-01-10 16:04:15 +0200561 HWC2::Error ret{};
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200562
563 ++total_stats_.total_frames_;
564
565 AtomicCommitArgs a_args{};
566 ret = CreateComposition(a_args);
567
568 if (ret != HWC2::Error::None)
569 ++total_stats_.failed_kms_present_;
570
571 if (ret == HWC2::Error::BadLayer) {
572 // Can we really have no client or device layers?
Roman Stratiienkodd214942022-05-03 18:24:49 +0300573 *out_present_fence = -1;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200574 return HWC2::Error::None;
575 }
576 if (ret != HWC2::Error::None)
577 return ret;
578
Roman Stratiienkodd214942022-05-03 18:24:49 +0300579 this->present_fence_ = UniqueFd::Dup(a_args.out_fence.Get());
580 *out_present_fence = a_args.out_fence.Release();
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200581
582 ++frame_no_;
583 return HWC2::Error::None;
584}
585
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200586HWC2::Error HwcDisplay::SetActiveConfigInternal(uint32_t config,
587 int64_t change_time) {
588 if (configs_.hwc_configs.count(config) == 0) {
589 ALOGE("Could not find active mode for %u", config);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200590 return HWC2::Error::BadConfig;
591 }
592
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200593 staged_mode_ = configs_.hwc_configs[config].mode;
594 staged_mode_change_time_ = change_time;
595 staged_mode_config_id_ = config;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200596
597 return HWC2::Error::None;
598}
599
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200600HWC2::Error HwcDisplay::SetActiveConfig(hwc2_config_t config) {
601 return SetActiveConfigInternal(config, ResourceManager::GetTimeMonotonicNs());
602}
603
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200604/* Find API details at:
605 * https://cs.android.com/android/platform/superproject/+/android-11.0.0_r3:hardware/libhardware/include/hardware/hwcomposer2.h;l=1861
606 */
607HWC2::Error HwcDisplay::SetClientTarget(buffer_handle_t target,
608 int32_t acquire_fence,
609 int32_t dataspace,
610 hwc_region_t /*damage*/) {
611 client_layer_.SetLayerBuffer(target, acquire_fence);
612 client_layer_.SetLayerDataspace(dataspace);
613
614 /*
615 * target can be nullptr, this does mean the Composer Service is calling
616 * cleanDisplayResources() on after receiving HOTPLUG event. See more at:
617 * https://cs.android.com/android/platform/superproject/+/master:hardware/interfaces/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/ComposerClient.h;l=350;drc=944b68180b008456ed2eb4d4d329e33b19bd5166
618 */
619 if (target == nullptr) {
Roman Stratiienkoa32f9072022-05-13 12:12:20 +0300620 client_layer_.SwChainClearCache();
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200621 return HWC2::Error::None;
622 }
623
Roman Stratiienko5070d512022-05-30 13:41:20 +0300624 if (IsInHeadlessMode()) {
625 return HWC2::Error::None;
626 }
627
Roman Stratiienko4b2cc482022-02-21 14:53:58 +0200628 client_layer_.PopulateLayerData(/*test = */ true);
629 if (!client_layer_.IsLayerUsableAsDevice()) {
630 ALOGE("Client layer must be always usable by DRM/KMS");
631 return HWC2::Error::BadLayer;
Roman Stratiienkoe9fbd8d2022-02-21 13:03:29 +0200632 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200633
Roman Stratiienko4b2cc482022-02-21 14:53:58 +0200634 auto &bi = client_layer_.GetLayerData().bi;
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300635 if (!bi) {
636 ALOGE("%s: Invalid state", __func__);
637 return HWC2::Error::BadLayer;
638 }
639
640 auto source_crop = (hwc_frect_t){.left = 0.0F,
641 .top = 0.0F,
642 .right = static_cast<float>(bi->width),
643 .bottom = static_cast<float>(bi->height)};
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200644 client_layer_.SetLayerSourceCrop(source_crop);
645
646 return HWC2::Error::None;
647}
648
649HWC2::Error HwcDisplay::SetColorMode(int32_t mode) {
650 if (mode < HAL_COLOR_MODE_NATIVE || mode > HAL_COLOR_MODE_BT2100_HLG)
651 return HWC2::Error::BadParameter;
652
653 if (mode != HAL_COLOR_MODE_NATIVE)
654 return HWC2::Error::Unsupported;
655
656 color_mode_ = mode;
657 return HWC2::Error::None;
658}
659
660HWC2::Error HwcDisplay::SetColorTransform(const float *matrix, int32_t hint) {
661 if (hint < HAL_COLOR_TRANSFORM_IDENTITY ||
662 hint > HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA)
663 return HWC2::Error::BadParameter;
664
665 if (!matrix && hint == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX)
666 return HWC2::Error::BadParameter;
667
668 color_transform_hint_ = static_cast<android_color_transform_t>(hint);
669 if (color_transform_hint_ == HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX)
670 std::copy(matrix, matrix + MATRIX_SIZE, color_transform_matrix_.begin());
671
672 return HWC2::Error::None;
673}
674
675HWC2::Error HwcDisplay::SetOutputBuffer(buffer_handle_t /*buffer*/,
676 int32_t /*release_fence*/) {
677 // TODO(nobody): Need virtual display support
678 return HWC2::Error::Unsupported;
679}
680
681HWC2::Error HwcDisplay::SetPowerMode(int32_t mode_in) {
682 auto mode = static_cast<HWC2::PowerMode>(mode_in);
Roman Stratiienkoccaf5162022-04-01 19:26:30 +0300683
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200684 AtomicCommitArgs a_args{};
685
686 switch (mode) {
687 case HWC2::PowerMode::Off:
688 a_args.active = false;
689 break;
690 case HWC2::PowerMode::On:
Roman Stratiienkoccaf5162022-04-01 19:26:30 +0300691 a_args.active = true;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200692 break;
693 case HWC2::PowerMode::Doze:
694 case HWC2::PowerMode::DozeSuspend:
695 return HWC2::Error::Unsupported;
696 default:
Roman Stratiienkoccaf5162022-04-01 19:26:30 +0300697 ALOGE("Incorrect power mode value (%d)\n", mode);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200698 return HWC2::Error::BadParameter;
Roman Stratiienkoccaf5162022-04-01 19:26:30 +0300699 }
700
701 if (IsInHeadlessMode()) {
702 return HWC2::Error::None;
703 }
704
Jia Ren80566fe2022-11-17 17:26:00 +0800705 if (a_args.active && *a_args.active) {
Roman Stratiienkoccaf5162022-04-01 19:26:30 +0300706 /*
707 * Setting the display to active before we have a composition
708 * can break some drivers, so skip setting a_args.active to
709 * true, as the next composition frame will implicitly activate
710 * the display
711 */
712 return GetPipe().atomic_state_manager->ActivateDisplayUsingDPMS() == 0
713 ? HWC2::Error::None
714 : HWC2::Error::BadParameter;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200715 };
716
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300717 auto err = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200718 if (err) {
719 ALOGE("Failed to apply the dpms composition err=%d", err);
720 return HWC2::Error::BadParameter;
721 }
722 return HWC2::Error::None;
723}
724
725HWC2::Error HwcDisplay::SetVsyncEnabled(int32_t enabled) {
Roman Stratiienko099c3112022-01-20 11:50:54 +0200726 vsync_event_en_ = HWC2_VSYNC_ENABLE == enabled;
727 if (vsync_event_en_) {
728 vsync_worker_.VSyncControl(true);
729 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200730 return HWC2::Error::None;
731}
732
733HWC2::Error HwcDisplay::ValidateDisplay(uint32_t *num_types,
734 uint32_t *num_requests) {
Roman Stratiienkof0c507f2022-01-17 18:29:24 +0200735 if (IsInHeadlessMode()) {
736 *num_types = *num_requests = 0;
737 return HWC2::Error::None;
738 }
Roman Stratiienkodd214942022-05-03 18:24:49 +0300739
740 /* In current drm_hwc design in case previous frame layer was not validated as
741 * a CLIENT, it is used by display controller (Front buffer). We have to store
742 * this state to provide the CLIENT with the release fences for such buffers.
743 */
744 for (auto &l : layers_) {
745 l.second.SetPriorBufferScanOutFlag(l.second.GetValidatedType() !=
746 HWC2::Composition::Client);
747 }
748
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200749 return backend_->ValidateDisplay(this, num_types, num_requests);
750}
751
752std::vector<HwcLayer *> HwcDisplay::GetOrderLayersByZPos() {
753 std::vector<HwcLayer *> ordered_layers;
754 ordered_layers.reserve(layers_.size());
755
756 for (auto &[handle, layer] : layers_) {
757 ordered_layers.emplace_back(&layer);
758 }
759
760 std::sort(std::begin(ordered_layers), std::end(ordered_layers),
761 [](const HwcLayer *lhs, const HwcLayer *rhs) {
762 return lhs->GetZOrder() < rhs->GetZOrder();
763 });
764
765 return ordered_layers;
766}
767
Roman Stratiienko099c3112022-01-20 11:50:54 +0200768HWC2::Error HwcDisplay::GetDisplayVsyncPeriod(
769 uint32_t *outVsyncPeriod /* ns */) {
770 return GetDisplayAttribute(configs_.active_config_id,
771 HWC2_ATTRIBUTE_VSYNC_PERIOD,
772 (int32_t *)(outVsyncPeriod));
773}
774
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200775#if PLATFORM_SDK_VERSION > 29
776HWC2::Error HwcDisplay::GetDisplayConnectionType(uint32_t *outType) {
Roman Stratiienko456e2d62022-01-29 01:17:39 +0200777 if (IsInHeadlessMode()) {
778 *outType = static_cast<uint32_t>(HWC2::DisplayConnectionType::Internal);
779 return HWC2::Error::None;
780 }
781 /* Primary display should be always internal,
782 * otherwise SF will be unhappy and will crash
783 */
Roman Stratiienko19c162f2022-02-01 09:35:08 +0200784 if (GetPipe().connector->Get()->IsInternal() || handle_ == kPrimaryDisplay)
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200785 *outType = static_cast<uint32_t>(HWC2::DisplayConnectionType::Internal);
Roman Stratiienko19c162f2022-02-01 09:35:08 +0200786 else if (GetPipe().connector->Get()->IsExternal())
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200787 *outType = static_cast<uint32_t>(HWC2::DisplayConnectionType::External);
788 else
789 return HWC2::Error::BadConfig;
790
791 return HWC2::Error::None;
792}
793
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200794HWC2::Error HwcDisplay::SetActiveConfigWithConstraints(
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200795 hwc2_config_t config,
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200796 hwc_vsync_period_change_constraints_t *vsyncPeriodChangeConstraints,
797 hwc_vsync_period_change_timeline_t *outTimeline) {
798 if (vsyncPeriodChangeConstraints == nullptr || outTimeline == nullptr) {
799 return HWC2::Error::BadParameter;
800 }
801
Roman Stratiienkod0c035b2022-01-21 15:12:56 +0200802 uint32_t current_vsync_period{};
803 GetDisplayVsyncPeriod(&current_vsync_period);
804
805 if (vsyncPeriodChangeConstraints->seamlessRequired) {
806 return HWC2::Error::SeamlessNotAllowed;
807 }
808
809 outTimeline->refreshTimeNanos = vsyncPeriodChangeConstraints
810 ->desiredTimeNanos -
811 current_vsync_period;
812 auto ret = SetActiveConfigInternal(config, outTimeline->refreshTimeNanos);
813 if (ret != HWC2::Error::None) {
814 return ret;
815 }
816
817 outTimeline->refreshRequired = true;
818 outTimeline->newVsyncAppliedTimeNanos = vsyncPeriodChangeConstraints
819 ->desiredTimeNanos;
820
821 last_vsync_ts_ = 0;
822 vsync_tracking_en_ = true;
823 vsync_worker_.VSyncControl(true);
824
825 return HWC2::Error::None;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200826}
827
828HWC2::Error HwcDisplay::SetAutoLowLatencyMode(bool /*on*/) {
829 return HWC2::Error::Unsupported;
830}
831
832HWC2::Error HwcDisplay::GetSupportedContentTypes(
833 uint32_t *outNumSupportedContentTypes,
834 const uint32_t *outSupportedContentTypes) {
835 if (outSupportedContentTypes == nullptr)
836 *outNumSupportedContentTypes = 0;
837
838 return HWC2::Error::None;
839}
840
841HWC2::Error HwcDisplay::SetContentType(int32_t contentType) {
842 if (contentType != HWC2_CONTENT_TYPE_NONE)
843 return HWC2::Error::Unsupported;
844
845 /* TODO: Map to the DRM Connector property:
846 * https://elixir.bootlin.com/linux/v5.4-rc5/source/drivers/gpu/drm/drm_connector.c#L809
847 */
848
849 return HWC2::Error::None;
850}
851#endif
852
853#if PLATFORM_SDK_VERSION > 28
854HWC2::Error HwcDisplay::GetDisplayIdentificationData(uint8_t *outPort,
855 uint32_t *outDataSize,
856 uint8_t *outData) {
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200857 if (IsInHeadlessMode()) {
Roman Stratiienkof87d8082022-05-06 11:33:56 +0300858 return HWC2::Error::Unsupported;
Roman Stratiienko3dacd472022-01-11 19:18:34 +0200859 }
Roman Stratiienkof87d8082022-05-06 11:33:56 +0300860
Roman Stratiienko19c162f2022-02-01 09:35:08 +0200861 auto blob = GetPipe().connector->Get()->GetEdidBlob();
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200862 if (!blob) {
Roman Stratiienkof87d8082022-05-06 11:33:56 +0300863 return HWC2::Error::Unsupported;
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200864 }
865
Roman Stratiienkof87d8082022-05-06 11:33:56 +0300866 *outPort = handle_; /* TDOD(nobody): What should be here? */
867
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200868 if (outData) {
869 *outDataSize = std::min(*outDataSize, blob->length);
870 memcpy(outData, blob->data, *outDataSize);
871 } else {
872 *outDataSize = blob->length;
873 }
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200874
875 return HWC2::Error::None;
876}
877
878HWC2::Error HwcDisplay::GetDisplayCapabilities(uint32_t *outNumCapabilities,
879 uint32_t * /*outCapabilities*/) {
880 if (outNumCapabilities == nullptr) {
881 return HWC2::Error::BadParameter;
882 }
883
884 *outNumCapabilities = 0;
885
886 return HWC2::Error::None;
887}
888
889HWC2::Error HwcDisplay::GetDisplayBrightnessSupport(bool *supported) {
890 *supported = false;
891 return HWC2::Error::None;
892}
893
894HWC2::Error HwcDisplay::SetDisplayBrightness(float /* brightness */) {
895 return HWC2::Error::Unsupported;
896}
897
898#endif /* PLATFORM_SDK_VERSION > 28 */
899
900#if PLATFORM_SDK_VERSION > 27
901
902HWC2::Error HwcDisplay::GetRenderIntents(
903 int32_t mode, uint32_t *outNumIntents,
904 int32_t * /*android_render_intent_v1_1_t*/ outIntents) {
905 if (mode != HAL_COLOR_MODE_NATIVE) {
906 return HWC2::Error::BadParameter;
907 }
908
909 if (outIntents == nullptr) {
910 *outNumIntents = 1;
911 return HWC2::Error::None;
912 }
913 *outNumIntents = 1;
914 outIntents[0] = HAL_RENDER_INTENT_COLORIMETRIC;
915 return HWC2::Error::None;
916}
917
918HWC2::Error HwcDisplay::SetColorModeWithIntent(int32_t mode, int32_t intent) {
919 if (intent < HAL_RENDER_INTENT_COLORIMETRIC ||
920 intent > HAL_RENDER_INTENT_TONE_MAP_ENHANCE)
921 return HWC2::Error::BadParameter;
922
923 if (mode < HAL_COLOR_MODE_NATIVE || mode > HAL_COLOR_MODE_BT2100_HLG)
924 return HWC2::Error::BadParameter;
925
926 if (mode != HAL_COLOR_MODE_NATIVE)
927 return HWC2::Error::Unsupported;
928
929 if (intent != HAL_RENDER_INTENT_COLORIMETRIC)
930 return HWC2::Error::Unsupported;
931
932 color_mode_ = mode;
933 return HWC2::Error::None;
934}
935
936#endif /* PLATFORM_SDK_VERSION > 27 */
937
938const Backend *HwcDisplay::backend() const {
939 return backend_.get();
940}
941
942void HwcDisplay::set_backend(std::unique_ptr<Backend> backend) {
943 backend_ = std::move(backend);
944}
945
Roman Stratiienko099c3112022-01-20 11:50:54 +0200946/* returns true if composition should be sent to client */
947bool HwcDisplay::ProcessClientFlatteningState(bool skip) {
Roman Stratiienkoa7913de2022-10-20 13:18:57 +0300948 const int flattenning_state = flattenning_state_;
Roman Stratiienko099c3112022-01-20 11:50:54 +0200949 if (flattenning_state == ClientFlattenningState::Disabled) {
950 return false;
951 }
952
953 if (skip) {
954 flattenning_state_ = ClientFlattenningState::NotRequired;
955 return false;
956 }
957
958 if (flattenning_state == ClientFlattenningState::ClientRefreshRequested) {
959 flattenning_state_ = ClientFlattenningState::Flattened;
960 return true;
961 }
962
963 vsync_flattening_en_ = true;
964 vsync_worker_.VSyncControl(true);
965 flattenning_state_ = ClientFlattenningState::VsyncCountdownMax;
966 return false;
967}
968
969void HwcDisplay::ProcessFlatenningVsyncInternal() {
970 if (flattenning_state_ > ClientFlattenningState::ClientRefreshRequested &&
971 --flattenning_state_ == ClientFlattenningState::ClientRefreshRequested &&
972 hwc2_->refresh_callback_.first != nullptr &&
973 hwc2_->refresh_callback_.second != nullptr) {
974 hwc2_->refresh_callback_.first(hwc2_->refresh_callback_.second, handle_);
975 vsync_flattening_en_ = false;
976 }
977}
978
Roman Stratiienko3627beb2022-01-04 16:02:55 +0200979} // namespace android