blob: 473703423ebfd61ac5e7ea5e41703e33e87acc2a [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
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050023#include <aidl/android/hardware/graphics/composer3/Composition.h>
Leon Scroggins III5967aec2021-12-29 11:14:22 -050024#include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050025
Peiyong Line9d809e2020-04-14 13:10:48 -070026#define ERROR_HAS_CHANGES 5
27
28namespace android {
29namespace hardware::graphics::composer::hal {
30
31namespace types = android::hardware::graphics::common;
32namespace V2_1 = android::hardware::graphics::composer::V2_1;
33namespace V2_2 = android::hardware::graphics::composer::V2_2;
34namespace V2_3 = android::hardware::graphics::composer::V2_3;
35namespace V2_4 = android::hardware::graphics::composer::V2_4;
36
37using types::V1_0::ColorTransform;
38using types::V1_0::Transform;
39using types::V1_1::RenderIntent;
40using types::V1_2::ColorMode;
41using types::V1_2::Dataspace;
42using types::V1_2::Hdr;
43using 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;
72
73} // namespace hardware::graphics::composer::hal
74
75inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
76 return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
77}
78
79inline std::string to_string(hardware::graphics::composer::hal::Attribute attribute) {
80 switch (attribute) {
81 case hardware::graphics::composer::hal::Attribute::INVALID:
82 return "Invalid";
83 case hardware::graphics::composer::hal::Attribute::WIDTH:
84 return "Width";
85 case hardware::graphics::composer::hal::Attribute::HEIGHT:
86 return "Height";
87 case hardware::graphics::composer::hal::Attribute::VSYNC_PERIOD:
88 return "VsyncPeriod";
89 case hardware::graphics::composer::hal::Attribute::DPI_X:
90 return "DpiX";
91 case hardware::graphics::composer::hal::Attribute::DPI_Y:
92 return "DpiY";
93 default:
94 return "Unknown";
95 }
96}
97
Leon Scroggins III2e1aa182021-12-01 17:33:12 -050098inline std::string to_string(
99 aidl::android::hardware::graphics::composer3::Composition composition) {
Peiyong Line9d809e2020-04-14 13:10:48 -0700100 switch (composition) {
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500101 case aidl::android::hardware::graphics::composer3::Composition::INVALID:
Peiyong Line9d809e2020-04-14 13:10:48 -0700102 return "Invalid";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500103 case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
Peiyong Line9d809e2020-04-14 13:10:48 -0700104 return "Client";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500105 case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
Peiyong Line9d809e2020-04-14 13:10:48 -0700106 return "Device";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500107 case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700108 return "SolidColor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500109 case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
Peiyong Line9d809e2020-04-14 13:10:48 -0700110 return "Cursor";
Leon Scroggins III2e1aa182021-12-01 17:33:12 -0500111 case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
Peiyong Line9d809e2020-04-14 13:10:48 -0700112 return "Sideband";
Leon Scroggins III09c25412021-12-02 14:49:56 -0500113 case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION:
114 return "DisplayDecoration";
Peiyong Line9d809e2020-04-14 13:10:48 -0700115 default:
116 return "Unknown";
117 }
118}
119
Leon Scroggins III515f0382021-12-29 11:17:04 -0500120inline std::string to_string(
121 aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability) {
122 switch (displayCapability) {
123 case aidl::android::hardware::graphics::composer3::DisplayCapability::INVALID:
124 return "Invalid";
125 case aidl::android::hardware::graphics::composer3::DisplayCapability::
126 SKIP_CLIENT_COLOR_TRANSFORM:
127 return "SkipColorTransform";
128 case aidl::android::hardware::graphics::composer3::DisplayCapability::DOZE:
129 return "Doze";
130 case aidl::android::hardware::graphics::composer3::DisplayCapability::BRIGHTNESS:
131 return "Brightness";
132 case aidl::android::hardware::graphics::composer3::DisplayCapability::PROTECTED_CONTENTS:
133 return "ProtectedContents";
134 case aidl::android::hardware::graphics::composer3::DisplayCapability::AUTO_LOW_LATENCY_MODE:
135 return "AutoLowLatencyMode";
136 case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND:
137 return "Suspend";
Leon Scroggins IIIe7c51c62022-02-01 15:53:54 -0500138 case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER:
139 return "DisplayIdleTimer";
Leon Scroggins III515f0382021-12-29 11:17:04 -0500140 default:
141 return "Unknown";
142 }
143}
144
Peiyong Line9d809e2020-04-14 13:10:48 -0700145inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
146 // 5 is reserved for historical reason, during validation 5 means has changes.
147 if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
148 return "HasChanges";
149 }
150 switch (error) {
151 case hardware::graphics::composer::hal::V2_4::Error::NONE:
152 return "None";
153 case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
154 return "BadConfig";
155 case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
156 return "BadDisplay";
157 case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
158 return "BadLayer";
159 case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
160 return "BadParameter";
161 case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
162 return "NoResources";
163 case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
164 return "NotValidated";
165 case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
166 return "Unsupported";
167 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
168 return "SeamlessNotAllowed";
169 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
170 return "SeamlessNotPossible";
171 default:
172 return "Unknown";
173 }
174}
175
176inline std::string to_string(hardware::graphics::composer::hal::Error error) {
177 return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
178}
179
180inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
181 switch (mode) {
182 case hardware::graphics::composer::hal::PowerMode::OFF:
183 return "Off";
Peiyong Line9d809e2020-04-14 13:10:48 -0700184 case hardware::graphics::composer::hal::PowerMode::DOZE:
185 return "Doze";
186 case hardware::graphics::composer::hal::PowerMode::ON:
187 return "On";
Peiyong Lin65248e02020-04-18 21:15:07 -0700188 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
189 return "DozeSuspend";
190 case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
191 return "OnSuspend";
Peiyong Line9d809e2020-04-14 13:10:48 -0700192 default:
193 return "Unknown";
194 }
195}
196
Ady Abraham4f960d12021-10-13 16:59:49 -0700197inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) {
198 switch (vsync) {
199 case hardware::graphics::composer::hal::Vsync::ENABLE:
200 return "Enable";
201 case hardware::graphics::composer::hal::Vsync::DISABLE:
202 return "Disable";
203 default:
204 return "Unknown";
205 }
206}
207
Peiyong Line9d809e2020-04-14 13:10:48 -0700208} // namespace android