Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 1 | /* |
| 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 Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 18 | #pragma clang diagnostic push |
| 19 | #pragma clang diagnostic ignored "-Wconversion" |
| 20 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 21 | // #define LOG_NDEBUG 0 |
| 22 | |
| 23 | #undef LOG_TAG |
| 24 | #define LOG_TAG "HWComposer" |
Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 25 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 26 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 27 | #include "HWComposer.h" |
| 28 | |
Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 29 | #include <android-base/properties.h> |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 30 | #include <compositionengine/Output.h> |
| 31 | #include <compositionengine/OutputLayer.h> |
| 32 | #include <compositionengine/impl/OutputLayerCompositionState.h> |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 33 | #include <ftl/concat.h> |
ramindani | b90711b | 2023-10-02 15:13:19 -0700 | [diff] [blame] | 34 | #include <gui/TraceUtils.h> |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 35 | #include <log/log.h> |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 36 | #include <ui/DebugUtils.h> |
Mathias Agopian | 921e6ac | 2012-07-23 23:11:29 -0700 | [diff] [blame] | 37 | #include <ui/GraphicBuffer.h> |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 38 | #include <utils/Errors.h> |
| 39 | #include <utils/Trace.h> |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 40 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 41 | #include "../Layer.h" // needed only for debugging |
Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 42 | #include "../SurfaceFlingerProperties.h" |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 43 | #include "ComposerHal.h" |
| 44 | #include "HWC2.h" |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 45 | |
Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 46 | #define LOG_HWC_DISPLAY_ERROR(hwcDisplayId, msg) \ |
| 47 | ALOGE("%s failed for HWC display %" PRIu64 ": %s", __FUNCTION__, hwcDisplayId, msg) |
| 48 | |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 49 | #define LOG_DISPLAY_ERROR(displayId, msg) \ |
Dominik Laskowski | 3415776 | 2018-10-31 13:07:19 -0700 | [diff] [blame] | 50 | ALOGE("%s failed for display %s: %s", __FUNCTION__, to_string(displayId).c_str(), msg) |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 51 | |
Dominik Laskowski | 3415776 | 2018-10-31 13:07:19 -0700 | [diff] [blame] | 52 | #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 Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 55 | |
| 56 | #define RETURN_IF_INVALID_DISPLAY(displayId, ...) \ |
| 57 | do { \ |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 58 | if (mDisplayData.count(displayId) == 0) { \ |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 59 | 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 Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 66 | if (error != hal::Error::NONE) { \ |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 67 | 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 Dang | 674b937 | 2022-11-18 10:58:44 +0100 | [diff] [blame] | 75 | using aidl::android::hardware::graphics::common::HdrConversionCapability; |
| 76 | using aidl::android::hardware::graphics::common::HdrConversionStrategy; |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 77 | using aidl::android::hardware::graphics::composer3::Capability; |
| 78 | using aidl::android::hardware::graphics::composer3::DisplayCapability; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 79 | namespace hal = android::hardware::graphics::composer::hal; |
| 80 | |
ramindani | f8c0f10 | 2023-10-09 12:42:57 -0700 | [diff] [blame^] | 81 | namespace { |
| 82 | bool isFrameIntervalOnCadence(android::TimePoint expectedPresentTime, |
| 83 | android::TimePoint lastExpectedPresentTimestamp, |
| 84 | android::Fps lastFrameInterval, android::Period timeout, |
| 85 | android::Duration threshold) { |
| 86 | if (lastFrameInterval.getPeriodNsecs() == 0) { |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | const auto expectedPresentTimeDeltaNs = |
| 91 | expectedPresentTime.ns() - lastExpectedPresentTimestamp.ns(); |
| 92 | |
| 93 | if (expectedPresentTimeDeltaNs > timeout.ns()) { |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | const auto expectedPresentPeriods = static_cast<nsecs_t>( |
| 98 | std::round(static_cast<float>(expectedPresentTimeDeltaNs) / |
| 99 | static_cast<float>(lastFrameInterval.getPeriodNsecs()))); |
| 100 | const auto calculatedPeriodsOutNs = lastFrameInterval.getPeriodNsecs() * expectedPresentPeriods; |
| 101 | const auto calculatedExpectedPresentTimeNs = |
| 102 | lastExpectedPresentTimestamp.ns() + calculatedPeriodsOutNs; |
| 103 | const auto presentTimeDelta = |
| 104 | std::abs(expectedPresentTime.ns() - calculatedExpectedPresentTimeNs); |
| 105 | return presentTimeDelta < threshold.ns(); |
| 106 | } |
| 107 | |
| 108 | bool isExpectedPresentWithinTimeout(android::TimePoint expectedPresentTime, |
| 109 | android::TimePoint lastExpectedPresentTimestamp, |
| 110 | std::optional<android::Period> timeoutOpt, |
| 111 | android::Duration threshold) { |
| 112 | if (!timeoutOpt) { |
| 113 | // Always within timeout if timeoutOpt is absent and don't send hint |
| 114 | // for the timeout |
| 115 | return true; |
| 116 | } |
| 117 | |
| 118 | if (timeoutOpt->ns() == 0) { |
| 119 | // Always outside timeout if timeoutOpt is 0 and always send |
| 120 | // the hint for the timeout. |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | if (expectedPresentTime.ns() < lastExpectedPresentTimestamp.ns() + timeoutOpt->ns()) { |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | // Check if within the threshold as it can be just outside the timeout |
| 129 | return std::abs(expectedPresentTime.ns() - |
| 130 | (lastExpectedPresentTimestamp.ns() + timeoutOpt->ns())) < threshold.ns(); |
| 131 | } |
| 132 | } // namespace |
| 133 | |
Marin Shalamanov | 6e84017 | 2020-12-14 22:13:28 +0100 | [diff] [blame] | 134 | namespace android { |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 135 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 136 | HWComposer::~HWComposer() = default; |
| 137 | |
| 138 | namespace impl { |
| 139 | |
Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 140 | HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer) |
| 141 | : mComposer(std::move(composer)), |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 142 | mMaxVirtualDisplayDimension(static_cast<size_t>(sysprop::max_virtual_display_dimension(0))), |
Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 143 | mUpdateDeviceProductInfoOnHotplugReconnect( |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 144 | sysprop::update_device_product_info_on_hotplug_reconnect(false)) {} |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 145 | |
| 146 | HWComposer::HWComposer(const std::string& composerServiceName) |
Ady Abraham | 9fc2805 | 2021-10-14 17:21:38 -0700 | [diff] [blame] | 147 | : HWComposer(Hwc2::Composer::create(composerServiceName)) {} |
Mathias Agopian | bef42c5 | 2013-08-21 17:45:46 -0700 | [diff] [blame] | 148 | |
Dominik Laskowski | b04f98a | 2018-11-07 21:07:16 -0800 | [diff] [blame] | 149 | HWComposer::~HWComposer() { |
| 150 | mDisplayData.clear(); |
| 151 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 152 | |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 153 | void HWComposer::setCallback(HWC2::ComposerCallback& callback) { |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 154 | loadCapabilities(); |
| 155 | loadLayerMetadataSupport(); |
Sally Qi | bb866c1 | 2022-10-17 11:31:20 -0700 | [diff] [blame] | 156 | loadOverlayProperties(); |
Kriti Dang | 674b937 | 2022-11-18 10:58:44 +0100 | [diff] [blame] | 157 | loadHdrConversionCapabilities(); |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 158 | |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 159 | if (mRegisteredCallback) { |
| 160 | ALOGW("Callback already registered. Ignored extra registration attempt."); |
| 161 | return; |
| 162 | } |
| 163 | mRegisteredCallback = true; |
Dominik Laskowski | ebc8d3a | 2021-04-16 23:18:31 -0700 | [diff] [blame] | 164 | |
Yichi Chen | 3401b56 | 2022-01-17 15:42:35 +0800 | [diff] [blame] | 165 | mComposer->registerCallback(callback); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 168 | bool HWComposer::getDisplayIdentificationData(hal::HWDisplayId hwcDisplayId, uint8_t* outPort, |
Dominik Laskowski | e9ef7c4 | 2018-03-12 19:34:30 -0700 | [diff] [blame] | 169 | DisplayIdentificationData* outData) const { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 170 | const auto error = static_cast<hal::Error>( |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 171 | mComposer->getDisplayIdentificationData(hwcDisplayId, outPort, outData)); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 172 | if (error != hal::Error::NONE) { |
| 173 | if (error != hal::Error::UNSUPPORTED) { |
Chia-I Wu | d0aff9d | 2018-06-21 13:39:09 +0800 | [diff] [blame] | 174 | LOG_HWC_DISPLAY_ERROR(hwcDisplayId, to_string(error).c_str()); |
| 175 | } |
Dominik Laskowski | e9ef7c4 | 2018-03-12 19:34:30 -0700 | [diff] [blame] | 176 | return false; |
| 177 | } |
| 178 | return true; |
| 179 | } |
| 180 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 181 | bool HWComposer::hasCapability(Capability capability) const { |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 182 | return mCapabilities.count(capability) > 0; |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 185 | bool HWComposer::hasDisplayCapability(HalDisplayId displayId, DisplayCapability capability) const { |
Dominik Laskowski | 1162e47 | 2020-04-02 19:02:47 -0700 | [diff] [blame] | 186 | RETURN_IF_INVALID_DISPLAY(displayId, false); |
Ady Abraham | 27fbcc7 | 2021-09-20 14:54:57 -0700 | [diff] [blame] | 187 | return mDisplayData.at(displayId).hwcDisplay->hasCapability(capability); |
Peiyong Lin | ed531a3 | 2018-10-26 18:27:56 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 190 | std::optional<DisplayIdentificationInfo> HWComposer::onHotplug(hal::HWDisplayId hwcDisplayId, |
| 191 | hal::Connection connection) { |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 192 | switch (connection) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 193 | case hal::Connection::CONNECTED: |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 194 | return onHotplugConnect(hwcDisplayId); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 195 | case hal::Connection::DISCONNECTED: |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 196 | return onHotplugDisconnect(hwcDisplayId); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 197 | case hal::Connection::INVALID: |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 198 | return {}; |
Dominik Laskowski | e9ef7c4 | 2018-03-12 19:34:30 -0700 | [diff] [blame] | 199 | } |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 202 | bool HWComposer::updatesDeviceProductInfoOnHotplugReconnect() const { |
| 203 | return mUpdateDeviceProductInfoOnHotplugReconnect; |
| 204 | } |
| 205 | |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 206 | std::optional<PhysicalDisplayId> HWComposer::onVsync(hal::HWDisplayId hwcDisplayId, |
| 207 | nsecs_t timestamp) { |
| 208 | const auto displayIdOpt = toPhysicalDisplayId(hwcDisplayId); |
| 209 | if (!displayIdOpt) { |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 210 | LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Invalid HWC display"); |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 211 | return {}; |
Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 212 | } |
Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 213 | |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 214 | RETURN_IF_INVALID_DISPLAY(*displayIdOpt, {}); |
Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 215 | |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 216 | auto& displayData = mDisplayData[*displayIdOpt]; |
Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 217 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 218 | { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 219 | // There have been reports of HWCs that signal several vsync events |
| 220 | // with the same timestamp when turning the display off and on. This |
| 221 | // is a bug in the HWC implementation, but filter the extra events |
| 222 | // out here so they don't cause havoc downstream. |
Dominik Laskowski | dc2bb80 | 2022-09-28 16:02:59 -0400 | [diff] [blame] | 223 | if (timestamp == displayData.lastPresentTimestamp) { |
Dominik Laskowski | 3415776 | 2018-10-31 13:07:19 -0700 | [diff] [blame] | 224 | ALOGW("Ignoring duplicate VSYNC event from HWC for display %s (t=%" PRId64 ")", |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 225 | to_string(*displayIdOpt).c_str(), timestamp); |
| 226 | return {}; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Dominik Laskowski | dc2bb80 | 2022-09-28 16:02:59 -0400 | [diff] [blame] | 229 | displayData.lastPresentTimestamp = timestamp; |
Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 230 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 231 | |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 232 | ATRACE_INT(ftl::Concat("HW_VSYNC_", displayIdOpt->value).c_str(), |
| 233 | displayData.vsyncTraceToggle); |
Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 234 | displayData.vsyncTraceToggle = !displayData.vsyncTraceToggle; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 235 | |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 236 | return displayIdOpt; |
Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 239 | size_t HWComposer::getMaxVirtualDisplayCount() const { |
| 240 | return mComposer->getMaxVirtualDisplayCount(); |
| 241 | } |
| 242 | |
| 243 | size_t HWComposer::getMaxVirtualDisplayDimension() const { |
| 244 | return mMaxVirtualDisplayDimension; |
| 245 | } |
| 246 | |
| 247 | bool HWComposer::allocateVirtualDisplay(HalVirtualDisplayId displayId, ui::Size resolution, |
Dominik Laskowski | 263eec4 | 2021-07-21 23:13:24 -0700 | [diff] [blame] | 248 | ui::PixelFormat* format) { |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 249 | if (!resolution.isValid()) { |
| 250 | ALOGE("%s: Invalid resolution %dx%d", __func__, resolution.width, resolution.height); |
| 251 | return false; |
Fabien Sanglard | e29055f | 2017-03-08 11:36:46 -0800 | [diff] [blame] | 252 | } |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 253 | |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 254 | const uint32_t width = static_cast<uint32_t>(resolution.width); |
| 255 | const uint32_t height = static_cast<uint32_t>(resolution.height); |
| 256 | |
| 257 | if (mMaxVirtualDisplayDimension > 0 && |
| 258 | (width > mMaxVirtualDisplayDimension || height > mMaxVirtualDisplayDimension)) { |
| 259 | ALOGE("%s: Resolution %ux%u exceeds maximum dimension %zu", __func__, width, height, |
| 260 | mMaxVirtualDisplayDimension); |
| 261 | return false; |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 262 | } |
| 263 | |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 264 | hal::HWDisplayId hwcDisplayId; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 265 | const auto error = static_cast<hal::Error>( |
Dominik Laskowski | 263eec4 | 2021-07-21 23:13:24 -0700 | [diff] [blame] | 266 | mComposer->createVirtualDisplay(width, height, format, &hwcDisplayId)); |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 267 | RETURN_IF_HWC_ERROR_FOR("createVirtualDisplay", error, displayId, false); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 268 | |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 269 | auto display = std::make_unique<HWC2::impl::Display>(*mComposer.get(), mCapabilities, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 270 | hwcDisplayId, hal::DisplayType::VIRTUAL); |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 271 | display->setConnected(true); |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 272 | auto& displayData = mDisplayData[displayId]; |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 273 | displayData.hwcDisplay = std::move(display); |
Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 274 | return true; |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 277 | void HWComposer::allocatePhysicalDisplay(hal::HWDisplayId hwcDisplayId, |
| 278 | PhysicalDisplayId displayId) { |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 279 | mPhysicalDisplayIdMap[hwcDisplayId] = displayId; |
| 280 | |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 281 | if (!mPrimaryHwcDisplayId) { |
| 282 | mPrimaryHwcDisplayId = hwcDisplayId; |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | auto& displayData = mDisplayData[displayId]; |
| 286 | auto newDisplay = |
| 287 | std::make_unique<HWC2::impl::Display>(*mComposer.get(), mCapabilities, hwcDisplayId, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 288 | hal::DisplayType::PHYSICAL); |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 289 | newDisplay->setConnected(true); |
| 290 | displayData.hwcDisplay = std::move(newDisplay); |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | int32_t HWComposer::getAttribute(hal::HWDisplayId hwcDisplayId, hal::HWConfigId configId, |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 294 | hal::Attribute attribute) const { |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 295 | int32_t value = 0; |
| 296 | auto error = static_cast<hal::Error>( |
| 297 | mComposer->getDisplayAttribute(hwcDisplayId, configId, attribute, &value)); |
| 298 | |
| 299 | RETURN_IF_HWC_ERROR_FOR("getDisplayAttribute", error, *toPhysicalDisplayId(hwcDisplayId), -1); |
| 300 | return value; |
| 301 | } |
| 302 | |
Lloyd Pique | 1b33fc3 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 303 | std::shared_ptr<HWC2::Layer> HWComposer::createLayer(HalDisplayId displayId) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 304 | RETURN_IF_INVALID_DISPLAY(displayId, nullptr); |
| 305 | |
Lloyd Pique | 1b33fc3 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 306 | auto expected = mDisplayData[displayId].hwcDisplay->createLayer(); |
| 307 | if (!expected.has_value()) { |
| 308 | auto error = std::move(expected).error(); |
| 309 | RETURN_IF_HWC_ERROR(error, displayId, nullptr); |
| 310 | } |
| 311 | return std::move(expected).value(); |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 314 | bool HWComposer::isConnected(PhysicalDisplayId displayId) const { |
Dominik Laskowski | f2ddca6 | 2022-08-17 12:08:07 -0700 | [diff] [blame] | 315 | return mDisplayData.count(displayId) && mDisplayData.at(displayId).hwcDisplay->isConnected(); |
Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 316 | } |
| 317 | |
ramindani | 263a3f1 | 2023-07-18 20:44:49 -0700 | [diff] [blame] | 318 | std::vector<HWComposer::HWCDisplayMode> HWComposer::getModes(PhysicalDisplayId displayId, |
| 319 | int32_t maxFrameIntervalNs) const { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 320 | RETURN_IF_INVALID_DISPLAY(displayId, {}); |
| 321 | |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 322 | const auto hwcDisplayId = mDisplayData.at(displayId).hwcDisplay->getId(); |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 323 | |
| 324 | if (mComposer->getDisplayConfigurationsSupported()) { |
ramindani | 263a3f1 | 2023-07-18 20:44:49 -0700 | [diff] [blame] | 325 | return getModesFromDisplayConfigurations(hwcDisplayId, maxFrameIntervalNs); |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | return getModesFromLegacyDisplayConfigs(hwcDisplayId); |
| 329 | } |
| 330 | |
| 331 | std::vector<HWComposer::HWCDisplayMode> HWComposer::getModesFromDisplayConfigurations( |
ramindani | 263a3f1 | 2023-07-18 20:44:49 -0700 | [diff] [blame] | 332 | uint64_t hwcDisplayId, int32_t maxFrameIntervalNs) const { |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 333 | std::vector<hal::DisplayConfiguration> configs; |
ramindani | 263a3f1 | 2023-07-18 20:44:49 -0700 | [diff] [blame] | 334 | auto error = static_cast<hal::Error>( |
| 335 | mComposer->getDisplayConfigurations(hwcDisplayId, maxFrameIntervalNs, &configs)); |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 336 | RETURN_IF_HWC_ERROR_FOR("getDisplayConfigurations", error, *toPhysicalDisplayId(hwcDisplayId), |
| 337 | {}); |
| 338 | |
| 339 | std::vector<HWCDisplayMode> modes; |
| 340 | modes.reserve(configs.size()); |
| 341 | for (auto config : configs) { |
ramindani | a04b8a5 | 2023-08-07 18:49:47 -0700 | [diff] [blame] | 342 | auto hwcMode = HWCDisplayMode{.hwcId = static_cast<hal::HWConfigId>(config.configId), |
| 343 | .width = config.width, |
| 344 | .height = config.height, |
| 345 | .vsyncPeriod = config.vsyncPeriod, |
| 346 | .configGroup = config.configGroup, |
| 347 | .vrrConfig = config.vrrConfig}; |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 348 | |
| 349 | if (config.dpi) { |
| 350 | hwcMode.dpiX = config.dpi->x; |
| 351 | hwcMode.dpiY = config.dpi->y; |
| 352 | } |
| 353 | |
| 354 | modes.push_back(hwcMode); |
| 355 | } |
| 356 | |
| 357 | return modes; |
| 358 | } |
| 359 | |
| 360 | std::vector<HWComposer::HWCDisplayMode> HWComposer::getModesFromLegacyDisplayConfigs( |
| 361 | uint64_t hwcDisplayId) const { |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 362 | std::vector<hal::HWConfigId> configIds; |
| 363 | auto error = static_cast<hal::Error>(mComposer->getDisplayConfigs(hwcDisplayId, &configIds)); |
| 364 | RETURN_IF_HWC_ERROR_FOR("getDisplayConfigs", error, *toPhysicalDisplayId(hwcDisplayId), {}); |
| 365 | |
| 366 | std::vector<HWCDisplayMode> modes; |
| 367 | modes.reserve(configIds.size()); |
| 368 | for (auto configId : configIds) { |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 369 | auto hwcMode = HWCDisplayMode{ |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 370 | .hwcId = configId, |
| 371 | .width = getAttribute(hwcDisplayId, configId, hal::Attribute::WIDTH), |
| 372 | .height = getAttribute(hwcDisplayId, configId, hal::Attribute::HEIGHT), |
| 373 | .vsyncPeriod = getAttribute(hwcDisplayId, configId, hal::Attribute::VSYNC_PERIOD), |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 374 | .configGroup = getAttribute(hwcDisplayId, configId, hal::Attribute::CONFIG_GROUP), |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 375 | }; |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 376 | |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 377 | const int32_t dpiX = getAttribute(hwcDisplayId, configId, hal::Attribute::DPI_X); |
| 378 | const int32_t dpiY = getAttribute(hwcDisplayId, configId, hal::Attribute::DPI_Y); |
| 379 | if (dpiX != -1) { |
| 380 | hwcMode.dpiX = static_cast<float>(dpiX) / 1000.f; |
| 381 | } |
| 382 | if (dpiY != -1) { |
| 383 | hwcMode.dpiY = static_cast<float>(dpiY) / 1000.f; |
| 384 | } |
| 385 | |
| 386 | modes.push_back(hwcMode); |
| 387 | } |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 388 | return modes; |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 391 | std::optional<hal::HWConfigId> HWComposer::getActiveMode(PhysicalDisplayId displayId) const { |
| 392 | RETURN_IF_INVALID_DISPLAY(displayId, std::nullopt); |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 393 | const auto hwcId = *fromPhysicalDisplayId(displayId); |
Dominik Laskowski | e2c5b0a | 2022-08-10 14:53:53 -0700 | [diff] [blame] | 394 | |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 395 | hal::HWConfigId configId; |
Dominik Laskowski | e2c5b0a | 2022-08-10 14:53:53 -0700 | [diff] [blame] | 396 | const auto error = static_cast<hal::Error>(mComposer->getActiveConfig(hwcId, &configId)); |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 397 | |
Dominik Laskowski | e2c5b0a | 2022-08-10 14:53:53 -0700 | [diff] [blame] | 398 | RETURN_IF_HWC_ERROR_FOR("getActiveConfig", error, displayId, std::nullopt); |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 399 | return configId; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 400 | } |
| 401 | |
Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 402 | // Composer 2.4 |
| 403 | |
Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 404 | ui::DisplayConnectionType HWComposer::getDisplayConnectionType(PhysicalDisplayId displayId) const { |
| 405 | RETURN_IF_INVALID_DISPLAY(displayId, ui::DisplayConnectionType::Internal); |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 406 | const auto& hwcDisplay = mDisplayData.at(displayId).hwcDisplay; |
| 407 | |
Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 408 | ui::DisplayConnectionType type; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 409 | const auto error = hwcDisplay->getConnectionType(&type); |
| 410 | |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 411 | const auto FALLBACK_TYPE = hwcDisplay->getId() == mPrimaryHwcDisplayId |
Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 412 | ? ui::DisplayConnectionType::Internal |
| 413 | : ui::DisplayConnectionType::External; |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 414 | |
| 415 | RETURN_IF_HWC_ERROR(error, displayId, FALLBACK_TYPE); |
| 416 | return type; |
| 417 | } |
| 418 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 419 | bool HWComposer::isVsyncPeriodSwitchSupported(PhysicalDisplayId displayId) const { |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 420 | RETURN_IF_INVALID_DISPLAY(displayId, false); |
Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 421 | return mDisplayData.at(displayId).hwcDisplay->isVsyncPeriodSwitchSupported(); |
| 422 | } |
| 423 | |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 424 | status_t HWComposer::getDisplayVsyncPeriod(PhysicalDisplayId displayId, |
| 425 | nsecs_t* outVsyncPeriod) const { |
Dominik Laskowski | 55c8540 | 2020-01-21 16:25:47 -0800 | [diff] [blame] | 426 | RETURN_IF_INVALID_DISPLAY(displayId, 0); |
| 427 | |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 428 | if (!isVsyncPeriodSwitchSupported(displayId)) { |
| 429 | return INVALID_OPERATION; |
Dominik Laskowski | f3749f8 | 2018-06-13 15:49:25 -0700 | [diff] [blame] | 430 | } |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 431 | const auto hwcId = *fromPhysicalDisplayId(displayId); |
| 432 | Hwc2::VsyncPeriodNanos vsyncPeriodNanos = 0; |
| 433 | auto error = |
| 434 | static_cast<hal::Error>(mComposer->getDisplayVsyncPeriod(hwcId, &vsyncPeriodNanos)); |
| 435 | RETURN_IF_HWC_ERROR(error, displayId, 0); |
| 436 | *outVsyncPeriod = static_cast<nsecs_t>(vsyncPeriodNanos); |
| 437 | return NO_ERROR; |
Lloyd Pique | 3c085a0 | 2018-05-09 19:38:32 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 440 | std::vector<ui::ColorMode> HWComposer::getColorModes(PhysicalDisplayId displayId) const { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 441 | RETURN_IF_INVALID_DISPLAY(displayId, {}); |
| 442 | |
Peiyong Lin | fd997e0 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 443 | std::vector<ui::ColorMode> modes; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 444 | auto error = mDisplayData.at(displayId).hwcDisplay->getColorModes(&modes); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 445 | RETURN_IF_HWC_ERROR(error, displayId, {}); |
Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 446 | return modes; |
| 447 | } |
| 448 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 449 | status_t HWComposer::setActiveColorMode(PhysicalDisplayId displayId, ui::ColorMode mode, |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 450 | ui::RenderIntent renderIntent) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 451 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 452 | |
| 453 | auto& displayData = mDisplayData[displayId]; |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 454 | auto error = displayData.hwcDisplay->setColorMode(mode, renderIntent); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 455 | RETURN_IF_HWC_ERROR_FOR(("setColorMode(" + decodeColorMode(mode) + ", " + |
| 456 | decodeRenderIntent(renderIntent) + ")") |
| 457 | .c_str(), |
| 458 | error, displayId, UNKNOWN_ERROR); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 459 | |
| 460 | return NO_ERROR; |
| 461 | } |
| 462 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 463 | void HWComposer::setVsyncEnabled(PhysicalDisplayId displayId, hal::Vsync enabled) { |
Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 464 | RETURN_IF_INVALID_DISPLAY(displayId); |
| 465 | auto& displayData = mDisplayData[displayId]; |
| 466 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 467 | // NOTE: we use our own internal lock here because we have to call |
| 468 | // into the HWC with the lock held, and we want to make sure |
| 469 | // that even if HWC blocks (which it shouldn't), it won't |
| 470 | // affect other threads. |
Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 471 | std::lock_guard lock(displayData.vsyncEnabledLock); |
| 472 | if (enabled == displayData.vsyncEnabled) { |
| 473 | return; |
Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 474 | } |
Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 475 | |
| 476 | ATRACE_CALL(); |
| 477 | auto error = displayData.hwcDisplay->setVsyncEnabled(enabled); |
| 478 | RETURN_IF_HWC_ERROR(error, displayId); |
| 479 | |
| 480 | displayData.vsyncEnabled = enabled; |
| 481 | |
Leon Scroggins III | 959a7ff | 2023-02-07 11:24:25 -0500 | [diff] [blame] | 482 | ATRACE_INT(ftl::Concat("HW_VSYNC_ON_", displayId.value).c_str(), |
| 483 | enabled == hal::Vsync::ENABLE ? 1 : 0); |
Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 486 | status_t HWComposer::setClientTarget(HalDisplayId displayId, uint32_t slot, |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 487 | const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target, |
| 488 | ui::Dataspace dataspace) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 489 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 490 | |
Dominik Laskowski | 3415776 | 2018-10-31 13:07:19 -0700 | [diff] [blame] | 491 | ALOGV("%s for display %s", __FUNCTION__, to_string(displayId).c_str()); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 492 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; |
Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 493 | auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 494 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 495 | return NO_ERROR; |
| 496 | } |
| 497 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 498 | status_t HWComposer::getDeviceCompositionChanges( |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 499 | HalDisplayId displayId, bool frameUsesClientComposition, |
Ady Abraham | f1db803 | 2023-03-24 17:52:34 -0700 | [diff] [blame] | 500 | std::optional<std::chrono::steady_clock::time_point> earliestPresentTime, |
| 501 | nsecs_t expectedPresentTime, |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 502 | std::optional<android::HWComposer::DeviceRequestedChanges>* outChanges) { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 503 | ATRACE_CALL(); |
| 504 | |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 505 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 506 | |
| 507 | auto& displayData = mDisplayData[displayId]; |
| 508 | auto& hwcDisplay = displayData.hwcDisplay; |
| 509 | if (!hwcDisplay->isConnected()) { |
| 510 | return NO_ERROR; |
| 511 | } |
| 512 | |
| 513 | uint32_t numTypes = 0; |
| 514 | uint32_t numRequests = 0; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 515 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 516 | hal::Error error = hal::Error::NONE; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 517 | |
Ady Abraham | ec7aa8a | 2021-06-28 12:37:09 -0700 | [diff] [blame] | 518 | // First try to skip validate altogether. We can do that when |
| 519 | // 1. The previous frame has not been presented yet or already passed the |
| 520 | // earliest time to present. Otherwise, we may present a frame too early. |
| 521 | // 2. There is no client composition. Otherwise, we first need to render the |
Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 522 | // client target buffer. |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 523 | const bool canSkipValidate = [&] { |
| 524 | // We must call validate if we have client composition |
| 525 | if (frameUsesClientComposition) { |
| 526 | return false; |
| 527 | } |
| 528 | |
| 529 | // If composer supports getting the expected present time, we can skip |
| 530 | // as composer will make sure to prevent early presentation |
Ady Abraham | f1db803 | 2023-03-24 17:52:34 -0700 | [diff] [blame] | 531 | if (!earliestPresentTime) { |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 532 | return true; |
| 533 | } |
| 534 | |
| 535 | // composer doesn't support getting the expected present time. We can only |
| 536 | // skip validate if we know that we are not going to present early. |
Ady Abraham | f1db803 | 2023-03-24 17:52:34 -0700 | [diff] [blame] | 537 | return std::chrono::steady_clock::now() >= *earliestPresentTime; |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 538 | }(); |
| 539 | |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 540 | displayData.validateWasSkipped = false; |
ramindani | f8c0f10 | 2023-10-09 12:42:57 -0700 | [diff] [blame^] | 541 | { |
| 542 | std::scoped_lock lock{displayData.expectedPresentLock}; |
| 543 | displayData.lastExpectedPresentTimestamp = TimePoint::fromNs(expectedPresentTime); |
| 544 | // TODO(b/296636176) Update displayData.lastFrameInterval for present display commands |
| 545 | } |
| 546 | |
Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 547 | if (canSkipValidate) { |
Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 548 | sp<Fence> outPresentFence; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 549 | uint32_t state = UINT32_MAX; |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 550 | error = hwcDisplay->presentOrValidate(expectedPresentTime, &numTypes, &numRequests, |
| 551 | &outPresentFence, &state); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 552 | if (!hasChangesError(error)) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 553 | RETURN_IF_HWC_ERROR_FOR("presentOrValidate", error, displayId, UNKNOWN_ERROR); |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 554 | } |
| 555 | if (state == 1) { //Present Succeeded. |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 556 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 557 | error = hwcDisplay->getReleaseFences(&releaseFences); |
| 558 | displayData.releaseFences = std::move(releaseFences); |
| 559 | displayData.lastPresentFence = outPresentFence; |
| 560 | displayData.validateWasSkipped = true; |
| 561 | displayData.presentError = error; |
| 562 | return NO_ERROR; |
| 563 | } |
| 564 | // Present failed but Validate ran. |
| 565 | } else { |
Ady Abraham | 43065bd | 2021-12-10 17:22:15 -0800 | [diff] [blame] | 566 | error = hwcDisplay->validate(expectedPresentTime, &numTypes, &numRequests); |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 567 | } |
| 568 | ALOGV("SkipValidate failed, Falling back to SLOW validate/present"); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 569 | if (!hasChangesError(error)) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 570 | RETURN_IF_HWC_ERROR_FOR("validate", error, displayId, BAD_INDEX); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 571 | } |
| 572 | |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 573 | android::HWComposer::DeviceRequestedChanges::ChangedTypes changedTypes; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 574 | changedTypes.reserve(numTypes); |
| 575 | error = hwcDisplay->getChangedCompositionTypes(&changedTypes); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 576 | RETURN_IF_HWC_ERROR_FOR("getChangedCompositionTypes", error, displayId, BAD_INDEX); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 577 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 578 | auto displayRequests = static_cast<hal::DisplayRequest>(0); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 579 | android::HWComposer::DeviceRequestedChanges::LayerRequests layerRequests; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 580 | layerRequests.reserve(numRequests); |
Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 581 | error = hwcDisplay->getRequests(&displayRequests, &layerRequests); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 582 | RETURN_IF_HWC_ERROR_FOR("getRequests", error, displayId, BAD_INDEX); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 583 | |
Peiyong Lin | dfc3f7c | 2020-05-07 20:15:50 -0700 | [diff] [blame] | 584 | DeviceRequestedChanges::ClientTargetProperty clientTargetProperty; |
Alec Mouri | 8506569 | 2022-03-18 00:58:26 +0000 | [diff] [blame] | 585 | error = hwcDisplay->getClientTargetProperty(&clientTargetProperty); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 586 | |
Peiyong Lin | dfc3f7c | 2020-05-07 20:15:50 -0700 | [diff] [blame] | 587 | outChanges->emplace(DeviceRequestedChanges{std::move(changedTypes), std::move(displayRequests), |
| 588 | std::move(layerRequests), |
Alec Mouri | 8506569 | 2022-03-18 00:58:26 +0000 | [diff] [blame] | 589 | std::move(clientTargetProperty)}); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 590 | error = hwcDisplay->acceptChanges(); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 591 | RETURN_IF_HWC_ERROR_FOR("acceptChanges", error, displayId, BAD_INDEX); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 592 | |
| 593 | return NO_ERROR; |
| 594 | } |
| 595 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 596 | sp<Fence> HWComposer::getPresentFence(HalDisplayId displayId) const { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 597 | RETURN_IF_INVALID_DISPLAY(displayId, Fence::NO_FENCE); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 598 | return mDisplayData.at(displayId).lastPresentFence; |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 599 | } |
| 600 | |
Dominik Laskowski | dc2bb80 | 2022-09-28 16:02:59 -0400 | [diff] [blame] | 601 | nsecs_t HWComposer::getPresentTimestamp(PhysicalDisplayId displayId) const { |
| 602 | RETURN_IF_INVALID_DISPLAY(displayId, 0); |
| 603 | return mDisplayData.at(displayId).lastPresentTimestamp; |
| 604 | } |
| 605 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 606 | sp<Fence> HWComposer::getLayerReleaseFence(HalDisplayId displayId, HWC2::Layer* layer) const { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 607 | RETURN_IF_INVALID_DISPLAY(displayId, Fence::NO_FENCE); |
Tim Murray | 2d3f8b8 | 2019-12-04 16:24:17 -0800 | [diff] [blame] | 608 | const auto& displayFences = mDisplayData.at(displayId).releaseFences; |
| 609 | auto fence = displayFences.find(layer); |
| 610 | if (fence == displayFences.end()) { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 611 | ALOGV("getLayerReleaseFence: Release fence not found"); |
| 612 | return Fence::NO_FENCE; |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 613 | } |
Tim Murray | 2d3f8b8 | 2019-12-04 16:24:17 -0800 | [diff] [blame] | 614 | return fence->second; |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 615 | } |
| 616 | |
Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 617 | status_t HWComposer::presentAndGetReleaseFences( |
Ady Abraham | f1db803 | 2023-03-24 17:52:34 -0700 | [diff] [blame] | 618 | HalDisplayId displayId, |
| 619 | std::optional<std::chrono::steady_clock::time_point> earliestPresentTime) { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 620 | ATRACE_CALL(); |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 621 | |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 622 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Pablo Ceballos | d814cf2 | 2015-09-11 14:37:39 -0700 | [diff] [blame] | 623 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 624 | auto& displayData = mDisplayData[displayId]; |
| 625 | auto& hwcDisplay = displayData.hwcDisplay; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 626 | |
| 627 | if (displayData.validateWasSkipped) { |
Chia-I Wu | ae5a6b8 | 2017-10-10 09:09:22 -0700 | [diff] [blame] | 628 | // explicitly flush all pending commands |
Leon Scroggins III | e24d78f | 2022-09-20 16:38:19 -0400 | [diff] [blame] | 629 | auto error = static_cast<hal::Error>(mComposer->executeCommands(hwcDisplay->getId())); |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 630 | RETURN_IF_HWC_ERROR_FOR("executeCommands", error, displayId, UNKNOWN_ERROR); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 631 | RETURN_IF_HWC_ERROR_FOR("present", displayData.presentError, displayId, UNKNOWN_ERROR); |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 632 | return NO_ERROR; |
| 633 | } |
| 634 | |
Ady Abraham | f1db803 | 2023-03-24 17:52:34 -0700 | [diff] [blame] | 635 | if (earliestPresentTime) { |
Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 636 | ATRACE_NAME("wait for earliest present time"); |
Ady Abraham | f1db803 | 2023-03-24 17:52:34 -0700 | [diff] [blame] | 637 | std::this_thread::sleep_until(*earliestPresentTime); |
Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 638 | } |
| 639 | |
Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 640 | auto error = hwcDisplay->present(&displayData.lastPresentFence); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 641 | RETURN_IF_HWC_ERROR_FOR("present", error, displayId, UNKNOWN_ERROR); |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 642 | |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 643 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 644 | error = hwcDisplay->getReleaseFences(&releaseFences); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 645 | RETURN_IF_HWC_ERROR_FOR("getReleaseFences", error, displayId, UNKNOWN_ERROR); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 646 | |
| 647 | displayData.releaseFences = std::move(releaseFences); |
| 648 | |
| 649 | return NO_ERROR; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 650 | } |
| 651 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 652 | status_t HWComposer::setPowerMode(PhysicalDisplayId displayId, hal::PowerMode mode) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 653 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 654 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 655 | if (mode == hal::PowerMode::OFF) { |
| 656 | setVsyncEnabled(displayId, hal::Vsync::DISABLE); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 657 | } |
| 658 | |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 659 | const auto& displayData = mDisplayData[displayId]; |
Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 660 | auto& hwcDisplay = displayData.hwcDisplay; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 661 | switch (mode) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 662 | case hal::PowerMode::OFF: |
| 663 | case hal::PowerMode::ON: |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 664 | ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str()); |
| 665 | { |
| 666 | auto error = hwcDisplay->setPowerMode(mode); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 667 | if (error != hal::Error::NONE) { |
| 668 | LOG_HWC_ERROR(("setPowerMode(" + to_string(mode) + ")").c_str(), error, |
| 669 | displayId); |
Peiyong Lin | 306e499 | 2018-05-07 16:18:22 -0700 | [diff] [blame] | 670 | } |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 671 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 672 | break; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 673 | case hal::PowerMode::DOZE: |
| 674 | case hal::PowerMode::DOZE_SUSPEND: |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 675 | ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str()); |
| 676 | { |
| 677 | bool supportsDoze = false; |
Leon Scroggins III | 689c80f | 2023-06-05 17:49:32 -0400 | [diff] [blame] | 678 | const auto queryDozeError = hwcDisplay->supportsDoze(&supportsDoze); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 679 | |
Leon Scroggins III | 689c80f | 2023-06-05 17:49:32 -0400 | [diff] [blame] | 680 | // queryDozeError might be NO_RESOURCES, in the case of a display that has never |
| 681 | // been turned on. In that case, attempt to set to DOZE anyway. |
| 682 | if (!supportsDoze && queryDozeError == hal::Error::NONE) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 683 | mode = hal::PowerMode::ON; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 684 | } |
| 685 | |
Leon Scroggins III | 689c80f | 2023-06-05 17:49:32 -0400 | [diff] [blame] | 686 | auto error = hwcDisplay->setPowerMode(mode); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 687 | if (error != hal::Error::NONE) { |
| 688 | LOG_HWC_ERROR(("setPowerMode(" + to_string(mode) + ")").c_str(), error, |
| 689 | displayId); |
Leon Scroggins III | 689c80f | 2023-06-05 17:49:32 -0400 | [diff] [blame] | 690 | // If the display had never been turned on, so its doze |
| 691 | // support was unknown, it may truly not support doze. Try |
| 692 | // switching it to ON instead. |
| 693 | if (queryDozeError == hal::Error::NO_RESOURCES) { |
| 694 | ALOGD("%s: failed to set %s to %s. Trying again with ON", __func__, |
| 695 | to_string(displayId).c_str(), to_string(mode).c_str()); |
| 696 | error = hwcDisplay->setPowerMode(hal::PowerMode::ON); |
| 697 | if (error != hal::Error::NONE) { |
| 698 | LOG_HWC_ERROR("setPowerMode(ON)", error, displayId); |
| 699 | } |
| 700 | } |
Peiyong Lin | 306e499 | 2018-05-07 16:18:22 -0700 | [diff] [blame] | 701 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 702 | } |
| 703 | break; |
| 704 | default: |
| 705 | ALOGV("setPowerMode: Not calling HWC"); |
| 706 | break; |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 707 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 708 | |
| 709 | return NO_ERROR; |
| 710 | } |
| 711 | |
Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 712 | status_t HWComposer::setActiveModeWithConstraints( |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 713 | PhysicalDisplayId displayId, hal::HWConfigId hwcModeId, |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 714 | const hal::VsyncPeriodChangeConstraints& constraints, |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 715 | hal::VsyncPeriodChangeTimeline* outTimeline) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 716 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 717 | |
Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 718 | auto error = mDisplayData[displayId].hwcDisplay->setActiveConfigWithConstraints(hwcModeId, |
| 719 | constraints, |
| 720 | outTimeline); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 721 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 722 | return NO_ERROR; |
| 723 | } |
| 724 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 725 | status_t HWComposer::setColorTransform(HalDisplayId displayId, const mat4& transform) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 726 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 727 | |
| 728 | auto& displayData = mDisplayData[displayId]; |
Ady Abraham | dc011a9 | 2021-12-21 14:06:44 -0800 | [diff] [blame] | 729 | auto error = displayData.hwcDisplay->setColorTransform(transform); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 730 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 731 | return NO_ERROR; |
| 732 | } |
| 733 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 734 | void HWComposer::disconnectDisplay(HalDisplayId displayId) { |
Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 735 | RETURN_IF_INVALID_DISPLAY(displayId); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 736 | auto& displayData = mDisplayData[displayId]; |
Dominik Laskowski | 7e04546 | 2018-05-30 13:02:02 -0700 | [diff] [blame] | 737 | const auto hwcDisplayId = displayData.hwcDisplay->getId(); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 738 | |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 739 | mPhysicalDisplayIdMap.erase(hwcDisplayId); |
| 740 | mDisplayData.erase(displayId); |
Marin Shalamanov | 8b19659 | 2021-08-09 16:24:42 +0200 | [diff] [blame] | 741 | |
| 742 | // Reset the primary display ID if we're disconnecting it. |
| 743 | // This way isHeadless() will return false, which is necessary |
| 744 | // because getPrimaryDisplayId() will crash. |
| 745 | if (mPrimaryHwcDisplayId == hwcDisplayId) { |
| 746 | mPrimaryHwcDisplayId.reset(); |
| 747 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 748 | } |
| 749 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 750 | status_t HWComposer::setOutputBuffer(HalVirtualDisplayId displayId, const sp<Fence>& acquireFence, |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 751 | const sp<GraphicBuffer>& buffer) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 752 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 753 | const auto& displayData = mDisplayData[displayId]; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 754 | |
Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 755 | auto error = displayData.hwcDisplay->setOutputBuffer(buffer, acquireFence); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 756 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 757 | return NO_ERROR; |
| 758 | } |
| 759 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 760 | void HWComposer::clearReleaseFences(HalDisplayId displayId) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 761 | RETURN_IF_INVALID_DISPLAY(displayId); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 762 | mDisplayData[displayId].releaseFences.clear(); |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 763 | } |
| 764 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 765 | status_t HWComposer::getHdrCapabilities(HalDisplayId displayId, HdrCapabilities* outCapabilities) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 766 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 767 | |
| 768 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 769 | auto error = hwcDisplay->getHdrCapabilities(outCapabilities); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 770 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 771 | return NO_ERROR; |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 772 | } |
| 773 | |
Sally Qi | bb866c1 | 2022-10-17 11:31:20 -0700 | [diff] [blame] | 774 | const aidl::android::hardware::graphics::composer3::OverlayProperties& |
| 775 | HWComposer::getOverlaySupport() const { |
| 776 | return mOverlayProperties; |
Sally Qi | 0cbd08b | 2022-08-17 12:12:28 -0700 | [diff] [blame] | 777 | } |
| 778 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 779 | int32_t HWComposer::getSupportedPerFrameMetadata(HalDisplayId displayId) const { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 780 | RETURN_IF_INVALID_DISPLAY(displayId, 0); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 781 | return mDisplayData.at(displayId).hwcDisplay->getSupportedPerFrameMetadata(); |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 782 | } |
| 783 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 784 | std::vector<ui::RenderIntent> HWComposer::getRenderIntents(HalDisplayId displayId, |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 785 | ui::ColorMode colorMode) const { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 786 | RETURN_IF_INVALID_DISPLAY(displayId, {}); |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 787 | |
| 788 | std::vector<ui::RenderIntent> renderIntents; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 789 | auto error = mDisplayData.at(displayId).hwcDisplay->getRenderIntents(colorMode, &renderIntents); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 790 | RETURN_IF_HWC_ERROR(error, displayId, {}); |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 791 | return renderIntents; |
| 792 | } |
| 793 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 794 | mat4 HWComposer::getDataspaceSaturationMatrix(HalDisplayId displayId, ui::Dataspace dataspace) { |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 795 | RETURN_IF_INVALID_DISPLAY(displayId, {}); |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 796 | |
| 797 | mat4 matrix; |
| 798 | auto error = mDisplayData[displayId].hwcDisplay->getDataspaceSaturationMatrix(dataspace, |
| 799 | &matrix); |
Dominik Laskowski | fc2c032 | 2018-04-19 14:47:33 -0700 | [diff] [blame] | 800 | RETURN_IF_HWC_ERROR(error, displayId, {}); |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 801 | return matrix; |
| 802 | } |
| 803 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 804 | status_t HWComposer::getDisplayedContentSamplingAttributes(HalDisplayId displayId, |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 805 | ui::PixelFormat* outFormat, |
| 806 | ui::Dataspace* outDataspace, |
| 807 | uint8_t* outComponentMask) { |
| 808 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 809 | const auto error = |
| 810 | mDisplayData[displayId] |
| 811 | .hwcDisplay->getDisplayedContentSamplingAttributes(outFormat, outDataspace, |
| 812 | outComponentMask); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 813 | if (error == hal::Error::UNSUPPORTED) RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 814 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 815 | return NO_ERROR; |
| 816 | } |
| 817 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 818 | status_t HWComposer::setDisplayContentSamplingEnabled(HalDisplayId displayId, bool enabled, |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 819 | uint8_t componentMask, uint64_t maxFrames) { |
| 820 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 821 | const auto error = |
| 822 | mDisplayData[displayId].hwcDisplay->setDisplayContentSamplingEnabled(enabled, |
| 823 | componentMask, |
| 824 | maxFrames); |
| 825 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 826 | if (error == hal::Error::UNSUPPORTED) RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 827 | if (error == hal::Error::BAD_PARAMETER) RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
Kevin DuBois | 74e5377 | 2018-11-19 10:52:38 -0800 | [diff] [blame] | 828 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 829 | return NO_ERROR; |
| 830 | } |
| 831 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 832 | status_t HWComposer::getDisplayedContentSample(HalDisplayId displayId, uint64_t maxFrames, |
Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 833 | uint64_t timestamp, DisplayedFrameStats* outStats) { |
| 834 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 835 | const auto error = |
| 836 | mDisplayData[displayId].hwcDisplay->getDisplayedContentSample(maxFrames, timestamp, |
| 837 | outStats); |
| 838 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 839 | return NO_ERROR; |
| 840 | } |
| 841 | |
Dominik Laskowski | b17c621 | 2022-05-09 09:36:19 -0700 | [diff] [blame] | 842 | ftl::Future<status_t> HWComposer::setDisplayBrightness( |
Alec Mouri | 4d8a05d | 2022-03-23 18:14:26 +0000 | [diff] [blame] | 843 | PhysicalDisplayId displayId, float brightness, float brightnessNits, |
Alec Mouri | cdf1679 | 2021-12-10 13:16:06 -0800 | [diff] [blame] | 844 | const Hwc2::Composer::DisplayBrightnessOptions& options) { |
Dominik Laskowski | 4e2b71f | 2020-11-10 15:05:32 -0800 | [diff] [blame] | 845 | RETURN_IF_INVALID_DISPLAY(displayId, ftl::yield<status_t>(BAD_INDEX)); |
Dominik Laskowski | 5690bde | 2020-04-23 19:04:22 -0700 | [diff] [blame] | 846 | auto& display = mDisplayData[displayId].hwcDisplay; |
| 847 | |
Dominik Laskowski | b17c621 | 2022-05-09 09:36:19 -0700 | [diff] [blame] | 848 | return display->setDisplayBrightness(brightness, brightnessNits, options) |
Dominik Laskowski | 5690bde | 2020-04-23 19:04:22 -0700 | [diff] [blame] | 849 | .then([displayId](hal::Error error) -> status_t { |
| 850 | if (error == hal::Error::UNSUPPORTED) { |
| 851 | RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 852 | } |
| 853 | if (error == hal::Error::BAD_PARAMETER) { |
| 854 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
| 855 | } |
| 856 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 857 | return NO_ERROR; |
| 858 | }); |
Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 859 | } |
| 860 | |
Matt Buckley | 50c4406 | 2022-01-17 20:48:10 +0000 | [diff] [blame] | 861 | bool HWComposer::getValidateSkipped(HalDisplayId displayId) const { |
| 862 | if (mDisplayData.count(displayId) == 0) { |
| 863 | return false; |
| 864 | } |
| 865 | return mDisplayData.at(displayId).validateWasSkipped; |
| 866 | } |
| 867 | |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 868 | status_t HWComposer::setBootDisplayMode(PhysicalDisplayId displayId, |
| 869 | hal::HWConfigId displayModeId) { |
| 870 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 871 | const auto error = mDisplayData[displayId].hwcDisplay->setBootDisplayConfig(displayModeId); |
| 872 | if (error == hal::Error::UNSUPPORTED) { |
| 873 | RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 874 | } |
| 875 | if (error == hal::Error::BAD_PARAMETER) { |
| 876 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
| 877 | } |
| 878 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 879 | return NO_ERROR; |
| 880 | } |
| 881 | |
| 882 | status_t HWComposer::clearBootDisplayMode(PhysicalDisplayId displayId) { |
| 883 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 884 | const auto error = mDisplayData[displayId].hwcDisplay->clearBootDisplayConfig(); |
| 885 | if (error == hal::Error::UNSUPPORTED) { |
| 886 | RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 887 | } |
| 888 | if (error == hal::Error::BAD_PARAMETER) { |
| 889 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
| 890 | } |
| 891 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 892 | return NO_ERROR; |
| 893 | } |
| 894 | |
Kriti Dang | 16ca297 | 2022-02-01 20:07:03 +0100 | [diff] [blame] | 895 | std::optional<hal::HWConfigId> HWComposer::getPreferredBootDisplayMode( |
| 896 | PhysicalDisplayId displayId) { |
| 897 | RETURN_IF_INVALID_DISPLAY(displayId, std::nullopt); |
| 898 | hal::HWConfigId displayModeId; |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 899 | const auto error = |
| 900 | mDisplayData[displayId].hwcDisplay->getPreferredBootDisplayConfig(&displayModeId); |
Kriti Dang | 16ca297 | 2022-02-01 20:07:03 +0100 | [diff] [blame] | 901 | if (error != hal::Error::NONE) { |
| 902 | LOG_DISPLAY_ERROR(displayId, to_string(error).c_str()); |
| 903 | return std::nullopt; |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 904 | } |
Kriti Dang | 7defaf3 | 2021-11-15 11:55:43 +0100 | [diff] [blame] | 905 | return displayModeId; |
| 906 | } |
| 907 | |
Kriti Dang | 674b937 | 2022-11-18 10:58:44 +0100 | [diff] [blame] | 908 | std::vector<HdrConversionCapability> HWComposer::getHdrConversionCapabilities() const { |
| 909 | return mHdrConversionCapabilities; |
| 910 | } |
| 911 | |
Kriti Dang | d432bb5 | 2023-02-09 18:21:04 +0100 | [diff] [blame] | 912 | status_t HWComposer::setHdrConversionStrategy( |
| 913 | HdrConversionStrategy hdrConversionStrategy, |
| 914 | aidl::android::hardware::graphics::common::Hdr* outPreferredHdrOutputType) { |
| 915 | const auto error = |
| 916 | mComposer->setHdrConversionStrategy(hdrConversionStrategy, outPreferredHdrOutputType); |
Kriti Dang | 674b937 | 2022-11-18 10:58:44 +0100 | [diff] [blame] | 917 | if (error != hal::Error::NONE) { |
| 918 | ALOGE("Error in setting HDR conversion strategy %s", to_string(error).c_str()); |
Kriti Dang | d432bb5 | 2023-02-09 18:21:04 +0100 | [diff] [blame] | 919 | return INVALID_OPERATION; |
Kriti Dang | 674b937 | 2022-11-18 10:58:44 +0100 | [diff] [blame] | 920 | } |
| 921 | return NO_ERROR; |
| 922 | } |
| 923 | |
ramindani | b2158ee | 2023-02-13 20:29:59 -0800 | [diff] [blame] | 924 | status_t HWComposer::setRefreshRateChangedCallbackDebugEnabled(PhysicalDisplayId displayId, |
| 925 | bool enabled) { |
| 926 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 927 | const auto error = |
| 928 | mComposer->setRefreshRateChangedCallbackDebugEnabled(mDisplayData[displayId] |
| 929 | .hwcDisplay->getId(), |
| 930 | enabled); |
| 931 | if (error != hal::Error::NONE) { |
| 932 | ALOGE("Error in setting refresh refresh rate change callback debug enabled %s", |
| 933 | to_string(error).c_str()); |
| 934 | return INVALID_OPERATION; |
| 935 | } |
| 936 | return NO_ERROR; |
| 937 | } |
| 938 | |
ramindani | b90711b | 2023-10-02 15:13:19 -0700 | [diff] [blame] | 939 | status_t HWComposer::notifyExpectedPresentIfRequired(PhysicalDisplayId displayId, |
ramindani | f8c0f10 | 2023-10-09 12:42:57 -0700 | [diff] [blame^] | 940 | Period vsyncPeriod, |
| 941 | TimePoint expectedPresentTime, |
| 942 | Fps frameInterval, |
| 943 | std::optional<Period> timeoutOpt) { |
ramindani | 3acaaf5 | 2023-09-25 10:31:27 -0700 | [diff] [blame] | 944 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
ramindani | b90711b | 2023-10-02 15:13:19 -0700 | [diff] [blame] | 945 | auto& displayData = mDisplayData[displayId]; |
ramindani | f8c0f10 | 2023-10-09 12:42:57 -0700 | [diff] [blame^] | 946 | { |
| 947 | std::scoped_lock lock{displayData.expectedPresentLock}; |
| 948 | const auto lastExpectedPresentTimestamp = displayData.lastExpectedPresentTimestamp; |
| 949 | const auto lastFrameInterval = displayData.lastFrameInterval; |
| 950 | displayData.lastFrameInterval = frameInterval; |
| 951 | const auto threshold = Duration::fromNs(vsyncPeriod.ns() / 2); |
ramindani | b90711b | 2023-10-02 15:13:19 -0700 | [diff] [blame] | 952 | |
ramindani | f8c0f10 | 2023-10-09 12:42:57 -0700 | [diff] [blame^] | 953 | const constexpr nsecs_t kOneSecondNs = |
| 954 | std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count(); |
| 955 | const bool frameIntervalIsOnCadence = |
| 956 | isFrameIntervalOnCadence(expectedPresentTime, lastExpectedPresentTimestamp, |
| 957 | lastFrameInterval, |
| 958 | Period::fromNs(timeoutOpt && timeoutOpt->ns() > 0 |
| 959 | ? timeoutOpt->ns() |
| 960 | : kOneSecondNs), |
| 961 | threshold); |
| 962 | |
| 963 | const bool expectedPresentWithinTimeout = |
| 964 | isExpectedPresentWithinTimeout(expectedPresentTime, lastExpectedPresentTimestamp, |
| 965 | timeoutOpt, threshold); |
| 966 | |
| 967 | if (expectedPresentWithinTimeout && frameIntervalIsOnCadence) { |
| 968 | return NO_ERROR; |
| 969 | } |
| 970 | |
| 971 | displayData.lastExpectedPresentTimestamp = expectedPresentTime; |
| 972 | } |
ramindani | b90711b | 2023-10-02 15:13:19 -0700 | [diff] [blame] | 973 | ATRACE_FORMAT("%s ExpectedPresentTime %" PRId64 " frameIntervalNs %d", __func__, |
ramindani | f8c0f10 | 2023-10-09 12:42:57 -0700 | [diff] [blame^] | 974 | expectedPresentTime, frameInterval.getPeriodNsecs()); |
ramindani | b90711b | 2023-10-02 15:13:19 -0700 | [diff] [blame] | 975 | const auto error = mComposer->notifyExpectedPresent(displayData.hwcDisplay->getId(), |
ramindani | f8c0f10 | 2023-10-09 12:42:57 -0700 | [diff] [blame^] | 976 | expectedPresentTime.ns(), |
| 977 | frameInterval.getPeriodNsecs()); |
ramindani | b90711b | 2023-10-02 15:13:19 -0700 | [diff] [blame] | 978 | |
ramindani | 3acaaf5 | 2023-09-25 10:31:27 -0700 | [diff] [blame] | 979 | if (error != hal::Error::NONE) { |
| 980 | ALOGE("Error in notifyExpectedPresent call %s", to_string(error).c_str()); |
| 981 | return INVALID_OPERATION; |
| 982 | } |
| 983 | return NO_ERROR; |
| 984 | } |
| 985 | |
Leon Scroggins III | e7c51c6 | 2022-02-01 15:53:54 -0500 | [diff] [blame] | 986 | status_t HWComposer::getDisplayDecorationSupport( |
| 987 | PhysicalDisplayId displayId, |
| 988 | std::optional<aidl::android::hardware::graphics::common::DisplayDecorationSupport>* |
| 989 | support) { |
| 990 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 991 | const auto error = mDisplayData[displayId].hwcDisplay->getDisplayDecorationSupport(support); |
| 992 | if (error == hal::Error::UNSUPPORTED) { |
| 993 | RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 994 | } |
| 995 | if (error == hal::Error::BAD_PARAMETER) { |
| 996 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
| 997 | } |
| 998 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 999 | return NO_ERROR; |
| 1000 | } |
| 1001 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 1002 | status_t HWComposer::setAutoLowLatencyMode(PhysicalDisplayId displayId, bool on) { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1003 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 1004 | const auto error = mDisplayData[displayId].hwcDisplay->setAutoLowLatencyMode(on); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1005 | if (error == hal::Error::UNSUPPORTED) { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1006 | RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 1007 | } |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1008 | if (error == hal::Error::BAD_PARAMETER) { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1009 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
| 1010 | } |
| 1011 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 1012 | return NO_ERROR; |
| 1013 | } |
| 1014 | |
| 1015 | status_t HWComposer::getSupportedContentTypes( |
Dominik Laskowski | 6c7b36e | 2022-03-03 08:27:58 -0800 | [diff] [blame] | 1016 | PhysicalDisplayId displayId, |
| 1017 | std::vector<hal::ContentType>* outSupportedContentTypes) const { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1018 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
Dominik Laskowski | 6c7b36e | 2022-03-03 08:27:58 -0800 | [diff] [blame] | 1019 | const auto error = mDisplayData.at(displayId).hwcDisplay->getSupportedContentTypes( |
| 1020 | outSupportedContentTypes); |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1021 | |
| 1022 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 1023 | |
| 1024 | return NO_ERROR; |
| 1025 | } |
| 1026 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 1027 | status_t HWComposer::setContentType(PhysicalDisplayId displayId, hal::ContentType contentType) { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1028 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 1029 | const auto error = mDisplayData[displayId].hwcDisplay->setContentType(contentType); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1030 | if (error == hal::Error::UNSUPPORTED) { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1031 | RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 1032 | } |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1033 | if (error == hal::Error::BAD_PARAMETER) { |
Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 1034 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
| 1035 | } |
| 1036 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 1037 | |
| 1038 | return NO_ERROR; |
| 1039 | } |
| 1040 | |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 1041 | const std::unordered_map<std::string, bool>& HWComposer::getSupportedLayerGenericMetadata() const { |
| 1042 | return mSupportedLayerGenericMetadata; |
| 1043 | } |
| 1044 | |
Yiwei Zhang | 5434a78 | 2018-12-05 18:06:32 -0800 | [diff] [blame] | 1045 | void HWComposer::dump(std::string& result) const { |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 1046 | result.append(mComposer->dumpDebugInfo()); |
Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 1047 | } |
| 1048 | |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 1049 | std::optional<PhysicalDisplayId> HWComposer::toPhysicalDisplayId( |
| 1050 | hal::HWDisplayId hwcDisplayId) const { |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1051 | if (const auto it = mPhysicalDisplayIdMap.find(hwcDisplayId); |
| 1052 | it != mPhysicalDisplayIdMap.end()) { |
| 1053 | return it->second; |
| 1054 | } |
| 1055 | return {}; |
| 1056 | } |
| 1057 | |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 1058 | std::optional<hal::HWDisplayId> HWComposer::fromPhysicalDisplayId( |
| 1059 | PhysicalDisplayId displayId) const { |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 1060 | if (const auto it = mDisplayData.find(displayId); it != mDisplayData.end()) { |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1061 | return it->second.hwcDisplay->getId(); |
| 1062 | } |
| 1063 | return {}; |
| 1064 | } |
| 1065 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1066 | bool HWComposer::shouldIgnoreHotplugConnect(hal::HWDisplayId hwcDisplayId, |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1067 | bool hasDisplayIdentificationData) const { |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1068 | if (mHasMultiDisplaySupport && !hasDisplayIdentificationData) { |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1069 | ALOGE("Ignoring connection of display %" PRIu64 " without identification data", |
| 1070 | hwcDisplayId); |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1071 | return true; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 1074 | // Legacy mode only supports IDs LEGACY_DISPLAY_TYPE_PRIMARY and LEGACY_DISPLAY_TYPE_EXTERNAL. |
| 1075 | if (!mHasMultiDisplaySupport && mPhysicalDisplayIdMap.size() == 2) { |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1076 | ALOGE("Ignoring connection of tertiary display %" PRIu64, hwcDisplayId); |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1077 | return true; |
| 1078 | } |
| 1079 | |
| 1080 | return false; |
| 1081 | } |
| 1082 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1083 | std::optional<DisplayIdentificationInfo> HWComposer::onHotplugConnect( |
| 1084 | hal::HWDisplayId hwcDisplayId) { |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1085 | std::optional<DisplayIdentificationInfo> info; |
| 1086 | if (const auto displayId = toPhysicalDisplayId(hwcDisplayId)) { |
| 1087 | info = DisplayIdentificationInfo{.id = *displayId, |
| 1088 | .name = std::string(), |
| 1089 | .deviceProductInfo = std::nullopt}; |
Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 1090 | if (mUpdateDeviceProductInfoOnHotplugReconnect) { |
| 1091 | uint8_t port; |
| 1092 | DisplayIdentificationData data; |
| 1093 | getDisplayIdentificationData(hwcDisplayId, &port, &data); |
| 1094 | if (auto newInfo = parseDisplayIdentificationData(port, data)) { |
| 1095 | info->deviceProductInfo = std::move(newInfo->deviceProductInfo); |
| 1096 | } else { |
| 1097 | ALOGE("Failed to parse identification data for display %" PRIu64, hwcDisplayId); |
| 1098 | } |
| 1099 | } |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1100 | } else { |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1101 | uint8_t port; |
| 1102 | DisplayIdentificationData data; |
| 1103 | const bool hasDisplayIdentificationData = |
| 1104 | getDisplayIdentificationData(hwcDisplayId, &port, &data); |
| 1105 | if (mPhysicalDisplayIdMap.empty()) { |
| 1106 | mHasMultiDisplaySupport = hasDisplayIdentificationData; |
| 1107 | ALOGI("Switching to %s multi-display mode", |
| 1108 | mHasMultiDisplaySupport ? "generalized" : "legacy"); |
| 1109 | } |
| 1110 | |
| 1111 | if (shouldIgnoreHotplugConnect(hwcDisplayId, hasDisplayIdentificationData)) { |
| 1112 | return {}; |
| 1113 | } |
| 1114 | |
| 1115 | info = [this, hwcDisplayId, &port, &data, hasDisplayIdentificationData] { |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 1116 | const bool isPrimary = !mPrimaryHwcDisplayId; |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1117 | if (mHasMultiDisplaySupport) { |
| 1118 | if (const auto info = parseDisplayIdentificationData(port, data)) { |
| 1119 | return *info; |
| 1120 | } |
| 1121 | ALOGE("Failed to parse identification data for display %" PRIu64, hwcDisplayId); |
| 1122 | } else { |
| 1123 | ALOGW_IF(hasDisplayIdentificationData, |
| 1124 | "Ignoring identification data for display %" PRIu64, hwcDisplayId); |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 1125 | port = isPrimary ? LEGACY_DISPLAY_TYPE_PRIMARY : LEGACY_DISPLAY_TYPE_EXTERNAL; |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1126 | } |
| 1127 | |
Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 1128 | return DisplayIdentificationInfo{.id = PhysicalDisplayId::fromPort(port), |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 1129 | .name = isPrimary ? "Primary display" |
| 1130 | : "Secondary display", |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1131 | .deviceProductInfo = std::nullopt}; |
| 1132 | }(); |
Leon Scroggins III | e24d78f | 2022-09-20 16:38:19 -0400 | [diff] [blame] | 1133 | |
| 1134 | mComposer->onHotplugConnect(hwcDisplayId); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1137 | if (!isConnected(info->id)) { |
| 1138 | allocatePhysicalDisplay(hwcDisplayId, info->id); |
| 1139 | } |
| 1140 | return info; |
| 1141 | } |
| 1142 | |
| 1143 | std::optional<DisplayIdentificationInfo> HWComposer::onHotplugDisconnect( |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1144 | hal::HWDisplayId hwcDisplayId) { |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 1145 | LOG_ALWAYS_FATAL_IF(hwcDisplayId == mPrimaryHwcDisplayId, |
| 1146 | "Primary display cannot be disconnected."); |
| 1147 | |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1148 | const auto displayId = toPhysicalDisplayId(hwcDisplayId); |
| 1149 | if (!displayId) { |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 1150 | LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Invalid HWC display"); |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1151 | return {}; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 1152 | } |
| 1153 | |
Dominik Laskowski | f2ddca6 | 2022-08-17 12:08:07 -0700 | [diff] [blame] | 1154 | if (!isConnected(*displayId)) { |
Dominik Laskowski | f8db0f0 | 2021-04-19 11:05:25 -0700 | [diff] [blame] | 1155 | LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Already disconnected"); |
Dominik Laskowski | f2ddca6 | 2022-08-17 12:08:07 -0700 | [diff] [blame] | 1156 | return {}; |
Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 1157 | } |
Dominik Laskowski | f2ddca6 | 2022-08-17 12:08:07 -0700 | [diff] [blame] | 1158 | |
| 1159 | // The display will later be destroyed by a call to HWComposer::disconnectDisplay. For now, mark |
| 1160 | // it as disconnected. |
| 1161 | mDisplayData.at(*displayId).hwcDisplay->setConnected(false); |
Leon Scroggins III | e24d78f | 2022-09-20 16:38:19 -0400 | [diff] [blame] | 1162 | mComposer->onHotplugDisconnect(hwcDisplayId); |
Dominik Laskowski | f2ddca6 | 2022-08-17 12:08:07 -0700 | [diff] [blame] | 1163 | return DisplayIdentificationInfo{.id = *displayId}; |
Steven Thomas | 6e8f706 | 2017-11-22 14:15:29 -0800 | [diff] [blame] | 1164 | } |
| 1165 | |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 1166 | void HWComposer::loadCapabilities() { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1167 | static_assert(sizeof(hal::Capability) == sizeof(int32_t), "Capability size has changed"); |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 1168 | auto capabilities = mComposer->getCapabilities(); |
| 1169 | for (auto capability : capabilities) { |
Ady Abraham | de549d4 | 2022-01-26 19:19:17 -0800 | [diff] [blame] | 1170 | mCapabilities.emplace(capability); |
Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 1171 | } |
| 1172 | } |
| 1173 | |
Sally Qi | bb866c1 | 2022-10-17 11:31:20 -0700 | [diff] [blame] | 1174 | void HWComposer::loadOverlayProperties() { |
| 1175 | mComposer->getOverlaySupport(&mOverlayProperties); |
| 1176 | } |
| 1177 | |
Kriti Dang | 674b937 | 2022-11-18 10:58:44 +0100 | [diff] [blame] | 1178 | void HWComposer::loadHdrConversionCapabilities() { |
| 1179 | const auto error = mComposer->getHdrConversionCapabilities(&mHdrConversionCapabilities); |
| 1180 | if (error != hal::Error::NONE) { |
| 1181 | ALOGE("Error in fetching HDR conversion capabilities %s", to_string(error).c_str()); |
| 1182 | mHdrConversionCapabilities = {}; |
| 1183 | } |
| 1184 | } |
| 1185 | |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 1186 | status_t HWComposer::setIdleTimerEnabled(PhysicalDisplayId displayId, |
| 1187 | std::chrono::milliseconds timeout) { |
| 1188 | ATRACE_CALL(); |
| 1189 | RETURN_IF_INVALID_DISPLAY(displayId, BAD_INDEX); |
| 1190 | const auto error = mDisplayData[displayId].hwcDisplay->setIdleTimerEnabled(timeout); |
| 1191 | if (error == hal::Error::UNSUPPORTED) { |
| 1192 | RETURN_IF_HWC_ERROR(error, displayId, INVALID_OPERATION); |
| 1193 | } |
| 1194 | if (error == hal::Error::BAD_PARAMETER) { |
| 1195 | RETURN_IF_HWC_ERROR(error, displayId, BAD_VALUE); |
| 1196 | } |
| 1197 | RETURN_IF_HWC_ERROR(error, displayId, UNKNOWN_ERROR); |
| 1198 | return NO_ERROR; |
| 1199 | } |
| 1200 | |
ramindani | 06e518e | 2022-03-14 18:47:53 +0000 | [diff] [blame] | 1201 | bool HWComposer::hasDisplayIdleTimerCapability(PhysicalDisplayId displayId) const { |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 1202 | RETURN_IF_INVALID_DISPLAY(displayId, false); |
ramindani | 06e518e | 2022-03-14 18:47:53 +0000 | [diff] [blame] | 1203 | return mDisplayData.at(displayId).hwcDisplay->hasDisplayIdleTimerCapability(); |
| 1204 | } |
| 1205 | |
| 1206 | Hwc2::AidlTransform HWComposer::getPhysicalDisplayOrientation(PhysicalDisplayId displayId) const { |
| 1207 | ATRACE_CALL(); |
| 1208 | RETURN_IF_INVALID_DISPLAY(displayId, Hwc2::AidlTransform::NONE); |
| 1209 | Hwc2::AidlTransform outTransform; |
| 1210 | const auto& hwcDisplay = mDisplayData.at(displayId).hwcDisplay; |
| 1211 | const auto error = hwcDisplay->getPhysicalDisplayOrientation(&outTransform); |
| 1212 | RETURN_IF_HWC_ERROR(error, displayId, Hwc2::AidlTransform::NONE); |
| 1213 | return outTransform; |
ramindani | 32cf060 | 2022-03-02 02:30:29 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 1216 | void HWComposer::loadLayerMetadataSupport() { |
| 1217 | mSupportedLayerGenericMetadata.clear(); |
| 1218 | |
| 1219 | std::vector<Hwc2::IComposerClient::LayerGenericMetadataKey> supportedMetadataKeyInfo; |
| 1220 | const auto error = mComposer->getLayerGenericMetadataKeys(&supportedMetadataKeyInfo); |
| 1221 | if (error != hardware::graphics::composer::V2_4::Error::NONE) { |
Ady Abraham | 3891cbe | 2021-03-29 11:29:31 -0700 | [diff] [blame] | 1222 | if (error != hardware::graphics::composer::V2_4::Error::UNSUPPORTED) { |
| 1223 | ALOGE("%s: %s failed: %s (%d)", __FUNCTION__, "getLayerGenericMetadataKeys", |
| 1224 | toString(error).c_str(), static_cast<int32_t>(error)); |
| 1225 | } |
Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 1226 | return; |
| 1227 | } |
| 1228 | |
| 1229 | for (const auto& [name, mandatory] : supportedMetadataKeyInfo) { |
| 1230 | mSupportedLayerGenericMetadata.emplace(name, mandatory); |
| 1231 | } |
| 1232 | } |
| 1233 | |
Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 1234 | } // namespace impl |
Dominik Laskowski | f9750f2 | 2018-06-06 12:24:53 -0700 | [diff] [blame] | 1235 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 1236 | |
| 1237 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 1238 | #pragma clang diagnostic pop // ignored "-Wconversion" |