blob: 02d065881b8be4778480ae2a7fbce613ca7b88be [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
23#define ERROR_HAS_CHANGES 5
24
25namespace android {
26namespace hardware::graphics::composer::hal {
27
28namespace types = android::hardware::graphics::common;
29namespace V2_1 = android::hardware::graphics::composer::V2_1;
30namespace V2_2 = android::hardware::graphics::composer::V2_2;
31namespace V2_3 = android::hardware::graphics::composer::V2_3;
32namespace V2_4 = android::hardware::graphics::composer::V2_4;
33
34using types::V1_0::ColorTransform;
35using types::V1_0::Transform;
36using types::V1_1::RenderIntent;
37using types::V1_2::ColorMode;
38using types::V1_2::Dataspace;
39using types::V1_2::Hdr;
40using types::V1_2::PixelFormat;
41
42using V2_1::Error;
43using V2_4::IComposer;
44using V2_4::IComposerCallback;
45using V2_4::IComposerClient;
46using V2_4::VsyncPeriodChangeTimeline;
47using V2_4::VsyncPeriodNanos;
48
49using Attribute = IComposerClient::Attribute;
50using BlendMode = IComposerClient::BlendMode;
51using Color = IComposerClient::Color;
52using Composition = IComposerClient::Composition;
53using Connection = IComposerCallback::Connection;
54using ContentType = IComposerClient::ContentType;
55using Capability = IComposer::Capability;
Peiyong Lindfc3f7c2020-05-07 20:15:50 -070056using ClientTargetProperty = IComposerClient::ClientTargetProperty;
Peiyong Line9d809e2020-04-14 13:10:48 -070057using DisplayCapability = IComposerClient::DisplayCapability;
58using 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
98inline std::string to_string(hardware::graphics::composer::hal::Composition composition) {
99 switch (composition) {
100 case hardware::graphics::composer::hal::Composition::INVALID:
101 return "Invalid";
102 case hardware::graphics::composer::hal::Composition::CLIENT:
103 return "Client";
104 case hardware::graphics::composer::hal::Composition::DEVICE:
105 return "Device";
106 case hardware::graphics::composer::hal::Composition::SOLID_COLOR:
107 return "SolidColor";
108 case hardware::graphics::composer::hal::Composition::CURSOR:
109 return "Cursor";
110 case hardware::graphics::composer::hal::Composition::SIDEBAND:
111 return "Sideband";
112 default:
113 return "Unknown";
114 }
115}
116
117inline std::string to_string(hardware::graphics::composer::hal::V2_4::Error error) {
118 // 5 is reserved for historical reason, during validation 5 means has changes.
119 if (ERROR_HAS_CHANGES == static_cast<int32_t>(error)) {
120 return "HasChanges";
121 }
122 switch (error) {
123 case hardware::graphics::composer::hal::V2_4::Error::NONE:
124 return "None";
125 case hardware::graphics::composer::hal::V2_4::Error::BAD_CONFIG:
126 return "BadConfig";
127 case hardware::graphics::composer::hal::V2_4::Error::BAD_DISPLAY:
128 return "BadDisplay";
129 case hardware::graphics::composer::hal::V2_4::Error::BAD_LAYER:
130 return "BadLayer";
131 case hardware::graphics::composer::hal::V2_4::Error::BAD_PARAMETER:
132 return "BadParameter";
133 case hardware::graphics::composer::hal::V2_4::Error::NO_RESOURCES:
134 return "NoResources";
135 case hardware::graphics::composer::hal::V2_4::Error::NOT_VALIDATED:
136 return "NotValidated";
137 case hardware::graphics::composer::hal::V2_4::Error::UNSUPPORTED:
138 return "Unsupported";
139 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_ALLOWED:
140 return "SeamlessNotAllowed";
141 case hardware::graphics::composer::hal::V2_4::Error::SEAMLESS_NOT_POSSIBLE:
142 return "SeamlessNotPossible";
143 default:
144 return "Unknown";
145 }
146}
147
148inline std::string to_string(hardware::graphics::composer::hal::Error error) {
149 return to_string(static_cast<hardware::graphics::composer::hal::V2_4::Error>(error));
150}
151
152inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
153 switch (mode) {
154 case hardware::graphics::composer::hal::PowerMode::OFF:
155 return "Off";
Peiyong Line9d809e2020-04-14 13:10:48 -0700156 case hardware::graphics::composer::hal::PowerMode::DOZE:
157 return "Doze";
158 case hardware::graphics::composer::hal::PowerMode::ON:
159 return "On";
Peiyong Lin65248e02020-04-18 21:15:07 -0700160 case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
161 return "DozeSuspend";
162 case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
163 return "OnSuspend";
Peiyong Line9d809e2020-04-14 13:10:48 -0700164 default:
165 return "Unknown";
166 }
167}
168
Ady Abraham4f960d12021-10-13 16:59:49 -0700169inline std::string to_string(hardware::graphics::composer::hal::Vsync vsync) {
170 switch (vsync) {
171 case hardware::graphics::composer::hal::Vsync::ENABLE:
172 return "Enable";
173 case hardware::graphics::composer::hal::Vsync::DISABLE:
174 return "Disable";
175 default:
176 return "Unknown";
177 }
178}
179
Peiyong Line9d809e2020-04-14 13:10:48 -0700180} // namespace android