blob: bf3089f04060ec84879417df38ba4f29dc919bfc [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
Marc Kassisbdf7e4b2022-11-04 17:26:48 +010023#include <aidl/android/hardware/graphics/common/Hdr.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050024#include <aidl/android/hardware/graphics/composer3/Composition.h>
Leon Scroggins III5967aec2021-12-29 11:14:22 -050025#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050026
Peiyong Line9d809e2020-04-14 13:10:48 -070027#define ERROR_HAS_CHANGES 5
28
29namespace android {
30namespace hardware::graphics::composer::hal {
31
32namespace types = android::hardware::graphics::common;
33namespace V2_1 = android::hardware::graphics::composer::V2_1;
34namespace V2_2 = android::hardware::graphics::composer::V2_2;
35namespace V2_3 = android::hardware::graphics::composer::V2_3;
36namespace V2_4 = android::hardware::graphics::composer::V2_4;
37
38using types::V1_0::ColorTransform;
39using types::V1_0::Transform;
40using types::V1_1::RenderIntent;
41using types::V1_2::ColorMode;
42using types::V1_2::Dataspace;
Peiyong Line9d809e2020-04-14 13:10:48 -070043using types::V1_2::PixelFormat;
44
45using V2_1::Error;
46using V2_4::IComposer;
47using V2_4::IComposerCallback;
48using V2_4::IComposerClient;
49using V2_4::VsyncPeriodChangeTimeline;
50using V2_4::VsyncPeriodNanos;
51
52using Attribute = IComposerClient::Attribute;
53using BlendMode = IComposerClient::BlendMode;
Peiyong Line9d809e2020-04-14 13:10:48 -070054using Connection = IComposerCallback::Connection;
55using ContentType = IComposerClient::ContentType;
56using Capability = IComposer::Capability;
Peiyong Lindfc3f7c2020-05-07 20:15:50 -070057using ClientTargetProperty = IComposerClient::ClientTargetProperty;
Peiyong Line9d809e2020-04-14 13:10:48 -070058using DisplayRequest = IComposerClient::DisplayRequest;
59using DisplayType = IComposerClient::DisplayType;
60using HWConfigId = V2_1::Config;
61using HWDisplayId = V2_1::Display;
62using HWError = V2_1::Error;
63using HWLayerId = V2_1::Layer;
64using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
65using LayerRequest = IComposerClient::LayerRequest;
66using PerFrameMetadata = IComposerClient::PerFrameMetadata;
67using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
68using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
69using PowerMode = IComposerClient::PowerMode;
70using Vsync = IComposerClient::Vsync;
71using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
Marc Kassisbdf7e4b2022-11-04 17:26:48 +010072using Hdr = aidl::android::hardware::graphics::common::Hdr;
Peiyong Line9d809e2020-04-14 13:10:48 -070073
74} // namespace hardware::graphics::composer::hal
75
76inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
77 return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
78}
79
80inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) {
81 switch (attribute) {
82 case hardware::graphics::composer::hal::Attribute::INVALID:
83 return "Invalid";
84 case hardware::graphics::composer::hal::Attribute::WIDTH:
85 return "Width";
86 case hardware::graphics::composer::hal::Attribute::HEIGHT:
87 return "Height";
88 case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD:
89 return "VsyncPeriod";
90 case hardware::graphics::composer::hal::Attribute::DPI_X:
91 return "DpiX";
92 case hardware::graphics::composer::hal::Attribute::DPI_Y:
93 return "DpiY";
94 default:
95 return "Unknown";
96 }
97}
98
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050099inline std::string to_string(
100 aidl::android::hardware::graphics::composer3::Composition composition) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700101 switch (composition) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500102 case aidl::android::hardware::graphics::composer3::Composition::INVALID:
Peiyong Line9d809e2020-04-14 13:10:48 -0700103 return "Invalid";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500104 case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
Peiyong Line9d809e2020-04-14 13:10:48 -0700105 return "Client";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500106 case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
Peiyong Line9d809e2020-04-14 13:10:48 -0700107 return "Device";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500108 case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700109 return "SolidColor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500110 case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700111 return "Cursor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500112 case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
Peiyong Line9d809e2020-04-14 13:10:48 -0700113 return "Sideband";
Leon Scroggins III09c25412021-12-02 14:49:56 -0500114 case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION:
115 return "DisplayDecoration";
ramindanic1945cb2023-02-03 13:28:15 -0800116 case aidl::android::hardware::graphics::composer3::Composition::REFRESH_RATE_INDICATOR:
117 return "RefreshRateIndicator";
Peiyong Line9d809e2020-04-14 13:10:48 -0700118 default:
119 return "Unknown";
120 }
121}
122
Leon Scroggins III515f0382021-12-29 11:17:04 -0500123inline std::string to_string(
124 aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability) {
125 switch (displayCapability) {
126 case aidl::android::hardware::graphics::composer3::DisplayCapability::INVALID:
127 return "Invalid";
128 case aidl::android::hardware::graphics::composer3::DisplayCapability::
129 SKIP_CLIENT_COLOR_TRANSFORM:
130 return "SkipColorTransform";
131 case aidl::android::hardware::graphics::composer3::DisplayCapability::DOZE:
132 return "Doze";
133 case aidl::android::hardware::graphics::composer3::DisplayCapability::BRIGHTNESS:
134 return "Brightness";
135 case aidl::android::hardware::graphics::composer3::DisplayCapability::PROTECTED_CONTENTS:
136 return "ProtectedContents";
137 case aidl::android::hardware::graphics::composer3::DisplayCapability::AUTO_LOW_LATENCY_MODE:
138 return "AutoLowLatencyMode";
139 case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND:
140 return "Suspend";
Leon Scroggins IIIe7c51c62022-02-01 15:53:54 -0500141 case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER:
142 return "DisplayIdleTimer";
Leon Scroggins III515f0382021-12-29 11:17:04 -0500143 default:
144 return "Unknown";
145 }
146}
147
Peiyong Line9d809e2020-04-14 13:10:48 -0700148inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
149 // 5 is reserved for historical reason, during validation 5 means has changes.
150 if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
151 return "HasChanges";
152 }
153 switch (error) {
154 case hardware::graphics::composer::hal::V2_4::Error::NONE:
155 return "None";
156 case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
157 return "BadConfig";
158 case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
159 return "BadDisplay";
160 case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
161 return "BadLayer";
162 case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
163 return "BadParameter";
164 case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
165 return "NoResources";
166 case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
167 return "NotValidated";
168 case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
169 return "Unsupported";
170 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
171 return "SeamlessNotAllowed";
172 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
173 return "SeamlessNotPossible";
174 default:
175 return "Unknown";
176 }
177}
178
179inline std::string to_string(hardware::graphics::composer::hal::Error error) {
180 return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
181}
182
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700183// For utils::Dumper ADL.
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400184namespace hardware::graphics::composer {
185namespace V2_2 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700186
Peiyong Line9d809e2020-04-14 13:10:48 -0700187inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
188 switch (mode) {
189 case hardware::graphics::composer::hal::PowerMode::OFF:
190 return "Off";
Peiyong Line9d809e2020-04-14 13:10:48 -0700191 case hardware::graphics::composer::hal::PowerMode::DOZE:
192 return "Doze";
193 case hardware::graphics::composer::hal::PowerMode::ON:
194 return "On";
Peiyong Lin65248e02020-04-18 21:15:07 -0700195 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
196 return "DozeSuspend";
197 case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
198 return "OnSuspend";
Peiyong Line9d809e2020-04-14 13:10:48 -0700199 default:
200 return "Unknown";
201 }
202}
203
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400204} // namespace V2_2
205
206namespace V2_1 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700207
Ady Abraham4f960d12021-10-13 16:59:49 -0700208inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) {
209 switch (vsync) {
210 case hardware::graphics::composer::hal::Vsync::ENABLE:
211 return "Enable";
212 case hardware::graphics::composer::hal::Vsync::DISABLE:
213 return "Disable";
214 default:
215 return "Unknown";
216 }
217}
218
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400219} // namespace V2_1
220} // namespace hardware::graphics::composer
Peiyong Line9d809e2020-04-14 13:10:48 -0700221} // namespace android