blob: e95ae8934da06f2de0e89104a23b0213a813b5c8 [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>
ramindani0cd1d8d2023-06-13 13:43:23 -070026#include <aidl/android/hardware/graphics/composer3/DisplayConfiguration.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050027
Peiyong Line9d809e2020-04-14 13:10:48 -070028#define ERROR_HAS_CHANGES 5
29
30namespace android {
31namespace hardware::graphics::composer::hal {
32
33namespace types = android::hardware::graphics::common;
34namespace V2_1 = android::hardware::graphics::composer::V2_1;
35namespace V2_2 = android::hardware::graphics::composer::V2_2;
36namespace V2_3 = android::hardware::graphics::composer::V2_3;
37namespace V2_4 = android::hardware::graphics::composer::V2_4;
ramindani0cd1d8d2023-06-13 13:43:23 -070038namespace V3_0 = ::aidl::android::hardware::graphics::composer3;
Peiyong Line9d809e2020-04-14 13:10:48 -070039
40using types::V1_0::ColorTransform;
41using types::V1_0::Transform;
42using types::V1_1::RenderIntent;
43using types::V1_2::ColorMode;
44using types::V1_2::Dataspace;
Peiyong Line9d809e2020-04-14 13:10:48 -070045using types::V1_2::PixelFormat;
46
47using V2_1::Error;
48using V2_4::IComposer;
49using V2_4::IComposerCallback;
50using V2_4::IComposerClient;
51using V2_4::VsyncPeriodChangeTimeline;
52using V2_4::VsyncPeriodNanos;
53
54using Attribute = IComposerClient::Attribute;
55using BlendMode = IComposerClient::BlendMode;
Peiyong Line9d809e2020-04-14 13:10:48 -070056using Connection = IComposerCallback::Connection;
57using ContentType = IComposerClient::ContentType;
58using Capability = IComposer::Capability;
Peiyong Lindfc3f7c2020-05-07 20:15:50 -070059using ClientTargetProperty = IComposerClient::ClientTargetProperty;
Peiyong Line9d809e2020-04-14 13:10:48 -070060using DisplayRequest = IComposerClient::DisplayRequest;
61using DisplayType = IComposerClient::DisplayType;
62using HWConfigId = V2_1::Config;
63using HWDisplayId = V2_1::Display;
64using HWError = V2_1::Error;
65using HWLayerId = V2_1::Layer;
66using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
67using LayerRequest = IComposerClient::LayerRequest;
68using PerFrameMetadata = IComposerClient::PerFrameMetadata;
69using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
70using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
71using PowerMode = IComposerClient::PowerMode;
72using Vsync = IComposerClient::Vsync;
73using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
Marc Kassisbdf7e4b2022-11-04 17:26:48 +010074using Hdr = aidl::android::hardware::graphics::common::Hdr;
ramindani0cd1d8d2023-06-13 13:43:23 -070075using DisplayConfiguration = V3_0::DisplayConfiguration;
Peiyong Line9d809e2020-04-14 13:10:48 -070076
77} // namespace hardware::graphics::composer::hal
78
79inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
80 return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
81}
82
83inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) {
84 switch (attribute) {
85 case hardware::graphics::composer::hal::Attribute::INVALID:
86 return "Invalid";
87 case hardware::graphics::composer::hal::Attribute::WIDTH:
88 return "Width";
89 case hardware::graphics::composer::hal::Attribute::HEIGHT:
90 return "Height";
91 case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD:
92 return "VsyncPeriod";
93 case hardware::graphics::composer::hal::Attribute::DPI_X:
94 return "DpiX";
95 case hardware::graphics::composer::hal::Attribute::DPI_Y:
96 return "DpiY";
97 default:
98 return "Unknown";
99 }
100}
101
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500102inline std::string to_string(
103 aidl::android::hardware::graphics::composer3::Composition composition) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700104 switch (composition) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500105 case aidl::android::hardware::graphics::composer3::Composition::INVALID:
Peiyong Line9d809e2020-04-14 13:10:48 -0700106 return "Invalid";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500107 case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
Peiyong Line9d809e2020-04-14 13:10:48 -0700108 return "Client";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500109 case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
Peiyong Line9d809e2020-04-14 13:10:48 -0700110 return "Device";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500111 case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700112 return "SolidColor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500113 case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700114 return "Cursor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500115 case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
Peiyong Line9d809e2020-04-14 13:10:48 -0700116 return "Sideband";
Leon Scroggins III09c25412021-12-02 14:49:56 -0500117 case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION:
118 return "DisplayDecoration";
ramindanic1945cb2023-02-03 13:28:15 -0800119 case aidl::android::hardware::graphics::composer3::Composition::REFRESH_RATE_INDICATOR:
120 return "RefreshRateIndicator";
Peiyong Line9d809e2020-04-14 13:10:48 -0700121 default:
122 return "Unknown";
123 }
124}
125
Leon Scroggins III515f0382021-12-29 11:17:04 -0500126inline std::string to_string(
127 aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability) {
128 switch (displayCapability) {
129 case aidl::android::hardware::graphics::composer3::DisplayCapability::INVALID:
130 return "Invalid";
131 case aidl::android::hardware::graphics::composer3::DisplayCapability::
132 SKIP_CLIENT_COLOR_TRANSFORM:
133 return "SkipColorTransform";
134 case aidl::android::hardware::graphics::composer3::DisplayCapability::DOZE:
135 return "Doze";
136 case aidl::android::hardware::graphics::composer3::DisplayCapability::BRIGHTNESS:
137 return "Brightness";
138 case aidl::android::hardware::graphics::composer3::DisplayCapability::PROTECTED_CONTENTS:
139 return "ProtectedContents";
140 case aidl::android::hardware::graphics::composer3::DisplayCapability::AUTO_LOW_LATENCY_MODE:
141 return "AutoLowLatencyMode";
142 case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND:
143 return "Suspend";
Leon Scroggins IIIe7c51c62022-02-01 15:53:54 -0500144 case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER:
145 return "DisplayIdleTimer";
Leon Scroggins III515f0382021-12-29 11:17:04 -0500146 default:
147 return "Unknown";
148 }
149}
150
Peiyong Line9d809e2020-04-14 13:10:48 -0700151inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
152 // 5 is reserved for historical reason, during validation 5 means has changes.
153 if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
154 return "HasChanges";
155 }
156 switch (error) {
157 case hardware::graphics::composer::hal::V2_4::Error::NONE:
158 return "None";
159 case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
160 return "BadConfig";
161 case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
162 return "BadDisplay";
163 case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
164 return "BadLayer";
165 case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
166 return "BadParameter";
167 case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
168 return "NoResources";
169 case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
170 return "NotValidated";
171 case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
172 return "Unsupported";
173 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
174 return "SeamlessNotAllowed";
175 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
176 return "SeamlessNotPossible";
177 default:
178 return "Unknown";
179 }
180}
181
182inline std::string to_string(hardware::graphics::composer::hal::Error error) {
183 return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
184}
185
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700186// For utils::Dumper ADL.
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400187namespace hardware::graphics::composer {
188namespace V2_2 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700189
Peiyong Line9d809e2020-04-14 13:10:48 -0700190inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
191 switch (mode) {
192 case hardware::graphics::composer::hal::PowerMode::OFF:
193 return "Off";
Peiyong Line9d809e2020-04-14 13:10:48 -0700194 case hardware::graphics::composer::hal::PowerMode::DOZE:
195 return "Doze";
196 case hardware::graphics::composer::hal::PowerMode::ON:
197 return "On";
Peiyong Lin65248e02020-04-18 21:15:07 -0700198 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
199 return "DozeSuspend";
200 case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
201 return "OnSuspend";
Peiyong Line9d809e2020-04-14 13:10:48 -0700202 default:
203 return "Unknown";
204 }
205}
206
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400207} // namespace V2_2
208
209namespace V2_1 {
Dominik Laskowskie70461a2022-08-30 14:42:01 -0700210
Ady Abraham4f960d12021-10-13 16:59:49 -0700211inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) {
212 switch (vsync) {
213 case hardware::graphics::composer::hal::Vsync::ENABLE:
214 return "Enable";
215 case hardware::graphics::composer::hal::Vsync::DISABLE:
216 return "Disable";
217 default:
218 return "Unknown";
219 }
220}
221
Dominik Laskowski03cfce82022-11-02 12:13:29 -0400222} // namespace V2_1
223} // namespace hardware::graphics::composer
Peiyong Line9d809e2020-04-14 13:10:48 -0700224} // namespace android