blob: e33dc0f9a84451352c8c48b968a1a2ee2253f9bf [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;
54using Color = IComposerClient::Color;
Peiyong Line9d809e2020-04-14 13:10:48 -070055using Connection = IComposerCallback::Connection;
56using ContentType = IComposerClient::ContentType;
57using Capability = IComposer::Capability;
Peiyong Lindfc3f7c2020-05-07 20:15:50 -070058using ClientTargetProperty = IComposerClient::ClientTargetProperty;
Peiyong Line9d809e2020-04-14 13:10:48 -070059using DisplayRequest = IComposerClient::DisplayRequest;
60using DisplayType = IComposerClient::DisplayType;
61using HWConfigId = V2_1::Config;
62using HWDisplayId = V2_1::Display;
63using HWError = V2_1::Error;
64using HWLayerId = V2_1::Layer;
65using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
66using LayerRequest = IComposerClient::LayerRequest;
67using PerFrameMetadata = IComposerClient::PerFrameMetadata;
68using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
69using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
70using PowerMode = IComposerClient::PowerMode;
71using Vsync = IComposerClient::Vsync;
72using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
73
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";
Peiyong Line9d809e2020-04-14 13:10:48 -0700116 default:
117 return "Unknown";
118 }
119}
120
Leon Scroggins III515f0382021-12-29 11:17:04 -0500121inline std::string to_string(
122 aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability) {
123 switch (displayCapability) {
124 case aidl::android::hardware::graphics::composer3::DisplayCapability::INVALID:
125 return "Invalid";
126 case aidl::android::hardware::graphics::composer3::DisplayCapability::
127 SKIP_CLIENT_COLOR_TRANSFORM:
128 return "SkipColorTransform";
129 case aidl::android::hardware::graphics::composer3::DisplayCapability::DOZE:
130 return "Doze";
131 case aidl::android::hardware::graphics::composer3::DisplayCapability::BRIGHTNESS:
132 return "Brightness";
133 case aidl::android::hardware::graphics::composer3::DisplayCapability::PROTECTED_CONTENTS:
134 return "ProtectedContents";
135 case aidl::android::hardware::graphics::composer3::DisplayCapability::AUTO_LOW_LATENCY_MODE:
136 return "AutoLowLatencyMode";
137 case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND:
138 return "Suspend";
139 default:
140 return "Unknown";
141 }
142}
143
Peiyong Line9d809e2020-04-14 13:10:48 -0700144inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
145 // 5 is reserved for historical reason, during validation 5 means has changes.
146 if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
147 return "HasChanges";
148 }
149 switch (error) {
150 case hardware::graphics::composer::hal::V2_4::Error::NONE:
151 return "None";
152 case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
153 return "BadConfig";
154 case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
155 return "BadDisplay";
156 case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
157 return "BadLayer";
158 case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
159 return "BadParameter";
160 case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
161 return "NoResources";
162 case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
163 return "NotValidated";
164 case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
165 return "Unsupported";
166 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
167 return "SeamlessNotAllowed";
168 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
169 return "SeamlessNotPossible";
170 default:
171 return "Unknown";
172 }
173}
174
175inline std::string to_string(hardware::graphics::composer::hal::Error error) {
176 return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
177}
178
179inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
180 switch (mode) {
181 case hardware::graphics::composer::hal::PowerMode::OFF:
182 return "Off";
Peiyong Line9d809e2020-04-14 13:10:48 -0700183 case hardware::graphics::composer::hal::PowerMode::DOZE:
184 return "Doze";
185 case hardware::graphics::composer::hal::PowerMode::ON:
186 return "On";
Peiyong Lin65248e02020-04-18 21:15:07 -0700187 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
188 return "DozeSuspend";
189 case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
190 return "OnSuspend";
Peiyong Line9d809e2020-04-14 13:10:48 -0700191 default:
192 return "Unknown";
193 }
194}
195
Ady Abraham4f960d12021-10-13 16:59:49 -0700196inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) {
197 switch (vsync) {
198 case hardware::graphics::composer::hal::Vsync::ENABLE:
199 return "Enable";
200 case hardware::graphics::composer::hal::Vsync::DISABLE:
201 return "Disable";
202 default:
203 return "Unknown";
204 }
205}
206
Peiyong Line9d809e2020-04-14 13:10:48 -0700207} // namespace android