blob: 61d4541e77b6f162fb0bee790d46ce50650ce860 [file] [log] [blame]
Mathias Agopiana350ff92010-08-10 17:14:02 -07001/*
2 * Copyright (C) 2010 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
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080017// TODO(b/129481165): remove the #pragma below and fix conversion issues
ramindanic67d22c2023-11-28 14:58:47 -080018#include <chrono>
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -080019#pragma clang diagnostic push
20#pragma clang diagnostic ignored "-Wconversion"
21
Dan Stoza9e56aa02015-11-02 13:00:03 -080022// #define LOG_NDEBUG 0
23
24#undef LOG_TAG
25#define LOG_TAG "HWComposer"
Mathias Agopian2965b262012-04-08 15:13:32 -070026#define ATRACE_TAG ATRACE_TAG_GRAPHICS
27
Lloyd Pique66d68602019-02-13 14:23:31 -080028#include "HWComposer.h"
29
Marin Shalamanovf8c63722020-10-06 13:11:21 +020030#include <android-base/properties.h>
Vishnu Nairbe0ad902024-06-27 23:38:43 +000031#include <common/trace.h>
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080032#include <compositionengine/Output.h>
33#include <compositionengine/OutputLayer.h>
34#include <compositionengine/impl/OutputLayerCompositionState.h>
Leon Scroggins III959a7ff2023-02-07 11:24:25 -050035#include <ftl/concat.h>
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080036#include <log/log.h>
Dominik Laskowskifc2c0322018-04-19 14:47:33 -070037#include <ui/DebugUtils.h>
Mathias Agopian921e6ac2012-07-23 23:11:29 -070038#include <ui/GraphicBuffer.h>
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080039#include <utils/Errors.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070040
Lloyd Pique66d68602019-02-13 14:23:31 -080041#include "../Layer.h" // needed only for debugging
Marin Shalamanovf8c63722020-10-06 13:11:21 +020042#include "../SurfaceFlingerProperties.h"
Lloyd Pique66d68602019-02-13 14:23:31 -080043#include "ComposerHal.h"
44#include "HWC2.h"
Mathias Agopiana350ff92010-08-10 17:14:02 -070045
Dominik Laskowskic1f18f62018-06-13 15:17:55 -070046#define LOG_HWC_DISPLAY_ERROR(hwcDisplayId, msg) \
47 ALOGE("%s failed for HWC display %" PRIu64 ": %s", __FUNCTION__, hwcDisplayId, msg)
48
Dominik Laskowskifc2c0322018-04-19 14:47:33 -070049#define LOG_DISPLAY_ERROR(displayId, msg) \
Dominik Laskowski34157762018-10-31 13:07:19 -070050 ALOGE("%s failed for display %s: %s", __FUNCTION__, to_string(displayId).c_str(), msg)
Dominik Laskowskifc2c0322018-04-19 14:47:33 -070051
Dominik Laskowski34157762018-10-31 13:07:19 -070052#define LOG_HWC_ERROR(what, error, displayId) \
53 ALOGE("%s: %s failed for display %s: %s (%d)", __FUNCTION__, what, \
54 to_string(displayId).c_str(), to_string(error).c_str(), static_cast<int32_t>(error))
Dominik Laskowskifc2c0322018-04-19 14:47:33 -070055
56#define RETURN_IF_INVALID_DISPLAY(displayId, ...) \
57 do { \
Dominik Laskowski075d3172018-05-24 15:50:06 -070058 if (mDisplayData.count(displayId) == 0) { \
Dominik Laskowskifc2c0322018-04-19 14:47:33 -070059 LOG_DISPLAY_ERROR(displayId, "Invalid display"); \
60 return __VA_ARGS__; \
61 } \
62 } while (false)
63
64#define RETURN_IF_HWC_ERROR_FOR(what, error, displayId, ...) \
65 do { \
Peiyong Line9d809e2020-04-14 13:10:48 -070066 if (error != hal::Error::NONE) { \
Dominik Laskowskifc2c0322018-04-19 14:47:33 -070067 LOG_HWC_ERROR(what, error, displayId); \
68 return __VA_ARGS__; \
69 } \
70 } while (false)
71
72#define RETURN_IF_HWC_ERROR(error, displayId, ...) \
73 RETURN_IF_HWC_ERROR_FOR(__FUNCTION__, error, displayId, __VA_ARGS__)
74
Kriti Dang674b9372022-11-18 10:58:44 +010075using aidl::android::hardware::graphics::common::HdrConversionCapability;
76using aidl::android::hardware::graphics::common::HdrConversionStrategy;
Ady Abrahamde549d42022-01-26 19:19:17 -080077using aidl::android::hardware::graphics::composer3::Capability;
78using aidl::android::hardware::graphics::composer3::DisplayCapability;
Lucas Berthou8d0a0c42024-08-27 14:32:31 +000079using aidl::android::hardware::graphics::composer3::DisplayConfiguration;
ramindani355fca82023-12-18 12:07:34 -080080using namespace std::string_literals;
Peiyong Line9d809e2020-04-14 13:10:48 -070081
Marin Shalamanov6e840172020-12-14 22:13:28 +010082namespace android {
Peiyong Linbdd08cc2019-12-17 21:35:14 -080083
Lloyd Pique441d5042018-10-18 16:49:51 -070084HWComposer::~HWComposer() = default;
85
86namespace impl {
87
Marin Shalamanovf8c63722020-10-06 13:11:21 +020088HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer)
89 : mComposer(std::move(composer)),
Dominik Laskowski13948602021-03-08 20:48:28 -080090 mMaxVirtualDisplayDimension(static_cast<size_t>(sysprop::max_virtual_display_dimension(0))),
Marin Shalamanovf8c63722020-10-06 13:11:21 +020091 mUpdateDeviceProductInfoOnHotplugReconnect(
ramindani355fca82023-12-18 12:07:34 -080092 sysprop::update_device_product_info_on_hotplug_reconnect(false)),
ramindanid2dc07a2024-02-16 16:34:03 -080093 mEnableVrrTimeout(base::GetBoolProperty("debug.sf.vrr_timeout_hint_enabled"s, true)) {}
Peiyong Linbdd08cc2019-12-17 21:35:14 -080094
95HWComposer::HWComposer(const std::string& composerServiceName)
Ady Abraham9fc28052021-10-14 17:21:38 -070096 : HWComposer(Hwc2::Composer::create(composerServiceName)) {}
Mathias Agopianbef42c52013-08-21 17:45:46 -070097
Dominik Laskowskib04f98a2018-11-07 21:07:16 -080098HWComposer::~HWComposer() {
99 mDisplayData.clear();
100}
Dan Stoza9e56aa02015-11-02 13:00:03 -0800101
Yichi Chen3401b562022-01-17 15:42:35 +0800102void HWComposer::setCallback(HWC2::ComposerCallback& callback) {
Lloyd Pique4603f3c2020-02-11 12:06:56 -0800103 loadCapabilities();
104 loadLayerMetadataSupport();
Sally Qibb866c12022-10-17 11:31:20 -0700105 loadOverlayProperties();
Kriti Dang674b9372022-11-18 10:58:44 +0100106 loadHdrConversionCapabilities();
Lloyd Pique4603f3c2020-02-11 12:06:56 -0800107
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800108 if (mRegisteredCallback) {
109 ALOGW("Callback already registered. Ignored extra registration attempt.");
110 return;
111 }
112 mRegisteredCallback = true;
Dominik Laskowskiebc8d3a2021-04-16 23:18:31 -0700113
Yichi Chen3401b562022-01-17 15:42:35 +0800114 mComposer->registerCallback(callback);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800115}
116
Peiyong Line9d809e2020-04-14 13:10:48 -0700117bool HWComposer::getDisplayIdentificationData(hal::HWDisplayId hwcDisplayId, uint8_t* outPort,
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700118 DisplayIdentificationData* outData) const {
Peiyong Line9d809e2020-04-14 13:10:48 -0700119 const auto error = static_cast<hal::Error>(
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800120 mComposer->getDisplayIdentificationData(hwcDisplayId, outPort, outData));
Peiyong Line9d809e2020-04-14 13:10:48 -0700121 if (error != hal::Error::NONE) {
122 if (error != hal::Error::UNSUPPORTED) {
Chia-I Wud0aff9d2018-06-21 13:39:09 +0800123 LOG_HWC_DISPLAY_ERROR(hwcDisplayId, to_string(error).c_str());
124 }
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700125 return false;
126 }
127 return true;
128}
129
Ady Abrahamde549d42022-01-26 19:19:17 -0800130bool HWComposer::hasCapability(Capability capability) const {
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800131 return mCapabilities.count(capability) > 0;
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700132}
133
Ady Abrahamde549d42022-01-26 19:19:17 -0800134bool HWComposer::hasDisplayCapability(HalDisplayId displayId, DisplayCapability capability) const {
Dominik Laskowski1162e472020-04-02 19:02:47 -0700135 RETURN_IF_INVALID_DISPLAY(displayId, false);
Ady Abraham27fbcc72021-09-20 14:54:57 -0700136 return mDisplayData.at(displayId).hwcDisplay->hasCapability(capability);
Peiyong Lined531a32018-10-26 18:27:56 -0700137}
138
Peiyong Line9d809e2020-04-14 13:10:48 -0700139std::optional<DisplayIdentificationInfo> HWComposer::onHotplug(hal::HWDisplayId hwcDisplayId,
140 hal::Connection connection) {
Marin Shalamanovbdd59152020-02-14 15:30:06 +0100141 switch (connection) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700142 case hal::Connection::CONNECTED:
Marin Shalamanovbdd59152020-02-14 15:30:06 +0100143 return onHotplugConnect(hwcDisplayId);
Peiyong Line9d809e2020-04-14 13:10:48 -0700144 case hal::Connection::DISCONNECTED:
Marin Shalamanovbdd59152020-02-14 15:30:06 +0100145 return onHotplugDisconnect(hwcDisplayId);
Peiyong Line9d809e2020-04-14 13:10:48 -0700146 case hal::Connection::INVALID:
Dominik Laskowski075d3172018-05-24 15:50:06 -0700147 return {};
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700148 }
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700149}
150
Marin Shalamanovf8c63722020-10-06 13:11:21 +0200151bool HWComposer::updatesDeviceProductInfoOnHotplugReconnect() const {
152 return mUpdateDeviceProductInfoOnHotplugReconnect;
153}
154
Leon Scroggins III959a7ff2023-02-07 11:24:25 -0500155std::optional<PhysicalDisplayId> HWComposer::onVsync(hal::HWDisplayId hwcDisplayId,
156 nsecs_t timestamp) {
157 const auto displayIdOpt = toPhysicalDisplayId(hwcDisplayId);
158 if (!displayIdOpt) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700159 LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Invalid HWC display");
Leon Scroggins III959a7ff2023-02-07 11:24:25 -0500160 return {};
Jesse Hall1bd20e02012-08-29 10:47:52 -0700161 }
Jesse Hall1bd20e02012-08-29 10:47:52 -0700162
Leon Scroggins III959a7ff2023-02-07 11:24:25 -0500163 RETURN_IF_INVALID_DISPLAY(*displayIdOpt, {});
Dominik Laskowskic1f18f62018-06-13 15:17:55 -0700164
Leon Scroggins III959a7ff2023-02-07 11:24:25 -0500165 auto& displayData = mDisplayData[*displayIdOpt];
Jesse Hall1bd20e02012-08-29 10:47:52 -0700166
Dan Stoza9e56aa02015-11-02 13:00:03 -0800167 {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800168 // There have been reports of HWCs that signal several vsync events
169 // with the same timestamp when turning the display off and on. This
170 // is a bug in the HWC implementation, but filter the extra events
171 // out here so they don't cause havoc downstream.
Dominik Laskowskidc2bb802022-09-28 16:02:59 -0400172 if (timestamp == displayData.lastPresentTimestamp) {
Dominik Laskowski34157762018-10-31 13:07:19 -0700173 ALOGW("Ignoring duplicate VSYNC event from HWC for display %s (t=%" PRId64 ")",
Leon Scroggins III959a7ff2023-02-07 11:24:25 -0500174 to_string(*displayIdOpt).c_str(), timestamp);
175 return {};
Dan Stoza9e56aa02015-11-02 13:00:03 -0800176 }
177
Dominik Laskowskidc2bb802022-09-28 16:02:59 -0400178 displayData.lastPresentTimestamp = timestamp;
Jesse Hall1c569c42013-04-05 13:44:52 -0700179 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800180
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000181 SFTRACE_INT(ftl::Concat("HW_VSYNC_", displayIdOpt->value).c_str(),
182 displayData.vsyncTraceToggle);
Dominik Laskowski1af47932018-11-12 10:20:46 -0800183 displayData.vsyncTraceToggle = !displayData.vsyncTraceToggle;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800184
Leon Scroggins III959a7ff2023-02-07 11:24:25 -0500185 return displayIdOpt;
Jesse Hall1c569c42013-04-05 13:44:52 -0700186}
187
Dominik Laskowski13948602021-03-08 20:48:28 -0800188size_t HWComposer::getMaxVirtualDisplayCount() const {
189 return mComposer->getMaxVirtualDisplayCount();
190}
191
192size_t HWComposer::getMaxVirtualDisplayDimension() const {
193 return mMaxVirtualDisplayDimension;
194}
195
196bool HWComposer::allocateVirtualDisplay(HalVirtualDisplayId displayId, ui::Size resolution,
Dominik Laskowski263eec42021-07-21 23:13:24 -0700197 ui::PixelFormat* format) {
Dominik Laskowski13948602021-03-08 20:48:28 -0800198 if (!resolution.isValid()) {
199 ALOGE("%s: Invalid resolution %dx%d", __func__, resolution.width, resolution.height);
200 return false;
Fabien Sanglarde29055f2017-03-08 11:36:46 -0800201 }
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200202
Dominik Laskowski13948602021-03-08 20:48:28 -0800203 const uint32_t width = static_cast<uint32_t>(resolution.width);
204 const uint32_t height = static_cast<uint32_t>(resolution.height);
205
206 if (mMaxVirtualDisplayDimension > 0 &&
207 (width > mMaxVirtualDisplayDimension || height > mMaxVirtualDisplayDimension)) {
208 ALOGE("%s: Resolution %ux%u exceeds maximum dimension %zu", __func__, width, height,
209 mMaxVirtualDisplayDimension);
210 return false;
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200211 }
212
Dominik Laskowski13948602021-03-08 20:48:28 -0800213 hal::HWDisplayId hwcDisplayId;
Peiyong Line9d809e2020-04-14 13:10:48 -0700214 const auto error = static_cast<hal::Error>(
Dominik Laskowski263eec42021-07-21 23:13:24 -0700215 mComposer->createVirtualDisplay(width, height, format, &hwcDisplayId));
Dominik Laskowski13948602021-03-08 20:48:28 -0800216 RETURN_IF_HWC_ERROR_FOR("createVirtualDisplay", error, displayId, false);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800217
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800218 auto display = std::make_unique<HWC2::impl::Display>(*mComposer.get(), mCapabilities,
Peiyong Line9d809e2020-04-14 13:10:48 -0700219 hwcDisplayId, hal::DisplayType::VIRTUAL);
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800220 display->setConnected(true);
Dominik Laskowski13948602021-03-08 20:48:28 -0800221 auto& displayData = mDisplayData[displayId];
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800222 displayData.hwcDisplay = std::move(display);
Dominik Laskowski13948602021-03-08 20:48:28 -0800223 return true;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700224}
225
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000226void HWComposer::allocatePhysicalDisplay(hal::HWDisplayId hwcDisplayId, PhysicalDisplayId displayId,
227 std::optional<ui::Size> physicalSize) {
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100228 mPhysicalDisplayIdMap[hwcDisplayId] = displayId;
229
Dominik Laskowskif8db0f02021-04-19 11:05:25 -0700230 if (!mPrimaryHwcDisplayId) {
231 mPrimaryHwcDisplayId = hwcDisplayId;
Marin Shalamanovbdd59152020-02-14 15:30:06 +0100232 }
233
234 auto& displayData = mDisplayData[displayId];
235 auto newDisplay =
236 std::make_unique<HWC2::impl::Display>(*mComposer.get(), mCapabilities, hwcDisplayId,
Peiyong Line9d809e2020-04-14 13:10:48 -0700237 hal::DisplayType::PHYSICAL);
Marin Shalamanovbdd59152020-02-14 15:30:06 +0100238 newDisplay->setConnected(true);
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000239 newDisplay->setPhysicalSizeInMm(physicalSize);
Marin Shalamanovbdd59152020-02-14 15:30:06 +0100240 displayData.hwcDisplay = std::move(newDisplay);
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100241}
242
243int32_t HWComposer::getAttribute(hal::HWDisplayId hwcDisplayId, hal::HWConfigId configId,
Marin Shalamanov045b7002021-01-07 16:56:24 +0100244 hal::Attribute attribute) const {
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100245 int32_t value = 0;
246 auto error = static_cast<hal::Error>(
247 mComposer->getDisplayAttribute(hwcDisplayId, configId, attribute, &value));
248
249 RETURN_IF_HWC_ERROR_FOR("getDisplayAttribute", error, *toPhysicalDisplayId(hwcDisplayId), -1);
250 return value;
251}
252
Lloyd Pique1b33fc32021-05-07 14:36:58 -0700253std::shared_ptr<HWC2::Layer> HWComposer::createLayer(HalDisplayId displayId) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700254 RETURN_IF_INVALID_DISPLAY(displayId, nullptr);
255
Lloyd Pique1b33fc32021-05-07 14:36:58 -0700256 auto expected = mDisplayData[displayId].hwcDisplay->createLayer();
257 if (!expected.has_value()) {
258 auto error = std::move(expected).error();
259 RETURN_IF_HWC_ERROR(error, displayId, nullptr);
260 }
261 return std::move(expected).value();
Steven Thomas94e35b92017-07-26 18:48:28 -0700262}
263
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200264bool HWComposer::isConnected(PhysicalDisplayId displayId) const {
Dominik Laskowskif2ddca62022-08-17 12:08:07 -0700265 return mDisplayData.count(displayId) && mDisplayData.at(displayId).hwcDisplay->isConnected();
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700266}
267
ramindani263a3f12023-07-18 20:44:49 -0700268std::vector<HWComposer::HWCDisplayMode> HWComposer::getModes(PhysicalDisplayId displayId,
269 int32_t maxFrameIntervalNs) const {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700270 RETURN_IF_INVALID_DISPLAY(displayId, {});
271
Marin Shalamanov045b7002021-01-07 16:56:24 +0100272 const auto hwcDisplayId = mDisplayData.at(displayId).hwcDisplay->getId();
ramindani0cd1d8d2023-06-13 13:43:23 -0700273
ramindani19919ff2023-12-07 11:27:06 -0800274 if (mComposer->isVrrSupported()) {
ramindani263a3f12023-07-18 20:44:49 -0700275 return getModesFromDisplayConfigurations(hwcDisplayId, maxFrameIntervalNs);
ramindani0cd1d8d2023-06-13 13:43:23 -0700276 }
277
278 return getModesFromLegacyDisplayConfigs(hwcDisplayId);
279}
280
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000281DisplayConfiguration::Dpi HWComposer::getEstimatedDotsPerInchFromSize(
282 uint64_t hwcDisplayId, const HWCDisplayMode& hwcMode) const {
283 if (!FlagManager::getInstance().correct_dpi_with_display_size()) {
284 return {-1, -1};
285 }
286 if (const auto displayId = toPhysicalDisplayId(hwcDisplayId)) {
287 if (const auto it = mDisplayData.find(displayId.value());
288 it != mDisplayData.end() && it->second.hwcDisplay->getPhysicalSizeInMm()) {
289 ui::Size size = it->second.hwcDisplay->getPhysicalSizeInMm().value();
290 if (hwcMode.width > 0 && hwcMode.height > 0 && size.width > 0 && size.height > 0) {
291 static constexpr float kMmPerInch = 25.4f;
292 return {hwcMode.width * kMmPerInch / size.width,
293 hwcMode.height * kMmPerInch / size.height};
294 }
295 }
296 }
297 return {-1, -1};
298}
299
300DisplayConfiguration::Dpi HWComposer::correctedDpiIfneeded(
301 DisplayConfiguration::Dpi dpi, DisplayConfiguration::Dpi estimatedDpi) const {
302 // hwc can be unreliable when it comes to dpi. A rough estimated dpi may yield better
303 // results. For instance, libdrm and bad edid may result in a dpi of {350, 290} for a
304 // 16:9 3840x2160 display, which would match a 4:3 aspect ratio.
305 // The logic here checks if hwc was able to provide some dpi, and if so if the dpi
306 // disparity between the axes is more reasonable than a rough estimate, otherwise use
307 // the estimated dpi as a corrected value.
Lucas Berthou685c3522024-09-16 14:39:05 +0000308 if (estimatedDpi.x == -1 || estimatedDpi.y == -1) {
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000309 return dpi;
310 }
311 if (dpi.x == -1 || dpi.y == -1) {
312 return estimatedDpi;
313 }
314 if (std::min(dpi.x, dpi.y) != 0 && std::min(estimatedDpi.x, estimatedDpi.y) != 0 &&
315 abs(dpi.x - dpi.y) / std::min(dpi.x, dpi.y) >
316 abs(estimatedDpi.x - estimatedDpi.y) / std::min(estimatedDpi.x, estimatedDpi.y)) {
317 return estimatedDpi;
318 }
319 return dpi;
320}
321
ramindani0cd1d8d2023-06-13 13:43:23 -0700322std::vector<HWComposer::HWCDisplayMode> HWComposer::getModesFromDisplayConfigurations(
ramindani263a3f12023-07-18 20:44:49 -0700323 uint64_t hwcDisplayId, int32_t maxFrameIntervalNs) const {
ramindani0cd1d8d2023-06-13 13:43:23 -0700324 std::vector<hal::DisplayConfiguration> configs;
ramindani263a3f12023-07-18 20:44:49 -0700325 auto error = static_cast<hal::Error>(
326 mComposer->getDisplayConfigurations(hwcDisplayId, maxFrameIntervalNs, &configs));
ramindani0cd1d8d2023-06-13 13:43:23 -0700327 RETURN_IF_HWC_ERROR_FOR("getDisplayConfigurations", error, *toPhysicalDisplayId(hwcDisplayId),
328 {});
329
330 std::vector<HWCDisplayMode> modes;
331 modes.reserve(configs.size());
332 for (auto config : configs) {
ramindania04b8a52023-08-07 18:49:47 -0700333 auto hwcMode = HWCDisplayMode{.hwcId = static_cast<hal::HWConfigId>(config.configId),
334 .width = config.width,
335 .height = config.height,
336 .vsyncPeriod = config.vsyncPeriod,
337 .configGroup = config.configGroup,
338 .vrrConfig = config.vrrConfig};
ramindani0cd1d8d2023-06-13 13:43:23 -0700339
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000340 const DisplayConfiguration::Dpi estimatedDPI =
341 getEstimatedDotsPerInchFromSize(hwcDisplayId, hwcMode);
ramindani0cd1d8d2023-06-13 13:43:23 -0700342 if (config.dpi) {
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000343 const DisplayConfiguration::Dpi dpi =
344 correctedDpiIfneeded(config.dpi.value(), estimatedDPI);
345 hwcMode.dpiX = dpi.x;
346 hwcMode.dpiY = dpi.y;
347 } else if (estimatedDPI.x != -1 && estimatedDPI.y != -1) {
348 hwcMode.dpiX = estimatedDPI.x;
349 hwcMode.dpiY = estimatedDPI.y;
ramindani0cd1d8d2023-06-13 13:43:23 -0700350 }
351
ramindani355fca82023-12-18 12:07:34 -0800352 if (!mEnableVrrTimeout) {
353 hwcMode.vrrConfig->notifyExpectedPresentConfig = {};
354 }
355
ramindani0cd1d8d2023-06-13 13:43:23 -0700356 modes.push_back(hwcMode);
357 }
358
359 return modes;
360}
361
362std::vector<HWComposer::HWCDisplayMode> HWComposer::getModesFromLegacyDisplayConfigs(
363 uint64_t hwcDisplayId) const {
Marin Shalamanov045b7002021-01-07 16:56:24 +0100364 std::vector<hal::HWConfigId> configIds;
365 auto error = static_cast<hal::Error>(mComposer->getDisplayConfigs(hwcDisplayId, &configIds));
366 RETURN_IF_HWC_ERROR_FOR("getDisplayConfigs", error, *toPhysicalDisplayId(hwcDisplayId), {});
367
368 std::vector<HWCDisplayMode> modes;
369 modes.reserve(configIds.size());
370 for (auto configId : configIds) {
ramindani0cd1d8d2023-06-13 13:43:23 -0700371 auto hwcMode = HWCDisplayMode{
Marin Shalamanov045b7002021-01-07 16:56:24 +0100372 .hwcId = configId,
373 .width = getAttribute(hwcDisplayId, configId, hal::Attribute::WIDTH),
374 .height = getAttribute(hwcDisplayId, configId, hal::Attribute::HEIGHT),
375 .vsyncPeriod = getAttribute(hwcDisplayId, configId, hal::Attribute::VSYNC_PERIOD),
Marin Shalamanov045b7002021-01-07 16:56:24 +0100376 .configGroup = getAttribute(hwcDisplayId, configId, hal::Attribute::CONFIG_GROUP),
ramindani0cd1d8d2023-06-13 13:43:23 -0700377 };
Marin Shalamanov045b7002021-01-07 16:56:24 +0100378
ramindani0cd1d8d2023-06-13 13:43:23 -0700379 const int32_t dpiX = getAttribute(hwcDisplayId, configId, hal::Attribute::DPI_X);
380 const int32_t dpiY = getAttribute(hwcDisplayId, configId, hal::Attribute::DPI_Y);
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000381 const DisplayConfiguration::Dpi hwcDpi =
Lucas Berthouae3611d2024-10-16 19:58:52 +0000382 DisplayConfiguration::Dpi{dpiX == -1 ? dpiX : dpiX / 1000.f,
Lucas Berthou8d0a0c42024-08-27 14:32:31 +0000383 dpiY == -1 ? dpiY : dpiY / 1000.f};
384 const DisplayConfiguration::Dpi estimatedDPI =
385 getEstimatedDotsPerInchFromSize(hwcDisplayId, hwcMode);
386 const DisplayConfiguration::Dpi dpi = correctedDpiIfneeded(hwcDpi, estimatedDPI);
387 hwcMode.dpiX = dpi.x;
388 hwcMode.dpiY = dpi.y;
ramindani0cd1d8d2023-06-13 13:43:23 -0700389
390 modes.push_back(hwcMode);
391 }
Marin Shalamanov045b7002021-01-07 16:56:24 +0100392 return modes;
Mathias Agopianda27af92012-09-13 18:17:13 -0700393}
394
Dominik Laskowskid940a012024-01-28 13:25:44 -0500395ftl::Expected<hal::HWConfigId, status_t> HWComposer::getActiveMode(
396 PhysicalDisplayId displayId) const {
397 RETURN_IF_INVALID_DISPLAY(displayId, ftl::Unexpected(BAD_INDEX));
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100398 const auto hwcId = *fromPhysicalDisplayId(displayId);
Dominik Laskowskie2c5b0a2022-08-10 14:53:53 -0700399
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100400 hal::HWConfigId configId;
Dominik Laskowskie2c5b0a2022-08-10 14:53:53 -0700401 const auto error = static_cast<hal::Error>(mComposer->getActiveConfig(hwcId, &configId));
Dominik Laskowskid940a012024-01-28 13:25:44 -0500402 if (error == hal::Error::BAD_CONFIG) {
403 return ftl::Unexpected(NO_INIT);
404 }
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100405
Dominik Laskowskid940a012024-01-28 13:25:44 -0500406 RETURN_IF_HWC_ERROR_FOR("getActiveConfig", error, displayId, ftl::Unexpected(UNKNOWN_ERROR));
Marin Shalamanov045b7002021-01-07 16:56:24 +0100407 return configId;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700408}
409
Ady Abraham3a77a7b2019-12-02 18:46:59 -0800410// Composer 2.4
411
Marin Shalamanov228f46b2021-01-28 21:11:45 +0100412ui::DisplayConnectionType HWComposer::getDisplayConnectionType(PhysicalDisplayId displayId) const {
413 RETURN_IF_INVALID_DISPLAY(displayId, ui::DisplayConnectionType::Internal);
Dominik Laskowski55c85402020-01-21 16:25:47 -0800414 const auto& hwcDisplay = mDisplayData.at(displayId).hwcDisplay;
415
Dominik Laskowski969cdcb2024-02-08 16:35:29 -0500416 if (const auto connectionType = hwcDisplay->getConnectionType()) {
417 return connectionType.value();
418 } else {
419 LOG_HWC_ERROR(__func__, connectionType.error(), displayId);
420 return hwcDisplay->getId() == mPrimaryHwcDisplayId ? ui::DisplayConnectionType::Internal
421 : ui::DisplayConnectionType::External;
422 }
Dominik Laskowski55c85402020-01-21 16:25:47 -0800423}
424
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200425bool HWComposer::isVsyncPeriodSwitchSupported(PhysicalDisplayId displayId) const {
Dominik Laskowski55c85402020-01-21 16:25:47 -0800426 RETURN_IF_INVALID_DISPLAY(displayId, false);
Ady Abraham3a77a7b2019-12-02 18:46:59 -0800427 return mDisplayData.at(displayId).hwcDisplay->isVsyncPeriodSwitchSupported();
428}
429
Dominik Laskowskia109bb22024-01-28 13:33:51 -0500430ftl::Expected<nsecs_t, status_t> HWComposer::getDisplayVsyncPeriod(
431 PhysicalDisplayId displayId) const {
432 RETURN_IF_INVALID_DISPLAY(displayId, ftl::Unexpected(BAD_INDEX));
Dominik Laskowski55c85402020-01-21 16:25:47 -0800433
Marin Shalamanov045b7002021-01-07 16:56:24 +0100434 if (!isVsyncPeriodSwitchSupported(displayId)) {
Dominik Laskowskia109bb22024-01-28 13:33:51 -0500435 return ftl::Unexpected(INVALID_OPERATION);
Dominik Laskowskif3749f82018-06-13 15:49:25 -0700436 }
Dominik Laskowskia109bb22024-01-28 13:33:51 -0500437
Marin Shalamanov045b7002021-01-07 16:56:24 +0100438 const auto hwcId = *fromPhysicalDisplayId(displayId);
439 Hwc2::VsyncPeriodNanos vsyncPeriodNanos = 0;
Dominik Laskowskia109bb22024-01-28 13:33:51 -0500440 const auto error =
Marin Shalamanov045b7002021-01-07 16:56:24 +0100441 static_cast<hal::Error>(mComposer->getDisplayVsyncPeriod(hwcId, &vsyncPeriodNanos));
Dominik Laskowskia109bb22024-01-28 13:33:51 -0500442 RETURN_IF_HWC_ERROR(error, displayId, ftl::Unexpected(UNKNOWN_ERROR));
443 return static_cast<nsecs_t>(vsyncPeriodNanos);
Lloyd Pique3c085a02018-05-09 19:38:32 -0700444}
445
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200446std::vector<ui::ColorMode> HWComposer::getColorModes(PhysicalDisplayId displayId) const {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700447 RETURN_IF_INVALID_DISPLAY(displayId, {});
448
Peiyong Linfd997e02018-03-28 15:29:00 -0700449 std::vector<ui::ColorMode> modes;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700450 auto error = mDisplayData.at(displayId).hwcDisplay->getColorModes(&modes);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700451 RETURN_IF_HWC_ERROR(error, displayId, {});
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600452 return modes;
453}
454
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200455status_t HWComposer::setActiveColorMode(PhysicalDisplayId displayId, ui::ColorMode mode,
Dominik Laskowski075d3172018-05-24 15:50:06 -0700456 ui::RenderIntent renderIntent) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700457 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Michael Wright28f24d02016-07-12 13:30:53 -0700458
459 auto& displayData = mDisplayData[displayId];
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700460 auto error = displayData.hwcDisplay->setColorMode(mode, renderIntent);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700461 RETURN_IF_HWC_ERROR_FOR(("setColorMode(" + decodeColorMode(mode) + ", " +
462 decodeRenderIntent(renderIntent) + ")")
463 .c_str(),
464 error, displayId, UNKNOWN_ERROR);
Michael Wright28f24d02016-07-12 13:30:53 -0700465
466 return NO_ERROR;
467}
468
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200469void HWComposer::setVsyncEnabled(PhysicalDisplayId displayId, hal::Vsync enabled) {
Dominik Laskowskic1f18f62018-06-13 15:17:55 -0700470 RETURN_IF_INVALID_DISPLAY(displayId);
471 auto& displayData = mDisplayData[displayId];
472
Dan Stoza9e56aa02015-11-02 13:00:03 -0800473 // NOTE: we use our own internal lock here because we have to call
474 // into the HWC with the lock held, and we want to make sure
475 // that even if HWC blocks (which it shouldn't), it won't
476 // affect other threads.
Dominik Laskowski1af47932018-11-12 10:20:46 -0800477 std::lock_guard lock(displayData.vsyncEnabledLock);
478 if (enabled == displayData.vsyncEnabled) {
479 return;
Colin Cross10fbdb62012-07-12 17:56:34 -0700480 }
Dominik Laskowski1af47932018-11-12 10:20:46 -0800481
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000482 SFTRACE_CALL();
Dominik Laskowski1af47932018-11-12 10:20:46 -0800483 auto error = displayData.hwcDisplay->setVsyncEnabled(enabled);
484 RETURN_IF_HWC_ERROR(error, displayId);
485
486 displayData.vsyncEnabled = enabled;
487
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000488 SFTRACE_INT(ftl::Concat("HW_VSYNC_ON_", displayId.value).c_str(),
489 enabled == hal::Vsync::ENABLE ? 1 : 0);
Colin Cross10fbdb62012-07-12 17:56:34 -0700490}
491
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200492status_t HWComposer::setClientTarget(HalDisplayId displayId, uint32_t slot,
Dominik Laskowski075d3172018-05-24 15:50:06 -0700493 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target,
Alec Mourif97df4d2023-09-06 02:10:05 +0000494 ui::Dataspace dataspace, float hdrSdrRatio) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700495 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Jesse Hall851cfe82013-03-20 13:44:00 -0700496
Dominik Laskowski34157762018-10-31 13:07:19 -0700497 ALOGV("%s for display %s", __FUNCTION__, to_string(displayId).c_str());
Dan Stoza9e56aa02015-11-02 13:00:03 -0800498 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
Alec Mourif97df4d2023-09-06 02:10:05 +0000499 auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace, hdrSdrRatio);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700500 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
Jesse Hall851cfe82013-03-20 13:44:00 -0700501 return NO_ERROR;
502}
503
Lloyd Pique66d68602019-02-13 14:23:31 -0800504status_t HWComposer::getDeviceCompositionChanges(
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200505 HalDisplayId displayId, bool frameUsesClientComposition,
Ady Abrahamf1db8032023-03-24 17:52:34 -0700506 std::optional<std::chrono::steady_clock::time_point> earliestPresentTime,
ramindani4aac32c2023-10-30 14:13:30 -0700507 nsecs_t expectedPresentTime, Fps frameInterval,
Lloyd Pique66d68602019-02-13 14:23:31 -0800508 std::optional<android::HWComposer::DeviceRequestedChanges>* outChanges) {
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000509 SFTRACE_CALL();
Dan Stoza9e56aa02015-11-02 13:00:03 -0800510
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700511 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800512
513 auto& displayData = mDisplayData[displayId];
514 auto& hwcDisplay = displayData.hwcDisplay;
515 if (!hwcDisplay->isConnected()) {
516 return NO_ERROR;
517 }
518
519 uint32_t numTypes = 0;
520 uint32_t numRequests = 0;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700521
Peiyong Line9d809e2020-04-14 13:10:48 -0700522 hal::Error error = hal::Error::NONE;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700523
Ady Abrahamec7aa8a2021-06-28 12:37:09 -0700524 // First try to skip validate altogether. We can do that when
525 // 1. The previous frame has not been presented yet or already passed the
526 // earliest time to present. Otherwise, we may present a frame too early.
527 // 2. There is no client composition. Otherwise, we first need to render the
Ady Abrahamb42cdc12021-05-11 14:31:26 -0700528 // client target buffer.
Ady Abraham43065bd2021-12-10 17:22:15 -0800529 const bool canSkipValidate = [&] {
530 // We must call validate if we have client composition
531 if (frameUsesClientComposition) {
532 return false;
533 }
534
535 // If composer supports getting the expected present time, we can skip
536 // as composer will make sure to prevent early presentation
Ady Abrahamf1db8032023-03-24 17:52:34 -0700537 if (!earliestPresentTime) {
Ady Abraham43065bd2021-12-10 17:22:15 -0800538 return true;
539 }
540
541 // composer doesn't support getting the expected present time. We can only
542 // skip validate if we know that we are not going to present early.
Ady Abrahamf1db8032023-03-24 17:52:34 -0700543 return std::chrono::steady_clock::now() >= *earliestPresentTime;
Ady Abraham43065bd2021-12-10 17:22:15 -0800544 }();
545
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700546 displayData.validateWasSkipped = false;
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000547 SFTRACE_FORMAT("NextFrameInterval %d_Hz", frameInterval.getIntValue());
Ady Abrahamb42cdc12021-05-11 14:31:26 -0700548 if (canSkipValidate) {
Leon Scroggins IIIabc2c452023-11-08 17:04:51 -0500549 sp<Fence> outPresentFence = Fence::NO_FENCE;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700550 uint32_t state = UINT32_MAX;
ramindani4aac32c2023-10-30 14:13:30 -0700551 error = hwcDisplay->presentOrValidate(expectedPresentTime, frameInterval.getPeriodNsecs(),
552 &numTypes, &numRequests, &outPresentFence, &state);
Peiyong Line9d809e2020-04-14 13:10:48 -0700553 if (!hasChangesError(error)) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700554 RETURN_IF_HWC_ERROR_FOR("presentOrValidate", error, displayId, UNKNOWN_ERROR);
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700555 }
556 if (state == 1) { //Present Succeeded.
Steven Thomas94e35b92017-07-26 18:48:28 -0700557 std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700558 error = hwcDisplay->getReleaseFences(&releaseFences);
559 displayData.releaseFences = std::move(releaseFences);
560 displayData.lastPresentFence = outPresentFence;
561 displayData.validateWasSkipped = true;
562 displayData.presentError = error;
563 return NO_ERROR;
564 }
565 // Present failed but Validate ran.
566 } else {
ramindani09acbb82023-11-03 09:02:38 -0700567 error = hwcDisplay->validate(expectedPresentTime, frameInterval.getPeriodNsecs(), &numTypes,
568 &numRequests);
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700569 }
570 ALOGV("SkipValidate failed, Falling back to SLOW validate/present");
Peiyong Line9d809e2020-04-14 13:10:48 -0700571 if (!hasChangesError(error)) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700572 RETURN_IF_HWC_ERROR_FOR("validate", error, displayId, BAD_INDEX);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800573 }
574
Lloyd Pique66d68602019-02-13 14:23:31 -0800575 android::HWComposer::DeviceRequestedChanges::ChangedTypes changedTypes;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800576 changedTypes.reserve(numTypes);
577 error = hwcDisplay->getChangedCompositionTypes(&changedTypes);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700578 RETURN_IF_HWC_ERROR_FOR("getChangedCompositionTypes", error, displayId, BAD_INDEX);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800579
Peiyong Line9d809e2020-04-14 13:10:48 -0700580 auto displayRequests = static_cast<hal::DisplayRequest>(0);
Lloyd Pique66d68602019-02-13 14:23:31 -0800581 android::HWComposer::DeviceRequestedChanges::LayerRequests layerRequests;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800582 layerRequests.reserve(numRequests);
Lloyd Pique66d68602019-02-13 14:23:31 -0800583 error = hwcDisplay->getRequests(&displayRequests, &layerRequests);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700584 RETURN_IF_HWC_ERROR_FOR("getRequests", error, displayId, BAD_INDEX);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800585
Peiyong Lindfc3f7c2020-05-07 20:15:50 -0700586 DeviceRequestedChanges::ClientTargetProperty clientTargetProperty;
Alec Mouri85065692022-03-18 00:58:26 +0000587 error = hwcDisplay->getClientTargetProperty(&clientTargetProperty);
Sally Qi11dcd582024-08-16 18:11:27 -0700588 RETURN_IF_HWC_ERROR_FOR("getClientTargetProperty", error, displayId, BAD_INDEX);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800589
Sally Qi95f669a2024-08-27 11:31:42 -0700590 DeviceRequestedChanges::LayerLuts layerLuts;
591 error = hwcDisplay->getRequestedLuts(&layerLuts, mLutFileDescriptorMapper);
592 RETURN_IF_HWC_ERROR_FOR("getRequestedLuts", error, displayId, BAD_INDEX);
593
Peiyong Lindfc3f7c2020-05-07 20:15:50 -0700594 outChanges->emplace(DeviceRequestedChanges{std::move(changedTypes), std::move(displayRequests),
595 std::move(layerRequests),
Sally Qi95f669a2024-08-27 11:31:42 -0700596 std::move(clientTargetProperty),
597 std::move(layerLuts)});
Dan Stoza9e56aa02015-11-02 13:00:03 -0800598 error = hwcDisplay->acceptChanges();
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700599 RETURN_IF_HWC_ERROR_FOR("acceptChanges", error, displayId, BAD_INDEX);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800600
601 return NO_ERROR;
602}
603
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200604sp<Fence> HWComposer::getPresentFence(HalDisplayId displayId) const {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700605 RETURN_IF_INVALID_DISPLAY(displayId, Fence::NO_FENCE);
Dominik Laskowski075d3172018-05-24 15:50:06 -0700606 return mDisplayData.at(displayId).lastPresentFence;
Jesse Hall851cfe82013-03-20 13:44:00 -0700607}
608
Dominik Laskowskidc2bb802022-09-28 16:02:59 -0400609nsecs_t HWComposer::getPresentTimestamp(PhysicalDisplayId displayId) const {
610 RETURN_IF_INVALID_DISPLAY(displayId, 0);
611 return mDisplayData.at(displayId).lastPresentTimestamp;
612}
613
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200614sp<Fence> HWComposer::getLayerReleaseFence(HalDisplayId displayId, HWC2::Layer* layer) const {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700615 RETURN_IF_INVALID_DISPLAY(displayId, Fence::NO_FENCE);
Tim Murray2d3f8b82019-12-04 16:24:17 -0800616 const auto& displayFences = mDisplayData.at(displayId).releaseFences;
617 auto fence = displayFences.find(layer);
618 if (fence == displayFences.end()) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800619 ALOGV("getLayerReleaseFence: Release fence not found");
620 return Fence::NO_FENCE;
Riley Andrews03414a12014-07-01 14:22:59 -0700621 }
Tim Murray2d3f8b82019-12-04 16:24:17 -0800622 return fence->second;
Riley Andrews03414a12014-07-01 14:22:59 -0700623}
624
Ady Abrahamb42cdc12021-05-11 14:31:26 -0700625status_t HWComposer::presentAndGetReleaseFences(
Ady Abrahamf1db8032023-03-24 17:52:34 -0700626 HalDisplayId displayId,
627 std::optional<std::chrono::steady_clock::time_point> earliestPresentTime) {
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000628 SFTRACE_CALL();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700629
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700630 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Pablo Ceballosd814cf22015-09-11 14:37:39 -0700631
Dan Stoza9e56aa02015-11-02 13:00:03 -0800632 auto& displayData = mDisplayData[displayId];
633 auto& hwcDisplay = displayData.hwcDisplay;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700634
635 if (displayData.validateWasSkipped) {
Chia-I Wuae5a6b82017-10-10 09:09:22 -0700636 // explicitly flush all pending commands
Leon Scroggins IIIe24d78f2022-09-20 16:38:19 -0400637 auto error = static_cast<hal::Error>(mComposer->executeCommands(hwcDisplay->getId()));
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800638 RETURN_IF_HWC_ERROR_FOR("executeCommands", error, displayId, UNKNOWN_ERROR);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700639 RETURN_IF_HWC_ERROR_FOR("present", displayData.presentError, displayId, UNKNOWN_ERROR);
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700640 return NO_ERROR;
641 }
642
Ady Abrahamf1db8032023-03-24 17:52:34 -0700643 if (earliestPresentTime) {
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000644 SFTRACE_NAME("wait for earliest present time");
Ady Abrahamf1db8032023-03-24 17:52:34 -0700645 std::this_thread::sleep_until(*earliestPresentTime);
Ady Abrahamb42cdc12021-05-11 14:31:26 -0700646 }
647
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800648 auto error = hwcDisplay->present(&displayData.lastPresentFence);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700649 RETURN_IF_HWC_ERROR_FOR("present", error, displayId, UNKNOWN_ERROR);
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700650
Steven Thomas94e35b92017-07-26 18:48:28 -0700651 std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800652 error = hwcDisplay->getReleaseFences(&releaseFences);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700653 RETURN_IF_HWC_ERROR_FOR("getReleaseFences", error, displayId, UNKNOWN_ERROR);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800654
655 displayData.releaseFences = std::move(releaseFences);
656
657 return NO_ERROR;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700658}
659
Leon Scroggins IIIa3ba7fa2024-05-22 16:34:52 -0400660status_t HWComposer::executeCommands(HalDisplayId displayId) {
661 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
662 auto error = static_cast<hal::Error>(mComposer->executeCommands(hwcDisplay->getId()));
663 RETURN_IF_HWC_ERROR_FOR("executeCommands", error, displayId, UNKNOWN_ERROR);
664 return NO_ERROR;
665}
666
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200667status_t HWComposer::setPowerMode(PhysicalDisplayId displayId, hal::PowerMode mode) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700668 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
669
Peiyong Line9d809e2020-04-14 13:10:48 -0700670 if (mode == hal::PowerMode::OFF) {
671 setVsyncEnabled(displayId, hal::Vsync::DISABLE);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800672 }
673
Dominik Laskowskif8db0f02021-04-19 11:05:25 -0700674 const auto& displayData = mDisplayData[displayId];
Dominik Laskowskic1f18f62018-06-13 15:17:55 -0700675 auto& hwcDisplay = displayData.hwcDisplay;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800676 switch (mode) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700677 case hal::PowerMode::OFF:
678 case hal::PowerMode::ON:
Dan Stoza9e56aa02015-11-02 13:00:03 -0800679 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
680 {
681 auto error = hwcDisplay->setPowerMode(mode);
Peiyong Line9d809e2020-04-14 13:10:48 -0700682 if (error != hal::Error::NONE) {
683 LOG_HWC_ERROR(("setPowerMode(" + to_string(mode) + ")").c_str(), error,
684 displayId);
Peiyong Lin306e4992018-05-07 16:18:22 -0700685 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700686 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800687 break;
Peiyong Line9d809e2020-04-14 13:10:48 -0700688 case hal::PowerMode::DOZE:
689 case hal::PowerMode::DOZE_SUSPEND:
Dan Stoza9e56aa02015-11-02 13:00:03 -0800690 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
691 {
692 bool supportsDoze = false;
Leon Scroggins III689c80f2023-06-05 17:49:32 -0400693 const auto queryDozeError = hwcDisplay->supportsDoze(&supportsDoze);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700694
Leon Scroggins III689c80f2023-06-05 17:49:32 -0400695 // queryDozeError might be NO_RESOURCES, in the case of a display that has never
696 // been turned on. In that case, attempt to set to DOZE anyway.
697 if (!supportsDoze && queryDozeError == hal::Error::NONE) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700698 mode = hal::PowerMode::ON;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800699 }
700
Leon Scroggins III689c80f2023-06-05 17:49:32 -0400701 auto error = hwcDisplay->setPowerMode(mode);
Peiyong Line9d809e2020-04-14 13:10:48 -0700702 if (error != hal::Error::NONE) {
703 LOG_HWC_ERROR(("setPowerMode(" + to_string(mode) + ")").c_str(), error,
704 displayId);
Leon Scroggins III689c80f2023-06-05 17:49:32 -0400705 // If the display had never been turned on, so its doze
706 // support was unknown, it may truly not support doze. Try
707 // switching it to ON instead.
708 if (queryDozeError == hal::Error::NO_RESOURCES) {
709 ALOGD("%s: failed to set %s to %s. Trying again with ON", __func__,
710 to_string(displayId).c_str(), to_string(mode).c_str());
711 error = hwcDisplay->setPowerMode(hal::PowerMode::ON);
712 if (error != hal::Error::NONE) {
713 LOG_HWC_ERROR("setPowerMode(ON)", error, displayId);
714 }
715 }
Peiyong Lin306e4992018-05-07 16:18:22 -0700716 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800717 }
718 break;
719 default:
720 ALOGV("setPowerMode: Not calling HWC");
721 break;
Mathias Agopianda27af92012-09-13 18:17:13 -0700722 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800723
724 return NO_ERROR;
725}
726
Marin Shalamanov3ea1d602020-12-16 19:59:39 +0100727status_t HWComposer::setActiveModeWithConstraints(
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100728 PhysicalDisplayId displayId, hal::HWConfigId hwcModeId,
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200729 const hal::VsyncPeriodChangeConstraints& constraints,
Peiyong Line9d809e2020-04-14 13:10:48 -0700730 hal::VsyncPeriodChangeTimeline* outTimeline) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700731 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800732
Marin Shalamanov12c9e5a2021-01-07 00:25:35 +0100733 auto error = mDisplayData[displayId].hwcDisplay->setActiveConfigWithConstraints(hwcModeId,
734 constraints,
735 outTimeline);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700736 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800737 return NO_ERROR;
738}
739
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200740status_t HWComposer::setColorTransform(HalDisplayId displayId, const mat4& transform) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700741 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700742
743 auto& displayData = mDisplayData[displayId];
Ady Abrahamdc011a92021-12-21 14:06:44 -0800744 auto error = displayData.hwcDisplay->setColorTransform(transform);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700745 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700746 return NO_ERROR;
747}
748
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200749void HWComposer::disconnectDisplay(HalDisplayId displayId) {
Dominik Laskowskic1f18f62018-06-13 15:17:55 -0700750 RETURN_IF_INVALID_DISPLAY(displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800751 auto& displayData = mDisplayData[displayId];
Dominik Laskowski7e045462018-05-30 13:02:02 -0700752 const auto hwcDisplayId = displayData.hwcDisplay->getId();
Dominik Laskowski075d3172018-05-24 15:50:06 -0700753
Peiyong Linbdd08cc2019-12-17 21:35:14 -0800754 mPhysicalDisplayIdMap.erase(hwcDisplayId);
755 mDisplayData.erase(displayId);
Marin Shalamanov8b196592021-08-09 16:24:42 +0200756
757 // Reset the primary display ID if we're disconnecting it.
758 // This way isHeadless() will return false, which is necessary
759 // because getPrimaryDisplayId() will crash.
760 if (mPrimaryHwcDisplayId == hwcDisplayId) {
761 mPrimaryHwcDisplayId.reset();
762 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800763}
764
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200765status_t HWComposer::setOutputBuffer(HalVirtualDisplayId displayId, const sp<Fence>& acquireFence,
Dominik Laskowski075d3172018-05-24 15:50:06 -0700766 const sp<GraphicBuffer>& buffer) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700767 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Dominik Laskowskic1f18f62018-06-13 15:17:55 -0700768 const auto& displayData = mDisplayData[displayId];
Dan Stoza9e56aa02015-11-02 13:00:03 -0800769
Dominik Laskowskic1f18f62018-06-13 15:17:55 -0700770 auto error = displayData.hwcDisplay->setOutputBuffer(buffer, acquireFence);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700771 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800772 return NO_ERROR;
773}
774
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200775void HWComposer::clearReleaseFences(HalDisplayId displayId) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700776 RETURN_IF_INVALID_DISPLAY(displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800777 mDisplayData[displayId].releaseFences.clear();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700778}
779
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200780status_t HWComposer::getHdrCapabilities(HalDisplayId displayId, HdrCapabilities* outCapabilities) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700781 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Dan Stozac4f471e2016-03-24 09:31:08 -0700782
783 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
Peiyong Lin62665892018-04-16 11:07:44 -0700784 auto error = hwcDisplay->getHdrCapabilities(outCapabilities);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700785 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
Peiyong Lin62665892018-04-16 11:07:44 -0700786 return NO_ERROR;
Dan Stozac4f471e2016-03-24 09:31:08 -0700787}
788
Sally Qibb866c12022-10-17 11:31:20 -0700789const aidl::android::hardware::graphics::composer3::OverlayProperties&
790HWComposer::getOverlaySupport() const {
791 return mOverlayProperties;
Sally Qi0cbd08b2022-08-17 12:12:28 -0700792}
793
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200794int32_t HWComposer::getSupportedPerFrameMetadata(HalDisplayId displayId) const {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700795 RETURN_IF_INVALID_DISPLAY(displayId, 0);
Dominik Laskowski075d3172018-05-24 15:50:06 -0700796 return mDisplayData.at(displayId).hwcDisplay->getSupportedPerFrameMetadata();
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700797}
798
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200799std::vector<ui::RenderIntent> HWComposer::getRenderIntents(HalDisplayId displayId,
Dominik Laskowski075d3172018-05-24 15:50:06 -0700800 ui::ColorMode colorMode) const {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700801 RETURN_IF_INVALID_DISPLAY(displayId, {});
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700802
803 std::vector<ui::RenderIntent> renderIntents;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700804 auto error = mDisplayData.at(displayId).hwcDisplay->getRenderIntents(colorMode, &renderIntents);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700805 RETURN_IF_HWC_ERROR(error, displayId, {});
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700806 return renderIntents;
807}
808
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200809mat4 HWComposer::getDataspaceSaturationMatrix(HalDisplayId displayId, ui::Dataspace dataspace) {
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700810 RETURN_IF_INVALID_DISPLAY(displayId, {});
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700811
812 mat4 matrix;
813 auto error = mDisplayData[displayId].hwcDisplay->getDataspaceSaturationMatrix(dataspace,
814 &matrix);
Dominik Laskowskifc2c0322018-04-19 14:47:33 -0700815 RETURN_IF_HWC_ERROR(error, displayId, {});
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700816 return matrix;
817}
818
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200819status_t HWComposer::getDisplayedContentSamplingAttributes(HalDisplayId displayId,
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700820 ui::PixelFormat* outFormat,
821 ui::Dataspace* outDataspace,
822 uint8_t* outComponentMask) {
823 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
824 const auto error =
825 mDisplayData[displayId]
826 .hwcDisplay->getDisplayedContentSamplingAttributes(outFormat, outDataspace,
827 outComponentMask);
Peiyong Line9d809e2020-04-14 13:10:48 -0700828 if (error == hal::Error::UNSUPPORTED) RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700829 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
830 return NO_ERROR;
831}
832
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200833status_t HWComposer::setDisplayContentSamplingEnabled(HalDisplayId displayId, bool enabled,
Kevin DuBois74e53772018-11-19 10:52:38 -0800834 uint8_t componentMask, uint64_t maxFrames) {
835 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
836 const auto error =
837 mDisplayData[displayId].hwcDisplay->setDisplayContentSamplingEnabled(enabled,
838 componentMask,
839 maxFrames);
840
Peiyong Line9d809e2020-04-14 13:10:48 -0700841 if (error == hal::Error::UNSUPPORTED) RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
842 if (error == hal::Error::BAD_PARAMETER) RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
Kevin DuBois74e53772018-11-19 10:52:38 -0800843 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
844 return NO_ERROR;
845}
846
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200847status_t HWComposer::getDisplayedContentSample(HalDisplayId displayId, uint64_t maxFrames,
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700848 uint64_t timestamp, DisplayedFrameStats* outStats) {
849 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
850 const auto error =
851 mDisplayData[displayId].hwcDisplay->getDisplayedContentSample(maxFrames, timestamp,
852 outStats);
853 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
854 return NO_ERROR;
855}
856
Dominik Laskowskib17c6212022-05-09 09:36:19 -0700857ftl::Future<status_t> HWComposer::setDisplayBrightness(
Alec Mouri4d8a05d2022-03-23 18:14:26 +0000858 PhysicalDisplayId displayId, float brightness, float brightnessNits,
Alec Mouricdf16792021-12-10 13:16:06 -0800859 const Hwc2::Composer::DisplayBrightnessOptions& options) {
Dominik Laskowski4e2b71f2020-11-10 15:05:32 -0800860 RETURN_IF_INVALID_DISPLAY(displayId, ftl::yield<status_t>(BAD_INDEX));
Dominik Laskowski5690bde2020-04-23 19:04:22 -0700861 auto& display = mDisplayData[displayId].hwcDisplay;
862
Dominik Laskowskib17c6212022-05-09 09:36:19 -0700863 return display->setDisplayBrightness(brightness, brightnessNits, options)
Dominik Laskowski5690bde2020-04-23 19:04:22 -0700864 .then([displayId](hal::Error error) -> status_t {
865 if (error == hal::Error::UNSUPPORTED) {
866 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
867 }
868 if (error == hal::Error::BAD_PARAMETER) {
869 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
870 }
871 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
872 return NO_ERROR;
873 });
Dan Gittik57e63c52019-01-18 16:37:54 +0000874}
875
Matt Buckley50c44062022-01-17 20:48:10 +0000876bool HWComposer::getValidateSkipped(HalDisplayId displayId) const {
877 if (mDisplayData.count(displayId) == 0) {
878 return false;
879 }
880 return mDisplayData.at(displayId).validateWasSkipped;
881}
882
Kriti Dang7defaf32021-11-15 11:55:43 +0100883status_t HWComposer::setBootDisplayMode(PhysicalDisplayId displayId,
884 hal::HWConfigId displayModeId) {
885 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
886 const auto error = mDisplayData[displayId].hwcDisplay->setBootDisplayConfig(displayModeId);
887 if (error == hal::Error::UNSUPPORTED) {
888 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
889 }
890 if (error == hal::Error::BAD_PARAMETER) {
891 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
892 }
893 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
894 return NO_ERROR;
895}
896
897status_t HWComposer::clearBootDisplayMode(PhysicalDisplayId displayId) {
898 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
899 const auto error = mDisplayData[displayId].hwcDisplay->clearBootDisplayConfig();
900 if (error == hal::Error::UNSUPPORTED) {
901 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
902 }
903 if (error == hal::Error::BAD_PARAMETER) {
904 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
905 }
906 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
907 return NO_ERROR;
908}
909
Kriti Dang16ca2972022-02-01 20:07:03 +0100910std::optional<hal::HWConfigId> HWComposer::getPreferredBootDisplayMode(
911 PhysicalDisplayId displayId) {
912 RETURN_IF_INVALID_DISPLAY(displayId, std::nullopt);
913 hal::HWConfigId displayModeId;
Kriti Dang7defaf32021-11-15 11:55:43 +0100914 const auto error =
915 mDisplayData[displayId].hwcDisplay->getPreferredBootDisplayConfig(&displayModeId);
Kriti Dang16ca2972022-02-01 20:07:03 +0100916 if (error != hal::Error::NONE) {
917 LOG_DISPLAY_ERROR(displayId, to_string(error).c_str());
918 return std::nullopt;
Kriti Dang7defaf32021-11-15 11:55:43 +0100919 }
Kriti Dang7defaf32021-11-15 11:55:43 +0100920 return displayModeId;
921}
922
Kriti Dang674b9372022-11-18 10:58:44 +0100923std::vector<HdrConversionCapability> HWComposer::getHdrConversionCapabilities() const {
924 return mHdrConversionCapabilities;
925}
926
Kriti Dangd432bb52023-02-09 18:21:04 +0100927status_t HWComposer::setHdrConversionStrategy(
928 HdrConversionStrategy hdrConversionStrategy,
929 aidl::android::hardware::graphics::common::Hdr* outPreferredHdrOutputType) {
930 const auto error =
931 mComposer->setHdrConversionStrategy(hdrConversionStrategy, outPreferredHdrOutputType);
Kriti Dang674b9372022-11-18 10:58:44 +0100932 if (error != hal::Error::NONE) {
933 ALOGE("Error in setting HDR conversion strategy %s", to_string(error).c_str());
Kriti Dangd432bb52023-02-09 18:21:04 +0100934 return INVALID_OPERATION;
Kriti Dang674b9372022-11-18 10:58:44 +0100935 }
936 return NO_ERROR;
937}
938
ramindanib2158ee2023-02-13 20:29:59 -0800939status_t HWComposer::setRefreshRateChangedCallbackDebugEnabled(PhysicalDisplayId displayId,
940 bool enabled) {
941 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
942 const auto error =
943 mComposer->setRefreshRateChangedCallbackDebugEnabled(mDisplayData[displayId]
944 .hwcDisplay->getId(),
945 enabled);
946 if (error != hal::Error::NONE) {
947 ALOGE("Error in setting refresh refresh rate change callback debug enabled %s",
948 to_string(error).c_str());
949 return INVALID_OPERATION;
950 }
951 return NO_ERROR;
952}
953
ramindanic67d22c2023-11-28 14:58:47 -0800954status_t HWComposer::notifyExpectedPresent(PhysicalDisplayId displayId,
955 TimePoint expectedPresentTime, Fps frameInterval) {
ramindani3acaaf52023-09-25 10:31:27 -0700956 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Vishnu Nairbe0ad902024-06-27 23:38:43 +0000957 SFTRACE_FORMAT("%s ExpectedPresentTime in %.2fms frameInterval %.2fms", __func__,
958 ticks<std::milli, float>(expectedPresentTime - TimePoint::now()),
959 ticks<std::milli, float>(Duration::fromNs(frameInterval.getPeriodNsecs())));
ramindanic67d22c2023-11-28 14:58:47 -0800960 const auto error = mComposer->notifyExpectedPresent(mDisplayData[displayId].hwcDisplay->getId(),
ramindanif8c0f102023-10-09 12:42:57 -0700961 expectedPresentTime.ns(),
962 frameInterval.getPeriodNsecs());
ramindani3acaaf52023-09-25 10:31:27 -0700963 if (error != hal::Error::NONE) {
964 ALOGE("Error in notifyExpectedPresent call %s", to_string(error).c_str());
965 return INVALID_OPERATION;
966 }
967 return NO_ERROR;
968}
969
Leon Scroggins IIIe7c51c62022-02-01 15:53:54 -0500970status_t HWComposer::getDisplayDecorationSupport(
971 PhysicalDisplayId displayId,
972 std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>*
973 support) {
974 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
975 const auto error = mDisplayData[displayId].hwcDisplay->getDisplayDecorationSupport(support);
976 if (error == hal::Error::UNSUPPORTED) {
977 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
978 }
979 if (error == hal::Error::BAD_PARAMETER) {
980 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
981 }
982 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
983 return NO_ERROR;
984}
985
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +0200986status_t HWComposer::setAutoLowLatencyMode(PhysicalDisplayId displayId, bool on) {
Galia Peycheva5492cb52019-10-30 14:13:16 +0100987 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
988 const auto error = mDisplayData[displayId].hwcDisplay->setAutoLowLatencyMode(on);
Peiyong Line9d809e2020-04-14 13:10:48 -0700989 if (error == hal::Error::UNSUPPORTED) {
Galia Peycheva5492cb52019-10-30 14:13:16 +0100990 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
991 }
Peiyong Line9d809e2020-04-14 13:10:48 -0700992 if (error == hal::Error::BAD_PARAMETER) {
Galia Peycheva5492cb52019-10-30 14:13:16 +0100993 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
994 }
995 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
996 return NO_ERROR;
997}
998
999status_t HWComposer::getSupportedContentTypes(
Dominik Laskowski6c7b36e2022-03-03 08:27:58 -08001000 PhysicalDisplayId displayId,
1001 std::vector<hal::ContentType>* outSupportedContentTypes) const {
Galia Peycheva5492cb52019-10-30 14:13:16 +01001002 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
Dominik Laskowski6c7b36e2022-03-03 08:27:58 -08001003 const auto error = mDisplayData.at(displayId).hwcDisplay->getSupportedContentTypes(
1004 outSupportedContentTypes);
Galia Peycheva5492cb52019-10-30 14:13:16 +01001005
1006 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
1007
1008 return NO_ERROR;
1009}
1010
Marin Shalamanov0f10d0d2020-08-06 20:04:06 +02001011status_t HWComposer::setContentType(PhysicalDisplayId displayId, hal::ContentType contentType) {
Galia Peycheva5492cb52019-10-30 14:13:16 +01001012 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
1013 const auto error = mDisplayData[displayId].hwcDisplay->setContentType(contentType);
Peiyong Line9d809e2020-04-14 13:10:48 -07001014 if (error == hal::Error::UNSUPPORTED) {
Galia Peycheva5492cb52019-10-30 14:13:16 +01001015 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
1016 }
Peiyong Line9d809e2020-04-14 13:10:48 -07001017 if (error == hal::Error::BAD_PARAMETER) {
Galia Peycheva5492cb52019-10-30 14:13:16 +01001018 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
1019 }
1020 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
1021
1022 return NO_ERROR;
1023}
1024
Brian Lindahl7a4cb7e2024-10-30 10:42:21 -06001025int32_t HWComposer::getMaxLayerPictureProfiles(PhysicalDisplayId displayId) {
1026 int32_t maxProfiles = 0;
1027 RETURN_IF_INVALID_DISPLAY(displayId, 0);
1028 const auto error = mDisplayData[displayId].hwcDisplay->getMaxLayerPictureProfiles(&maxProfiles);
1029 RETURN_IF_HWC_ERROR(error, displayId, 0);
1030 return maxProfiles;
1031}
1032
1033status_t HWComposer::setDisplayPictureProfileHandle(PhysicalDisplayId displayId,
1034 const PictureProfileHandle& handle) {
1035 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
1036 const auto error = mDisplayData[displayId].hwcDisplay->setPictureProfileHandle(handle);
1037 if (error != hal::Error::UNSUPPORTED) {
1038 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
1039 }
1040 return NO_ERROR;
1041}
1042
Lloyd Pique4603f3c2020-02-11 12:06:56 -08001043const std::unordered_map<std::string, bool>& HWComposer::getSupportedLayerGenericMetadata() const {
1044 return mSupportedLayerGenericMetadata;
1045}
1046
Sally Qi95f669a2024-08-27 11:31:42 -07001047ftl::SmallMap<HWC2::Layer*, ndk::ScopedFileDescriptor, 20>&
1048HWComposer::getLutFileDescriptorMapper() {
1049 return mLutFileDescriptorMapper;
1050}
1051
Sally Qi254ef492024-04-08 15:01:28 -07001052void HWComposer::dumpOverlayProperties(std::string& result) const {
1053 // dump overlay properties
1054 result.append("OverlayProperties:\n");
1055 base::StringAppendF(&result, "supportMixedColorSpaces: %d\n",
1056 mOverlayProperties.supportMixedColorSpaces);
1057 base::StringAppendF(&result, "SupportedBufferCombinations(%zu entries)\n",
1058 mOverlayProperties.combinations.size());
1059 for (const auto& combination : mOverlayProperties.combinations) {
1060 result.append(" pixelFormats=\n");
1061 for (const auto& pixelFormat : combination.pixelFormats) {
1062 base::StringAppendF(&result, " %s (%d)\n",
1063 decodePixelFormat(static_cast<PixelFormat>(pixelFormat)).c_str(),
1064 static_cast<uint32_t>(pixelFormat));
1065 }
1066 result.append(" standards=\n");
1067 for (const auto& standard : combination.standards) {
1068 base::StringAppendF(&result, " %s (%d)\n",
Sally Qi5dfdf142024-04-15 16:50:24 +00001069 decodeStandardOnly(static_cast<uint32_t>(standard)).c_str(),
Sally Qi254ef492024-04-08 15:01:28 -07001070 static_cast<uint32_t>(standard));
1071 }
1072 result.append(" transfers=\n");
1073 for (const auto& transfer : combination.transfers) {
1074 base::StringAppendF(&result, " %s (%d)\n",
1075 decodeTransferOnly(static_cast<uint32_t>(transfer)).c_str(),
1076 static_cast<uint32_t>(transfer));
1077 }
1078 result.append(" ranges=\n");
1079 for (const auto& range : combination.ranges) {
1080 base::StringAppendF(&result, " %s (%d)\n",
1081 decodeRangeOnly(static_cast<uint32_t>(range)).c_str(),
1082 static_cast<uint32_t>(range));
1083 }
1084 result.append("\n");
1085 }
1086}
1087
Yiwei Zhang5434a782018-12-05 18:06:32 -08001088void HWComposer::dump(std::string& result) const {
Peiyong Linbdd08cc2019-12-17 21:35:14 -08001089 result.append(mComposer->dumpDebugInfo());
Sally Qi254ef492024-04-08 15:01:28 -07001090 dumpOverlayProperties(result);
Mathias Agopian83727852010-09-23 18:13:21 -07001091}
1092
Marin Shalamanova524a092020-07-27 21:39:55 +02001093std::optional<PhysicalDisplayId> HWComposer::toPhysicalDisplayId(
1094 hal::HWDisplayId hwcDisplayId) const {
Dominik Laskowski075d3172018-05-24 15:50:06 -07001095 if (const auto it = mPhysicalDisplayIdMap.find(hwcDisplayId);
1096 it != mPhysicalDisplayIdMap.end()) {
1097 return it->second;
1098 }
1099 return {};
1100}
1101
Marin Shalamanova524a092020-07-27 21:39:55 +02001102std::optional<hal::HWDisplayId> HWComposer::fromPhysicalDisplayId(
1103 PhysicalDisplayId displayId) const {
Dominik Laskowskif8db0f02021-04-19 11:05:25 -07001104 if (const auto it = mDisplayData.find(displayId); it != mDisplayData.end()) {
Dominik Laskowski075d3172018-05-24 15:50:06 -07001105 return it->second.hwcDisplay->getId();
1106 }
1107 return {};
1108}
1109
Peiyong Line9d809e2020-04-14 13:10:48 -07001110bool HWComposer::shouldIgnoreHotplugConnect(hal::HWDisplayId hwcDisplayId,
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001111 bool hasDisplayIdentificationData) const {
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001112 if (mHasMultiDisplaySupport && !hasDisplayIdentificationData) {
Dominik Laskowski075d3172018-05-24 15:50:06 -07001113 ALOGE("Ignoring connection of display %" PRIu64 " without identification data",
1114 hwcDisplayId);
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001115 return true;
Dominik Laskowski075d3172018-05-24 15:50:06 -07001116 }
1117
Dominik Laskowskif8db0f02021-04-19 11:05:25 -07001118 // Legacy mode only supports IDs LEGACY_DISPLAY_TYPE_PRIMARY and LEGACY_DISPLAY_TYPE_EXTERNAL.
1119 if (!mHasMultiDisplaySupport && mPhysicalDisplayIdMap.size() == 2) {
Dominik Laskowski075d3172018-05-24 15:50:06 -07001120 ALOGE("Ignoring connection of tertiary display %" PRIu64, hwcDisplayId);
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001121 return true;
1122 }
1123
1124 return false;
1125}
1126
Peiyong Line9d809e2020-04-14 13:10:48 -07001127std::optional<DisplayIdentificationInfo> HWComposer::onHotplugConnect(
1128 hal::HWDisplayId hwcDisplayId) {
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001129 std::optional<DisplayIdentificationInfo> info;
1130 if (const auto displayId = toPhysicalDisplayId(hwcDisplayId)) {
1131 info = DisplayIdentificationInfo{.id = *displayId,
1132 .name = std::string(),
1133 .deviceProductInfo = std::nullopt};
Marin Shalamanovf8c63722020-10-06 13:11:21 +02001134 if (mUpdateDeviceProductInfoOnHotplugReconnect) {
1135 uint8_t port;
1136 DisplayIdentificationData data;
1137 getDisplayIdentificationData(hwcDisplayId, &port, &data);
1138 if (auto newInfo = parseDisplayIdentificationData(port, data)) {
1139 info->deviceProductInfo = std::move(newInfo->deviceProductInfo);
Lucas Berthou8d0a0c42024-08-27 14:32:31 +00001140 info->preferredDetailedTimingDescriptor =
1141 std::move(newInfo->preferredDetailedTimingDescriptor);
Marin Shalamanovf8c63722020-10-06 13:11:21 +02001142 } else {
1143 ALOGE("Failed to parse identification data for display %" PRIu64, hwcDisplayId);
1144 }
1145 }
Dominik Laskowski075d3172018-05-24 15:50:06 -07001146 } else {
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001147 uint8_t port;
1148 DisplayIdentificationData data;
1149 const bool hasDisplayIdentificationData =
1150 getDisplayIdentificationData(hwcDisplayId, &port, &data);
1151 if (mPhysicalDisplayIdMap.empty()) {
1152 mHasMultiDisplaySupport = hasDisplayIdentificationData;
1153 ALOGI("Switching to %s multi-display mode",
1154 mHasMultiDisplaySupport ? "generalized" : "legacy");
1155 }
1156
1157 if (shouldIgnoreHotplugConnect(hwcDisplayId, hasDisplayIdentificationData)) {
1158 return {};
1159 }
1160
1161 info = [this, hwcDisplayId, &port, &data, hasDisplayIdentificationData] {
Dominik Laskowskif8db0f02021-04-19 11:05:25 -07001162 const bool isPrimary = !mPrimaryHwcDisplayId;
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001163 if (mHasMultiDisplaySupport) {
1164 if (const auto info = parseDisplayIdentificationData(port, data)) {
1165 return *info;
1166 }
1167 ALOGE("Failed to parse identification data for display %" PRIu64, hwcDisplayId);
1168 } else {
1169 ALOGW_IF(hasDisplayIdentificationData,
1170 "Ignoring identification data for display %" PRIu64, hwcDisplayId);
Peiyong Lin65248e02020-04-18 21:15:07 -07001171 port = isPrimary ? LEGACY_DISPLAY_TYPE_PRIMARY : LEGACY_DISPLAY_TYPE_EXTERNAL;
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001172 }
1173
Marin Shalamanova524a092020-07-27 21:39:55 +02001174 return DisplayIdentificationInfo{.id = PhysicalDisplayId::fromPort(port),
Dominik Laskowskif8db0f02021-04-19 11:05:25 -07001175 .name = isPrimary ? "Primary display"
1176 : "Secondary display",
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001177 .deviceProductInfo = std::nullopt};
1178 }();
Leon Scroggins IIIe24d78f2022-09-20 16:38:19 -04001179
1180 mComposer->onHotplugConnect(hwcDisplayId);
Dominik Laskowski075d3172018-05-24 15:50:06 -07001181 }
1182
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001183 if (!isConnected(info->id)) {
Lucas Berthou8d0a0c42024-08-27 14:32:31 +00001184 std::optional<ui::Size> size = std::nullopt;
1185 if (info->preferredDetailedTimingDescriptor) {
1186 size = info->preferredDetailedTimingDescriptor->physicalSizeInMm;
1187 }
1188 allocatePhysicalDisplay(hwcDisplayId, info->id, size);
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001189 }
1190 return info;
1191}
1192
1193std::optional<DisplayIdentificationInfo> HWComposer::onHotplugDisconnect(
Peiyong Line9d809e2020-04-14 13:10:48 -07001194 hal::HWDisplayId hwcDisplayId) {
Dominik Laskowskif8db0f02021-04-19 11:05:25 -07001195 LOG_ALWAYS_FATAL_IF(hwcDisplayId == mPrimaryHwcDisplayId,
1196 "Primary display cannot be disconnected.");
1197
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001198 const auto displayId = toPhysicalDisplayId(hwcDisplayId);
1199 if (!displayId) {
Dominik Laskowskif8db0f02021-04-19 11:05:25 -07001200 LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Invalid HWC display");
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001201 return {};
Dominik Laskowski075d3172018-05-24 15:50:06 -07001202 }
1203
Dominik Laskowskif2ddca62022-08-17 12:08:07 -07001204 if (!isConnected(*displayId)) {
Dominik Laskowskif8db0f02021-04-19 11:05:25 -07001205 LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Already disconnected");
Dominik Laskowskif2ddca62022-08-17 12:08:07 -07001206 return {};
Marin Shalamanovbdd59152020-02-14 15:30:06 +01001207 }
Dominik Laskowskif2ddca62022-08-17 12:08:07 -07001208
1209 // The display will later be destroyed by a call to HWComposer::disconnectDisplay. For now, mark
1210 // it as disconnected.
1211 mDisplayData.at(*displayId).hwcDisplay->setConnected(false);
Leon Scroggins IIIe24d78f2022-09-20 16:38:19 -04001212 mComposer->onHotplugDisconnect(hwcDisplayId);
Dominik Laskowskif2ddca62022-08-17 12:08:07 -07001213 return DisplayIdentificationInfo{.id = *displayId};
Steven Thomas6e8f7062017-11-22 14:15:29 -08001214}
1215
Peiyong Linbdd08cc2019-12-17 21:35:14 -08001216void HWComposer::loadCapabilities() {
Peiyong Line9d809e2020-04-14 13:10:48 -07001217 static_assert(sizeof(hal::Capability) == sizeof(int32_t), "Capability size has changed");
Peiyong Linbdd08cc2019-12-17 21:35:14 -08001218 auto capabilities = mComposer->getCapabilities();
1219 for (auto capability : capabilities) {
Ady Abrahamde549d42022-01-26 19:19:17 -08001220 mCapabilities.emplace(capability);
Peiyong Linbdd08cc2019-12-17 21:35:14 -08001221 }
1222}
1223
Sally Qibb866c12022-10-17 11:31:20 -07001224void HWComposer::loadOverlayProperties() {
1225 mComposer->getOverlaySupport(&mOverlayProperties);
1226}
1227
Kriti Dang674b9372022-11-18 10:58:44 +01001228void HWComposer::loadHdrConversionCapabilities() {
1229 const auto error = mComposer->getHdrConversionCapabilities(&mHdrConversionCapabilities);
1230 if (error != hal::Error::NONE) {
1231 ALOGE("Error in fetching HDR conversion capabilities %s", to_string(error).c_str());
1232 mHdrConversionCapabilities = {};
1233 }
1234}
1235
ramindani32cf0602022-03-02 02:30:29 +00001236status_t HWComposer::setIdleTimerEnabled(PhysicalDisplayId displayId,
1237 std::chrono::milliseconds timeout) {
Vishnu Nairbe0ad902024-06-27 23:38:43 +00001238 SFTRACE_CALL();
ramindani32cf0602022-03-02 02:30:29 +00001239 RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX);
1240 const auto error = mDisplayData[displayId].hwcDisplay->setIdleTimerEnabled(timeout);
1241 if (error == hal::Error::UNSUPPORTED) {
1242 RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION);
1243 }
1244 if (error == hal::Error::BAD_PARAMETER) {
1245 RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE);
1246 }
1247 RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR);
1248 return NO_ERROR;
1249}
1250
ramindani06e518e2022-03-14 18:47:53 +00001251bool HWComposer::hasDisplayIdleTimerCapability(PhysicalDisplayId displayId) const {
ramindani32cf0602022-03-02 02:30:29 +00001252 RETURN_IF_INVALID_DISPLAY(displayId, false);
ramindani06e518e2022-03-14 18:47:53 +00001253 return mDisplayData.at(displayId).hwcDisplay->hasDisplayIdleTimerCapability();
1254}
1255
1256Hwc2::AidlTransform HWComposer::getPhysicalDisplayOrientation(PhysicalDisplayId displayId) const {
Vishnu Nairbe0ad902024-06-27 23:38:43 +00001257 SFTRACE_CALL();
ramindani06e518e2022-03-14 18:47:53 +00001258 RETURN_IF_INVALID_DISPLAY(displayId, Hwc2::AidlTransform::NONE);
1259 Hwc2::AidlTransform outTransform;
1260 const auto& hwcDisplay = mDisplayData.at(displayId).hwcDisplay;
1261 const auto error = hwcDisplay->getPhysicalDisplayOrientation(&outTransform);
1262 RETURN_IF_HWC_ERROR(error, displayId, Hwc2::AidlTransform::NONE);
1263 return outTransform;
ramindani32cf0602022-03-02 02:30:29 +00001264}
1265
Lloyd Pique4603f3c2020-02-11 12:06:56 -08001266void HWComposer::loadLayerMetadataSupport() {
1267 mSupportedLayerGenericMetadata.clear();
1268
1269 std::vector<Hwc2::IComposerClient::LayerGenericMetadataKey> supportedMetadataKeyInfo;
1270 const auto error = mComposer->getLayerGenericMetadataKeys(&supportedMetadataKeyInfo);
1271 if (error != hardware::graphics::composer::V2_4::Error::NONE) {
Ady Abraham3891cbe2021-03-29 11:29:31 -07001272 if (error != hardware::graphics::composer::V2_4::Error::UNSUPPORTED) {
1273 ALOGE("%s: %s failed: %s (%d)", __FUNCTION__, "getLayerGenericMetadataKeys",
1274 toString(error).c_str(), static_cast<int32_t>(error));
1275 }
Lloyd Pique4603f3c2020-02-11 12:06:56 -08001276 return;
1277 }
1278
1279 for (const auto& [name, mandatory] : supportedMetadataKeyInfo) {
1280 mSupportedLayerGenericMetadata.emplace(name, mandatory);
1281 }
1282}
1283
Lloyd Pique441d5042018-10-18 16:49:51 -07001284} // namespace impl
Dominik Laskowskif9750f22018-06-06 12:24:53 -07001285} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -08001286
1287// TODO(b/129481165): remove the #pragma below and fix conversion issues
1288#pragma clang diagnostic pop // ignored "-Wconversion"