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