blob: 568d75892210786f6790e4e18d8275cb6a28cc4a [file] [log] [blame]
Peiyong Line9d809e2020-04-14 13:10:48 -07001/*
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 Navarefc2a4a72024-11-12 23:59:21 +000020#include <android/hardware/graphics/composer/2.1/types.h>
Peiyong Line9d809e2020-04-14 13:10:48 -070021#include <android/hardware/graphics/composer/2.4/IComposer.h>
22#include <android/hardware/graphics/composer/2.4/IComposerClient.h>
Manasi Navarefc2a4a72024-11-12 23:59:21 +000023#include <android/hardware/graphics/composer/2.4/types.h>
Peiyong Line9d809e2020-04-14 13:10:48 -070024
Huihong Luo791bef92023-09-19 21:18:45 -070025#include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h>
Marc Kassisbdf7e4b2022-11-04 17:26:48 +010026#include <aidl/android/hardware/graphics/common/Hdr.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050027#include <aidl/android/hardware/graphics/composer3/Composition.h>
Leon Scroggins III5967aec2021-12-29 11:14:22 -050028#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
ramindani0cd1d8d2023-06-13 13:43:23 -070029#include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h>
Manasi Navarefc2a4a72024-11-12 23:59:21 +000030#include <aidl/android/hardware/graphics/composer3/IComposerClient.h>
ramindania04b8a52023-08-07 18:49:47 -070031#include <aidl/android/hardware/graphics/composer3/VrrConfig.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050032
Manasi Navarefc2a4a72024-11-12 23:59:21 +000033#include <ftl/enum.h>
34
Peiyong Line9d809e2020-04-14 13:10:48 -070035#define ERROR_HAS_CHANGES 5
36
37namespace android {
38namespace hardware::graphics::composer::hal {
39
40namespace types = android::hardware::graphics::common;
41namespace V2_1 = android::hardware::graphics::composer::V2_1;
42namespace V2_2 = android::hardware::graphics::composer::V2_2;
43namespace V2_3 = android::hardware::graphics::composer::V2_3;
44namespace V2_4 = android::hardware::graphics::composer::V2_4;
ramindani0cd1d8d2023-06-13 13:43:23 -070045namespace V3_0 = ::aidl::android::hardware::graphics::composer3;
Peiyong Line9d809e2020-04-14 13:10:48 -070046
47using types::V1_0::ColorTransform;
48using types::V1_0::Transform;
49using types::V1_1::RenderIntent;
50using types::V1_2::ColorMode;
51using types::V1_2::Dataspace;
Peiyong Line9d809e2020-04-14 13:10:48 -070052using types::V1_2::PixelFormat;
53
Peiyong Line9d809e2020-04-14 13:10:48 -070054using V2_4::IComposer;
55using V2_4::IComposerCallback;
56using V2_4::IComposerClient;
57using V2_4::VsyncPeriodChangeTimeline;
58using V2_4::VsyncPeriodNanos;
59
60using Attribute = IComposerClient::Attribute;
61using BlendMode = IComposerClient::BlendMode;
Peiyong Line9d809e2020-04-14 13:10:48 -070062using Connection = IComposerCallback::Connection;
63using ContentType = IComposerClient::ContentType;
64using Capability = IComposer::Capability;
Peiyong Lindfc3f7c2020-05-07 20:15:50 -070065using ClientTargetProperty = IComposerClient::ClientTargetProperty;
Huihong Luo791bef92023-09-19 21:18:45 -070066using DisplayHotplugEvent = aidl::android::hardware::graphics::common::DisplayHotplugEvent;
Peiyong Line9d809e2020-04-14 13:10:48 -070067using DisplayRequest = IComposerClient::DisplayRequest;
68using DisplayType = IComposerClient::DisplayType;
69using HWConfigId = V2_1::Config;
70using HWDisplayId = V2_1::Display;
71using HWError = V2_1::Error;
72using HWLayerId = V2_1::Layer;
73using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
74using LayerRequest = IComposerClient::LayerRequest;
75using PerFrameMetadata = IComposerClient::PerFrameMetadata;
76using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
77using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
78using PowerMode = IComposerClient::PowerMode;
79using Vsync = IComposerClient::Vsync;
80using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
Marc Kassisbdf7e4b2022-11-04 17:26:48 +010081using Hdr = aidl::android::hardware::graphics::common::Hdr;
ramindani0cd1d8d2023-06-13 13:43:23 -070082using DisplayConfiguration = V3_0::DisplayConfiguration;
ramindania04b8a52023-08-07 18:49:47 -070083using VrrConfig = V3_0::VrrConfig;
Peiyong Line9d809e2020-04-14 13:10:48 -070084
Manasi Navarefc2a4a72024-11-12 23:59:21 +000085enum 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 Line9d809e2020-04-14 13:10:48 -0700101} // namespace hardware::graphics::composer::hal
102
103inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
104 return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
105}
106
107inline 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 III2e1aa182021-12-01 17:33:12 -0500126inline std::string to_string(
127 aidl::android::hardware::graphics::composer3::Composition composition) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700128 switch (composition) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500129 case aidl::android::hardware::graphics::composer3::Composition::INVALID:
Peiyong Line9d809e2020-04-14 13:10:48 -0700130 return "Invalid";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500131 case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
Peiyong Line9d809e2020-04-14 13:10:48 -0700132 return "Client";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500133 case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
Peiyong Line9d809e2020-04-14 13:10:48 -0700134 return "Device";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500135 case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700136 return "SolidColor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500137 case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700138 return "Cursor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500139 case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
Peiyong Line9d809e2020-04-14 13:10:48 -0700140 return "Sideband";
Leon Scroggins III09c25412021-12-02 14:49:56 -0500141 case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION:
142 return "DisplayDecoration";
ramindanic1945cb2023-02-03 13:28:15 -0800143 case aidl::android::hardware::graphics::composer3::Composition::REFRESH_RATE_INDICATOR:
144 return "RefreshRateIndicator";
Peiyong Line9d809e2020-04-14 13:10:48 -0700145 default:
146 return "Unknown";
147 }
148}
149
Leon Scroggins III515f0382021-12-29 11:17:04 -0500150inline 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 IIIe7c51c62022-02-01 15:53:54 -0500168 case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER:
169 return "DisplayIdleTimer";
Leon Scroggins III515f0382021-12-29 11:17:04 -0500170 default:
171 return "Unknown";
172 }
173}
174
ramindania04b8a52023-08-07 18:49:47 -0700175inline 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) {
ramindanicbd7a6d2023-12-19 16:00:30 -0800192 out << "headsUpNs=" << vrrConfig->notifyExpectedPresentConfig->headsUpNs
193 << ", timeoutNs=" << vrrConfig->notifyExpectedPresentConfig->timeoutNs;
ramindania04b8a52023-08-07 18:49:47 -0700194 }
195 out << "}}";
196 return out.str();
197 }
198 return "N/A";
199}
200
Peiyong Line9d809e2020-04-14 13:10:48 -0700201inline 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
232inline std::string to_string(hardware::graphics::composer::hal::Error error) {
Manasi Navarefc2a4a72024-11-12 23:59:21 +0000233 // 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 Line9d809e2020-04-14 13:10:48 -0700238}
239
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700240// For utils::Dumper ADL.
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400241namespace hardware::graphics::composer {
242namespace V2_2 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700243
Peiyong Line9d809e2020-04-14 13:10:48 -0700244inline 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 Line9d809e2020-04-14 13:10:48 -0700248 case hardware::graphics::composer::hal::PowerMode::DOZE:
249 return "Doze";
250 case hardware::graphics::composer::hal::PowerMode::ON:
251 return "On";
Peiyong Lin65248e02020-04-18 21:15:07 -0700252 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
253 return "DozeSuspend";
254 case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
255 return "OnSuspend";
Peiyong Line9d809e2020-04-14 13:10:48 -0700256 default:
257 return "Unknown";
258 }
259}
260
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400261} // namespace V2_2
262
263namespace V2_1 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700264
Ady Abraham4f960d12021-10-13 16:59:49 -0700265inline 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 Laskowski03cfce82022-11-02 12:13:29 -0400276} // namespace V2_1
277} // namespace hardware::graphics::composer
Peiyong Line9d809e2020-04-14 13:10:48 -0700278} // namespace android