Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <android/hardware/graphics/common/1.1/types.h> |
Manasi Navare | fc2a4a7 | 2024-11-12 23:59:21 +0000 | [diff] [blame] | 20 | #include <android/hardware/graphics/composer/2.1/types.h> |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 21 | #include <android/hardware/graphics/composer/2.4/IComposer.h> |
| 22 | #include <android/hardware/graphics/composer/2.4/IComposerClient.h> |
Manasi Navare | fc2a4a7 | 2024-11-12 23:59:21 +0000 | [diff] [blame] | 23 | #include <android/hardware/graphics/composer/2.4/types.h> |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 24 | |
Huihong Luo | 791bef9 | 2023-09-19 21:18:45 -0700 | [diff] [blame] | 25 | #include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h> |
Marc Kassis | bdf7e4b | 2022-11-04 17:26:48 +0100 | [diff] [blame] | 26 | #include <aidl/android/hardware/graphics/common/Hdr.h> |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 27 | #include <aidl/android/hardware/graphics/composer3/Composition.h> |
Leon Scroggins III | 5967aec | 2021-12-29 11:14:22 -0500 | [diff] [blame] | 28 | #include <aidl/android/hardware/graphics/composer3/DisplayCapability.h> |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 29 | #include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h> |
Manasi Navare | fc2a4a7 | 2024-11-12 23:59:21 +0000 | [diff] [blame] | 30 | #include <aidl/android/hardware/graphics/composer3/IComposerClient.h> |
ramindani | a04b8a5 | 2023-08-07 18:49:47 -0700 | [diff] [blame] | 31 | #include <aidl/android/hardware/graphics/composer3/VrrConfig.h> |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 32 | |
Manasi Navare | fc2a4a7 | 2024-11-12 23:59:21 +0000 | [diff] [blame] | 33 | #include <ftl/enum.h> |
| 34 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 35 | #define ERROR_HAS_CHANGES 5 |
| 36 | |
| 37 | namespace android { |
| 38 | namespace hardware::graphics::composer::hal { |
| 39 | |
| 40 | namespace types = android::hardware::graphics::common; |
| 41 | namespace V2_1 = android::hardware::graphics::composer::V2_1; |
| 42 | namespace V2_2 = android::hardware::graphics::composer::V2_2; |
| 43 | namespace V2_3 = android::hardware::graphics::composer::V2_3; |
| 44 | namespace V2_4 = android::hardware::graphics::composer::V2_4; |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 45 | namespace V3_0 = ::aidl::android::hardware::graphics::composer3; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 46 | |
| 47 | using types::V1_0::ColorTransform; |
| 48 | using types::V1_0::Transform; |
| 49 | using types::V1_1::RenderIntent; |
| 50 | using types::V1_2::ColorMode; |
| 51 | using types::V1_2::Dataspace; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 52 | using types::V1_2::PixelFormat; |
| 53 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 54 | using V2_4::IComposer; |
| 55 | using V2_4::IComposerCallback; |
| 56 | using V2_4::IComposerClient; |
| 57 | using V2_4::VsyncPeriodChangeTimeline; |
| 58 | using V2_4::VsyncPeriodNanos; |
| 59 | |
| 60 | using Attribute = IComposerClient::Attribute; |
| 61 | using BlendMode = IComposerClient::BlendMode; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 62 | using Connection = IComposerCallback::Connection; |
| 63 | using ContentType = IComposerClient::ContentType; |
| 64 | using Capability = IComposer::Capability; |
Peiyong Lin | dfc3f7c | 2020-05-07 20:15:50 -0700 | [diff] [blame] | 65 | using ClientTargetProperty = IComposerClient::ClientTargetProperty; |
Huihong Luo | 791bef9 | 2023-09-19 21:18:45 -0700 | [diff] [blame] | 66 | using DisplayHotplugEvent = aidl::android::hardware::graphics::common::DisplayHotplugEvent; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 67 | using DisplayRequest = IComposerClient::DisplayRequest; |
| 68 | using DisplayType = IComposerClient::DisplayType; |
| 69 | using HWConfigId = V2_1::Config; |
| 70 | using HWDisplayId = V2_1::Display; |
| 71 | using HWError = V2_1::Error; |
| 72 | using HWLayerId = V2_1::Layer; |
| 73 | using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey; |
| 74 | using LayerRequest = IComposerClient::LayerRequest; |
| 75 | using PerFrameMetadata = IComposerClient::PerFrameMetadata; |
| 76 | using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey; |
| 77 | using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob; |
| 78 | using PowerMode = IComposerClient::PowerMode; |
| 79 | using Vsync = IComposerClient::Vsync; |
| 80 | using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints; |
Marc Kassis | bdf7e4b | 2022-11-04 17:26:48 +0100 | [diff] [blame] | 81 | using Hdr = aidl::android::hardware::graphics::common::Hdr; |
ramindani | 0cd1d8d | 2023-06-13 13:43:23 -0700 | [diff] [blame] | 82 | using DisplayConfiguration = V3_0::DisplayConfiguration; |
ramindani | a04b8a5 | 2023-08-07 18:49:47 -0700 | [diff] [blame] | 83 | using VrrConfig = V3_0::VrrConfig; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 84 | |
Manasi Navare | fc2a4a7 | 2024-11-12 23:59:21 +0000 | [diff] [blame] | 85 | enum class Error : int32_t { |
| 86 | NONE = static_cast<int32_t>(V2_1::Error::NONE), |
| 87 | BAD_CONFIG = static_cast<int32_t>(V2_1::Error::BAD_CONFIG), |
| 88 | BAD_DISPLAY = static_cast<int32_t>(V2_1::Error::BAD_DISPLAY), |
| 89 | BAD_LAYER = static_cast<int32_t>(V2_1::Error::BAD_LAYER), |
| 90 | BAD_PARAMETER = static_cast<int32_t>(V2_1::Error::BAD_PARAMETER), |
| 91 | NO_RESOURCES = static_cast<int32_t>(V2_1::Error::NO_RESOURCES), |
| 92 | NOT_VALIDATED = static_cast<int32_t>(V2_1::Error::NOT_VALIDATED), |
| 93 | UNSUPPORTED = static_cast<int32_t>(V2_1::Error::UNSUPPORTED), |
| 94 | SEAMLESS_NOT_ALLOWED = static_cast<int32_t>(V2_4::Error::SEAMLESS_NOT_ALLOWED), |
| 95 | SEAMLESS_NOT_POSSIBLE = static_cast<int32_t>(V2_4::Error::SEAMLESS_NOT_POSSIBLE), |
| 96 | CONFIG_FAILED = V3_0::IComposerClient::EX_CONFIG_FAILED, |
| 97 | PICTURE_PROFILE_MAX_EXCEEDED = V3_0::IComposerClient::EX_PICTURE_PROFILE_MAX_EXCEEDED, |
| 98 | ftl_last = PICTURE_PROFILE_MAX_EXCEEDED |
| 99 | }; |
| 100 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 101 | } // namespace hardware::graphics::composer::hal |
| 102 | |
| 103 | inline bool hasChangesError(hardware::graphics::composer::hal::Error error) { |
| 104 | return ERROR_HAS_CHANGES == static_cast<int32_t>(error); |
| 105 | } |
| 106 | |
| 107 | inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) { |
| 108 | switch (attribute) { |
| 109 | case hardware::graphics::composer::hal::Attribute::INVALID: |
| 110 | return "Invalid"; |
| 111 | case hardware::graphics::composer::hal::Attribute::WIDTH: |
| 112 | return "Width"; |
| 113 | case hardware::graphics::composer::hal::Attribute::HEIGHT: |
| 114 | return "Height"; |
| 115 | case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD: |
| 116 | return "VsyncPeriod"; |
| 117 | case hardware::graphics::composer::hal::Attribute::DPI_X: |
| 118 | return "DpiX"; |
| 119 | case hardware::graphics::composer::hal::Attribute::DPI_Y: |
| 120 | return "DpiY"; |
| 121 | default: |
| 122 | return "Unknown"; |
| 123 | } |
| 124 | } |
| 125 | |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 126 | inline std::string to_string( |
| 127 | aidl::android::hardware::graphics::composer3::Composition composition) { |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 128 | switch (composition) { |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 129 | case aidl::android::hardware::graphics::composer3::Composition::INVALID: |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 130 | return "Invalid"; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 131 | case aidl::android::hardware::graphics::composer3::Composition::CLIENT: |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 132 | return "Client"; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 133 | case aidl::android::hardware::graphics::composer3::Composition::DEVICE: |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 134 | return "Device"; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 135 | case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR: |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 136 | return "SolidColor"; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 137 | case aidl::android::hardware::graphics::composer3::Composition::CURSOR: |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 138 | return "Cursor"; |
Leon Scroggins III | 2e1aa18 | 2021-12-01 17:33:12 -0500 | [diff] [blame] | 139 | case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND: |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 140 | return "Sideband"; |
Leon Scroggins III | 09c2541 | 2021-12-02 14:49:56 -0500 | [diff] [blame] | 141 | case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION: |
| 142 | return "DisplayDecoration"; |
ramindani | c1945cb | 2023-02-03 13:28:15 -0800 | [diff] [blame] | 143 | case aidl::android::hardware::graphics::composer3::Composition::REFRESH_RATE_INDICATOR: |
| 144 | return "RefreshRateIndicator"; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 145 | default: |
| 146 | return "Unknown"; |
| 147 | } |
| 148 | } |
| 149 | |
Leon Scroggins III | 515f038 | 2021-12-29 11:17:04 -0500 | [diff] [blame] | 150 | inline std::string to_string( |
| 151 | aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability) { |
| 152 | switch (displayCapability) { |
| 153 | case aidl::android::hardware::graphics::composer3::DisplayCapability::INVALID: |
| 154 | return "Invalid"; |
| 155 | case aidl::android::hardware::graphics::composer3::DisplayCapability:: |
| 156 | SKIP_CLIENT_COLOR_TRANSFORM: |
| 157 | return "SkipColorTransform"; |
| 158 | case aidl::android::hardware::graphics::composer3::DisplayCapability::DOZE: |
| 159 | return "Doze"; |
| 160 | case aidl::android::hardware::graphics::composer3::DisplayCapability::BRIGHTNESS: |
| 161 | return "Brightness"; |
| 162 | case aidl::android::hardware::graphics::composer3::DisplayCapability::PROTECTED_CONTENTS: |
| 163 | return "ProtectedContents"; |
| 164 | case aidl::android::hardware::graphics::composer3::DisplayCapability::AUTO_LOW_LATENCY_MODE: |
| 165 | return "AutoLowLatencyMode"; |
| 166 | case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND: |
| 167 | return "Suspend"; |
Leon Scroggins III | e7c51c6 | 2022-02-01 15:53:54 -0500 | [diff] [blame] | 168 | case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER: |
| 169 | return "DisplayIdleTimer"; |
Leon Scroggins III | 515f038 | 2021-12-29 11:17:04 -0500 | [diff] [blame] | 170 | default: |
| 171 | return "Unknown"; |
| 172 | } |
| 173 | } |
| 174 | |
ramindani | a04b8a5 | 2023-08-07 18:49:47 -0700 | [diff] [blame] | 175 | inline std::string to_string( |
| 176 | const std::optional<aidl::android::hardware::graphics::composer3::VrrConfig>& vrrConfig) { |
| 177 | if (vrrConfig) { |
| 178 | std::ostringstream out; |
| 179 | out << "{minFrameIntervalNs=" << vrrConfig->minFrameIntervalNs << ", "; |
| 180 | out << "frameIntervalPowerHints={"; |
| 181 | if (vrrConfig->frameIntervalPowerHints) { |
| 182 | const auto& powerHint = *vrrConfig->frameIntervalPowerHints; |
| 183 | for (size_t i = 0; i < powerHint.size(); i++) { |
| 184 | if (i > 0) out << ", "; |
| 185 | out << "[frameIntervalNs=" << powerHint[i]->frameIntervalNs |
| 186 | << ", averageRefreshPeriodNs=" << powerHint[i]->averageRefreshPeriodNs << "]"; |
| 187 | } |
| 188 | } |
| 189 | out << "}, "; |
| 190 | out << "notifyExpectedPresentConfig={"; |
| 191 | if (vrrConfig->notifyExpectedPresentConfig) { |
ramindani | cbd7a6d | 2023-12-19 16:00:30 -0800 | [diff] [blame] | 192 | out << "headsUpNs=" << vrrConfig->notifyExpectedPresentConfig->headsUpNs |
| 193 | << ", timeoutNs=" << vrrConfig->notifyExpectedPresentConfig->timeoutNs; |
ramindani | a04b8a5 | 2023-08-07 18:49:47 -0700 | [diff] [blame] | 194 | } |
| 195 | out << "}}"; |
| 196 | return out.str(); |
| 197 | } |
| 198 | return "N/A"; |
| 199 | } |
| 200 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 201 | inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) { |
| 202 | // 5 is reserved for historical reason, during validation 5 means has changes. |
| 203 | if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) { |
| 204 | return "HasChanges"; |
| 205 | } |
| 206 | switch (error) { |
| 207 | case hardware::graphics::composer::hal::V2_4::Error::NONE: |
| 208 | return "None"; |
| 209 | case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG: |
| 210 | return "BadConfig"; |
| 211 | case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY: |
| 212 | return "BadDisplay"; |
| 213 | case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER: |
| 214 | return "BadLayer"; |
| 215 | case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER: |
| 216 | return "BadParameter"; |
| 217 | case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES: |
| 218 | return "NoResources"; |
| 219 | case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED: |
| 220 | return "NotValidated"; |
| 221 | case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED: |
| 222 | return "Unsupported"; |
| 223 | case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED: |
| 224 | return "SeamlessNotAllowed"; |
| 225 | case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE: |
| 226 | return "SeamlessNotPossible"; |
| 227 | default: |
| 228 | return "Unknown"; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | inline std::string to_string(hardware::graphics::composer::hal::Error error) { |
Manasi Navare | fc2a4a7 | 2024-11-12 23:59:21 +0000 | [diff] [blame] | 233 | // 5 is reserved for historical reason, during validation 5 means has changes. |
| 234 | if (hasChangesError(error)) { |
| 235 | return "HAS_CHANGES"; |
| 236 | } |
| 237 | return ftl::enum_string(error); |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Dominik Laskowski | e70461a | 2022-08-30 14:42:01 -0700 | [diff] [blame] | 240 | // For utils::Dumper ADL. |
Dominik Laskowski | 03cfce8 | 2022-11-02 12:13:29 -0400 | [diff] [blame] | 241 | namespace hardware::graphics::composer { |
| 242 | namespace V2_2 { |
Dominik Laskowski | e70461a | 2022-08-30 14:42:01 -0700 | [diff] [blame] | 243 | |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 244 | inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) { |
| 245 | switch (mode) { |
| 246 | case hardware::graphics::composer::hal::PowerMode::OFF: |
| 247 | return "Off"; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 248 | case hardware::graphics::composer::hal::PowerMode::DOZE: |
| 249 | return "Doze"; |
| 250 | case hardware::graphics::composer::hal::PowerMode::ON: |
| 251 | return "On"; |
Peiyong Lin | 65248e0 | 2020-04-18 21:15:07 -0700 | [diff] [blame] | 252 | case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND: |
| 253 | return "DozeSuspend"; |
| 254 | case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND: |
| 255 | return "OnSuspend"; |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 256 | default: |
| 257 | return "Unknown"; |
| 258 | } |
| 259 | } |
| 260 | |
Dominik Laskowski | 03cfce8 | 2022-11-02 12:13:29 -0400 | [diff] [blame] | 261 | } // namespace V2_2 |
| 262 | |
| 263 | namespace V2_1 { |
Dominik Laskowski | e70461a | 2022-08-30 14:42:01 -0700 | [diff] [blame] | 264 | |
Ady Abraham | 4f960d1 | 2021-10-13 16:59:49 -0700 | [diff] [blame] | 265 | inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) { |
| 266 | switch (vsync) { |
| 267 | case hardware::graphics::composer::hal::Vsync::ENABLE: |
| 268 | return "Enable"; |
| 269 | case hardware::graphics::composer::hal::Vsync::DISABLE: |
| 270 | return "Disable"; |
| 271 | default: |
| 272 | return "Unknown"; |
| 273 | } |
| 274 | } |
| 275 | |
Dominik Laskowski | 03cfce8 | 2022-11-02 12:13:29 -0400 | [diff] [blame] | 276 | } // namespace V2_1 |
| 277 | } // namespace hardware::graphics::composer |
Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 278 | } // namespace android |