blob: e3d962237bec49d69052dc00b1d6b38326d927ab [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>
20#include <android/hardware/graphics/composer/2.4/IComposer.h>
21#include <android/hardware/graphics/composer/2.4/IComposerClient.h>
22
Huihong Luo791bef92023-09-19 21:18:45 -070023#include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h>
Marc Kassisbdf7e4b2022-11-04 17:26:48 +010024#include <aidl/android/hardware/graphics/common/Hdr.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050025#include <aidl/android/hardware/graphics/composer3/Composition.h>
Leon Scroggins III5967aec2021-12-29 11:14:22 -050026#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
ramindani0cd1d8d2023-06-13 13:43:23 -070027#include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h>
ramindania04b8a52023-08-07 18:49:47 -070028#include <aidl/android/hardware/graphics/composer3/VrrConfig.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050029
Peiyong Line9d809e2020-04-14 13:10:48 -070030#define ERROR_HAS_CHANGES 5
31
32namespace android {
33namespace hardware::graphics::composer::hal {
34
35namespace types = android::hardware::graphics::common;
36namespace V2_1 = android::hardware::graphics::composer::V2_1;
37namespace V2_2 = android::hardware::graphics::composer::V2_2;
38namespace V2_3 = android::hardware::graphics::composer::V2_3;
39namespace V2_4 = android::hardware::graphics::composer::V2_4;
ramindani0cd1d8d2023-06-13 13:43:23 -070040namespace V3_0 = ::aidl::android::hardware::graphics::composer3;
Peiyong Line9d809e2020-04-14 13:10:48 -070041
42using types::V1_0::ColorTransform;
43using types::V1_0::Transform;
44using types::V1_1::RenderIntent;
45using types::V1_2::ColorMode;
46using types::V1_2::Dataspace;
Peiyong Line9d809e2020-04-14 13:10:48 -070047using types::V1_2::PixelFormat;
48
49using V2_1::Error;
50using V2_4::IComposer;
51using V2_4::IComposerCallback;
52using V2_4::IComposerClient;
53using V2_4::VsyncPeriodChangeTimeline;
54using V2_4::VsyncPeriodNanos;
55
56using Attribute = IComposerClient::Attribute;
57using BlendMode = IComposerClient::BlendMode;
Peiyong Line9d809e2020-04-14 13:10:48 -070058using Connection = IComposerCallback::Connection;
59using ContentType = IComposerClient::ContentType;
60using Capability = IComposer::Capability;
Peiyong Lindfc3f7c2020-05-07 20:15:50 -070061using ClientTargetProperty = IComposerClient::ClientTargetProperty;
Huihong Luo791bef92023-09-19 21:18:45 -070062using DisplayHotplugEvent = aidl::android::hardware::graphics::common::DisplayHotplugEvent;
Peiyong Line9d809e2020-04-14 13:10:48 -070063using DisplayRequest = IComposerClient::DisplayRequest;
64using DisplayType = IComposerClient::DisplayType;
65using HWConfigId = V2_1::Config;
66using HWDisplayId = V2_1::Display;
67using HWError = V2_1::Error;
68using HWLayerId = V2_1::Layer;
69using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
70using LayerRequest = IComposerClient::LayerRequest;
71using PerFrameMetadata = IComposerClient::PerFrameMetadata;
72using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
73using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
74using PowerMode = IComposerClient::PowerMode;
75using Vsync = IComposerClient::Vsync;
76using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
Marc Kassisbdf7e4b2022-11-04 17:26:48 +010077using Hdr = aidl::android::hardware::graphics::common::Hdr;
ramindani0cd1d8d2023-06-13 13:43:23 -070078using DisplayConfiguration = V3_0::DisplayConfiguration;
ramindania04b8a52023-08-07 18:49:47 -070079using VrrConfig = V3_0::VrrConfig;
Peiyong Line9d809e2020-04-14 13:10:48 -070080
81} // namespace hardware::graphics::composer::hal
82
83inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
84 return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
85}
86
87inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) {
88 switch (attribute) {
89 case hardware::graphics::composer::hal::Attribute::INVALID:
90 return "Invalid";
91 case hardware::graphics::composer::hal::Attribute::WIDTH:
92 return "Width";
93 case hardware::graphics::composer::hal::Attribute::HEIGHT:
94 return "Height";
95 case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD:
96 return "VsyncPeriod";
97 case hardware::graphics::composer::hal::Attribute::DPI_X:
98 return "DpiX";
99 case hardware::graphics::composer::hal::Attribute::DPI_Y:
100 return "DpiY";
101 default:
102 return "Unknown";
103 }
104}
105
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500106inline std::string to_string(
107 aidl::android::hardware::graphics::composer3::Composition composition) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700108 switch (composition) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500109 case aidl::android::hardware::graphics::composer3::Composition::INVALID:
Peiyong Line9d809e2020-04-14 13:10:48 -0700110 return "Invalid";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500111 case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
Peiyong Line9d809e2020-04-14 13:10:48 -0700112 return "Client";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500113 case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
Peiyong Line9d809e2020-04-14 13:10:48 -0700114 return "Device";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500115 case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700116 return "SolidColor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500117 case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700118 return "Cursor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500119 case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
Peiyong Line9d809e2020-04-14 13:10:48 -0700120 return "Sideband";
Leon Scroggins III09c25412021-12-02 14:49:56 -0500121 case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION:
122 return "DisplayDecoration";
ramindanic1945cb2023-02-03 13:28:15 -0800123 case aidl::android::hardware::graphics::composer3::Composition::REFRESH_RATE_INDICATOR:
124 return "RefreshRateIndicator";
Peiyong Line9d809e2020-04-14 13:10:48 -0700125 default:
126 return "Unknown";
127 }
128}
129
Leon Scroggins III515f0382021-12-29 11:17:04 -0500130inline std::string to_string(
131 aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability) {
132 switch (displayCapability) {
133 case aidl::android::hardware::graphics::composer3::DisplayCapability::INVALID:
134 return "Invalid";
135 case aidl::android::hardware::graphics::composer3::DisplayCapability::
136 SKIP_CLIENT_COLOR_TRANSFORM:
137 return "SkipColorTransform";
138 case aidl::android::hardware::graphics::composer3::DisplayCapability::DOZE:
139 return "Doze";
140 case aidl::android::hardware::graphics::composer3::DisplayCapability::BRIGHTNESS:
141 return "Brightness";
142 case aidl::android::hardware::graphics::composer3::DisplayCapability::PROTECTED_CONTENTS:
143 return "ProtectedContents";
144 case aidl::android::hardware::graphics::composer3::DisplayCapability::AUTO_LOW_LATENCY_MODE:
145 return "AutoLowLatencyMode";
146 case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND:
147 return "Suspend";
Leon Scroggins IIIe7c51c62022-02-01 15:53:54 -0500148 case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER:
149 return "DisplayIdleTimer";
Leon Scroggins III515f0382021-12-29 11:17:04 -0500150 default:
151 return "Unknown";
152 }
153}
154
ramindania04b8a52023-08-07 18:49:47 -0700155inline std::string to_string(
156 const std::optional<aidl::android::hardware::graphics::composer3::VrrConfig>& vrrConfig) {
157 if (vrrConfig) {
158 std::ostringstream out;
159 out << "{minFrameIntervalNs=" << vrrConfig->minFrameIntervalNs << ", ";
160 out << "frameIntervalPowerHints={";
161 if (vrrConfig->frameIntervalPowerHints) {
162 const auto& powerHint = *vrrConfig->frameIntervalPowerHints;
163 for (size_t i = 0; i < powerHint.size(); i++) {
164 if (i > 0) out << ", ";
165 out << "[frameIntervalNs=" << powerHint[i]->frameIntervalNs
166 << ", averageRefreshPeriodNs=" << powerHint[i]->averageRefreshPeriodNs << "]";
167 }
168 }
169 out << "}, ";
170 out << "notifyExpectedPresentConfig={";
171 if (vrrConfig->notifyExpectedPresentConfig) {
ramindanicbd7a6d2023-12-19 16:00:30 -0800172 out << "headsUpNs=" << vrrConfig->notifyExpectedPresentConfig->headsUpNs
173 << ", timeoutNs=" << vrrConfig->notifyExpectedPresentConfig->timeoutNs;
ramindania04b8a52023-08-07 18:49:47 -0700174 }
175 out << "}}";
176 return out.str();
177 }
178 return "N/A";
179}
180
Peiyong Line9d809e2020-04-14 13:10:48 -0700181inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
182 // 5 is reserved for historical reason, during validation 5 means has changes.
183 if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
184 return "HasChanges";
185 }
186 switch (error) {
187 case hardware::graphics::composer::hal::V2_4::Error::NONE:
188 return "None";
189 case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
190 return "BadConfig";
191 case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
192 return "BadDisplay";
193 case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
194 return "BadLayer";
195 case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
196 return "BadParameter";
197 case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
198 return "NoResources";
199 case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
200 return "NotValidated";
201 case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
202 return "Unsupported";
203 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
204 return "SeamlessNotAllowed";
205 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
206 return "SeamlessNotPossible";
207 default:
208 return "Unknown";
209 }
210}
211
212inline std::string to_string(hardware::graphics::composer::hal::Error error) {
213 return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
214}
215
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700216// For utils::Dumper ADL.
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400217namespace hardware::graphics::composer {
218namespace V2_2 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700219
Peiyong Line9d809e2020-04-14 13:10:48 -0700220inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
221 switch (mode) {
222 case hardware::graphics::composer::hal::PowerMode::OFF:
223 return "Off";
Peiyong Line9d809e2020-04-14 13:10:48 -0700224 case hardware::graphics::composer::hal::PowerMode::DOZE:
225 return "Doze";
226 case hardware::graphics::composer::hal::PowerMode::ON:
227 return "On";
Peiyong Lin65248e02020-04-18 21:15:07 -0700228 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
229 return "DozeSuspend";
230 case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
231 return "OnSuspend";
Peiyong Line9d809e2020-04-14 13:10:48 -0700232 default:
233 return "Unknown";
234 }
235}
236
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400237} // namespace V2_2
238
239namespace V2_1 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700240
Ady Abraham4f960d12021-10-13 16:59:49 -0700241inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) {
242 switch (vsync) {
243 case hardware::graphics::composer::hal::Vsync::ENABLE:
244 return "Enable";
245 case hardware::graphics::composer::hal::Vsync::DISABLE:
246 return "Disable";
247 default:
248 return "Unknown";
249 }
250}
251
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400252} // namespace V2_1
253} // namespace hardware::graphics::composer
Peiyong Line9d809e2020-04-14 13:10:48 -0700254} // namespace android