• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include <aidl/android/hardware/graphics/common/Hdr.h>
24 #include <aidl/android/hardware/graphics/composer3/Composition.h>
25 #include <aidl/android/hardware/graphics/composer3/DisplayCapability.h>
26 
27 #define ERROR_HAS_CHANGES 5
28 
29 namespace android {
30 namespace hardware::graphics::composer::hal {
31 
32 namespace types = android::hardware::graphics::common;
33 namespace V2_1 = android::hardware::graphics::composer::V2_1;
34 namespace V2_2 = android::hardware::graphics::composer::V2_2;
35 namespace V2_3 = android::hardware::graphics::composer::V2_3;
36 namespace V2_4 = android::hardware::graphics::composer::V2_4;
37 
38 using types::V1_0::ColorTransform;
39 using types::V1_0::Transform;
40 using types::V1_1::RenderIntent;
41 using types::V1_2::ColorMode;
42 using types::V1_2::Dataspace;
43 using types::V1_2::PixelFormat;
44 
45 using V2_1::Error;
46 using V2_4::IComposer;
47 using V2_4::IComposerCallback;
48 using V2_4::IComposerClient;
49 using V2_4::VsyncPeriodChangeTimeline;
50 using V2_4::VsyncPeriodNanos;
51 
52 using Attribute = IComposerClient::Attribute;
53 using BlendMode = IComposerClient::BlendMode;
54 using Connection = IComposerCallback::Connection;
55 using ContentType = IComposerClient::ContentType;
56 using Capability = IComposer::Capability;
57 using ClientTargetProperty = IComposerClient::ClientTargetProperty;
58 using DisplayRequest = IComposerClient::DisplayRequest;
59 using DisplayType = IComposerClient::DisplayType;
60 using HWConfigId = V2_1::Config;
61 using HWDisplayId = V2_1::Display;
62 using HWError = V2_1::Error;
63 using HWLayerId = V2_1::Layer;
64 using LayerGenericMetadataKey = IComposerClient::LayerGenericMetadataKey;
65 using LayerRequest = IComposerClient::LayerRequest;
66 using PerFrameMetadata = IComposerClient::PerFrameMetadata;
67 using PerFrameMetadataKey = IComposerClient::PerFrameMetadataKey;
68 using PerFrameMetadataBlob = IComposerClient::PerFrameMetadataBlob;
69 using PowerMode = IComposerClient::PowerMode;
70 using Vsync = IComposerClient::Vsync;
71 using VsyncPeriodChangeConstraints = IComposerClient::VsyncPeriodChangeConstraints;
72 using Hdr = aidl::android::hardware::graphics::common::Hdr;
73 
74 } // namespace hardware::graphics::composer::hal
75 
hasChangesError(hardware::graphics::composer::hal::Error error)76 inline bool hasChangesError(hardware::graphics::composer::hal::Error error) {
77     return ERROR_HAS_CHANGES == static_cast<int32_t>(error);
78 }
79 
to_string(hardware::graphics::composer::hal::Attribute attribute)80 inline 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 
to_string(aidl::android::hardware::graphics::composer3::Composition composition)99 inline std::string to_string(
100         aidl::android::hardware::graphics::composer3::Composition composition) {
101     switch (composition) {
102         case aidl::android::hardware::graphics::composer3::Composition::INVALID:
103             return "Invalid";
104         case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
105             return "Client";
106         case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
107             return "Device";
108         case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
109             return "SolidColor";
110         case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
111             return "Cursor";
112         case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
113             return "Sideband";
114         case aidl::android::hardware::graphics::composer3::Composition::DISPLAY_DECORATION:
115             return "DisplayDecoration";
116         case aidl::android::hardware::graphics::composer3::Composition::REFRESH_RATE_INDICATOR:
117             return "RefreshRateIndicator";
118         default:
119             return "Unknown";
120     }
121 }
122 
to_string(aidl::android::hardware::graphics::composer3::DisplayCapability displayCapability)123 inline 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";
141         case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_IDLE_TIMER:
142             return "DisplayIdleTimer";
143         default:
144             return "Unknown";
145     }
146 }
147 
to_string(hardware::graphics::composer::hal::V2_4::Error error)148 inline 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 
to_string(hardware::graphics::composer::hal::Error error)179 inline 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 
183 // For utils::Dumper ADL.
184 namespace hardware::graphics::composer {
185 namespace V2_2 {
186 
to_string(hardware::graphics::composer::hal::PowerMode mode)187 inline std::string to_string(hardware::graphics::composer::hal::PowerMode mode) {
188     switch (mode) {
189         case hardware::graphics::composer::hal::PowerMode::OFF:
190             return "Off";
191         case hardware::graphics::composer::hal::PowerMode::DOZE:
192             return "Doze";
193         case hardware::graphics::composer::hal::PowerMode::ON:
194             return "On";
195         case hardware::graphics::composer::hal::PowerMode::DOZE_SUSPEND:
196             return "DozeSuspend";
197         case hardware::graphics::composer::hal::PowerMode::ON_SUSPEND:
198             return "OnSuspend";
199         default:
200             return "Unknown";
201     }
202 }
203 
204 } // namespace V2_2
205 
206 namespace V2_1 {
207 
to_string(hardware::graphics::composer::hal::Vsync vsync)208 inline 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 
219 } // namespace V2_1
220 } // namespace hardware::graphics::composer
221 } // namespace android
222